Few-shot prompting
Show, don’t tell. A couple of worked examples in the prompt teach a model a format, a label set or a voice more reliably than a paragraph of instructions.
Add examples one at a time
The task: label app feedback. Choose how many examples to include and watch the typical answer change.
Prompt
Typical answer
Zero-shot: the model doesn’t know you wanted a label, so it answers like a helpful assistant, and gives troubleshooting advice nobody asked for.
Why it works
Large language models are pattern-continuers. Examples turn a vague instruction (“label this”) into a pattern the model can continue exactly: the same fields, the same vocabulary, the same length. Brown et al. showed in the GPT-3 paper that performance on many tasks rose sharply from zero to a few examples, without any retraining.
How to write good examples
- Cover the range. Include each category or case you expect, plus one edge case.
- Keep the format identical. Same labels, same separators, same order.
- Match the real input. Examples should look like what you’ll actually send.
- Mark them clearly. Use “Input:/Output:” or
<example>tags so the model knows they are examples, not instructions.
The Example field in the prompt generator slots your sample into the right place. Compare with chain-of-thought prompting, which you can combine with few-shot by writing the reasoning into your examples.
Questions
What is few-shot prompting?
Few-shot prompting means including a few worked examples (input and desired output) in the prompt before the real input. The model infers the pattern and applies it. The term comes from the 2020 GPT-3 paper “Language Models are Few-Shot Learners” by Brown et al.
What is the difference between zero-shot, one-shot and few-shot?
Zero-shot gives only the instruction. One-shot adds a single example. Few-shot adds several, typically two to five. More examples help with complex formats and label sets, with diminishing returns after a handful.
How many examples should I use?
Start with one. Add more when outputs vary in ways the examples could fix. Cover the range of cases, including an edge case, and keep examples consistent in format, because the model copies inconsistencies too.
Can examples hurt?
Yes. Models copy surface features: if all examples are short, answers get short; if every example is positive, the model leans positive. Vary examples deliberately and keep them representative.