Sample many solutions, keep the common answer
A model asked once can take a wrong turn early and follow it to a wrong answer. Self-consistency asks the same question many times with sampling switched on, so each run can reason differently, and returns the final answer that most runs reach. Wang et al. describe it as marginalising out the reasoning: many different paths can lead to the right answer, while wrong paths tend to scatter over different wrong answers. With the final answers of samples,
No second model is needed and nothing is trained; the price is times the tokens. On this page Qwen2.5-Math-1.5B-Instruct answers GSM8K test rows 0–39, the Thinking tab's problems, 32 times each, with its model card's chain-of-thought prompt and at most 512 new tokens. A final answer is the number in the last \boxed{}.
Greedy and sampled solutions
Greedy decoding takes the most likely token at every step, , so it gives one solution and always the same one. The samples draw each token from the model's distribution at temperature 0.7 over the 40 most likely tokens. A sample copies greedy until its first draw that is not the most likely token; the Where #j left the greedy path panel shows that token's distribution, the uniform the sample drew and the slice of probability it fell in. After that one token the two solutions see different text, and every later step can differ too.
Each sample has its own stream of uniforms (sample of row is seeded ), so it does not depend on the batch it ran in, and every recorded token reproduces from its logits and seed. Greedy is right on 31 of the 40 problems; a single sample is right 80.2 % of the time on average.
The vote
The panel The vote draws the final answers of the first samples as bars, most votes first, green when the answer is the reference. Samples without a boxed number do not vote, and a tie goes to the answer voted for first. On row 0 all 32 samples agree; on row 8 the samples give a dozen different numbers and 12 give none, and the 7 votes for 45 still win.
Whether the vote is right depends on which answer is the most likely one, not on how likely it is. If on some problem the right answer is the most frequent answer of the model's answer distribution, the vote of samples is right with a probability that tends to 1 as grows; if a wrong answer is the most frequent, more samples make the vote surer of the wrong answer. Row 3 is such a problem: 23 of its 32 samples say 180 and 8 say the reference, 540. The vote cannot recover an answer the model rarely reaches; it only removes the bad luck of a single draw.
Accuracy against samples
The Accuracy against samples panel and its table give, for = 1, 2, 4 … 32, the accuracy of the vote over samples. "Vote" is its expected value, the vote over samples averaged over 256 random orderings of the 32; "first N" is the vote of the samples in the order they were drawn, a single noisier estimate. The expected vote rises from 80 % with one sample to 85 % with 8 and 86 % with 16, and the vote of all 32 is right on 34 of the 40 problems. Most of the gain comes from the first few samples: past that the vote of most problems is already settled.
"Any right" is the share of problems where at least one of the samples has the reference answer, rising from 80 % to 100 % at 32. It is the ceiling a perfect verifier could reach by picking a right sample whenever there is one; Brown et al. call it coverage and find it keeps growing over many orders of magnitude of samples. The gap between the vote and "any right" is right answers the model wrote and the vote outvoted. Cost grows linearly: about 312 tokens a sample, 9,997 a problem for 32 samples against 306 for greedy.
Where it came from
Wang et al. introduced self-consistency on top of chain-of-thought prompting (Wei et al.) and found large gains on GSM8K and other reasoning benchmarks over greedy chain-of-thought. It needs answers that can be compared for equality, such as numbers; free-form answers need a way to group equivalent ones first. Later work measured how accuracy scales with the number of samples and compared voting with choosing by a learned verifier (Wu et al.).
The Best-of-N tab replaces the vote with a reward model that scores each of the first 16 of these samples, and the PRM tab with a model that scores every step; the Thinking tab spends a similar budget on one long reasoning instead of many short ones.
Papers
- Self-Consistency Improves Chain of Thought Reasoning in Language Models Introduces sampling several reasoning paths and taking the majority final answer.
- Qwen2.5-Math Technical Report: Toward Mathematical Expert Model via Self-Improvement The model recorded here, a 1.5 B maths model tuned to write step-by-step solutions that end in a boxed answer.
- Chain-of-Thought Prompting Elicits Reasoning in Large Language Models Reasoning written out before the answer, the solutions self-consistency samples.
- Training Verifiers to Solve Math Word Problems GSM8K, the problems on this page, and the first verifier for choosing among sampled solutions.
- Large Language Monkeys: Scaling Inference Compute with Repeated Sampling Coverage, the share of problems some sample solves, as the number of samples grows, and how much of it voting and reward models recover.
- Inference Scaling Laws: An Empirical Analysis of Compute-Optimal Inference for Problem-Solving with Language Models Majority voting and reward-weighted voting against the number of samples and model size, at equal compute.