← All lessons
Lesson 13 Prompt Engineering 8:01

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.

ExamplesWhenNote
0common tasks, capable modelssaves context, little control
1the format is obvious from one caserisk of copying that one case too closely
3most situationsbest quality/cost ratio
5+ambiguous or very specific taskseats 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

SituationTechnique
The output format is wrongfew-shot
The result is wrong on multi-step problemschain of thought
Bothexamples that include the reasoning
Simple task, capable modelzero-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.

TechniqueClassic modelReasoning model
“Think step by step”Big improvementRedundant: it already does
Examples including reasoningVery usefulCan hurt: it interferes
Examples with the answer onlyUseful for formatStill 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

ConceptIn one line
Few-shotShowing examples instead of describing the format
Three examplesThe reasonable starting point almost always
DiversityExamples must cover different cases, not repeat one
Chain of Thought“Think step by step”: more accuracy on complex problems
LimitWritten reasoning does not mean correct reasoning
Example biasesImbalance, order and irrelevant traits mislead the model
Reasoning modelsGuide the result, not the reasoning

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.

Watch on YouTube