Lesson 03
Zero-shot vs few-shot: the pattern worth more than a bigger model
When to give the model examples and when not. Golden rule: if you can show it, don't describe it.
The million-dollar question
When is it worth spending tokens on examples?
Short answer: any time the format is unusual, the task is ambiguous, or the tone is specific.
Long answer: keep reading — without this, you stay mediocre.
Zero-shot — no examples
You ask the model to do something without showing it any case. Works very well for common tasks the model has “seen” in training.
const res = await client.messages.create({
model: "claude-haiku-4-5",
max_tokens: 100,
messages: [
{ role: "user", content: "Translate to Spanish: 'Hello, how are you?'" },
],
});
// → "Hola, ¿qué tal?"
Tasks where zero-shot usually works:
- Translation between common languages
- Summarizing text
- Factual Q&A
- Rewriting in a different tone
Few-shot — 2 to 5 examples
You show several examples, then ask for a new one. The model learns the pattern, not the specific answer.
const res = await client.messages.create({
model: "claude-haiku-4-5",
max_tokens: 100,
system: "You convert company names into URL-friendly slugs.",
messages: [
{
role: "user",
content: `Examples:
"Café & Tea Ltd." → cafe-tea
"My Restaurant 24/7" → my-restaurant-24-7
"Acme Corp." → acme-corp
Convert: "María Jewelry Boutique"`,
},
],
});
// → "maria-jewelry-boutique"
Without examples, you might get MariaJewelryBoutique, mar%C3%ADa-jewelry, or anything else. With three examples, you nail the pattern.
The practical rule
If you can show the output, don’t describe it.
Compare:
Bad (zero-shot describing format):
Return a JSON object with fields name, age, and profession, all lowercase,
where profession is always an array even if it has a single value.
Good (few-shot showing format):
Examples:
"Ana, 30, engineer" → { "name": "ana", "age": 30, "profession": ["engineer"] }
"Luis, 45, lawyer and teacher" → { "name": "luis", "age": 45, "profession": ["lawyer", "teacher"] }
Convert: "María, 28, doctor"
The second prompt is shorter, clearer, and much more reliable.
How many examples
- 1 example (one-shot) → most cases. Enough to lock down format.
- 3-5 examples → when there are variations or edge cases to show.
- >5 examples → almost never. Past that, prefer fine-tuning or RAG.
Example bias
Watch out: the model copies patterns. If all your examples are similar in length, it will expect that length back. If all end with a period, it will too.
So vary on purpose:
"yes" → positive
"NO." → negative
"haha sure, totally" → negative (sarcastic)
Three examples, three lengths, three tones. You are teaching the model that the answer does not depend on shape, but on meaning.
Challenge
Design a few-shot prompt that takes product reviews and returns a score from 1 to 5.
Share it in the community Discord and other learners will spot the blind spots. In the next lesson, chain-of-thought: the trick that makes the model reason instead of guessing.
Pro challenge
Pro challenge for this lesson
Same idea, no hints, graded by automated tests.
Hard Mode
Hard Mode
Extreme variant of the challenge. Time-bound with extra constraints.