Few-shot prompting
Few-shot prompting means showing the model a handful of examples of the input-output mapping you want before asking it to handle your real input. It is one of the most consistently effective techniques in prompt engineering, because a single good example often communicates more than a paragraph of description.
The names are simple: zero examples is zero-shot, one example is one-shot, and a few examples is few-shot. The skill is in choosing and formatting the examples well.
Last reviewed
Why do examples beat description?
Examples beat description because words make the model translate your description into a concrete shape, and it often translates loosely. An example removes that step: it shows the exact format, length, tone, and level of detail in a form the model can copy directly.
This matters most for tasks where the shape is hard to describe but easy to demonstrate: classification with your own labels, extraction into a specific structure, rewriting in a particular voice, or formatting that has fiddly rules.
Classify each support message as Billing, Bug, or Feature request. Message: "I was charged twice this month." Label: Billing Message: "The export button does nothing on Safari." Label: Bug Message: "Could you add dark mode?" Label: Feature request Message: "My invoice shows the wrong VAT rate." Label:
How many examples should you use?
Start with one. A single clear example resolves most ambiguity about format and tone. Add a second and third when the task has variety the first example did not cover, for instance when you want the model to handle several categories or edge cases.
There are diminishing returns, and examples cost tokens on every call. Two or three well-chosen examples usually beat ten mediocre ones. If you find yourself needing many examples to get consistent output, that is often a sign the task should be split or the instructions tightened.
How do you choose good examples?
The examples carry your standards, so pick them deliberately.
- Make them representative of the real inputs, not the easy cases.
- Cover the range: if there are several output categories, show at least one of each.
- Keep the format identical across every example so the pattern is unmistakable.
- Include a tricky case if your real data has them, so the model learns the edge behaviour.
- Double-check the examples are correct. A wrong example teaches the wrong thing, reliably.
How should you format few-shot examples?
Consistency is everything. Use the same delimiters, the same labels, and the same order in every example, then leave the final answer blank for the model to fill in. Clear separators (blank lines, headings, or simple tags) stop the model from blurring one example into the next.
If the output should be structured, show the structure in the examples exactly as you want it back, down to the punctuation. The model matches what it sees.
What are the most common few-shot mistakes?
Three failures show up again and again. The first is inconsistent formatting between examples, which leaves the model unsure which pattern to follow. The second is examples that are all easy or all the same category, so the model never learns the harder cases. The third is a subtle error in one of the examples, which the model dutifully copies into its answers.
When few-shot output drifts, re-read your examples before you rewrite the instructions. The problem is usually in the demonstrations, not the wording around them.
Key takeaways
- Few-shot prompting shows the model worked examples of the input-output mapping you want.
- One example resolves most format ambiguity; add a second or third to cover variety and edge cases.
- Keep formatting identical across examples and make sure every example is correct.
- When output drifts, fix the examples before rewriting the instructions.
See how your prompt scores
Paste any prompt into the free Promptrace scorer and get an instant breakdown across all seven dimensions. No signup.
Open the prompt scorer →Frequently asked questions
What is few-shot prompting?
Few-shot prompting is a technique where you include a small number of worked examples of the input and the output you want before asking the model to handle your real input. The examples show the exact format, tone, and detail level you expect, which steers the output more reliably than describing it in words.
How many examples should a few-shot prompt have?
Start with one and add more only as needed. Two or three well-chosen examples usually outperform a long list of mediocre ones, and every example costs tokens on each call. Make sure the examples cover the variety in your real inputs, including any tricky cases.
What is the difference between zero-shot, one-shot, and few-shot?
Zero-shot gives the model no examples, just the instruction. One-shot gives a single example. Few-shot gives several. More examples generally improve consistency on pattern-based tasks, at the cost of more tokens per call.
Sources and further reading
Related guides
Zero-shot vs few-shot
What the terms mean, and a simple rule for deciding how many examples to include.
TechniquesChain-of-thought
Ask the model to reason step by step. Why it helps on hard problems, and when to skip it.
FrameworksRACE
Role, Action, Context, Expectation. The four-part framework Promptrace is named after.