Why 2-4 Examples Work
Enough to set a pattern, few enough to stay general.
The Core Idea
Few-shot prompting works because Claude generalizes from examples — it doesn't just memorize and repeat them. The exam fact sheet is precise about the dose: use 2-4 targeted examples per ambiguity.
That range is not arbitrary. It is enough to set a pattern, yet few enough to keep the model general. This lesson explains why that sweet spot holds for production work.
Examples Teach a Rule, Not a Lookup Table
When you show Claude 2-4 examples, you are demonstrating a rule: this input shape maps to that output shape. The model infers the underlying pattern and applies it to new, unseen inputs.
This is why few-shot is the go-to tool for consistency, edge cases, output format, and reducing hallucination — all areas where a vague instruction leaves too much room for drift.
system = (
"Classify each support message as: billing, technical, or other.\n"
"Examples:\n"
"Message: 'My card was charged twice' -> billing\n"
"Message: 'The app crashes on login' -> technical\n"
"Message: 'Do you have a dark mode?' -> other"
)
# 3 examples set the mapping rule; Claude generalizes to new messages.