Foundation reference

Chain-of-Thought Prompting

Chain-of-thought prompting asks a language model to write intermediate reasoning before its final answer. With eight worked examples in the prompt, PaLM 540B went from 17.9% to 56.9% on the GSM8K grade-school math benchmark (Wei et al., 2022).

Concept 75 of 100Scaling & AlignmentStudy phase 11
Key equation
p(r,a∣q)=∏tp(rt∣q,r<t)⋅p(a∣q,r)p(r, a \mid q) = \prod_{t} p(r_t \mid q, r_{<t}) \cdot p(a \mid q, r)
Reading map and next steps

Study guide

Where to start

Concept 75 of 100Chain of ThoughtScaling & Alignment · Study phase 11: Reasoning at inference time & synthetic data
Question

Why does writing out intermediate steps help a model that does a fixed amount of computation per token, and which kinds of problem benefit most (Nye et al., 2021; Feng et al., 2023)?

How to study this pagePredict · Check · Generalize · Continue
PredictSay what you expect.

Pick a concrete input and say what the equation should give before you read the math.

CheckCheck against the math and the papers.

Work through the math, then read the cited papers for the original argument.

GeneralizeName what stays the same.

Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.

ContinueFollow the connections.

Use the prerequisites and related concepts at the end of the page to fill the next gap.

Why It Matters for Modern Models

  • Chain-of-thought prompting asks a language model to write intermediate reasoning before its final answer. With eight worked examples in the prompt, PaLM 540B went from 17.9% to 56.9% on the GSM8K grade-school math benchmark (Wei et al., 2022).
  • Wei et al. (2022) saw the gains only in models of about 100 billion parameters and above, and called the ability emergent; whether such abilities really appear suddenly with scale, or only look sudden under some evaluation metrics, is contested (Schaeffer et al., 2023).
  • Reasoning models extend the idea by training the chain of thought with reinforcement learning instead of only prompting for it; OpenAI describes its o1 models this way (OpenAI, 2024).

Questions to Think About

  • Does the written chain of thought show how the model actually reached its answer, given that Turpin et al. (2023) found explanations that leave out the real cause of a prediction and Lanham et al. (2023) found that how much answers depend on the stated reasoning varies widely across tasks?
  • Why does sampling several reasoning paths and taking a majority vote over their final answers beat decoding a single greedy path (Wang et al., 2023)?

Core Math

Key Equation
p(r,a∣q)=∏tp(rt∣q,r<t)⋅p(a∣q,r)p(r, a \mid q) = \prod_{t} p(r_t \mid q, r_{<t}) \cdot p(a \mid q, r)

Chain-of-thought prompting asks a language model to write out intermediate reasoning rr before its final answer aa, either by including a few worked examples in the prompt (Wei et al., 2022) or simply by adding "Let's think step by step" (Kojima et al., 2022). The model generates the reasoning token by token, and each step conditions on the question qq and the steps before it:

p(r,a∣q)=∏t=1∣r∣p(rt∣q,r<t)⋅p(a∣q,r)p(r, a \mid q) = \prod_{t=1}^{|r|} p(r_t \mid q, r_{<t}) \cdot p(a \mid q, r)

A transformer does a fixed amount of computation per token, so writing the steps out gives it more sequential computation before it commits to an answer (Nye et al., 2021; Feng et al., 2023).

Self-consistency samples NN reasoning paths at a positive temperature, reads off their final answers a1,…,aNa_1, \dots, a_N, and returns the most common one (Wang et al., 2023):

a∗=arg⁡max⁡a∑i=1N1[ai=a]a^* = \arg\max_a \sum_{i=1}^N \mathbf{1}[a_i = a]

This approximates choosing the answer with the highest total probability over reasoning paths, ∑rp(r,a∣q)\sum_r p(r, a \mid q), instead of trusting a single greedy path.

Key Papers

Chain-of-Thought Prompting Elicits Reasoning in Large Language Models

Wei et al.2022NeurIPS
Read paper →

Self-Consistency Improves Chain of Thought Reasoning in Language Models

Wang et al.2023ICLR
Read paper →

Large Language Models are Zero-Shot Reasoners

Kojima et al.2022NeurIPS
Read paper →

Show Your Work: Scratchpads for Intermediate Computation with Language Models

Nye et al.2021arXiv
Read paper →

Language Models Don't Always Say What They Think: Unfaithful Explanations in Chain-of-Thought Prompting

Turpin et al.2023NeurIPS
Read paper →

Measuring Faithfulness in Chain-of-Thought Reasoning

Lanham et al.2023arXiv
Read paper →

Connections

Where to go next

Deliberative Alignment builds directly on Chain of Thought. The other ideas that build on this page are listed under Leads to, above.

Deliberative Alignment