Few-shot prompting
Fundamentals
Level 1 · FoundationsShow the model a handful of examples (typically 2-5) before the real task.
Few-shot prompting extends one-shot by giving several examples, which lets the model infer the pattern more robustly and generalize across variation — different phrasings, edge cases, or output lengths — instead of anchoring on a single case.
When to use it
Use it for tasks with real variety across inputs, or when a single example left the model guessing wrong on some cases — a well-chosen set of 2-5 diverse examples usually fixes that. Choose examples that are genuinely different from each other — a typical case, an edge case, and (where relevant) a borderline or ambiguous case. Five similar examples teach the model less than three well-chosen, diverse ones.
When to avoid it
Avoid it for very simple, unambiguous tasks where the extra examples just add tokens and cost without improving the result, and for tasks where good examples are hard to produce consistently.
Advantages
- More robust than zero/one-shot across varied inputs
- Lets you demonstrate edge cases directly instead of describing them
- Often the most reliable technique for structured or stylistic tasks
Disadvantages
- Uses noticeably more tokens (cost and latency)
- Quality is very sensitive to which examples you pick
- Poorly chosen or inconsistent examples can confuse the model more than a plain instruction would
Examples
Task: classify a support ticket as Billing, Technical, or Account. Examples: "I was charged twice this month" -> Billing "The app crashes when I upload a photo" -> Technical "I can't remember my username" -> Account Now apply the same pattern to: "My invoice shows the wrong plan"
Pairs well with
Try it
Fill in the placeholders below and see the compiled prompt update live.
What you want to achieve.
Provide 2-5 example pairs, one per line, in the format: Input: ... → Output: ... Include at least one typical case and one edge case.
Who or what this is written for or about.
- 11
- Words
- 86
- Characters
- 0/3
- Placeholders filled
- 1 min
- Reading time
- Completeness0
- Clarity0
- Context0
- Specificity0
- Constraints0
- Format0
- Output0
- Constraints note0
- Success criteria0
- Scope focus100
- Verification step0
- Negative example0
- Confidence0
- Placeholder syntax100
- Markdown structure0
- Fill in the remaining placeholders.
- Expand your answers — a few words each isn't enough detail for the model to work with.
- Add background context so the model understands the situation.