AI State of the Art
SOTA/Reasoning Models/21 min
Section 167

Chain-of-Thought Prompting: Fundamentals

Listen as a podcast →

When a Few Examples Changed AI

In 2022, researchers at Google Brain (Wei et al.) did something almost absurdly simple: instead of showing the model examples of the form "question → answer", they showed it examples of the form "question → written-out reasoning → answer". The result? The model suddenly solved problems it had been systematically failing at before.

It's simple, it's almost trivial, and yet it's revolutionary. Chain-of-Thought (CoT) was born, and with it an entirely new era of LLM reasoning. This page picks up where the fundamentals lesson on chain-of-thought leaves off: same ideas, seen this time as the starting point of reasoning models.

Chain-of-Thought Prompting Elicits Reasoning in Large Language Models (Wei et al., 2022)
The fundamental insight

LLMs have latent reasoning capabilities that direct prompting doesn't trigger. CoT unlocks them by forcing the model to show its work, exactly like a math teacher asking "show me your work, not just the answer." By transforming a complex problem into a series of simple steps, each step becomes individually solvable.

Showing Your Work: Why It's Better

Without CoT: The "gut feeling" answer

Without CoT: direct answer

Q: Roger has 5 tennis balls. He buys 2 cans of 3 balls. How many does he have now?

A: 11

The model "feels" the answer. Sometimes it's right, sometimes not. On simple problems, it works. On more complex problems (multiple steps, conditions, traps), the model makes frequent mistakes because it tries to jump straight to the conclusion.

With CoT: Explicit reasoning

With CoT: visual reasoning

Q: Roger has 5 tennis balls. He buys 2 cans of 3 balls. How many does he have now?

A: Roger starts with 5 balls. 2 cans of 3 = 2 x 3 = 6 balls. Total: 5 + 6 = 11 balls.

Same answer here, but the path is explicit. And it's this path that makes all the difference on harder problems. Like a student showing their work on an exam: not only can the teacher follow the reasoning, but more importantly, the student themselves makes fewer mistakes when writing out each step.

Two Variants: Few-shot and Zero-shot

Few-shot CoT: Learning by example

You show the model a few examples of step-by-step reasoning, then give it the new problem:

Few-shot CoT Template

Example 1: Q: [problem] A: [step by step] -> [answer]

Example 2: Q: [problem] A: [step by step] -> [answer]

Q: [new problem] A:

The model recognizes the pattern and applies it to the new problem. The examples act as a mold: they show the model the expected structure of the reasoning.

Zero-shot CoT: The magic phrase

Even simpler, and surprisingly effective:

Zero-shot CoT Template

Q: [problem] A: Let's think step by step.

No examples, just this instruction. And it works remarkably well.

Zero-shot CoT: surprising effectiveness

The "magic phrase" was discovered by Kojima et al. (2022), not by Wei et al. Their abstract gives the numbers, measured on InstructGPT (text-davinci-002): simply adding "Let's think step by step" lifts accuracy from 17.7% to 78.7% on MultiArith and from 10.4% to 40.7% on GSM8K. No examples needed. It's one of the most powerful prompting techniques ever discovered, and certainly the simplest to implement.

Large Language Models are Zero-Shot Reasoners (Kojima et al., 2022)

Why It Works: Four Mechanisms

1. Problem Decomposition

A complex 5-step problem is essentially 5 simple sub-problems that the model knows how to solve. "Calculate the total price with 20% tax on 150 euros" is hard in a single mental leap. But "calculate 150 x 0.2 = ?" (answer: 30) then "150 + 30 = ?" (answer: 180) is trivial. CoT transforms a difficult leap into a series of small steps.

Diagram comparing three ways of handling the same input. On the left, the input goes straight to the model with no intermediate step. In the middle, a chain of N reasoning steps is inserted before the model. On the right, a longer chain with K additional steps. At the bottom, three labels: Accuracy 1 less than Accuracy 2, itself less than Accuracy 3.
Breaking the problem down is not just a metaphor: lengthening the chain of steps mechanically improves accuracy. Direct answer on the left, short chain in the middle, long chain on the right, and accuracy rises in that order. In other words, it is not only the act of reasoning that helps, it is how many small steps the model allows itself to write down.Source : The Impact of Reasoning Step Length on LLMs (Jin et al., 2024, figure 1), via MarkTechPost

2. Externalized Working Memory

When the model writes "first, the unit price is 2 euros," those tokens stay in the context. At the next step, it can re-read that information to continue its reasoning. It's like taking notes on scratch paper: without scratch paper, you have to keep everything in your head. With scratch paper, each intermediate result is accessible. CoT turns the context into working memory.

3. Complexity Reduction

Solving a 5-step problem in a single pass exposes the model to potentially exponential combinatorics (each intermediate choice multiplies). In 5 sequential passes, complexity becomes linear. Mathematically, it's just much easier, and the model mechanically makes fewer errors.

4. Emergence Based on Model Size

Important point: CoT only works well on sufficiently large models. The threshold reported in the Wei et al. paper is high: around 100 billion parameters. It's an emergent capability (a capability that only appears beyond a certain model size, small models don't benefit from it, then it "emerges" suddenly past a threshold): below this threshold, CoT doesn't help, and can even degrade performance. Recent models cross this threshold much earlier, because their training explicitly prepares them for reasoning, but the paper's figure remains the 2022 one. Details in the fundamentals lesson.

Grid of nine plots. Columns correspond to the LaMDA, GPT and PaLM model families, rows to the GSM8K, SVAMP and MAWPS benchmarks. Each plot has model size in billions of parameters on the x-axis and solve rate on the y-axis. The black standard-prompting curve and the blue chain-of-thought curve overlap on small models, then the blue one lifts clearly above the black one on the largest models. A dashed orange line marks the best result previously obtained by supervised training.
Emergence, in one figure. On the left of each plot (small models), the blue CoT curve sticks to the black standard-prompting one: asking the model to think step by step buys nothing, and sometimes hurts. Then, past a certain parameter count, the two curves split apart abruptly. On GSM8K with PaLM, CoT even ends up above the orange line, meaning it beats the best score previously reached by models specifically trained for the task.Source : Wei et al., 2022 paper (figure 4), via DZone

The Numbers: The Gain is Massive

ModelWithout CoTWith CoTGain
PaLM 540B17.9%56.9%+39.0 points
GPT-3 175B15.6%46.9%+31.3 points
Codex19.7%63.1%+43.4 points

Figures from table 2 of the Wei et al. paper, on GSM8K (elementary school math problems), with the same protocol in both columns: 8 exemplars in the prompt, a single generated answer per problem. The gain is staggering: PaLM goes from 18% to 57%, a tripling of performance, just by asking the model to show its work.

CoT is essentially free

Zero additional training. It's pure prompting. The only cost: a few more tokens in the response. For any reasoning task, it's almost always an excellent investment. The gain-to-cost ratio is unbeatable.

How to Structure Reasoning Well

Good vs bad structure

Good structure:

  • Step 1: Identify known variables
  • Step 2: Set up the equation
  • Step 3: Solve
  • Step 4: Verify the result

Bad structure:

  • "Let's see... hmm... I think that..."

Explicit labels ("Step 1", "Data", "Conclusion") greatly help the model organize its reasoning. A well-structured CoT is significantly more reliable than a CoT that rambles.

Best Practices

1. Structure Explicitly

Use clear labels: "Step 1:", "First...", "Known data:" The model performs better when the structure is explicit.

2. Ask for Verification

Add "Verify your reasoning" or "Recalculate to confirm" at the end of the prompt. This encourages the model to re-read its own answer and catch obvious errors.

3. Separate Reasoning and Answer

Enforce a clear output format: reasoning on one side, then "Final answer: X" on the other. This is essential if you need to extract the answer programmatically.

4. Don't Use CoT Everywhere

CoT is made for reasoning: math, logic, multi-step analysis. For "What is the capital of France?", CoT is useless and can even degrade performance. The model "thinks" too much and ends up overcomplicating a trivial question.

On the left, a meta-analysis: thirteen task categories are stacked vertically, from text classification at the top to symbolic and algorithmic reasoning at the bottom. For each, a scatter of points shows the improvement CoT brings over direct answering, from minus 60 to plus 60 points. The top categories are centred on zero, while the bottom ones, math and symbolic, are clearly shifted toward positive gains. On the right, a five-axis radar chart labelled Mathematical, Soft Reasoning, Commonsense, Knowledge and Symbolic: the orange zero-shot CoT curve clearly exceeds the blue direct-answer curve on the Mathematical and Symbolic axes and overlaps it on the other three.
A meta-analysis over a hundred-plus studies settles the question of when. Tasks are ordered top to bottom by increasing gain: on text classification, encyclopedic knowledge or commonsense, the points scatter around zero and CoT buys nothing. On math and symbolic reasoning, at the bottom, the gains are large. The radar on the right says the same thing: only two axes lift off.Source : To CoT or not to CoT paper (Sprague et al., 2024, figure 1), via The Moonlight
The reasoning can look perfect and be wrong

A CoT can be beautifully articulated, with each step seemingly following logically from the previous one, while being mathematically incorrect. LLMs are excellent at generating text that sounds logical. Never blindly trust a model's reasoning: verify the results, especially on problems that matter.

The Legacy of Chain-of-Thought

CoT opened up an entire lineage of techniques: self-consistency (voting among multiple reasoning chains), Tree of Thoughts (exploring a tree of reasoning paths), Graph of Thoughts, and ultimately reasoning models like o1 and DeepSeek-R1 that internalize CoT directly into their generation process.

Chain-of-Thought is the foundation. Everything that came after, from the simplest techniques to the most sophisticated, is a refinement of this disarmingly simple idea: show your work.

Check your understanding0 / 4

1. A model produces a beautifully articulated step-by-step reasoning chain, where each step seems to follow logically from the previous one. What can you conclude about the final answer?

2. Why does the Wei et al. paper call Chain-of-Thought an emergent capability?

3. What role do the already-written steps (like 'first, the unit price is 2 euros') play for the rest of the generation?

4. According to the meta-analysis of over a hundred studies cited on this page, on which kinds of tasks does CoT deliver a real gain?