Give Examples Instead of Explanations
Introduction
Section titled “Introduction”🎯 Learning goals
- Understand the principle of “few-shot prompting”
- Learn how many examples is optimal
- Be able to create effective examples for custom instructions
The previous sections covered structuring your instructions and answering the right questions. Now you’ll learn one of the most powerful techniques in prompt engineering: showing instead of telling. A single well-chosen example can replace several sentences of explanation — and give dramatically better results.
You’ve probably experienced it: you carefully explain exactly what you want, but the tone is wrong, the format strange, or the level of detail not at all what you had in mind. There’s a simpler solution — and that’s what we look at now.
Why examples often beat explanations
The secret that the big AI companies use is simple: instead of trying to explain everything in words, show the model examples of exactly what you want the result to look like.
“Examples are your secret weapon shortcut for getting Claude to generate exactly what you need.” — Anthropic, Best Practices for Prompt Engineering
This is called few-shot prompting (or multishot prompting) — and it’s one of the most powerful techniques you can use. Zero-shot means you give no examples at all, one-shot means one example, and few-shot means two or more.
The fact that examples work better than explanations isn’t a coincidence — there are four concrete reasons why the technique is so powerful.
Why does it work so well?
1. Shows instead of tells
Section titled “1. Shows instead of tells”Humans (and AI models) learn better from concrete examples than from abstract descriptions. A single good example can clarify things that would take several sentences to explain.
2. Clarifies subtle nuances
Section titled “2. Clarifies subtle nuances”There are expectations that are difficult to express in words — such as exactly what tone you want, how formal the text should be, or how detailed an explanation should be. Examples show this directly, without interpretation.
3. Gives consistency
Section titled “3. Gives consistency”When the model has seen examples of the “correct” format, it follows that pattern much more consistently than if you just described it. Consistency is critical when you’re building an assistant that will be used in practice.
4. Reduces generic AI responses
Section titled “4. Reduces generic AI responses”According to tests from Anthropic, the right examples can eliminate up to 80% of generic, bland AI responses — especially if you combine positive and negative examples (more on that later in this section).
The difference between using and not using examples is easiest to understand with a concrete case. Here’s a direct comparison.
From zero-shot to few-shot: A practical comparison
❌ Zero-shot (without examples)
Section titled “❌ Zero-shot (without examples)”## TASKCategorize customer emails into the correct category.
## CATEGORIES- Technical support- Billing questions- Product information- Complaints- OtherResult: Works okay for clear-cut cases, but gets uncertain in borderline cases. What’s the difference between “Technical support” and “Complaints” if the customer is both complaining AND needs help?
✅ Few-shot (with examples)
Section titled “✅ Few-shot (with examples)”## TASKCategorize customer emails into the correct category.
## CATEGORIES- Technical support- Billing questions- Product information- Complaints- Other
## EXAMPLES
Email: "My app crashes every time I try to log in. Help!"Category: Technical support
Email: "Why have I been charged an extra $15?"Category: Billing questions
Email: "Does product X support Bluetooth 5.0?"Category: Product information
Email: "I'm extremely dissatisfied with your customer service and want compensation!"Category: Complaints
Email: "I've changed my email address, where do I update it?"Category: OtherResult: The model now has clear examples of what each category looks like and makes much better judgments — especially in borderline cases where a question could belong to more than one category.
One of the most common questions about few-shot prompting is: how many examples do I actually need? The answer is more nuanced than you might think.
How many examples do you need?
Anthropic’s recommendation: Start with one example
Section titled “Anthropic’s recommendation: Start with one example”“Start with one example (one-shot). Only add more examples (few-shot) if the output still doesn’t match your needs.”
Practical approach
Section titled “Practical approach”- Start with 0 examples (zero-shot) — test if the model handles the task anyway
- Add 1 example (one-shot) — this is often enough
- Increase to 2–3 examples if results still vary
- Use 5–10 examples only for complex or niche tasks
The principle of diminishing returns
Section titled “The principle of diminishing returns”Research shows that more examples aren’t always better. After a certain number, you get marginal improvement but use more tokens.
Rule of thumb
Section titled “Rule of thumb”- 1 example → Simple classification tasks, clear formats
- 2–3 examples → Medium complexity tasks, nuanced tone
- 5+ examples → Complex domains, highly specific requirements
Always test! The optimal number varies depending on the task and model.
Knowing that you need examples is one thing — creating good examples is another. Here’s what actually distinguishes an effective example from an ineffective one.
Creating effective examples
1. Representative of real use cases
Section titled “1. Representative of real use cases”Your examples should reflect the variation you expect in practice — not constructed textbook cases.
❌ Bad example (too simple and constructed)
Section titled “❌ Bad example (too simple and constructed)”Question: "What is Python?"Answer: "Python is a programming language."✅ Good example (realistic and with the right level of detail)
Section titled “✅ Good example (realistic and with the right level of detail)”Question: "I just started learning Python and don't understand thedifference between lists and tuples. Can you explain?"
Answer: "Great question! Both lists and tuples store multiple values,but the big difference is that lists can be changed (mutable)while tuples are fixed (immutable).
Think of it this way: A list is like a to-do list — you can add,remove, or change items. A tuple is like a birthday — once it'sset you can't change the date.
# List (can be changed) fruit = ['apple', 'banana'] fruit.append('orange') # OK!
# Tuple (can't be changed) date = (2024, 3, 15) date[0] = 2025 # ERROR! Raises an exception
Use lists when data can change, tuples when data should be constant."The second example is better because it shows how a real user asks the question, demonstrates the desired tone (educational, with analogies), and shows exactly the level of detail and structure you want.
2. Covers different scenarios
Section titled “2. Covers different scenarios”If you use multiple examples, make sure they show variation in tone and situation — not just easy, clear-cut cases.
## EXAMPLES
Scenario 1: Simple technical questionCustomer: "How do I reset my password?"Assistant: "Click 'Forgot password' on the login page.You'll receive an email with a reset link within 5 minutes.Also check your spam folder! Need more help? 😊"
Scenario 2: Frustrated customerCustomer: "This is the third time I've contacted you about the same problem!"Assistant: "I completely understand your frustration, and I apologizethat we haven't resolved this earlier. I'll prioritize your issueright now. Can you tell me what error number you received so I canescalate directly to our technical team?"
Scenario 3: Question outside knowledgeCustomer: "Do you have plans to release a Mac version?"Assistant: "Unfortunately I don't have information about futureproduct releases. I recommend following our blog at company.com/news.Is there anything else I can help you with today?"The examples cover different emotional states and show how the tone should adapt without compromising professionalism.
3. Clear structure that’s easy to follow
Section titled “3. Clear structure that’s easy to follow”Use consistent formatting in your examples so the model clearly sees the pattern.
## EXAMPLES
Input: [user's actual input]Output: [exact format you want]
Input: [next example]Output: [next response]4. Negative examples
Section titled “4. Negative examples”A powerful technique is to show both what you WANT and what you DON’T want. According to Anthropic’s tests, this can eliminate up to 80% of generic AI responses.
## EXAMPLES OF GOOD RESPONSES
Question: "What is machine learning?"
✅ GOOD RESPONSE:"Machine learning is when computers learn patterns from datainstead of following hardcoded rules. Think of it this way:instead of programming 'if email contains the word Viagra → spam'you train the model on thousands of examples.It learns on its own what patterns are typical for spam.
Example: Netflix recommendations use machine learningto learn what you like based on what you've watched before."
❌ BAD RESPONSE (too technical):"Machine learning is a subset of artificial intelligencethat uses statistical techniques to give computer systemsthe ability to 'learn' from data without being explicitly programmed."Why bad: Technical jargon without explanation, noanalogy or concrete example.
❌ BAD RESPONSE (too vague):"Machine learning is when computers get smarter."Why bad: Too superficial, doesn't give the userreal understanding.Key takeaways
Section titled “Key takeaways”Few-shot prompting is one of the most powerful techniques in prompt engineering — and easier to get started with than you think.
- Examples beat explanations — they show the model exactly what you want, including tone, format, and level of detail that are hard to describe in words.
- Start with 1 example — only add more if the output still doesn’t match your expectations.
- 2–3 examples are usually enough — more examples give diminishing returns and increase cost without proportional improvement.
- Make examples realistic — reflect real usage and variation, not constructed textbook cases.
- Show negative examples — demonstrating what you don’t want eliminates up to 80% of generic responses.
- Consistent formatting — use the same structure (Input/Output) across all examples so the model clearly sees the pattern.
Test your knowledge
5 questions · 100% correct to pass · Review your answers when done