Exercises — Chain-of-thought prompting
This page is a self-test. Each problem is stated cleanly; the full worked solution hides inside a collapsible callout. Try first, then open. Difficulty rises from L1 Recognition (do you know the words?) all the way to L5 Mastery (can you design and reason about the method?).
Everything here builds on Chain-of-thought prompting. Where a new idea appears, we lean on prerequisite topics like Self-Consistency Decoding, Temperature and Sampling, Few-shot In-context Learning, and Emergent Abilities of LLMs.
Level 1 — Recognition
(Can you correctly name and identify the pieces?)
Recall Solution
The question first produces a chain of intermediate reasoning steps , and only then the answer . The answer is read off the tail of the generation.
Recall Solution
- (a) Few-shot CoT — it supplies exemplars (worked demonstrations). See Few-shot In-context Learning.
- (b) Zero-shot CoT — no exemplars, only a trigger phrase.
Recall Solution
Count each distinct answer: appears 3 times, once, once. Majority vote returns with 3 out of 5 votes.
Level 2 — Application
(Can you actually produce a correct chain?)
Recall Solution
- Start state: books. (Why? Anchor the initial quantity before any operation.)
- Remove 9: . (Why? Do events in the order they happen.)
- Delivery: books arrive. (Why? Compute the sub-quantity before combining.)
- Add: .
- The answer is 26.
Recall Solution
- 3 painters → 3 walls in 3 hours, so each painter paints 1 wall in 3 hours. (Why? Normalise to a per-painter rate; that's the invariant quantity.)
- 9 painters each paint their own wall in parallel, still 1 wall in 3 hours each.
- So 9 walls are finished in 3 hours.
- The answer is 3 hours.
Recall Solution
Q: What is 10 + 6 - 4?
A: Start with 10 + 6 = 16. Then 16 - 4 = 12.
The answer is 12.
Q: What is 17 + 25 - 8?
A:
The exemplar demonstrates the format ("reason first, then 'The answer is X'"). The model pattern-matches: , then . The answer is 34.
Level 3 — Analysis
(Can you reason about why the method behaves as it does?)
Recall Solution
One answer token = one forward pass of compute, and everything the problem needs must be squeezed into that single pass. A hard problem needs more sequential steps than one pass can perform. Each reasoning token buys another forward pass, and — crucially — that token is fed back into the context. So the chain lets the model:
- Buy more compute — reasoning tokens extra forward passes, i.e. deeper effective computation.
- Externalise memory — partial results (like "") are written down, so they needn't survive inside one hidden state. The weights are unchanged; CoT changes only how much serial computation the model is allowed to spend.
Recall Solution
The sum runs over reasoning paths . A correct answer can be reached by many different valid paths — each contributes probability mass , and these mass contributions pile up on the same answer. A wrong answer usually comes from a lone idiosyncratic error — one stray path — so its mass is scattered thinly across many different wrong answers. Sampling chains (needs Temperature and Sampling with temperature for diversity) and counting the winner is a Monte-Carlo estimate of that marginal sum. The estimate concentrates on the answer with the most independent supporting paths — exactly . This is Self-Consistency Decoding.
Recall Solution
At temperature decoding is deterministic — the model always picks the single highest-probability next token, so every "sample" is the same chain. Voting over 20 identical chains gives no benefit over 1. Self-consistency needs diverse chains, which requires a temperature (e.g. –) so sampling explores different reasoning paths . Only then does the vote aggregate independent routes. See Temperature and Sampling.
Level 4 — Synthesis
(Can you combine ideas and design new pipelines?)
Recall Solution
Number of correct chains follows a binomial with , . Majority (≥2 correct): So majority-of-3 gives vs a single chain's — a +0.048 improvement. Voting helps because errors don't coordinate on one wrong answer.
Recall Solution
Combine CoT with retrieval (Retrieval-Augmented Generation):
- Retrieve documents relevant to the question and place them in the context.
- Prompt with CoT so the model reasons over the retrieved evidence step by step ("The document says the patent was filed in …; therefore …"). This targets CoT's core weakness: CoT adds reasoning compute but cannot invent missing facts — reasoning over a wrong premise still yields a wrong answer. RAG supplies the grounded premise; CoT chains the logic on top. (A tool-using variant that interleaves reasoning with actions is ReAct.)
Recall Solution
This is Tree of Thoughts: instead of one straight line , the model expands multiple candidate next-steps at each node, scores partial chains, keeps promising branches, and prunes/backtracks on dead ends — a deliberate search over reasoning states. Worth it when the problem needs exploration and lookahead (puzzles, planning, games) where a single greedy chain commits early to a bad path. For simple arithmetic it's overkill — plain CoT or self-consistency (Self-Consistency Decoding) is cheaper.
Level 5 — Mastery
(Can you reason about limits, edge cases, and pitfalls like an expert?)
Recall Solution
Not a prompt bug. CoT gains are largely emergent with scale (Emergent Abilities of LLMs) — they appear strongly only in large models (roughly ≳ 10B params in the original work). CoT unlocks a latent ability; it cannot create one the model lacks. A small model, when forced to write a chain, produces fluent-but-wrong reasoning that actively steers it into a bad answer — so it can score worse than just guessing directly. The fix is scale (or a smaller task), not a better trigger phrase.
Recall Solution
This assumes the chain is the causal cause of the answer — but CoT chains can be post-hoc rationalisations (the faithfulness problem). The model may compute the answer by some hidden shortcut and then generate a plausible-sounding justification that had no causal role. Consequences: (i) a correct answer does not validate the chain, and (ii) a correct-looking chain does not guarantee a correct answer. To test faithfulness you must intervene — e.g. corrupt a step and see whether the final answer actually changes.
Recall Solution
A layered pipeline:
- Retrieve evidence — Retrieval-Augmented Generation — because the weights alone may lack the facts.
- Few-shot CoT exemplars — Few-shot In-context Learning — to demonstrate the reason-then-answer format on this task type.
- Sample chains at temperature — Temperature and Sampling — to get diverse independent reasoning routes over the retrieved evidence.
- Majority vote — Self-Consistency Decoding — to concentrate mass on the most-supported answer and cancel idiosyncratic errors.
- (Optional) Tree search — Tree of Thoughts — if the problem needs branching/backtracking rather than linear chains.
- Use a large enough model — Emergent Abilities of LLMs — since CoT benefits are emergent with scale.
Recall One-line summary of the ladder
Recognise the pieces → apply to write chains → analyse why compute/voting work → synthesise with RAG/ToT → master the limits (emergence, faithfulness, systematic bias).