TL;DR
Wei and colleagues showed that a large language model can solve multi-step problems it otherwise gets wrong, if the prompt includes a few worked examples whose answers are preceded by written-out reasoning steps. The model is not retrained. The method is called chain-of-thought prompting, and it only helped in models of about 100 billion parameters or more. On the GSM8K benchmark of grade-school maths word problems, PaLM 540B went from 17.9% to 56.9% accuracy, which beat the prior fine-tuned state of the art.
Where you'll see it: in the default way people prompt reasoning models for maths and logic, in the evaluation suites that measure "reasoning" in new language models, and in the step-by-step traces that later reasoning-trained models learn to produce on their own.
The problem
By 2022, few-shot prompting, where a model is shown a handful of input-output examples before the test input, had become a standard way to use large language models. It worked well for simple question answering. It worked poorly for tasks that need several steps of reasoning. Scaling the model helped many tasks, but Rae et al. (2021) had found that scale alone did not solve challenging reasoning tasks.
Two routes were known. The first trained or fine-tuned models to write out intermediate reasoning, which needed many expensive, carefully written rationales. The second relied on prompting, which was cheap but gave weak reasoning. The paper asks whether the cheap route can be made to work for reasoning by changing what the examples look like.
Key idea
The examples in the prompt show the reasoning, not just the answer. Each exemplar is a triple of input, chain of thought, and output. A chain of thought is a short series of natural-language steps that leads to the answer. The model then imitates that pattern on a new question and writes its own steps before answering.
flowchart TD
subgraph Standard
S1[Question] --> S2[Answer directly]
end
subgraph Chain of thought
C1[Question] --> C2[Reasoning steps] --> C3[Answer]
end
The paper's example is a math word problem. A standard prompt shows a question and the bare answer. A chain-of-thought prompt shows the same question, followed by a sentence or two of arithmetic in plain English, then the answer. Given a new problem, the model writes its own reasoning before the number. Because the reasoning is written out, the model can spend more tokens on harder problems, and a reader can see where a wrong answer went off track.
The method
Prompting, not training
The authors use one fixed prompt per benchmark. A single set of eight exemplars serves every math dataset except AQuA, which is multiple choice and uses four exemplars taken from its training set. Each exemplar is a short question, a chain of thought, and an answer. The authors wrote the eight exemplars themselves and did not tune them to improve scores. The main results use greedy decoding, so each question gets one generated chain. No weights change.
Formally, let be the question, the chain of thought, and the final answer. Standard prompting models , where is the set of exemplars with their answers. Chain-of-thought prompting models , where contains exemplars that include . The method works by conditioning on , so the model writes before . This is a use of in-context learning with a different format for the examples.
Setup
The paper evaluates three families of task. Arithmetic covers five math word-problem sets: GSM8K, SVAMP, ASDiv, AQuA and MAWPS. Commonsense covers CSQA, StrategyQA, date and sports understanding, and SayCan. Symbolic covers last-letter concatenation and coin flip, with an out-of-domain test where the problems have more steps than any exemplar.
The models are GPT-3 (text-ada-001 through text-davinci-002, which presumably correspond to InstructGPT models of 350M to 175B parameters), LaMDA from 422M to 137B parameters, PaLM at 8B, 62B and 540B, UL2 20B, and Codex (code-davinci-002). All are decoded greedily.
Results
Arithmetic
The headline numbers come from the arithmetic benchmarks. The table below shows accuracy on GSM8K with standard versus chain-of-thought prompting.
| Model | Standard | Chain of thought |
|---|---|---|
| LaMDA 137B | 6.5 | 14.3 |
| GPT-3 175B (text-davinci-002) | 15.6 | 46.9 |
| Codex (code-davinci-002) | 19.7 | 63.1 |
| PaLM 540B | 17.9 | 56.9 |
The prior best on GSM8K is 55%, a fine-tuned GPT-3 with a verifier (Cobbe et al.), so PaLM's 56.9 is a new state of the art. Codex does better still at 63.1. On SVAMP, PaLM 540B rises from 69.4 to 79.0 (prior best 57.4, which standard prompting had already passed). On MAWPS, it rises from 79.2 to 93.3 (prior best 88.4). On ASDiv the prior best is 75.3 against PaLM's 73.9, and on AQuA it is 37.9 against 35.8, so PaLM lands within 2 points of the state of the art on ASDiv and just over 2 on AQuA. The text calls both "within 2%".
Gains grow with problem difficulty. GSM8K has the lowest baseline and more than doubles for the largest GPT and PaLM models, while on SingleOp, the one-step subset of MAWPS, gains are negative or tiny. Chain of thought also does not always help: LaMDA 137B drops on AQuA from 25.5 to 20.6.
Commonsense and symbolic tasks
On commonsense benchmarks the gains are smaller but consistent, and largest for PaLM 540B. It beats the prior best on StrategyQA (75.6% against 69.4%) and an unaided sports enthusiast on sports understanding (95.4% against 84%), but gains on CSQA are minimal. The authors argue the method suits these tasks because the reasoning is linguistic. On symbolic tasks, PaLM 540B with chain-of-thought prompting reaches almost 100% solve rates in-domain. Standard prompting already solves coin flip at this scale, though not for the smaller LaMDA 137B. Out of domain, with longer inputs than the exemplars, standard prompting fails on both. Chain-of-thought prompting gives rising accuracy with model size, so the model generalises to longer sequences than it saw in the examples.
Ablations
The authors tested three ways to explain the gain. The GSM8K numbers below are for LaMDA 137B (standard 6.5, chain of thought 14.3).
- Equation only. The model writes just the arithmetic equation before the answer. This helps for one- and two-step problems but not for GSM8K (5.4, slightly below standard), where the words carry the difficulty.
- Variable compute only. The model writes a string of dots as long as the equation, in characters. This does about as well as the baseline (6.4), so extra tokens alone are not the cause.
- Chain of thought after the answer. The reasoning comes after the answer. This also does about as well as the baseline (6.1), so the gain depends on the reasoning coming first.
Together these suggest that the natural-language steps do the work, not just the length of the output.
Robustness
Three co-authors (A, B and C) wrote independent chains of thought for the same exemplars, and A also wrote a more concise version. On LaMDA 137B and GSM8K, accuracy ranged from 11.1 (concise style) to 17.6 (annotator C), against 6.5 for standard prompting, so every version beat the baseline. Three sets of eight exemplars sampled from the GSM8K training set scored 12.6 to 12.7, also well above baseline.
Why it mattered
The paper made a simple idea into a standard tool. Chain-of-thought prompting became the default way to ask language models for multi-step answers, and it was widely used as a baseline in later work. It also set up a framing that drove later research: scale brings emergent abilities, and prompting only gives a lower bound on what a model can do. Later work built on it with self-consistency, which samples many chains and takes the majority answer, and with zero-shot variants that add a phrase like "let's think step by step".
The paper also made the reasoning visible. Because the steps are text, a person can read them and find errors, which is useful for debugging and for oversight.
Reading guide
The paper is short, and its sections map to a small set of prerequisites, in reading order:
- Section 1, Introduction. Needs in-context learning, the idea of putting examples in the prompt. Also helps to know what a Language Model does.
- Section 2, Chain-of-Thought Prompting. Needs Chain-of-Thought Prompting, the general technique, which this paper establishes at scale.
- Section 3, Arithmetic Reasoning. Needs the idea of a benchmark and accuracy. The results depend on scale, so skimming the scaling idea helps when reading Figure 4 and Table 2.
- Section 3.3, Ablation Study. No extra prerequisites. Read it as a sequence of controls.
- Sections 4 and 5, Commonsense and Symbolic. The symbolic tasks test generalisation to longer inputs, which is a length-generalisation test for transformers.
- Section 6, Discussion. Read the limitations as a list of open questions.
Check yourself
QuestionIn one sentence, what is the difference between a standard few-shot exemplar and a chain-of-thought exemplar?Show answer
A standard exemplar gives an input and its answer. A chain-of-thought exemplar gives an input, a short sequence of reasoning steps, and then the answer, so the model learns to write its own steps before answering.
QuestionPaLM 540B scores 17.9% on GSM8K with standard prompting and 56.9% with chain of thought. What is the absolute gain, and what is the relative gain?Show answer
The absolute gain is percentage points, which matches the paper's +39.0. In relative terms the score is times the baseline, a gain of about 218%.
QuestionThe 'variable compute only' ablation replaces the reasoning with a string of dots of the same length. It performs about as well as the baseline. What does that rule out, and what does it leave open?Show answer
It rules out the idea that the gain comes just from the model producing more tokens before answering. It leaves open the idea that the gain depends on the content of the intermediate steps, which the paper supports with its other ablations and with the equation-only result.
QuestionA team wants to use chain-of-thought prompting on a 7B-parameter model for a multi-step legal calculation. What does the paper suggest they should expect, and why?Show answer
They should not expect a large gain. The paper reports that chain of thought does not help small models, and gains appear only at around 100B parameters (for example, UL2 20B moves from 4.1 to 4.4 on GSM8K). A small model writes fluent but illogical chains, which can lower accuracy below standard prompting. A better choice would be a larger model, or fine-tuning on reasoning traces, whose annotation cost the paper notes could be prohibitive.
Sources
- Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models (2022).
- Brown et al., Language Models are Few-Shot Learners (2020).
- Cobbe et al., Training Verifiers to Solve Math Word Problems (2021).
- Chowdhery et al., PaLM: Scaling Language Modeling with Pathways (2022).
- Chain-of-thought prompting, Wikipedia.