Chapter 3: Use Examples (Few-Shot)
Show, Don't Just Tell
Sometimes the best way to get exactly what you want is to show the AI an example. This technique is called "few-shot learning" because you're giving the AI a few shots (examples) to learn from.
What is Few-Shot Learning?
Instead of describing what you want, you show it:
Without example (zero-shot):
"Write product descriptions in an exciting style"
With example (few-shot):
"Write product descriptions like this example:
Example: 'Meet the ThermoMax: your coffee stays volcano-hot for 12 hours, or your money back. Engineered for the busy professionals who refuse to drink lukewarm disappointment.'
Now write one for a laptop stand."
The AI now understands exactly what "exciting style" means to you.
The Power of Examples
Examples help AI understand:
| What You Want | How Examples Help |
|---|---|
| Format | Show the exact structure you need |
| Tone | Demonstrate the voice you want |
| Length | Provide a model of appropriate size |
| Style | Show specific word choices and patterns |
| Quality level | Set the bar for sophistication |
How to Provide Examples
Pattern 1: Single Example
Here's an example of what I want:
[Your example]
Now create something similar for [your topic].
Pattern 2: Multiple Examples
Here are examples of the style I need:
Example 1: [first example]
Example 2: [second example]
Example 3: [third example]
Now write one for: [your topic]
Pattern 3: Input-Output Pairs
I want you to transform text like this:
Input: [example input]
Output: [example output]
Input: [another example input]
Output: [another example output]
Now transform this:
Input: [your actual input]
Real Examples in Action
Example 1: Email Subject Lines
Prompt:
Write email subject lines for my newsletter. Here are examples of my style:
- "5 productivity hacks that actually work (tested by me)"
- "I made $500 by accident. Here's what happened."
- "The app that replaced 3 others (and saved me hours)"
Write 3 subject lines for my email about morning routines.
Why it works: AI learns your personal style—casual, specific, curiosity-driving.
Example 2: Code Comments
Prompt:
Write code comments in this style:
Example:
// Validate user input before processing// Returns: cleaned string or null if invalid// Note: strips HTML to prevent XSSNow write a comment for a function that calculates shipping costs.
Why it works: AI matches your documentation style exactly.
Example 3: Product Reviews
Prompt:
I'm responding to customer reviews. Match this tone:
Example review response: "Thank you so much for the kind words, Sarah! We're thrilled your daughter loved the dinosaur puzzle. 🦕 Can't wait to see what adventure you choose next!"
Write a response for a review that says: "Great quality, arrived fast. Will buy again."
Why it works: AI captures your brand voice including emoji use and enthusiasm level.
Example 4: Data Formatting
Prompt:
Convert company information into this format:
Input: Apple Inc, Cupertino, California, Technology Output: Apple Inc (Technology) - Cupertino, CA
Input: Toyota Motor Corporation, Toyota City, Japan, Automotive
Output: Toyota Motor Corporation (Automotive) - Toyota City, JapanNow convert this: Input: Microsoft Corporation, Redmond, Washington, Technology
Why it works: AI learns the exact transformation pattern.
When Examples Help Most
✅ Use Examples When:
- You need a specific format that's hard to describe
- You want to match an existing style
- You're doing repetitive transformations
- Describing what you want is complicated
- You've tried describing it and AI got it wrong
⚠️ Skip Examples When:
- The task is simple and clear
- You want AI to be creative (examples can limit creativity)
- You don't have a good example to share
- One-time tasks that don't need style matching
The Input-Output Pattern
This is especially powerful for transformations:
Transform [type of input] into [type of output]:
Input: [example 1 input]
Output: [example 1 output]
Input: [example 2 input]
Output: [example 2 output]
---
Now transform this:
Input: [your actual input]
Use Cases:
- Converting formats (dates, addresses, names)
- Rewriting text (formal→casual, long→short)
- Extracting information
- Standardizing data
🎯 Try It Now: Create an Example-Based Prompt
Step 1: Choose a writing style you want to replicate
- A favorite blog
- Your own previous writing
- A brand voice you admire
Step 2: Find or write 2-3 examples of that style
Step 3: Create a prompt:
Write [what you need] in this style:
Example 1: [paste example]
Example 2: [paste example]
Now write: [your specific request]
Step 4: Test it and see how closely AI matches your examples
5 Few-Shot Prompt Templates
1. Style Matching
Write in this style:
Example: "[Your example text]"
Now write [what you need] about [your topic].
Keep the same tone and length.
2. Format Replication
Format information like this:
Example input: [sample input]
Example output: [sample output]
Now format this: [your input]
3. Response Templates
Respond to messages like this example:
Their message: [example incoming message]
My response: [example response]
Now respond to: [actual message you received]
4. Content Generation
Create [content type] similar to these:
Example 1: [sample]
Example 2: [sample]
Key elements to keep: [what to preserve]
Create one for: [your specific need]
5. Translation/Adaptation
Adapt content like this:
Original: [original version]
Adapted: [adapted version]
Key changes made: [transformation you want]
Now adapt this: [content to adapt]
Quality of Examples Matters
Good Examples:
- Representative of what you want
- Clear and unambiguous
- Consistent with each other
- High quality (if you want high-quality output)
Bad Examples:
- Too varied (confuses AI about the pattern)
- Low quality (AI will match that quality)
- Contradictory styles
- Too long (key patterns get lost)
How Many Examples?
| Number | When to Use |
|---|---|
| 1 example | Simple style matching |
| 2-3 examples | Best balance—shows pattern without overwhelming |
| 4+ examples | Complex patterns or when 2-3 weren't enough |
More isn't always better. 2-3 good examples usually outperform 5-6 mediocre ones.
Quick Summary
- Few-shot learning = showing examples, not just describing
- Examples help AI understand format, tone, style, and quality
- The input-output pattern is great for transformations
- Use 2-3 high-quality, consistent examples
- Examples work best when describing what you want is difficult
Module 2 Complete!
You now know the three core techniques:
- ✅ Be Clear and Specific
- ✅ Provide Context
- ✅ Use Examples (Few-Shot)
What's Next?
Test your knowledge with the Module 2 Quiz, then move to Module 3: Practical Applications where you'll apply these skills to real tasks.