Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
Chain-of-Thought
prompting, explained.
Ask a student to shout the answer to a hard word problem instantly and they'll flub it. Give them a sheet of scratch paper and they'll get it right. This 2022 paper found the exact same thing about language models — and the fix was as simple as showing them how to work things out step by step.
What changes here: the examples show the work
Rung 1, so the comparison is against the few-shot prompting it modifies, and the modification is almost absurdly small. Standard few-shot prompting shows the model a handful of question-and-answer pairs and then a new question. Chain of thought shows it question, worked reasoning, answer — and then the new question. Nothing else changes. No training, no gradient, no parameters, no architecture.
Why that should matter at all is the interesting part. A model answering immediately has to produce the answer in a single forward pass, so the amount of computation available is fixed by the architecture regardless of how hard the question is. Generating intermediate steps lets the model take more forward passes on a harder problem (though the paper's dots-only ablation suggests the extra passes alone are not what helps), and lets each step condition on the written result of the last — externalising working memory into the context window, where it is exact, instead of holding it in activations, where it is not.
The second finding is the one that made the paper famous and is worth carrying up the ladder carefully. The benefit is not uniform across model sizes: below a certain scale, showing the reasoning does not help and can actively hurt, because a smaller model produces fluent chains that are wrong and then follows them. The gain appears at scale and appears sharply, which is where the vocabulary of emergent abilities attached to this result.
The one-leap problem
By 2022, big language models were fluent and knowledgeable, yet strangely bad at problems a careful ten-year-old could solve — multi-step arithmetic, word problems, chains of logic. A model prompted to answer straight away had to squeeze every step of the calculation into a single forward pass and blurt the result. On anything needing more than one step, it stumbled.
The failure wasn't knowledge. It was being forced to leap from question to answer with no room to work in between.
The big idea: show the working
The authors changed the prompt, not the model. In the few examples you show a model before asking your real question — the few-shot exemplars — they didn't just include the answer. They included the reasoning that leads to it, spelled out step by step. That trail of intermediate steps is the chain of thought.
Primed with a couple of examples of what good reasoning looks like, the model imitates the format: for your new question, it writes out its own steps before committing to an answer — giving itself the scratch paper it never had.
Same model, same question
Nothing about the model changed between these two panes — only whether it was allowed to think out loud. Breaking one hard leap into a handful of easy steps, each building on the last, is the entire trick.
There's a simple reason this compounds. If each reasoning step is right with probability p, the whole answer needs all k steps to land — p^k. Answering in one shot means each hidden step is less reliable (no room to work), so its p is lower, and p^k falls off a cliff:
The more steps a problem needs, the wider the gap — which is exactly where the paper found CoT helps most. The runnable version below makes that curve.
Why it only works at scale
The paper's most striking finding: chain-of-thought is an emergent ability. On small models it barely helps, and sometimes hurts — they produce reasoning that sounds right but doesn't hold together, and the wrong steps drag the answer down with them.
Then, somewhere past roughly 100 billion parameters, the curve bends sharply upward. Suddenly the reasoning is coherent, the steps are valid, and accuracy jumps. Reasoning wasn't something you could prompt into a small model; it appeared, almost like a phase change, only once the model was big enough.
This was one of the clearest early examples of an "emergent ability" — a skill that's absent at small scale and appears abruptly at large scale — which reshaped how the field thought about what more compute actually buys.
Zero-shot: the magic phrase
A closely related follow-up found you often don't even need worked examples. Append five words — "Let's think step by step" — to a question, and a large model starts generating its own reasoning chain unprompted. Much of the benefit of chain-of-thought, unlocked by a single sentence.
Why it still matters
Chain-of-thought reframed inference itself: a model that can spend more steps "thinking" before answering is more capable than one forced to reply instantly. That single insight seeded everything that followed — self-consistency (sample many chains, take the majority vote), tree-of-thought, and the modern reasoning models that are explicitly trained to generate long internal chains and spend extra compute at inference on hard problems.
When today's models "think" before they answer, they're standing on this paper. It's the moment the field learned that how you let a model compute can matter as much as how big it is.
The practical takeaway holds even for small prompts: for any multi-step task, ask the model to reason before it answers. It's the highest-leverage, lowest-effort prompt change you can make.
How Wei et al. ran chain-of-thought prompting
Chain-of-thought prompting comes from Jason Wei and colleagues at Google Research's Brain team. Nothing in the model changes. The whole method is how the prompt is built and how the answer is read back out, and the paper's contribution is doing that carefully across many models and tasks and then taking it apart with ablations.
- Write the exemplars by hand. For the math word-problem benchmarks the authors wrote one set of eight exemplars, each a question, a short chain of reasoning in plain language, and a closing line stating the answer. The same eight were reused for GSM8K, SVAMP, ASDiv and MAWPS. AQuA, which is multiple choice, got four exemplars taken from its training set. The commonsense and symbolic tasks got their own small hand-written sets.
- Build the baseline from the same exemplars. Standard few-shot prompting uses the identical questions and answers with the chains deleted, so the only difference between the two prompts is the reasoning text.
- Decode greedily and parse. The exemplars and the test question go in, and the model generates until it stops. Decoding is greedy, so each question gets exactly one chain, and the answer is read from the closing answer line the exemplars taught the model to write.
- Sweep model families and sizes. The same prompts ran on LaMDA (422M to 137B parameters), GPT-3 (InstructGPT variants from about 350M to 175B), PaLM (8B, 62B and 540B), UL2 20B and Codex. Sweeping size inside each family is what exposes the scale threshold.
- Cover three kinds of reasoning. Arithmetic on five math benchmarks; commonsense on CSQA, StrategyQA, date and sports understanding from BIG-bench, and SayCan robot planning; and symbolic manipulation, last-letter concatenation and coin flips, with test inputs longer than any exemplar showed.
- Ablate what the chain contributes. Three variants each isolate one explanation. Equation only: the exemplars show just the equation before the answer. Variable compute only: the exemplars show a run of dots as long as the equation, so the model spends extra tokens that carry no content. Reasoning after the answer: the chain follows the answer, so it cannot have produced it.
- Test robustness. Chains written by three different annotators, exemplars sampled from GSM8K's training set, and different exemplar orders and counts.
What the ablations rule out
Each ablation matches a cheap explanation of the gain. If it came from translating words into equations, equation-only prompting would match it; on GSM8K it helps little, though it does help on one- and two-step problems. If it came from extra tokens of computation, the dots would match it; they score about like the baseline. If the chain only reminded the model of relevant knowledge, moving it after the answer would keep the gain; it does not. What is left is that the content of the steps, written in order before the answer, is what helps.
Reading the errors
The authors also read chains by hand. For LaMDA 137B on GSM8K, nearly every chain that reached a correct answer was itself correct, with two that got there by coincidence. Among wrong answers, about half the chains were nearly right, spoiled by a calculator slip, a symbol-mapping error or one missing step, and the rest had major semantic or coherence errors. Comparing PaLM 62B with 540B, the larger model fixed a large share of the missing-step and semantic-understanding errors, which is the scale threshold seen one error at a time.
The decision rule: one greedy chain, then read the answer
Chain-of-thought prompting changes what the model conditions on, not how it is trained. With k exemplars, each a question xi, a chain ci and an answer yi, the model decodes greedily and the answer is parsed from the end of its output:
ŷ = parse( ẑ1 ẑ2 ⋯ ẑT )
xi ci yi— the hand-written exemplars; delete every ci and this is standard few-shot promptingx— the test questionẑt— the token chosen at step t; the argmax is greedy decoding, so one question yields one chainparse— reads the number or option from the closing answer line the exemplars taught
The rule commits to a single path: the answer is right only if that one chain is. At one extreme, k = 0 plus a trigger sentence is zero-shot chain of thought. At small model sizes the chain itself goes wrong, and parse faithfully reports the wrong answer it ends on. Replacing the argmax with sampling and voting over many chains is exactly the change the self-consistency paper makes next.
What Wei et al. ran, and what it showed
The headline test is GSM8K, grade-school math word problems, with the same eight exemplars used with and without their chains, greedy decoding, and solve rate as the score. The prior best was GPT-3 175B fine-tuned on GSM8K's training set and paired with a separately trained verifier, at 55%.
| Model, GSM8K | Standard prompting | Chain of thought |
|---|---|---|
| LaMDA 137B | 6.5% | 14.3% |
| GPT-3 175B (text-davinci-002) | 15.6% | 46.9% |
| PaLM 540B | 17.9% | 56.9% |
| Prior best: fine-tuned GPT-3 175B with a verifier | 55% | — |
PaLM 540B with eight exemplars and no training more than tripled its own baseline and passed the fine-tuned system. The pattern held beyond math: on StrategyQA, PaLM 540B with chain of thought reached 75.6% against a prior state of the art of 69.4%, and on sports understanding it reached 95.4%, above the 84% the paper cites for an unaided sports enthusiast.
Where it failed. Below roughly 100B parameters the chains were fluent but illogical, and accuracy did not improve; on some tasks it fell below standard prompting. On the easiest subset of MAWPS, problems needing a single operation, the gain was negative or very small, because there is no chain to write. The three ablations were negative by design: equation only, dots only and reasoning after the answer each recovered little or none of the GSM8K gain. Chains from three different annotators all beat the baseline by a wide margin, though they varied among themselves, which is both the robustness claim and its limit.
What the authors admit, and what happened next
The paper is careful about something that its popular summary is not: the generated chain is not a trace of the model's computation. It is text the model produced, which influences what it produces next. Whether it describes the process that actually determined the answer is a separate empirical question, and later work on faithfulness found the two can come apart — models will produce a chain that does not reflect the features actually driving their answer, including cases where an answer is steered by something the chain never mentions. Reading a chain of thought as an explanation is therefore a mistake with a specific name, and it matters most where the stakes are highest.
The emergence framing was also contested, usefully. Schaeffer and colleagues argued that apparent sharp jumps are frequently artefacts of discontinuous metrics — score a multi-step task by exact match and smooth underlying improvement shows up as a sudden threshold, because partial credit is unavailable. That critique does not make the practical effect unreal, and it changes what it is evidence of.
How it held up: it is the substrate for everything above it on this ladder and for a large share of the post-training ladder too. The most remarkable thing about it in retrospect is the ratio — a change to the wording of a prompt, requiring no resources at all, that unlocked a capability people had assumed needed a different kind of model. That ratio is also why the rest of this ladder exists: once it was clear the capability was latent, the question became how much compute it was worth spending to extract it.
Why the gap widens with every step
Chain-of-thought first solves the cafeteria problem as an explicit trace — then models why writing steps out wins. If each step is right with probability p, the whole answer needs all k steps to land: pk. Answering in one shot makes each hidden step less reliable, so its curve collapses far faster. Run it and watch direct answering fall to 6% at eight steps while the written-out chain holds at 66% — the paper's core finding, in one exponent. Change the per-step reliabilities or the step count.
Write the body of solve_cafeteria. Everything else in the file is
already written; this is the function the paper is about. Press ▶ Run to check it against
the 5 assertions below — they start red.
- The reasoning trace produces the correct answer
- Writing steps out raises per-step reliability
- Direct answering collapses faster than CoT over 8 steps
- The CoT advantage widens as the problem gets longer
- On a single step each equals its per-step reliability
Questions people ask about Chain-of-Thought Prompting
Does chain of thought work because of the extra tokens, or because of the reasoning itself?
Wei and colleagues tested this directly. One ablation replaced each exemplar's reasoning with a string of dots as long as the equation it needed, so the model spent the same extra tokens with no content in them; accuracy stayed about where standard prompting was. Another put the reasoning after the answer, so it could not have produced the answer; that also stayed near the baseline. A third showed only the equation, which helped little on GSM8K, though it did help on problems needing one or two steps. The conclusion the paper draws is that the gain comes from the content of the intermediate steps, written in order before the answer, not from extra computation and not from the prompt merely reminding the model of relevant knowledge.
What does a chain-of-thought exemplar look like in the original paper?
Each exemplar is a question, a few sentences of reasoning in plain language, and a closing line that states the answer. The best-known one is the cafeteria problem: 23 apples, 20 used for lunch, 6 more bought. The chain says that 23 minus 20 leaves 3 and 3 plus 6 makes 9, then states that the answer is 9. For the math benchmarks the authors wrote a single set of eight such exemplars by hand and reused it across GSM8K, SVAMP, ASDiv and MAWPS. The model reads all eight before the real question and imitates the format, writing its own steps and its own closing answer line, which is where the answer is parsed from.
At what model size does chain-of-thought prompting start to help?
In the paper's sweeps, chain of thought did not reliably help until models reached roughly 100 billion parameters, and below that it sometimes hurt, because smaller models wrote fluent chains that did not hold together and then followed them to a wrong answer. The threshold showed up in every family tested at scale: LaMDA up to 137B, GPT-3 up to 175B and PaLM up to 540B. The authors called it an emergent ability of scale. Schaeffer and colleagues later argued that such sharp jumps often reflect all-or-nothing metrics like exact match rather than abrupt changes in the model. The practical finding survives either reading: on large models the gain is large, on small ones it is unreliable.
Why does chain of thought help more on GSM8K than on easy math problems?
The gain grows with the number of steps a problem needs. GSM8K problems take several steps of arithmetic and language understanding, and GSM8K had the lowest standard-prompting baseline of the math benchmarks, so it had the most to gain: PaLM 540B went from 17.9% to 56.9%. On the easiest subset of MAWPS, where each problem needs one operation, the improvement was negative or very small, because there is no intermediate state worth writing down. The same logic explains the equation-only ablation, which helped on one- and two-step datasets but not on GSM8K: short problems translate straight into an equation, while multi-step word problems need the natural-language steps in between.
Is a chain of thought an explanation of how the model reached its answer?
Not necessarily, and the paper is careful about this. A chain is text the model generated, and it conditions what the model writes next, but nothing guarantees that it describes the computation that actually produced the answer. The authors' own error analysis found correct answers reached through flawed chains, if rarely. Later faithfulness research went further and found models writing plausible chains that leave out the real reason for an answer, such as a cue planted in the prompt. A chain is useful for spotting where a calculation went wrong and for steering a model, but treating it as an audit trail of the model's internal reasoning is a mistake.
4 questions to test what you just read
Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.
PaLM 540B went from 17.9% to 56.9% on GSM8K. By what factor did chain of thought multiply its solve rate, and by how many points did it clear the fine-tuned system with a verifier?
Show answer
56.9 ÷ 17.9 ≈ 3.2×. Against the prior best of 55%, chain of thought was 1.9 points ahead, using eight exemplars and no training, while the 55% system needed fine-tuning on GSM8K's training set plus a separately trained verifier.
The dots ablation gives the model as many extra tokens as the equation would use, but no content. If chain of thought worked purely by buying computation, what should that ablation have scored, and what did it score?
Show answer
If extra forward passes were the mechanism, the dots should have recovered most of the chain-of-thought gain. They scored about the same as standard prompting. Spending tokens is not enough; the tokens have to carry the intermediate results that later steps condition on.
Predict: a 1B-parameter model and PaLM 540B get the same chain-of-thought prompt on GSM8K. Which one is more likely to do worse than with standard prompting, and why?
Show answer
The 1B model. Below roughly 100B parameters the paper found chains that were fluent but illogical, and the model then followed its own wrong steps to the answer, so chain of thought gave no gain and sometimes cost accuracy. The 540B model writes chains coherent enough that each step actually helps the next.
Why does putting the reasoning after the answer test a different hypothesis than the dots ablation does?
Show answer
The dots test whether extra computation explains the gain. Reasoning-after-answer keeps all of the content but removes its position before the answer: if the chain helped only by reminding the model of relevant knowledge, it would still help there. It did not, so order matters; the steps help because the answer is generated conditioned on them.
Reasoning you can prompt, then train
It began as a prompting trick and ended as a training objective. Read in order, the progression from "let's think step by step" to a model trained to.
- 1Chain-of-Thought Prompting2022
- 2Self-Consistency2022
- 3Tree of Thoughts2023
- 4OpenAI o12024
- 5DeepSeek-R12025
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Paper Breakdowns
- Attention Is All You NeedThe paper that introduced the Transformer — the architecture underneath GPT, BERT, Claude, and Gemini. Self-attention, Query/Key/Value, multi-head attention, positional encoding, and the real BLEU results, explained in depth with analogies and animated visuals, not just equations.Read →
- BERTThe paper that made "pre-train once, fine-tune anywhere" the default for NLP. Bidirectional context, masked language modeling, next-sentence prediction, the [CLS]/[SEP] tokens, and the GLUE sweep — explained with analogies, not just equations.Read →
- LoRAThe paper that made fine-tuning affordable. Freeze the giant pretrained model and train two tiny low-rank matrices instead — up to 10,000x fewer trainable parameters, no extra inference latency, and swappable per-task adapters. The road to QLoRA and PEFT.Read →
- Direct Preference OptimizationRLHF without the RL. Align a model to human preference pairs with one simple classification-style loss — no separate reward model, no unstable reinforcement learning. Why "your LM is secretly a reward model", and how DPO became the default alignment method.Read →
- ChinchillaThe compute-optimal scaling law that said models were too big. Parameters and training tokens should scale together — ~20 tokens per parameter — so a 70B model trained on 1.4T tokens beat the 280B giants. Why every model since trains on trillions of tokens.Read →
- FlashAttentionAttention was slow for the wrong reason. By treating it as a memory-movement problem — tiling, online softmax, keeping work in fast SRAM instead of slow HBM — FlashAttention makes exact attention several times faster and cuts its memory from quadratic to linear, unlocking long context windows.Read →