Few-shot
Few-shot prompting is a technique in which you include a small number of input-and-output examples in the prompt so that a large language model (LLM) follows the same format, tone and criteria in its answer. The model picks up the pattern from the examples without any additional training or fine-tuning.[1][3]
What does Few-shot mean in simple terms?
Imagine handing a new colleague two or three finished reports and saying, "Write it like these." Even on a topic they have not seen before, they can match the layout and level of detail much more easily. Few-shot prompting works the same way: you place a few "for this input, give this output" pairs in the prompt, and the model follows that pattern in format and tone.[2][3] Because it needs no separate model-training run or weight changes, it is usually one of the first options to try when you want more consistent output.[3]
How can Few-shot be explained with an analogy?
It is like attaching two or three sample pages to a request for proposal and telling the vendor, "Please write it in this format."
Where is Few-shot used?
OpenAI GPT-3 — SuperGLUE with examples only
The GPT-3 paper tested the same 175-billion-parameter model with no examples (zero-shot), one example (one-shot) and many examples (few-shot), without updating its weights.[1] On the SuperGLUE language-understanding benchmark, few-shot GPT-3 with 32 examples per task scored 71.8 on the test set, above a fine-tuned BERT-Large (69.0) but well below the fine-tuned state of the art (89.0).[1] The authors also report that fewer than eight examples per task were enough to beat the fine-tuned BERT-Large on the overall score.[1] The paper became a common reference point for prompting with examples.
Result: SuperGLUE test average 71.8 for few-shot GPT-3, compared with 69.0 for fine-tuned BERT-Large and 89.0 for the fine-tuned state of the art.[1]
GPT-3 on TriviaQA — Scores rise with each step
In the same paper, closed-book TriviaQA accuracy rose from 64.3% (zero-shot) to 68.0% (one-shot) and 71.2% (few-shot).[1] For a task with a clear answer format, such as an internal FAQ assistant, this suggests why adding a few good sample answers is worth testing against a version without them.
Result: TriviaQA accuracy 64.3% → 68.0% → 71.2% (zero-, one- and few-shot GPT-3).[1]
Anthropic guidance — Controlling format and tone
Anthropic's current prompting guide calls examples "one of the most reliable ways" to steer Claude's output format, tone and structure, and recommends 3–5 examples that are relevant, diverse and wrapped in <example> tags.[2] An illustrative use (hypothetical, not a measured result): to extract fields from quotes or contracts into JSON, you add three examples that show the exact key names, how to handle missing values and how to nest items. This is most useful for tasks where an instruction such as "be friendly" or "summarise clearly" is too vague, such as ad copy tone or meeting-note layout.
Result: Anthropic recommends 3–5 relevant, diverse examples in <example> tags.[2]
Classification — Labelled examples in the prompt
OpenAI's prompt engineering guide shows a few-shot prompt that labels product reviews as Positive, Negative or Neutral, with one example review and answer for each label.[3] A team could apply the same pattern to sort customer enquiries into categories such as refund, delivery, account and other, before building a larger labelled training dataset. Which examples you choose matters: one study found that randomly selected examples cause high variance, and choosing more informative examples gave an average relative improvement of 14.3% across six classification tasks and three LLMs.[8]
Result: Example selection changes classification results; an informed selection method gave a 14.3% average relative improvement in one study.[8]
Try it today
- Pick one task you repeat often, such as classifying, summarising, extracting or writing copy.
- Write 3–5 input-and-output pairs for that task, covering typical cases and a few edge cases.[2]
- Add one line of instructions and place the pairs after it, each wrapped in
<example>tags.[2] - Run the same 10 inputs with and without the examples, and compare the results.
- Where the format still drifts, add one or two examples for those cases, and record the trade-off between token cost and quality.
Limits and direction
More examples do not always help. Results can swing from near chance to near state of the art depending on the prompt format, which examples are chosen and even their order, because models favour answers that appear near the end of the prompt or are common in training data.[5] Choosing which examples to include, and in what order, is a design task in its own right.[5][8] Examples also take up context: examples add input tokens and can increase cost and latency; prompt caching may reduce repeated-prefix processing, and one study found that parameter-efficient fine-tuning on the same few examples gave better accuracy at much lower compute cost.[7] If one example is atypical or wrong, the model may copy that mistake as well. Real quotes or customer records used as examples can expose sensitive data, so mask or anonymise them first.
Two directions stand out. The first is choosing examples dynamically: instead of attaching the same fixed set every time, a system retrieves the stored examples most similar to the current input. Retrieving semantically similar examples consistently beat random selection in a 2021 study on GPT-3.[6] The second is reasoning models, which need examples less often. Since OpenAI introduced o1 in September 2024, models that think before answering have become common.[9] OpenAI now advises trying zero-shot first with reasoning models and adding a few examples only when the output requirements are more complex, making sure the examples match the instructions closely.[4] Anthropic notes that examples still work with Claude's thinking and shape how it approaches similar problems.[2] A practical approach is to start without examples, then add them only where the format or judgement drifts.[2][4]
Which concepts are related to Few-shot?
- Similar conceptPrompt VersionA related prompting concept; use it when organizing instructions and examples for repeatable tasks.
- Similar conceptPrompt LibraryA related prompting concept; use it when organizing instructions and examples for repeatable tasks.
- Similar conceptPersona PromptingA related prompting concept; use it when organizing instructions and examples for repeatable tasks.
Which sources explain Few-shot?
- Brown et al. — Language Models are Few-Shot Learners (arXiv 2005.14165, 2020-05-28) — https://arxiv.org/abs/2005.14165
- Anthropic — Prompting best practices (Claude Platform Docs) — https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices
- OpenAI — Prompt engineering: Few-shot learning (OpenAI API Docs) — https://developers.openai.com/api/docs/guides/prompt-engineering
- OpenAI — Reasoning best practices (OpenAI API Docs) — https://developers.openai.com/api/docs/guides/reasoning-best-practices
- Zhao et al. — Calibrate Before Use: Improving Few-Shot Performance of Language Models (arXiv 2102.09690, 2021-02-19) — https://arxiv.org/abs/2102.09690
- Liu et al. — What Makes Good In-Context Examples for GPT-3? (arXiv 2101.06804, 2021-01-17) — https://arxiv.org/abs/2101.06804
- Liu et al. — Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learning (arXiv 2205.05638, 2022-05-11) — https://arxiv.org/abs/2205.05638
- Liu and Wang — Towards Informative Few-Shot Prompt with Maximum Information Gain for In-Context Learning (arXiv 2310.08923, 2023-10-13) — https://arxiv.org/abs/2310.08923
- OpenAI — Learning to reason with LLMs (2024-09-12) — https://openai.com/index/learning-to-reason-with-llms/
Tell us what you think
Your feedback helps us improve the content.