TL;DR
Chain-of-thought prompting asks a language model to write out its reasoning before the final answer. Usually the model is decoded greedily, which gives one reasoning path. Wang and colleagues replace that single path with a sample of many diverse paths, extract the final answer from each, and return the answer that appears most often. The method needs no training and no extra model. On arithmetic, commonsense and reading tasks it beat greedy chain-of-thought prompting on every model tested, by as much as 17.9 points on GSM8K with PaLM-540B.
Builds on: Chain-of-Thought Prompting, Autoregressive Model, Softmax Temperature, Law of Total Probability · Leads to: a family of sample-then-aggregate methods for reasoning models (no lesson node yet)
Why it mattered
Chain-of-thought prompting made large language models much better at multi-step problems, but greedy decoding has a weakness: it commits to the single most likely path, and one slip in the middle sends the answer wrong. Self-consistency fixes that without touching the model. The paper's Table 2 shows PaLM-540B going from 56.5 to 74.4 on GSM8K, and GPT-3 code-davinci-002 going from 60.1 to 78.0. The paper has about 8,400 citations on Semantic Scholar. Its idea, that agreement among varied attempts is a useful signal, shows up in many later methods that sample several answers and vote, rank or check them.
The problem
Two facts about reasoning tasks make greedy decoding fragile.
- A problem usually has more than one good solution path. A word problem can be worked out by adding first and then subtracting, or by subtracting the parts directly. Greedy decoding picks one and cannot recover if it goes wrong.
- The most likely path is not always the correct one. Language models are not calibrated: the probability of a path is a poor guide to whether its answer is right. The paper tests weighting each path by its probability, and that weighting does not beat a plain vote (Table 1, in the results).
The paper's hypothesis is that correct reasoning, even when it takes different routes, tends to reach the same final answer, while wrong reasoning scatters across many answers. Sampling many paths and counting the final answers exploits that difference.
Two earlier approaches were more complex. One trains a separate verifier to score answers, which needs labelled data. Another trains a re-ranker on human annotations. Self-consistency needs neither: it is unsupervised and works on a pre-trained model in a few-shot setting.
How it works
Take one arithmetic question and trace the method from start to finish. The question is from the paper's Table 4: Henry makes two stops on a 60-mile bike ride. The first stop is 20 miles in. The second is 15 miles before the end. How far does he ride between the stops?
- Prompt with chain-of-thought exemplars. The model sees a few worked examples, each with a written reasoning path ending in "The answer is X." For arithmetic the paper uses eight such exemplars. Check: the model is in the same format as the examples, so its outputs can be parsed.
- Sample several reasoning paths. Instead of taking the single greedy path, draw
mpaths from the model's distribution at a temperature above zero (a setting that flattens or sharpens the probabilities before sampling), with top-k truncation for some models (each next word is drawn only from the k most likely words). The paper uses 40 samples per question. Check: two runs give different paths for the same question. - Parse each final answer. For each path, read the number after "The answer is". Check: for the Henry question, one path ends in "The answer is 25." and another in "The answer is 40."
- Count the answers. Suppose the five sampled paths give the answers 25, 40, 25, 25 and 30. The answer 25 appears three times, 40 once, and 30 once. Check: the counts sum to the number of paths, 5.
- Pick the most consistent answer. Return 25, because it has the most votes. The greedy path that said 40 is not used.
flowchart LR A[Question plus CoT exemplars] --> B[Sample m reasoning paths] B --> C[Parse each final answer] C --> D[Count how often each answer occurs] D --> E[Return the most consistent answer]
Step 4 is the important one. The reasoning paths are discarded after parsing; only the answers are used. The paths matter only because they produce a spread of answers, and the correct answer should be the one the spread concentrates on.
The math
The paper's notation: a question and prompt together form the context. Each sampled output i is a pair of a reasoning path r_i and an answer a_i, where a_i is drawn from a fixed set A. The reasoning path is a latent variable: the model generates it on the way to the answer, but only the answer is scored.
Given m sampled outputs (r_i, a_i) for one question, self-consistency returns the answer that maximises the count of matching outputs:
Here 1[...] is an indicator, equal to 1 when the condition holds and 0 otherwise. This is a majority vote.
Step 4 in symbols
The sum over i in the definition is the count of each answer. The vote share is that count divided by m. For the example, the counts are 3 for 25, 1 for 40 and 1 for 30, so the shares are 3/5 = 0.6, 1/5 = 0.2 and 1/5 = 0.2.
Step 5 in symbols
The reason this works comes from marginalising the reasoning path, the law of total probability applied to the latent path:
Sampling m paths from P(r | prompt, q) gives an unbiased estimate of this sum, with each path weighted equally. The answer with the largest estimate is the one with the most sampled paths. The method does not need the path probabilities themselves, only the samples.
The weighted variant
The paper also tests a version that weights each output by its probability:
Here K is the number of tokens in the output, and w_i is the geometric mean of the per-token probabilities, which removes the advantage that longer outputs would otherwise get. The paper finds that this weighted version and the plain majority vote give nearly the same accuracy.
Results
The paper samples 40 outputs per question and averages over 10 runs. Table 2 compares greedy chain-of-thought with self-consistency on arithmetic. Selected numbers:
- GSM8K, PaLM-540B: greedy 56.5, self-consistency 74.4, a gain of 17.9 points.
- GSM8K, GPT-3 code-davinci-002: greedy 60.1, self-consistency 78.0, a gain of 17.9 points.
- AQuA, PaLM-540B: greedy 35.8, self-consistency 48.3, a gain of 12.5 points.
- SVAMP, PaLM-540B: greedy 79.0, self-consistency 86.6, a gain of 7.6 points.
Table 3 covers commonsense and symbolic tasks. The gains are smaller there, but they hold across models: StrategyQA for PaLM-540B goes from 75.3 to 81.6, and ARC-challenge from 85.2 to 88.7.
Table 1 checks the aggregation rule on PaLM-540B for GSM8K. Greedy decoding gives 56.5. The unweighted majority vote gives 74.4, and the normalised weighted sum gives 74.1. The unnormalised weighted sum gives 59.9, so the normalisation step matters, but majority voting does as well as the weighted version without any probabilities.
Table 5 shows that self-consistency also helps standard NLP tasks where chain-of-thought can hurt. On RTE, standard prompting gets 84.8, chain-of-thought gets 79.1, and self-consistency gets 86.3. On ANLI-R1, chain-of-thought drops below standard prompting (68.8 against 69.1), while self-consistency reaches 78.5.
The paper's ablations give three more results. Accuracy rises steadily as the number of paths goes from 1 to 40, and it saturates early, so 5 to 10 paths capture most of the gain. Self-consistency beats sample-and-rank, which takes the top path by log probability, and beats beam search. It is also robust to the choice of temperature and top-k for sampling, and to the choice of prompt set.
Limits. The main cost is compute: 40 samples means roughly 40 times the decoding work of one greedy path, though the paper notes that a few paths already give most of the gain. The method needs a final answer from a fixed set, so it does not directly apply to open-ended writing. The paper's suggested extension is to use self-consistency to produce better fine-tuning data (Section 5), not to vote on free text. Finally, the paper observes that sampled reasoning paths are sometimes wrong even when the vote is right, as in the StrategyQA example of Table 4, so the vote is a signal, not a proof.
Reading guide
- Section 1 (Introduction): the sample-and-marginalise idea and Figure 1. Needs Chain-of-Thought Prompting and In-Context Learning.
- Section 2 (Method): the latent-variable formulation and the weighted variant. Needs Law of Total Probability and Language Model.
- Section 3.1 (Setup): the sampling settings. Needs Softmax Temperature for what
Tdoes, and Autoregressive Model for how the samples are drawn one token at a time. - Section 3.2 (Main results): Tables 2 and 3. Read them against the one-path baseline.
- Section 3.4 (Comparisons): sample-and-rank and beam search. Needs Beam Search for the contrast.
- Section 3.5 (Additional studies): robustness to sampling settings and prompts.
- Section 5 (Conclusion): the cost limitation and the suggestion to use the method to generate training data.
Check yourself
QuestionWhat does self-consistency replace in chain-of-thought prompting, and what does it return?Show answer
It replaces greedy decoding, which produces one reasoning path, with sampling of many diverse reasoning paths. It returns the final answer that occurs most often among the parsed answers, which is a majority vote.
QuestionFive sampled paths give the answers 12, 15, 12, 12 and 20. Which answer is returned, and what is its vote share?Show answer
The answer 12 appears three times, so it is returned. Its vote share is 3/5 = 0.6.
QuestionWhy does the method discard the reasoning paths and only count the final answers?Show answer
The paths are latent: they are a means to reach an answer, and the answer is the thing that can be checked and compared. Counting answers implements the marginal over paths in the law of total probability. Paths with the same answer are treated as agreeing, even if their wording differs. Keeping the paths would require a way to compare them, which the paper does not need.
QuestionOn the RTE task in Table 5, how many points does self-consistency gain over standard prompting?Show answer
Self-consistency scores 86.3 and standard prompting scores 84.8, so the gain is 86.3 - 84.8 = 1.5 points.
QuestionA team wants to apply self-consistency to a task where the model writes a short story. Why is the method hard to apply directly, and what would they need?Show answer
The method counts identical final answers, and a story has no fixed answer set, so no two outputs match exactly. The paper does not study open-ended text. An extension would need a way to judge whether two generations agree or contradict each other, and without such a judgement the vote has nothing to count.
Sources
- Wang et al., "Self-Consistency Improves Chain of Thought Reasoning in Language Models", arXiv:2203.11171 (2022). arxiv.org/abs/2203.11171
- Full text: arxiv.org/pdf/2203.11171