DL0114 Chain-of-Thought Prompting

What is Chain-of-Thought prompting and why does it improve reasoning?

Answer

Chain-of-Thought (CoT) prompting makes a language model emit intermediate reasoning steps before its final answer, either through few-shot exemplars whose demonstrations contain worked solutions (Wei et al., 2022) or through a zero-shot trigger phrase such as “Let’s think step by step” (Kojima et al., 2022). The gains are large on multi-step problems: on GSM8K, 8-shot CoT lifted PaLM 540B from 17.9% to 56.9%, and the same trigger took GPT-3 (text-davinci-002) from 10.4% to 40.7% with no weight updates. Two mechanisms explain why. The first is serial compute: a transformer with L layers can apply only O(L) sequential operations before it must commit to the next token, so a task needing more sequential steps than the depth provides is simply not representable in one forward pass; every generated token reruns the whole stack, turning the context window into an external scratchpad that raises effective serial depth from L to L(T+1). Theory backs this up: constant-depth transformers with a polynomially long chain can simulate any polynomial-time computation, while the same model restricted to direct answers cannot. The second mechanism is factorized conditioning: instead of sampling one high-entropy jump from question to answer, the model decomposes the problem into a product of low-entropy conditionals, each conditioned on the already-written steps, which keeps it on the distribution of solution traces seen in pretraining. CoT is not universally free money: it is emergent with scale, and later meta-analysis shows the gains concentrate on math, symbolic, and logical tasks rather than on knowledge or commonsense retrieval.

(1) Two Elicitation Modes: few-shot CoT shows worked examples and controls format tightly, while zero-shot CoT appends one trigger sentence and costs almost no prompt tokens.
(2) Depth Becomes Time: each scratchpad token buys another full pass through the network, so the model trades latency and tokens for sequential computation it structurally lacked.
(3) Easier Conditionals: the chain rewrites one hard prediction as many easy ones, and each step reads all earlier steps as ordinary context.
(4) Emergent, Not Universal: below roughly 10B parameters, CoT often produces fluent but invalid chains and can score below direct prompting.
(5) Chains Are Not Guaranteed Faithful: models shift answers when a prompt carries a bias cue while the written rationale never mentions it, so a chain is an output artifact, not an audit trail.
(6) Cheap Ensembling On Top: because chains are stochastic, sampling k of them and majority-voting the final answers (self-consistency) pushed PaLM 540B on GSM8K to 74.4%.

Two-panel diagram: direct prompting sends the question through one L-layer forward pass to the answer, while chain-of-thought generates T scratchpad tokens, each of which reruns the full L-layer stack before the answer token

Figure 1: Direct prompting caps sequential computation at the network depth L; CoT reuses the same weights once per generated token, giving L(T+1) sequential steps and letting step t read every earlier step as context.

The costs are as concrete as the benefits. Chains are typically 100 to 400 decode tokens on grade-school math, so a CoT query can cost an order of magnitude more decode passes and time-to-last-token than a direct answer, which matters for anything user-facing. Errors also propagate: the decoder never backtracks, so a slip in the first arithmetic step is carried through every later step, and accuracy behaves roughly like the product of per-step accuracies. Few-shot CoT is additionally prompt-sensitive, since exemplar choice, ordering, and even the formatting of the equations move accuracy by several points. These properties are exactly why the field moved from prompting toward verifying or training the chain rather than just requesting it.

Mathematical Formulation:
p(a \mid q) = \sum_{z} p(a \mid q, z)\, p(z \mid q)
p(z \mid q) = \prod_{t=1}^{T} p(z_t \mid q, z_{1:t-1})
D_{\text{direct}} = L
D_{\text{CoT}} = L \cdot (T + 1)
\hat{a} = \arg\max_{a} \sum_{i=1}^{k} \mathbf{1}[a_i = a]

Where:

  • q is the prompt (question plus any exemplars), a the final answer span, and z = z_{1:T} the generated rationale, a latent variable the model writes into its own context.
  • t \in \{1, \ldots, T\} indexes chain tokens; T is the chain length and L the number of transformer layers.
  • D counts the sequential layer applications available before the answer is committed, which is the resource CoT actually adds.
  • k is the number of sampled chains in self-consistency, a_i the answer extracted from sample i, and \mathbf{1}[\cdot] the indicator used for majority voting.
  • Required condition: the sum over z is intractable, so plain CoT approximates it with a single greedy or sampled \hat{z}, and self-consistency approximates it with k Monte Carlo samples at temperature T_s > 0.
Grouped bar chart of GSM8K solve rate for PaLM at 8B, 62B and 540B parameters under standard prompting and 8-shot chain-of-thought, with the CoT advantage appearing only at 62B and growing at 540B

Figure 2: CoT is an emergent ability: at 8B parameters the chains are fluent but wrong and buy nothing, while at 540B they roughly triple the GSM8K solve rate. Values are approximate figures reported for PaLM by Wei et al. (2022) and Wang et al. (2023).

PropertyZero-shot CoTFew-shot CoTCoT + self-consistency
How it is elicitedOne trigger sentence appended to the questionA handful of exemplars that show the full reasoning traceSame CoT prompt sampled k times, majority vote on the extracted answer
Extra prompt tokensRoughly 10Hundreds to a few thousand, and it consumes contextUnchanged prompt, but k independent decodes
Reported GSM8K result10.4% to 40.7% on text-davinci-00217.9% to 56.9% on PaLM 540B, 8-shot74.4% on PaLM 540B with 40 sampled chains
Main weaknessFormat drift: the model may skip steps or answer immediatelySensitive to exemplar choice, order, and formattingk times the decode cost; needs a comparable, extractable final answer
Best fitQuick baseline and open-ended chat trafficA fixed task where output format must be stableHigh-value math or code queries where accuracy beats latency

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *