Skip to content

A model copies what it sees, including accidents and imbalances.

A comparison of two few-shot prompts for the same task: sorting incoming email into complaint, quote request, billing question, or other. On the left, lopsided examples: four complaints and one billing question, the same category at the end of the prompt, no edge cases; the model leans toward complaint. On the right, two real emails per category in mixed order plus one ambiguous email labeled other, checked against a test set. Below: only a comparison on a test set shows whether the examples help.

A few-shot prompt contains an instruction, a handful of worked examples, and finally the new input. The model continues the pattern. This is called in-context learning: the model learns from the request itself while its weights stay the same. A zero-shot prompt has no examples; a one-shot prompt has exactly one.

The distinction became widely known through “Language Models are Few-Shot Learners,” the 2020 OpenAI paper introducing GPT-3. Anthropic, OpenAI, and Google all recommend examples in their prompting guides today.

Examples are the cheapest way to teach a model a house standard: a fixed response format, a list of categories, the tone of your customer communication. They also bring their own failure modes, because a model copies what it sees, including accidents and imbalances. A test set shows whether they help.

Chapter 1 of 7

How a few-shot prompt is built.

A typical few-shot prompt has three parts. At the top is the instruction, such as “Assign each customer inquiry to exactly one category.” Below it come example pairs: a real inquiry and its correct category, then the next. At the end sits the new inquiry, and the model answers in the same format.

OpenAI describes few-shot learning as steering a model with a handful of input/output examples in the prompt instead of fine-tuning; the model picks up the pattern and applies it. Anthropic calls examples one of the most reliable ways to steer format, tone, and structure, and recommends wrapping them in tags such as <example> so they stay separate from the instructions.

In applications, examples often live in the system prompt, the fixed instruction before every conversation.

Chapter 2 of 7

Zero-shot, one-shot, and few-shot differ in the number of examples.

The GPT-3 paper by Brown and colleagues defines the three settings. Zero-shot means the model gets only an instruction in natural language. One-shot adds exactly one example. Few-shot provides several, usually 10 to 100 in the study, as many as fit into the context window at the time. None of them changes the weights.

The authors call zero-shot the most convenient but also the hardest setting. Without an example, even a person may not know which format is wanted, as with a request for a table of world records in the 200-meter dash.

One-shot has its own weakness. In 2021, Zhao and colleagues observed that GPT-3's accuracy often dropped going from zero examples to one, because the model kept repeating the category of that single example.

Chapter 3 of 7

Examples mainly set form and tone.

A group led by Sewon Min studied in 2022 what a model takes from examples. Replacing the correct answers with random ones barely hurt performance on classification and multiple-choice tasks, across twelve different models. Performance depended on which answers appear at all, what the inputs typically look like, and the format of the whole sequence.

Examples therefore work mostly as a template. They show how long an answer is, which fields it has, how formal it sounds, and which terms come up. That suits house formats, product copy in a set voice, or extraction into fixed fields.

Google's prompting guide for Gemini stresses that all examples should share one structure, or responses come back in unwanted formats. The examples still have to be correct: on open-ended tasks like summaries, a model that copies the form often copies the content too.

Chapter 4 of 7

Models copy examples, and examples can skew results.

A model continues whatever it sees, including things nobody meant to show. If every example happens to have three sentences, so will the answer. Google warns that too many examples can make a model overfit to them; Anthropic recommends varied examples to avoid unintended patterns.

In classification, the skew is measurable. Zhao and colleagues showed in 2021 that the choice, format, and even order of examples could swing GPT-3's accuracy from near chance to near state of the art. The model favored answers that appeared often in the examples or sat near the end of the prompt. Four complaints and one billing question therefore nudge it toward complaint.

The fixes are balanced examples per category, a mixed order, edge cases such as ambiguous inputs, and testing on real cases that aren't among the examples.

Chapter 5 of 7

Testing settles the right number of examples.

There is no fixed number. Anthropic suggests three to five as a starting point; Google advises experimenting. If a clear instruction already does the job reliably, the model often needs none.

More is possible. Now that models accept very long inputs, a Google DeepMind team studied prompts with hundreds or thousands of examples in 2024 and found clear gains over a handful. The authors call this many-shot in-context learning and name the catch too: there often aren't enough human-written examples.

Every example goes out as tokens with every request, gets billed, and takes up room in the context window. For a task that runs thousands of times a month, that adds up. The number of examples is a trade-off between accuracy and cost per request, and a test set settles it.

Chapter 6 of 7

What good implementation looks like.

Good examples come from real operations. They cover every category, hard cases included, and follow exactly the same structure. Someone owns them and updates them when categories or formats change.

Before launch, a fixed test set of real inputs with known correct results runs twice, without examples and with them. Only the comparison shows whether they help. The same set runs again after every change and every model switch, since a new model reacts differently to the same examples.

When examples spell out their reasoning, few-shot becomes chain-of-thought prompting. In 2022, Wei and colleagues reached the then state of the art on math word problems with a large model and just eight such examples. If the model lacks knowledge, examples won't help; that is the job of retrieval-augmented generation (RAG). If even many examples fall short, fine-tuning is the next option.

Chapter 7 of 7

Where the term stops working

Few-shot prompting shapes the form of an answer but adds no knowledge, and it only works within the request at hand. Facts from your own documents call for retrieval-augmented generation; permanent behavior changes call for fine-tuning. The system prompt sets role and rules, chain of thought adds the reasoning path, and context engineering covers everything a model sees in a request, examples included.

Frequently asked questions

What is few-shot prompting?

Few-shot prompting is a prompting technique in which a language model receives a few worked examples of input and output in the prompt. From them it infers the task, format, and tone for the new input. The model is not retrained.

What is the difference between zero-shot and few-shot prompting?

Zero-shot gives the model only an instruction; few-shot adds several examples. Zero-shot is enough when the task is unambiguous. Few-shot helps when output has to follow a fixed format, a category list, or a specific tone.

How many examples does a few-shot prompt need?

There is no fixed number; Anthropic suggests three to five as a starting point. More examples cost tokens on every request and can make the model overfit to them. A test set of real cases shows the right number.

Does few-shot prompting train the model?

No, the model's weights stay unchanged. The examples only work within their request and must be sent again each time. Only fine-tuning changes the model permanently.

What is the difference between few-shot prompting and chain of thought?

Few-shot shows input and result; chain of thought also shows the reasoning in between. The two combine well when the examples spell out their intermediate steps. That mainly helps with multi-step math and logic tasks.

When is fine-tuning better than few-shot prompting?

Fine-tuning pays off when a behavior would need so many examples that they blow up the cost and context window of every request. Few-shot is quicker to change and needs no training data, so it almost always comes first.

    ↑ ↓ select · Enter open · Esc close