What is few-shot prompting?
Few-shot prompting is a technique where you include a small number of examples in your prompt to show the model exactly what you want. Each example pairs an input with the matching output. The model reads the pattern and applies it to your real input.
The name comes from the number of examples. Zero-shot gives the model no examples, just an instruction. One-shot gives it one. Few-shot gives it a handful, usually two to five. More examples generally mean more reliable results, up to a point.
In plain words
Imagine asking a new colleague to format meeting notes. You could write a page of rules, or you could just show them three notes you already formatted the way you like. The second way is faster and clearer. Few-shot prompting is showing the model those three examples.
When to use it
- Consistent formatting. When you need the output in a specific shape every time, examples lock it in better than a description.
- Classification and tagging. Show a few labelled cases and the model learns your categories, including the edge cases that are hard to put into words.
- Matching a tone or style. Examples of the voice you want beat any adjective. "Write like these three" works where "write professionally" does not.
- Tricky transformations. When the rule is easier to demonstrate than to explain, a couple of before-and-after pairs do the job.
Common pitfalls
- Unrepresentative examples. The model copies what you show it, including the quirks. If your examples are all short, do not be surprised when long inputs go wrong.
- Too many examples. Each one costs tokens and adds latency. Beyond a few, returns drop off fast. Add examples only while they keep improving the output.
- Biased order. In classification tasks, the order and balance of examples can skew the answer. Mix the categories instead of grouping them.
- Using it when instructions would do. For simple tasks, a clear sentence is cheaper and just as good. Reach for few-shot when plain instructions are not enough.
Related articles:
- What is prompt engineering? - The broader discipline that few-shot prompting is one technique within.
- What is chain-of-thought prompting? - Another core technique, for reasoning rather than pattern-matching.
- What is a prompt? - The instruction itself, and why how you phrase it changes the answer.
Want to stay one step ahead?
Don't miss our best insights. No spam, just practical analyses, invitations to exclusive events, and podcast summaries delivered straight to your inbox.
