15.1 Chain of Thought Prompting
A shop has 18 bolts, receives four boxes of six, and uses nine. The answer is . A language model can emit 33 directly, or first write intermediate quantities such as 24 received and 42 before use. Those extra tokens give later predictions intermediate results to condition on. They also create more opportunities for an error to enter the computation.
Chain-of-thought (CoT) prompting asks a model to generate intermediate steps before its final answer. Wei et al. demonstrated gains on selected arithmetic, commonsense, and symbolic tasks using worked demonstrations [1]. The useful question is which tasks benefit enough to justify the extra tokens—not whether a longer explanation sounds more thoughtful.
1. What Intermediate Tokens Change
Both direct answers and CoT are ordinarily generated autoregressively: each new token conditions on the available prefix. Direct answering is not a single forward pass for an arbitrarily long output. CoT extends that prefix with a generated scratchpad before the answer. It changes the inference computation without changing the weights.
| Authored output for the bolt problem | Checkable content | What it establishes |
|---|---|---|
33 | The final quantity | Correct for this example, without an explanation |
4 × 6 = 24; 18 + 24 = 42; 42 − 9 = 33 | Intermediate arithmetic and final quantity | The written derivation is valid |
4 × 6 = 20; 18 + 20 − 9 = 29 | An explicit multiplication error | More text can expose an error, but does not prevent it |
These are authored examples, not captured model outputs. The second row is useful because its operations can be checked. It still does not prove that the displayed explanation faithfully describes every cause of a model’s answer.
Few-shot CoT includes worked examples in the prompt. Zero-shot CoT requests intermediate work without demonstrations. Kojima et al. studied a two-stage procedure that first elicited reasoning with a short instruction and then extracted an answer; the reported gains were for their tested models and tasks [2]. A phrase is not a universal switch that improves every model or question.
2. Correctness, Usefulness, and Faithfulness
Keep three questions separate:
- Correctness: does the final answer satisfy the task?
- Usefulness: can the written steps help a reader or external checker verify the result?
- Faithfulness: does the explanation accurately reflect the factors that caused the model’s answer?
Turpin et al. changed biasing prompt features, including answer positions, and found cases where model answers changed while their explanations did not disclose the influence [4]. This establishes a failure mode in the studied settings, not a claim that every rationale is false. It means that fluent explanations alone are weak evidence of the decision process.
For the bolt problem, arithmetic is independently checkable. For a document answer, check whether the cited passage supports the claim. For code, execute relevant tests in an isolated environment. These checks examine observable correctness; they do not turn an explanation into a complete account of internal computation. A verifier can also be incomplete or wrong, so retain its version, test inputs, and failures.
Decomposition is worth testing on tasks with intermediate state, such as arithmetic or constrained planning. For lookup, simple classification, or extraction, additional text may add latency without helping. Compare direct answering, one CoT sample, and a stronger verification route on the same held-out tasks. Do not assume that the prompting recipe transfers to an interface whose reasoning behavior is configured differently.
3. Self-Consistency: Agreement Is a Selection Rule
Self-consistency samples several solution paths and aggregates their final answers. Wang et al. reported gains over greedy CoT on their evaluated reasoning benchmarks [3]. Sampling can produce different paths, but the same model and prompt can also repeat a shared misconception. Independent random draws do not imply independent factual evidence.
For an authored sample set [33, 33, 33, 29, 29], a vote selects the correct answer. For [29, 29, 29, 33, 33], the same rule confidently selects an error. A vote fraction of is a property of those samples; without calibration it is not a 60% probability of correctness.
The answer representation matters. 33, 33 bolts, and thirty-three might be equivalent for one task. 33 kg is not equivalent to 33 g. Fix canonicalization, tie handling, malformed-output treatment, and the sample budget before evaluation. Otherwise parsing choices can create apparent gains.
An Offline Voting and Verification Example
Educational offline example, smoke-tested with Python 3.12. The input records below are authored fixtures, not model generations. This implements an exact integer-answer contract, a strict majority over all submitted records, and an arithmetic check for one synthetic task. It omits model calls, tokenization, semantic answer equivalence, retries, concurrency, and a general verifier. Invalid records remain in the denominator; this is a deliberately conservative policy, not a universal self-consistency rule.
from collections import Counter
def select_majority(records):
if not records:
raise ValueError("At least one attempted sample is required")
# Exact schema for this exercise. bool is not accepted as an integer answer.
valid = [r["answer"] for r in records
if isinstance(r, dict) and set(r) == {"answer"}
and type(r["answer"]) is int]
counts = Counter(valid)
winner, votes = counts.most_common(1)[0] if counts else (None, 0)
n = len(records)
return {
"answer": winner if votes * 2 > n else None,
"attempted": n,
"valid": len(valid),
"winner_votes": votes,
}
def verify_bolt_answer(answer):
return type(answer) is int and answer == 18 + 4 * 6 - 9
good = select_majority([{"answer": x} for x in [33, 33, 33, 29, 29]])
bad = select_majority([{"answer": x} for x in [29, 29, 29, 33, 33]])
missing = select_majority([{"answer": 33}, {"answer": 33}, {}, {}, {}])
tie = select_majority([{"answer": 33}, {"answer": 29}])
assert good["answer"] == 33 and verify_bolt_answer(good["answer"])
assert bad["answer"] == 29 and not verify_bolt_answer(bad["answer"])
assert missing["answer"] is None and missing["valid"] == 2
assert tie["answer"] is None
print(good, bad, missing, tie)
The two failure cases are different: the second fixture produces a clear but wrong majority, whereas the third lacks enough valid outputs. Preserve that distinction in evaluation logs. Routing both through a fallback may be sensible, but silently discarding invalid samples would change the vote policy.
4. Budget the Work and Validate the Result
Suppose an illustrative workload generates 96 intermediate tokens and 12 answer tokens per path. One path emits 108 tokens; five paths emit 540, compared with a 12-token direct answer. That is 45 times as many output tokens in this example, not a prediction of a 45-times latency or quality change. Parallel execution changes elapsed time and live memory; shared prefixes, stopping rules, and the serving engine also matter. Count prompt processing and verifier work separately.
For one sequence with a conventional dense KV cache,
where is layer count, is total cached length including prompt and generated tokens, is the number of KV heads, is head dimension, and is bytes per stored value. The first factor accounts for keys and values. This is payload only; weights, workspaces, quantization metadata, and allocator overhead are additional costs. Multiple live paths increase state unless the implementation can safely share some prefixes.
Before rollout, keep the task set, model revision, prompt template, decoding settings, answer parser, and verifier fixed for a paired comparison. Record final correctness, malformed/abstained results, useful domain slices, input/output tokens, and end-to-end latency. Set time and token limits and specify what happens when generation truncates or verification fails. A longer trace that exhausts the budget before producing a valid answer is a failure, not a partially correct sample to omit.
Return a validated answer in the application’s required format. Where intermediate text is available, treat it as untrusted generated material: never execute embedded commands or accept a claimed check as evidence that the check ran. A tag or regular expression can find a field; it cannot validate the reasoning or authorize an action.
5. Next: Compare Paths Explicitly
CoT supplies one sequential path; self-consistency compares final answers from several paths. 15.2 Tree/Graph of Thoughts adds an external controller that can compare partial states and revisit alternatives. All three need a task-specific way to distinguish useful computation from repeated mistakes.
Quizzes
Quiz 1: Why is it wrong to say direct answering uses one forward pass while CoT uses many?
An autoregressive direct answer also needs token-by-token generation. CoT adds intermediate tokens to the prefix before the final answer, increasing sequential work. The extra work can help particular tasks, but its presence does not establish correctness or faithful explanation.
Quiz 2: Five sampled answers all agree. What important evidence is still missing?
They may share the same error. Agreement is not an independent factual check or a calibrated correctness probability. Check the answer with task-appropriate evidence and measure the aggregation rule on held-out examples.
Quiz 3: Why does the offline example abstain when two samples return 33 and three are malformed?
Its declared rule requires a strict majority of all five attempted samples. Two valid agreeing answers do not pass that threshold. Dropping malformed outputs would silently replace this rule with a majority of the valid subset and conceal the parsing failure rate.
Quiz 4: What is the dense KV payload for one sequence with 32 layers, 8,192 total cached tokens, 8 KV heads, a head dimension of 128, and FP16 storage?
bytes, or 1 GiB. This includes both keys and values for one sequence, but excludes weights and runtime overhead. The token count includes the prompt and all retained intermediate/output tokens.
Quiz 5: An explanation contains a valid arithmetic derivation. Does that prove the model used that derivation to choose its answer?
No. The derivation establishes that the written calculation supports the answer. Faithfulness concerns the causes of the model’s choice, and can require interventions or other evidence. Valid output and a complete explanation of internal computation are different claims.
References
- Wei, J., et al. (2022). Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. arXiv:2201.11903.
- Kojima, T., et al. (2022). Large Language Models are Zero-Shot Reasoners. arXiv:2205.11916.
- Wang, X., et al. (2023). Self-Consistency Improves Chain of Thought Reasoning in Language Models. ICLR. arXiv:2203.11171.
- Turpin, M., Michael, J., Perez, E., & Bowman, S. R. (2023). Language Models Don’t Always Say What They Think: Unfaithful Explanations in Chain-of-Thought Prompting. NeurIPS. arXiv:2305.04388.