Few-Shot Prompting
Provide examples to teach the AI exactly what pattern you want it to follow.
What is Few-Shot Prompting?
Few-shot prompting means providing examples of the input-output pattern you want before giving the actual task. Instead of describing what you want, you show it.
Zero-shot: "Classify this review as positive or negative"
One-shot: "Example: 'Great product!' → Positive. Now classify: 'Terrible experience'"
Few-shot: Provide 3-5 examples before the actual task
Few-shot prompting is one of the most powerful techniques in prompt engineering. It works because the AI pattern-matches from your examples.
How to Structure Few-Shot Prompts
Follow this template:
```
I need you to [task description]. Here are some examples:
Input: [example 1 input]
Output: [example 1 output]
Input: [example 2 input]
Output: [example 2 output]
Input: [example 3 input]
Output: [example 3 output]
Now do the same for:
Input: [your actual input]
Output:
```
Key principles:
- Use 3-5 examples (diminishing returns after 5)
- Make examples representative of the variety you expect
- Include edge cases in your examples
- Keep formatting consistent across all examples
Create a few-shot prompt that classifies customer support emails into categories: billing, technical, feature-request, and complaint. Provide 2 examples per category, then test with new emails.
- ✓Few-shot prompting shows the AI what you want through examples
- ✓3-5 examples is the sweet spot for most tasks
- ✓Include edge cases and variety in your examples
- ✓Consistent formatting across examples is critical