Quick Stats
Completed
0
Time Spent
0m
Streak
0
User
Few-Shot Prompting
Teach by example.
Show, don't just tell
Few-shot prompting means including a handful of worked examples — the input and the output you want — right in the prompt. Instead of describing the pattern in words, you demonstrate it, and the model infers the rule and applies it to the new case. The name comes from the count: zero-shot (no examples), one-shot (one), few-shot (a few).
A worked example
Suppose you want consistent sentiment labels. Don't explain your labeling philosophy — show it:
Classify the sentiment as Positive, Negative, or Neutral.
Review: "Loved every minute." -> Positive
Review: "It was fine, nothing special." -> Neutral
Review: "Total waste of money." -> Negative
Review: "Best purchase this year!" ->The model sees the pattern — review in, single label out — and completes the last line with "Positive." No instructions about edge cases needed; the examples carry the definition.
When to reach for it
Few-shot earns its keep when you need:
- A consistent format that's fiddly to describe ("extract these five fields, in this order").
- A nuanced style or tone that's easier to show than explain.
- Edge-case handling — include a tricky example and the right answer for it.
How to choose examples
- Use 2 to 5 examples; more rarely helps and eats context.
- Make them diverse so they cover the range, not three near-identical cases.
- Match the real mix — if half your inputs are neutral, show a neutral.
- Keep the format identical across examples; the model copies structure faithfully, including any mistakes you leave in.
Two good examples usually beat a paragraph of rules. When you catch yourself writing "and if it's like X, do Y" for the third time, stop describing and start demonstrating.
Try this: Take a task where the model keeps drifting in format. Give it three clean input/output examples, then your real input with the output left blank. Watch it lock onto the shape you wanted instead of inventing its own.