Zero-Shot vs Few-Shot Prompting
How examples transform AI output quality.
Zero-Shot vs Few-Shot Prompting
This is one of the most powerful techniques in prompt engineering — and it's surprisingly simple.
Zero-Shot Prompting
You give the AI a task with no examples.
"Classify this customer review as positive, negative, or neutral: 'The product works fine but shipping was slow.'"
The AI uses its general training to figure out what you want. For simple tasks, this works well enough.
One-Shot Prompting
You give one example before your actual request.
"Classify customer reviews as positive, negative, or neutral.
Example:
Review: 'Absolutely love this product! Best purchase I've made all year.'
Classification: Positive
Now classify this:
Review: 'The product works fine but shipping was slow.'
Classification:"
Few-Shot Prompting
You give multiple examples (typically 2-5).
"Classify customer reviews. Here are examples:
Review: 'Absolutely love it! Best purchase ever.' → Positive
Review: 'Completely broken on arrival. Want a refund.' → Negative
Review: 'It's okay. Does what it says.' → Neutral
Review: 'Great quality but overpriced.' → Mixed
Now classify: 'The product works fine but shipping was slow.' →"
Why Few-Shot Is So Powerful
- 1.Pattern matching: The AI learns exactly what format you want
- 2.Edge cases: Your examples can show how to handle tricky situations
- 3.Consistency: Output format stays consistent across many items
- 4.Accuracy: Studies show few-shot prompting can improve accuracy by 20-40%
When to Use Each
| Technique | Best For |
|---|---|
| Zero-shot | Simple, unambiguous tasks |
| One-shot | Tasks where format matters |
| Few-shot | Classification, formatting, complex patterns, batch processing |
Pro Tips
- •Use diverse examples that cover different cases
- •Include edge cases in your examples
- •Keep examples concise but representative
- •3-5 examples is usually the sweet spot (more isn't always better)
Exercises
0/3Few-shot prompting can improve accuracy by approximately:
Create a few-shot prompt (3 examples) that teaches AI to convert informal meeting notes into professional action items. Test it with a real or made-up meeting note.
Hint: Example format: "Meeting note: John said he'd finish the report → Action: John to complete quarterly report by [date]"
What is the recommended sweet spot for number of examples in few-shot prompting?