GSM8K › Chain-of-Thought Evaluation
Language AI HandbookAll chapters GSM8K › Chain-of-Thought EvaluationOne section · Sections in this chapter4 / 13 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The breakthrough insight that transformed performance on GSM8K was the application of chain-of-thought (CoT) prompting. As we explored in prior chapters covering in-context learning emergence, reasoning capabilities in large language models often require explicit elicitation through prompting strategies that encourage step-by-step decomposition. Without such elicitation, even capable models may default to pattern matching or shortcut heuristics that fail on novel problem instances.
The mechanism behind chain-of-thought prompting parallels human cognitive strategies for complex problem solving. Just as students are taught to show their work to catch errors and maintain logical flow, language models benefit from externalizing intermediate computational steps. This externalization serves multiple functions: it breaks complex problems into manageable subproblems, it creates verification points where the model can check its own reasoning, and it increases the effective context available for solving each subcomponent by making intermediate results explicit rather than relying on implicit internal representations.
Standard Prompting vs. Chain-of-Thought
Standard few-shot prompting gives examples with direct question-answer pairs, presenting a mapping from problem statements to final solutions without intermediate reasoning:
Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?
A: 11
When models answer this way, they must perform all reasoning internally without externalizing intermediate steps. For complex multi-step problems, this often leads to errors because the model cannot show its work and verify each sub-calculation. The internal computation must simultaneously track the initial quantity, the conversion from cans to individual balls, and the final aggregation, creating ample opportunity for information loss or arithmetic drift. The model's attention mechanism must hold multiple numerical quantities in implicit working memory across many layers, a fragile arrangement that becomes increasingly unreliable as problem complexity grows.
Chain-of-thought prompting instead gives reasoning traces that make the computational path explicit:
Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?
A: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.
This approach yields large improvements across model scales. Large models (100B+ parameters) see accuracy increases from roughly 20% to over 60% when provided with chain-of-thought exemplars, while smaller models gain less benefit, suggesting that the capacity to generate useful reasoning chains emerges with scale. This scaling pattern indicates that chain-of-thought reasoning is a capability that develops as models acquire sufficient capacity to maintain and manipulate explicit intermediate states, rather than merely a prompting trick. Smaller models may lack the representational capacity to generate coherent reasoning chains while simultaneously solving the underlying mathematical operations.

Self-Consistency Decoding
A further refinement to chain-of-thought evaluation involves sampling multiple reasoning paths rather than relying on a single greedy decode. Self-consistency uses the observation that while individual reasoning chains may contain errors, the correct answer often emerges as the consensus across multiple independent attempts. This approach mirrors the human strategy of solving a problem multiple times to check for consistency.
The method operates through three specific stages:
- Sampling different chain-of-thought reasoning paths from the model using non-zero temperature, encouraging diversity in solution approaches
- Extracting the final answer from each path using the standard parsing methodology
- Selecting the most frequent answer (majority voting) as the final prediction
Formally, let be the answers extracted from independently sampled reasoning chains. The self-consistency prediction is:
where is the indicator function that equals 1 when the -th sample matches candidate answer .
The independence assumption underlying this approach is that different sampling paths will produce uncorrelated errors. While all paths might occasionally err, they are unlikely to err in exactly the same way simultaneously. If the correct answer is 42 and an arithmetic mistake in one chain produces 40, a different error in another chain might produce 44. These wrong answers split the vote, while the correct answer 42 concentrates votes from all chains that executed without error. Empirical results show that self-consistency can boost GSM8K accuracy by an additional 10-20% beyond standard chain-of-thought prompting, though at increased computational cost proportional to .

Zero-Shot Chain-of-Thought
While few-shot examples help, researchers discovered that simply appending "Let's think step by step" to prompts lets zero-shot chain-of-thought reasoning. This simple phrase triggers models to generate intermediate reasoning steps even without exemplars, closing much of the gap between zero-shot and few-shot performance. The effectiveness of this minimal prompt suggests that models have learned the pattern of step-by-step reasoning from their training data and require only a lightweight retrieval cue to activate this behavior.
The effectiveness of this phrase reveals something important about the training of modern language models. During pre-training and instruction tuning, models encounter large quantities of explanatory text, step-by-step tutorials, and worked mathematical examples. The phrase "Let's think step by step" is a retrieval cue that activates this learned pattern of structured reasoning. It effectively puts the model into an explanation mode where it verbalizes its reasoning process rather than jumping directly to conclusions. This zero-shot capability is particularly useful in production environments where crafting few-shot examples for every problem type is impractical.
Program of Thought: Delegating Arithmetic to Code
A significant extension beyond natural language chain-of-thought is the Program of Thought (PoT) approach, introduced by Chen et al. (2022). Instead of asking models to perform arithmetic in natural language, PoT prompts models to write Python code that computes the answer, then executes the code to obtain the result.
A PoT response to the Janet duck egg problem would look like:
eggs_per_day = 16
eaten_for_breakfast = 3
used_for_muffins = 4
sold = eggs_per_day - eaten_for_breakfast - used_for_muffins
price_per_egg = 2
daily_earnings = sold * price_per_egg
print(daily_earnings)18
This approach cleanly separates reasoning (which operations to perform and in what order) from arithmetic execution (obtaining the correct numerical result). The language model handles the reasoning component, which it does well, while a Python interpreter handles the arithmetic, which executes without error. This decomposition consistently outperforms pure chain-of-thought on problems where arithmetic mistakes dominate, particularly problems involving large numbers, percentages, or multi-digit multiplication.
PoT also improves interpretability: the generated code is unambiguous about what computation it performs, unlike natural language where phrases like "multiply that by 3" can be ambiguous about which intermediate result is being multiplied. The code execution trace gives a definitive record of the computational steps, simplifying error diagnosis considerably.