Teaching with Examples: Zero-Shot and Few-Shot
Learn when to show the model examples instead of describing what you want, how many to include, and how to choose examples that don't mislead.
Welcome back!
Step 1 of 13Learn
Describing a style is hard; showing it is easy
Omar runs support for an online plant shop. He wants the AI to tag incoming messages with a category and an urgency level. His first prompt describes the rules in two careful paragraphs. The results are close but inconsistent: sometimes "Urgent," sometimes "High," sometimes a full sentence explaining the choice.
Then he adds three examples:
Message: "My order arrived with a broken pot." → Category: Damage | Urgency: High Message: "Do you ship to Canada?" → Category: Shipping | Urgency: Low Message: "I was charged twice!" → Category: Billing | Urgency: High
Accuracy and consistency jump immediately. The model now copies the exact labels, the exact separator and the exact level of detail.
This is the difference between zero-shot prompting (instructions only) and few-shot prompting (instructions plus a few worked examples). Models are excellent pattern-matchers. An example communicates dozens of small decisions at once: length, vocabulary, punctuation, structure, level of formality, and what to leave out. Writing all of that as rules would take a page; one example does it in a line.
Step 2 of 13Compare
Zero-shot, one-shot and few-shot
| Aspect | Zero-shot | One-shot | Few-shot |
|---|---|---|---|
| What you give | Instructions only | Instructions plus one example | Instructions plus about 2–5 examples |
| Best for | Common tasks with obvious output (summaries, simple questions) | Fixing the format or style of the output | Classification, consistent labels, unusual formats, a particular voice |
| Risk | Format and style vary from run to run | Model may copy the single example too closely | Longer prompts; biased or repetitive examples mislead |
Step 3 of 13Practice · Choose one
Omar's zero-shot prompt gave correct but inconsistent labels ("Urgent" vs. "High"). Why did adding examples fix it?
Step 4 of 13Learn
Choosing good examples
Examples are powerful, which means bad examples are powerful too. The model treats them as the definition of "correct," so it copies their quirks.
Cover the range. If all three examples are short, positive reviews, the model may struggle with a long, angry one. Include at least one example of each category or label you expect, and vary length and tone.
Include the tricky case. If sarcastic messages ("Great, my package is lost again") are often mislabeled, put one in the examples with the correct label.
Keep the format identical. Every example should use exactly the structure you want in the output. If one example uses "Category:" and another uses "Type:", expect the output to wobble.
Watch for unintended patterns. If every example's answer is "High," the model may lean toward "High." If all your example emails start with "Hi Sarah," some outputs may greet Sarah. Shuffle labels and vary the details.
Don't overdo it. Two to five examples usually capture most of the benefit. Many more makes prompts long and can cause the model to imitate surface details rather than the underlying rule. If you need dozens of examples to get consistent behavior, the task may need clearer rules, or splitting into steps.
Step 5 of 13Practice · Chart
Labels in two sets of examples
Set A will make the model unsure about one label. Which one?
Tap the bar that answers the question, then press Check.
Step 6 of 13Practice · Select all that apply
Lucia is writing examples for a prompt that classifies product reviews as Positive, Negative or Mixed. Which choices are good practice? Select all that apply.
Select all that apply.
Step 7 of 13Note
Step 8 of 13Learn
Examples for style and voice
Few-shot prompting isn't only for labels. It's the fastest way to get writing that sounds like you or your organization.
Suppose you want product descriptions in your shop's voice. Describing the voice ("warm, a bit funny, short sentences, no clichés") gets you partway. Pasting two descriptions you've already written and saying "Write a description for the new item in the same style as these examples" gets you much closer, because the model can match sentence length, humor, vocabulary and structure directly.
The same trick works for:
- Email replies that match your team's tone.
- Meeting notes in a fixed template.
- Quiz questions at a particular difficulty.
- Data cleanup, where you show a messy input and the clean version you want.
One caution: the model may copy surface details too closely, reusing a phrase or joke from your example in every output. If that happens, add more varied examples, or tell it explicitly: "Match the tone and structure, but don't reuse phrases."
When you lack examples, you can ask the model to write a few candidates, pick the best, edit it until it's right, and then use that edited version as the example in your real prompt.
Step 9 of 13Diagram
A few-shot prompt sets up a pattern
Tap a shape with to see more.
- Short instruction
"Write product descriptions in our shop's voice."
- Example 1
- Example 2
- Example 3
Varied products, same voice and length.
- New input
The product you actually need described.
- Model continues the pattern
Matching voice, length and structure without a long style guide.
Step 10 of 13Note
Step 11 of 13Practice · True or false
If every example in a few-shot prompt has the same answer label, the model may become biased toward that label.
Step 12 of 13Practice · Spot the mistake
These four examples are meant to teach urgency labels for support tickets. Tap the two examples that would mislead the model.
Step 13 of 13Practice · What would you do?
What would you do?
Dev wants an AI to rewrite technical release notes into short, friendly updates for customers. Zero-shot results are accurate but too formal and too long. What is the best next step?
Lesson complete!