Few-shot and Chain of Thought
Teaching by example and thinking out loud. The two techniques that raise accuracy the most without touching the model.
The video loads only if you ask: no request to YouTube before the click.
The video is in Italian; this page is the written version in English.
Two techniques, one shared principle: instead of hoping the model guesses what you want, you show it. With examples, or with reasoning.
Few-shot: showing instead of explaining
Describing a format in words is laborious and ambiguous. Showing three examples is immediate.
| Examples | When | Note |
|---|---|---|
| 0 | common tasks, capable models | saves context, little control |
| 1 | the format is obvious from one case | risk of copying that one case too closely |
| 3 | most situations | best quality/cost ratio |
| 5+ | ambiguous or very specific tasks | eats a lot of context |
Start with three. If it is not enough, add more; if context is tight, drop to one or two.
Choosing the examples matters more than counting them. They must be different from each other:
Bad — the same case three times:
"The cat is lovely" → positive
"The dog is cute" → positive
"The flower is gorgeous" → positive
Good — cases that cover the space:
"The cat is lovely" → positive
"The service was awful" → negative
"Works, nothing special" → neutral
And they must be realistic: if every example is trivially easy, the model does not learn to handle real cases, which are shaded. Watch order and balance too: if all your examples end with the same label, the model leans that way.
Chain of Thought: thinking out loud
A model that answers immediately has a single pass to reach the solution. Invite it to write the steps and each step becomes context for the next — the difference on multi-stage problems is marked.
The minimal version is one appended sentence: “think step by step before answering”. On arithmetic, logic or multi-constraint problems accuracy rises sharply, essentially for free.
The structured version combines both techniques: give examples that include the reasoning, not just the final answer. The model then learns the kind of reasoning you expect, not merely the output format.
Two caveats. Reasoning costs context and time: on trivial tasks it is pure waste. And written reasoning is no guarantee: a model can produce impeccable steps and a wrong conclusion, or rationalise an answer it had already picked.
Note that recent models with built-in reasoning do this internally on their own: with them, explicitly asking for step-by-step adds little.
When to use what
| Situation | Technique |
|---|---|
| The output format is wrong | few-shot |
| The result is wrong on multi-step problems | chain of thought |
| Both | examples that include the reasoning |
| Simple task, capable model | zero-shot, and nothing more |
When examples make things worse
Few-shot is neither free nor always positive. Three documented biases produce systematic, silent errors.
Label imbalance: if four of your examples are positive and one negative, the model will classify as positive more often, regardless of content. Examples also teach how likely each answer is.
Recency weight: the example closest to the question weighs more than the others. If it is an edge case, the answer will resemble it.
Surface copying: if every example shares an irrelevant trait — same length, same sentence shape, same topic — the model may imitate that trait instead of the logic.
The countermeasures are simple: balance the labels, shuffle the order instead of grouping by category, use examples varied in length and form. And if results stay inconsistent, try removing them: on capable models, zero-shot with precise instructions sometimes beats an unbalanced few-shot.
With reasoning models, the rules change
With models that generate internal reasoning before answering, it is easy to go wrong out of habit.
| Technique | Classic model | Reasoning model |
|---|---|---|
| “Think step by step” | Big improvement | Redundant: it already does |
| Examples including reasoning | Very useful | Can hurt: it interferes |
| Examples with the answer only | Useful for format | Still the right way to guide it |
The counterintuitive part is the middle row: showing a reasoning model how it should reason tends to cage it in a scheme less effective than its own. With these models, describe the problem and the output format well, and let it find the path itself.
In short
| Concept | In one line |
|---|---|
| Few-shot | Showing examples instead of describing the format |
| Three examples | The reasonable starting point almost always |
| Diversity | Examples must cover different cases, not repeat one |
| Chain of Thought | “Think step by step”: more accuracy on complex problems |
| Limit | Written reasoning does not mean correct reasoning |
| Example biases | Imbalance, order and irrelevant traits mislead the model |
| Reasoning models | Guide the result, not the reasoning |
- Few-shot
- Chain of Thought
- Accuracy
Related lessons
- Prompting basics
The anatomy of a prompt that works: instruction, context, data and format. Four pieces that explain the difference between a vague answer and a useful one.
- Advanced prompting techniques
Beyond step-by-step: letting the model use tools, explore alternatives, and review its own work. The techniques behind what we now call agents.