Few-shot prompts include input→output examples so the model mimics format and edge behavior without weight updates.
When it helps
- Structured extraction (JSON keys, enums)
- Classification with nuanced labels
- Consistent tone for support macros
Example pattern
EXAMPLES = """
Input: Refund after 45 days
Output: {"eligible": false, "reason": "outside_30_day_policy"}
Input: Refund after 10 days, unused license
Output: {"eligible": true, "reason": "within_policy"}
"""
# Then append the live input to classify
Pitfalls
Contradictory examples confuse the model. Too many examples burn context—often 3–5 diverse cases beat 20 repetitive ones.
Important interview questions and answers
- Q: Few-shot vs fine-tuning?
A: Few-shot is instant but limited; fine-tuning moves behavior into weights for stable high-volume formats.
Self-check
- When is few-shot a good fit?
- What burns context in few-shot prompts?
Tip: Three diverse examples beat ten near-duplicates for format teaching.
Interview prep
- When few-shot?
Format teaching, nuanced labels, consistent tone without weight updates.
- Too many shots?
Burns context; contradictory examples hurt more than help.