Few-shot prompting includes a small number of worked examples in the prompt so the model can infer the pattern.
When It Helps
- A particular output format or style that's hard to describe.
- Classification into your own categories.
- Extraction where edge cases need showing, not telling.
- Matching a house tone of voice.
Example
Classify each support message as billing, technical or other.
Message: "I was charged twice this month."
Category: billing
Message: "The export button does nothing."
Category: technical
Message: "Do you have an office in Perth?"
Category:
Choosing Good Examples
- Representative: cover the common cases.
- Varied: differ in length, wording and difficulty, so the model doesn't copy surface features.
- Include edge cases: ambiguous or tricky inputs with the answer you want.
- Balanced: don't show five examples of one class and one of another.
- Correct: a wrong example teaches the wrong behaviour.
How Many?
Often three to five is enough. More examples cost more tokens and help less once the pattern is clear.
Combine With Instructions
Examples work best alongside a clear instruction explaining the task and any rules the examples might not make obvious.
Keep Evaluation Separate
Don't reuse your test cases as prompt examples, or your evaluation will overstate performance.