Lesson 12 of 1570
Few-Shot Prompting: Teach by Example
Instead of describing what you want, show the AI two or three examples. Few-shot prompting is often the fastest way to get consistent output.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1Show, don't just tell
- 2few-shot prompting
- 3zero-shot
- 4pattern matching
Concept cluster
Terms to connect while reading
Section 1
Show, don't just tell
Zero-shot means you ask with no examples — you just describe what you want. Few-shot means you give the AI a few example pairs so it can pattern-match. Few-shot dramatically improves consistency, especially for formatting and tone.
Compare the options
| Zero-shot | Few-shot |
|---|---|
| Describe the task in words only. | Give 2-5 example input/output pairs first. |
| Fast to write. | Takes more setup time. |
| Works for common tasks. | Works for weird, specific, or style-sensitive tasks. |
| Variable results. | Much more consistent results. |
A classic few-shot prompt
Three labeled examples teach the AI the pattern. The fourth is left unfinished for it to complete.
Convert these product reviews into a one-word sentiment tag. Use only: positive, negative, neutral.
Review: "The battery died after three hours. Very disappointed."
Sentiment: negative
Review: "Works fine, nothing special, does what it says."
Sentiment: neutral
Review: "Best headphones I've ever owned — crystal clear sound."
Sentiment: positive
Review: "Package arrived late but the product itself is amazing."
Sentiment:The AI will complete the fourth one with 'positive' — it picks up on the pattern: focus on the product, not the delivery. You didn't have to explain that rule in words. The examples carried the rule.
When few-shot wins
- Custom formatting that's hard to describe (e.g., a special kind of outline).
- Tone of voice — examples nail the vibe faster than adjectives.
- Tricky classification where the rules have exceptions.
- Translating between structured formats.
- Anything where you've thought 'I know it when I see it.'
Example: writing in a specific style
Style transfer via two clear examples.
Rewrite historical facts as if they were sports commentary. Two examples:
Fact: George Washington crossed the Delaware on December 25, 1776.
Commentary: "And there he goes — Washington making the gutsiest Christmas call of his career, charging through the icy Delaware with nothing but stones in his pockets and revolution on his mind!"
Fact: Neil Armstrong walked on the moon on July 20, 1969.
Commentary: "One small step for Armstrong, one giant leap for America's space program — what a clutch moment on the lunar stage tonight!"
Fact: The Wright Brothers' first flight lasted 12 seconds on December 17, 1903.
Commentary:Key terms in this lesson
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Few-Shot Prompting: Teach by Example”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Builders · 26 min
When Prompts Fail: Debugging Checklist
Bad output is almost never random. It's a clue. Here's how to diagnose and fix a broken prompt instead of just mashing the regenerate button.
Builders · 35 min
SQL Basics With AI
SELECT, WHERE, JOIN, GROUP BY. Four keywords run the data world. AI is excellent at SQL because it has read every StackOverflow answer ever.
Creators · 36 min
Meta-Prompting: AI That Writes AI Prompts
Use an AI to write, optimize, and debug your prompts. Meta-prompting is how top teams ship production prompts faster than humans alone could write them.
