Prompt Engineering· Lesson 2 of 7
- 1Anatomy of a Prompt — What It's Made Of6 min
- 2Few-Shot — Teach by Example7 min
- 3Structured Output — Make It Return JSON7 min
- 4Chain of Thought — Let It Reason Step by Step8 min
- 5Prompt Iteration — Improving It in Passes6 min
- 6Role & Persona — Tell It Who to Be7 min
- 7Prompt Injection Basics — When Input Turns Against You8 min
Few-Shot — Teach by Example
In one line · Instead of explaining what you want, give the model a few worked examples (input and output) and it imitates the pattern.
Some things are hard to describe in words but easy to show. Examples lock in the format and tone far better than any description — provided they're clean and consistent, because the model imitates whatever's in them, warts and all; a sloppy example teaches the wrong thing.
Like showing a new hire 3 messages and how we replied before, then saying 'continue in the same style'. Examples save a whole lecture.
Zero-shot means 'get it from the description'; few-shot means 'watch and imitate'. The second is sharper when the exact shape matters.
Want to rewrite sentences formally? Give two examples: 'wanna → I would like to' and 'gonna → I am going to', then add the new sentence and let it continue.
The model was trained to continue patterns, so when the prompt holds a few (input → output) pairs in the exact same shape and the last pair is left open, it completes it in that pattern. All of this happens in-context inside the context window — no training or fine-tuning takes place. Usually 2-5 varied examples are enough, and consistency of the example format matters far more than their count.
Rewrite the sentence formally.
Input: wanna grab lunch?
Output: Would you like to have lunch?
Input: gonna be late, sry
Output: I will be late, my apologies.
Input: can u send the file?
Output:Note the last line is deliberately left open — the model completes the pattern. And the format (Input: / Output:) is identical down to the character in every example.
🧪 Try it yourself: take a classification prompt of yours running zero-shot with shaky results. Add 3 real, consistently-formatted examples (make one an edge case), run the same inputs through both versions, and compare consistency — not just right vs wrong.
- Inconsistent examples (one JSON, one free text) — the model imitates the inconsistency itself.
- All examples are easy cases, so the first real edge case falls over; include at least one hard example.
- Piling on 15+ examples — burning tokens, cost, and latency for negligible gains, while the model sometimes copies superficial quirks of the examples.
When the shape, tone, or classification boundary is hard to describe but easy to show: custom formats, a specific voice, categories with fuzzy edges.
If a plain description works, zero-shot is cheaper and faster. And don't use examples to 'teach new logic' — they lock in shape and pattern; they don't grant reasoning ability the model lacked.