Few-Shot
Provides examples to guide the AI response format
beginner
FOUNDATIONAL
What Is This Pattern?
The Few-Shot Pattern teaches the AI by example. You provide 2-5 examples of the input-output pairs you want, and the AI learns the pattern to apply to new inputs. This is incredibly powerful for tasks where explaining the rules is harder than showing examples.
How It Works
You structure your prompt with clear examples showing the desired transformation or response style. The AI recognizes the pattern and applies the same logic to new inputs.
When To Use This Pattern
- The task is easier to show than explain
- You want consistent style or format across outputs
- You need the AI to follow a specific reasoning pattern
- Simple instructions aren't producing the right results
Example
✅ After (Strong)
Here are 3 examples of good code reviews...Best Practices
- Use 2-5 examples (more isn't always better)
- Make examples diverse but clear
- Show edge cases if relevant
- Keep examples concise and focused
Common Mistakes to Avoid
- Providing too many examples (confuses the pattern)
- Using inconsistent examples
- Not showing enough variety
- Making examples too complex