Skip to main content
BVDNET
Arnhem · websites & automationBVDNET
Practical Applications

Few-shot prompting

Few-shot prompting means showing an AI model a few examples of what you want inside your instruction, so it follows the pattern without extra training.

Also known as: multishot prompting, few-shot learning, one-shot prompting

Few-shot prompting means putting a few examples in your instruction to an AI model, so it sees what you want. To sort customer emails into complaint, question or order, you show three emails with the right label and then the new email; the model follows the pattern. No training is needed: change the examples and the behaviour changes with the next request.

Where does the term come from?

The term comes from machine learning, where few-shot learning means learning a task from only a handful of labelled examples. The GPT-3 paper by Brown et al. (OpenAI, 2020) applied it to the prompt. It compared three settings: zero-shot (only an instruction), one-shot (one example) and few-shot, in which the model gets several examples while it answers and its weights stay unchanged. There, few-shot meant 10 to 100 examples, as many as fit in the model's context window of 2,048 tokens. On the TriviaQA quiz questions GPT-3 scored 64.3% zero-shot, 68.0% one-shot and 71.2% few-shot. The ability behind it is called in-context learning.

How do you use it?

  • Use the format of the real task: each example an input followed by the output you want. OpenAI's guide shows product reviews, each with the label Positive, Negative or Neutral.
  • Vary the examples and include edge cases, so the model does not copy an accidental pattern. In September 2026 Anthropic recommends three to five examples, marked with <example> tags so the model can tell them from the instructions.
  • Pick examples that resemble the question. Liu et al. (2021) let a search step choose similar examples for each question, which beat randomly chosen ones.
  • Put fixed examples at the start of the prompt. OpenAI advises putting content you reuse first, so prompt caching makes it cheaper.

Where does it go wrong?

  • Small choices have large effects. Zhao et al. (2021) found that the format, the choice of examples and even their order could move GPT-3's accuracy from near chance to near the best known result; the model leaned towards answers near the end of the prompt. A good order for one model does not carry over to another (Lu et al., 2021), and formatting alone made up to 76 accuracy points of difference for LLaMA-2-13B (Sclar et al., 2023).
  • The model picks up the form more than the answers. Min et al. (2022) replaced the correct labels in the examples with random ones on classification and multiple-choice tasks, and performance barely dropped across 12 models. What counted was showing the possible labels, the kind of input and the format.
  • Examples cost money. They travel with every request as input tokens.
  • It does not always reach a trained model. In 2020 the GPT-3 authors wrote that few-shot results were still much worse than those of the best fine-tuned models.

Example

Suppose a webshop that sells garden tools wants to sort incoming email. The prompt holds three labelled examples and then the new email:

Plain Text
1Label each customer email as complaint, question or order.
2
3<example>
4Email: My parcel arrived with a broken handle.
5Label: complaint
6</example>
7<example>
8Email: Do you also ship to Belgium?
9Label: question
10</example>
11<example>
12Email: I'd like two more of the blue watering cans.
13Label: order
14</example>
15
16Email: The invoice shows the wrong address, can you fix that?
17Label:

The model answers with one word, in the form of the examples. If it keeps mislabelling one kind of email, such as a question that is really a complaint, add an example of that kind.