Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

~7 min readGoogle · 2022

Self-Consistency,
explained.

Chain-of-thought gave models the ability to reason step by step — and a new way to fail: one slip anywhere in the chain, and the answer at the end is garbage. Google's fix was almost suspiciously simple. Don't trust one chain. Sample thirty, let them disagree about the route, and vote on the destination. Wrong answers scatter; the right one keeps showing up.

The delta

What changes against chain of thought: one path becomes many

Rung 1 generates a single chain — usually the greedy one — and reports where it lands. That makes the answer hostage to one arithmetic slip in one step, and it ignores an obvious asymmetry in how reasoning goes wrong.

The change: sample many chains at a temperature that makes them genuinely different, then discard the reasoning and take a majority vote over the final answers. The reasoning is treated as a latent variable to be marginalised out rather than as the output — what you want is the answer the model's reasoning distribution concentrates on, not the answer one sample reached.

The premise underneath it is what makes this more than an ensembling trick: there are many valid routes to a correct answer and idiosyncratic routes to each wrong one. Correct answers therefore accumulate votes from diverse paths, while errors scatter. Stated in units the ladder can compare, this is the first clean instance on the site of a trade that dominates everything above it — spend N times the inference compute, get a double-digit accuracy gain, with the same weights and the same prompt. Reported on grade-school maths, the improvement over single-path chain of thought is around eighteen points.

01

One chain is a single point of failure

Chain-of-thought prompting unlocked multi-step reasoning: show the model how to work through a problem, and it works through new ones. But standard decoding generates one chain, greedily — always the locally most likely next token. A single arithmetic slip, one misread condition, and every step after inherits the error. The chain is only as strong as its weakest link, and there's exactly one chain.

Greedy decoding has a second, quieter cost: the most probable path isn't always the most correct one. The model often "knows" better routes — they're in the distribution, just not at its peak. Greedy never visits them.

02

The recipe: sample, extract, vote

Self-consistency replaces greedy decoding with three steps. Sample a set of chains — the same CoT prompt, but with temperature, so each run takes a genuinely different reasoning route. Extract each chain's final answer, ignoring how it got there. Vote: return the answer that appears most often.

Marginalize out the reasoning, keep the answer
CoT prompt
→
Sample N chains
temperature on
→
Extract answers
18, 26, 18, 18, 9…
→
Majority vote
→ 18

The paper frames it in one elegant phrase: the reasoning path is a latent variable. You don't care which route was taken — you marginalize the routes out and keep the answer they support. No training, no verifier, no new model. A pure decoding swap.

03

Why the vote lands on the truth

The magic is an asymmetry: correct answers are attractors; wrong answers are scattered. A math problem usually has many valid solution routes, and they all terminate at the same number. Errors, by contrast, are uncorrelated — a slip in step 2 of one chain and a misreading in step 4 of another land on different wrong answers. Agreement concentrates on truth; disagreement disperses over mistakes.

The key idea

It's a wisdom-of-crowds argument where the crowd is one model sampled many times. The vote doesn't need any path to be trustworthy — it needs errors to be uncorrelated, and diverse sampling is what buys that.

A bonus falls out for free: the size of the majority is a confidence signal. Twenty-eight of thirty chains agreeing means something very different from eleven — a calibration knob production systems still use.

The counterintuitive part: a single chain can be right less than half the time and the vote still wins. All that's required is that the correct answer be the plurality — more common than any single wrong answer. Spread the errors across enough distinct wrongs and that's easy:

As you add samples, the majority converges on the mode — and the mode is the truth. The runnable version below watches that curve climb.

05

The cost, and where it fits

The price is explicit: N samples cost N generations. Thirty-path self-consistency is ~30× the inference bill of one greedy chain. That's why production use is selective — high-stakes answers, eval harnesses, offline pipelines — and why the sample count is a dial, not a default.

It also only works where answers are discrete and comparable: math, multiple choice, classification, code that passes tests. Open-ended generation has no clean vote — thirty essays don't have a majority. (Extensions like universal self-consistency later asked the model itself to pick the most consistent response, stretching the idea to free-form output.)

06

Why it still matters

Self-consistency was the field's cleanest early proof that inference compute is a quality dial — the same model, same weights, gets measurably smarter if you let it try more. Formalize that trade, add verifiers and search, then train models to do the exploring internally, and you arrive at reasoning models. The lineage from sample-and-vote to test-time compute is direct.

It's also still the cheapest reliability upgrade in the toolbox: no retraining, model-agnostic, one loop of code. Any eval harness that reruns a flaky benchmark, any agent that generates three candidate plans and picks the consensus — that's self-consistency, doing its quiet work in production.

Read next

Self-consistency votes over independent chains; Tree of Thoughts goes further — exploring, evaluating and abandoning reasoning branches mid-flight, turning voting into genuine search.

How it works

How Wang et al. ran self-consistency decoding

Self-consistency comes from Xuezhi Wang, Jason Wei and colleagues at Google Research's Brain team, and was published at ICLR 2023. It keeps the chain-of-thought prompt exactly as it was and replaces only the decoder. Everything below happens at inference time on an unmodified model.

sampled paths, m = 40 in the paper CoT prompt + question sample 1 → 18 sample 2 → 26 sample 3 → 18 sample 4 → 9 sample 5 → 18 vote 18: 3 votes 26: 1 vote 9: 1 vote answer 18 greedy: one path answer = wherever it lands
Self-consistency swaps the decoder, not the prompt: sample many paths, keep only their final answers, and return the plurality. Greedy decoding keeps one path and inherits its mistakes.
  1. Reuse the chain-of-thought prompt. The same hand-written exemplars as the chain-of-thought paper, so any gain comes from decoding rather than from a better prompt.
  2. Sample m reasoning paths. Instead of one greedy decode, draw m independent completions with temperature sampling; the main results use m = 40. Settings were set per model family: UL2 20B and LaMDA 137B at temperature 0.5 with top-k truncation to the 40 most likely tokens, PaLM 540B at temperature 0.7 with the same top-k, and GPT-3 at temperature 0.7 with no truncation.
  3. Parse each path's final answer. Every completion ends in an answer line, so each path reduces to a pair (ri, ai): the reasoning and the answer it reached. This needs answers that can be compared for equality, such as a number or a multiple-choice letter.
  4. Aggregate. Return the answer that the most paths reached. The reasoning is discarded; only the answers vote.
  5. Average over runs. Because sampling is random, reported accuracies are means over 10 independent runs of 40 samples each.

The aggregation ablation

A vote is not the only way to combine paths, so the authors compared it with weighting each path by the model's own probability of generating it. Raw sequence probability shrinks with every token and so favors short chains, which is why they also tried a length-normalized version, the exponential of the mean token log-probability. A length-normalized weighted sum scored almost exactly the same as the unweighted vote. Weighted averages, which divide out how many paths agreed, did markedly worse. The paper's explanation is that the model gives its own diverse generations similar normalized probabilities, so the probabilities add little beyond the count, and the count is the signal.

The baselines it had to beat

  • Sample-and-rank. Sample many paths and return the single most probable one. With the same number of samples it trails voting by a wide margin.
  • Beam search. Decode the top beams and vote over them. Beams share most of their prefixes and so most of their mistakes, and voting over beams trailed voting over samples.
  • Prompt ensembles. Vote over outputs from reordered exemplars or from different exemplar sets. Self-consistency beat these as well.

Two further checks matter in practice. The gain held across temperatures, top-k values and nucleus sampling, so it is not a tuning artifact. And the share of paths agreeing with the winning answer tracked accuracy: low agreement flagged questions the model was likely to get wrong, which makes the vote margin usable as an uncertainty estimate.

The math

The aggregation rule, and the weighted variants it beat

For one question, sample m paths and parse each into reasoning ri and an answer ai. Self-consistency returns the answer with the most votes:

â = argmaxa Σi=1^m 1[ ai = a ]

The weighted variants replace each vote with the model's own length-normalized probability of that path:

wi = exp( (1/K) Σk=1^K log Pθ( tk | prompt, question, t1 … tk−1 ) )
  • m — the number of sampled paths, 40 in the paper's main results
  • 1[ai = a] — 1 if path i reached answer a, else 0; this is why answers must be comparable for equality
  • tk, K — the tokens of path i and its length; dividing by K stops long chains being penalized for their length
  • argmaxa — the plurality answer, which does not need a majority

At m = 1 the rule is one sampled chain with no protection against a slip. As m grows, the vote converges on the mode of the model's answer distribution: correct when that mode is the right answer, confidently wrong when the model is systematically biased. Summing the weights wi instead of counting gave nearly the same accuracy; averaging them, which throws away how many paths agreed, did worse.

The evidence

What Wang et al. ran, and what it showed

The evaluation covered UL2 20B, LaMDA 137B, PaLM 540B and GPT-3 (the Codex code-davinci models) on arithmetic benchmarks (GSM8K, SVAMP, AQuA, ASDiv, AddSub, MultiArith) and commonsense ones (CommonsenseQA, StrategyQA, ARC). The baseline is the chain-of-thought paper's own method, the same prompt decoded greedily. Self-consistency used 40 samples, averaged over 10 runs.

BenchmarkHeadline gain over greedy chain of thought
GSM8K+17.9 points
AQuA+12.2 points
SVAMP+11.0 points
StrategyQA+6.4 points
ARC-challenge+3.9 points

On GSM8K, PaLM 540B went from 56.5% with greedy chain of thought, the self-consistency paper's own baseline run, to 74.4%. Every model improved, and accuracy rose with the number of sampled paths, steeply at first and flattening toward 40.

What did not work, or worked less. Weighting votes by length-normalized probability matched plain counting, and averaging probabilities did worse, so the model's confidence added nothing the count did not. Sample-and-rank and beam search both trailed voting over diverse samples, which isolates diversity as the ingredient that matters. The gains were smallest where greedy decoding was already near the ceiling, as on the easier arithmetic sets for the largest models. And the method's precondition limits where these numbers apply: every benchmark here has a short answer that can be checked for equality, which open-ended generation does not.

Since then

What the authors admit, and what happened next

Two limits are structural. The cost is linear in the number of samples with no early exit, and the method needs answers that can be compared for equality — you can majority-vote a number or a multiple-choice letter, and you cannot majority-vote an essay, a proof or a piece of code without first solving the equality problem that made it hard.

The third limit is the one worth remembering, because it is a failure of the premise rather than of the method. Voting helps when errors are idiosyncratic. When a model is systematically wrong — it has learned a misconception, or the question contains a misleading cue — the samples agree on the wrong answer, and self-consistency converts a wrong answer into a confidently wrong answer. Agreement among samples measures the sharpness of the model's distribution, and people read it as confidence in the answer's truth. Those coincide only when the model is unbiased.

How it held up: as a default evaluation-time technique and as the conceptual seed of test-time compute. The idea that accuracy is something you can buy at inference rather than something fixed by the weights starts here, and rung 4 is that idea taken seriously enough to reorganise a model around. The step from here to the rest of the ladder is the recognition that if you are going to sample many candidates, choosing among them well is worth more than counting them — which is where a verifier beats a vote.

SOLVE IT YOURSELF

Watch the vote climb toward the truth

Self-consistency's surprise is that a single reasoning chain can be wrong more often than right and majority voting still nails the answer. This simulates it honestly: each sampled chain reaches the correct answer 45% of the time, and its errors scatter over eight different wrong answers. A single chain is a coin flip that loses — but because correct is the plurality, the vote converges on it. Run it and watch accuracy climb from ~43% (one chain) to ~100% (41 chains). Change the per-chain accuracy or the number of wrong answers.

YOUR TASK

Write the body of accuracy. Everything else in the file is already written; this is the function the paper is about. Press ▶ Run to check it against the 5 assertions below — they start red.

WHAT IT HAS TO SATISFY — 5 ASSERTIONS
  1. A single chain is right less than half the time
  2. The correct answer is the plurality (beats any single wrong)
  3. Voting many chains beats a single chain
  4. More samples do not hurt accuracy
  5. Enough votes recover the truth almost always
CPython · WebAssembly
Questions

Questions people ask about Self-Consistency

Does weighting the votes by model probability improve self-consistency?

Not in the paper's experiments. Wang and colleagues compared the plain majority vote with versions that weight each reasoning path by the model's own probability of generating it. Raw sequence probability favors short chains, so they also normalized by length, taking the exponential of the mean token log-probability. A length-normalized weighted sum scored almost exactly the same as the unweighted vote, and weighted averages, which divide by the number of agreeing paths, did worse because they discard the count. The paper's reading is that the model assigns similar normalized probabilities to its own diverse generations, so probability carries little information beyond how many paths agree. That is why the simple vote became the default.

What is the difference between maj@k and pass@k?

Both sample k answers per problem, and they answer different questions. maj@k, also written cons@k, scores a problem correct if the most common of the k answers is right; that is self-consistency, and it needs no outside checker. pass@k scores a problem correct if any of the k answers is right, which assumes something can recognize the right one, such as unit tests for code. pass@k therefore climbs toward 1 for any problem the model ever solves, while maj@k climbs only if the correct answer becomes the model's most common answer. A large gap between the two means a better selector, such as a verifier, could recover accuracy that voting leaves behind.

How many samples does self-consistency need?

The paper's main results use 40 sampled paths per question, and its accuracy curves rise steeply over the first several samples and then flatten toward 40. Most of the benefit arrives well before the maximum, and extra samples mostly confirm an answer the vote has already settled. Because cost grows linearly with the number of samples, the practical choice is the smallest count at which the plurality stops changing on your task. The vote margin helps decide: when most paths already agree, more samples rarely flip the result, and when they split widely, the question is one the model is likely to get wrong anyway.

What sampling temperature did the self-consistency paper use?

It depended on the model family. For UL2 20B and LaMDA 137B the authors sampled at temperature 0.5 with top-k truncation to the 40 most likely tokens; for PaLM 540B, temperature 0.7 with the same top-k; and for GPT-3, temperature 0.7 with no truncation. They also showed that the gain holds across a range of temperatures, top-k values and nucleus sampling settings, so the exact choice is not critical. What matters is diversity: the paths must differ enough that their mistakes land on different wrong answers. Greedy decoding gives one path, and beam search gives paths too similar to one another, which is why both underperform sampling.

Why does self-consistency fail when a model is confidently wrong?

The vote helps only when errors are scattered. If a model holds a systematic misconception, or a question contains a misleading cue, many sampled paths make the same mistake and land on the same wrong answer, which then wins the vote. Sampling more paths makes this worse rather than better, because the vote converges on the mode of the model's answer distribution, and here the mode is wrong. Agreement among samples measures how concentrated that distribution is, not whether its peak is correct. The paper found agreement correlates with accuracy on average, which makes it a useful warning signal, but a high-agreement wrong answer looks exactly like a high-agreement right one.

Check yourself

4 questions to test what you just read

Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.

Self-consistency samples 40 paths per question. If one greedy chain costs 1 unit of compute, what does the paper's setting cost, and what did it buy for PaLM 540B on GSM8K?

Show answer

40 units, since every path is a full generation and there is no early exit. For PaLM 540B it bought 56.5% → 74.4%, a 17.9-point gain, with no change to the weights or the prompt.

Ten sampled answers come back as 18, 26, 18, 9, 18, 26, 14, 18, 26, 9. What does self-consistency return, and would it change if every path carried about the same length-normalized probability?

Show answer

Tally: 18 appears 4 times, 26 three times, 9 twice and 14 once, so it returns 18, a plurality of 4 out of 10 rather than a majority. If every path carries roughly equal weight, the weighted sum is just the count times a constant, so the winner does not change, which is why the paper found the two rules nearly identical.

Why does voting over beam-search outputs help less than voting over temperature samples, even with the same number of paths?

Show answer

Voting needs the paths' errors to be uncorrelated. Beam search keeps the highest-probability continuations, which share most of their prefix and therefore most of their mistakes, so wrong answers cluster instead of scattering. Temperature sampling takes genuinely different routes, so a slip in one path rarely repeats in the others.

On one question 38 of 40 samples agree; on another only 12 of 40 share the plurality answer. Which answer should you trust more, and what is the caveat?

Show answer

The 38-of-40 answer: the paper found that the share of paths agreeing with the winner correlates with accuracy, so low agreement flags likely errors. The caveat is systematic bias. If the model holds a misconception, its samples agree on the same wrong answer, and high agreement then measures a sharp distribution, not a correct one.

Where this sits

Reasoning you can prompt, then train

It began as a prompting trick and ended as a training objective. Read in order, the progression from "let's think step by step" to a model trained to.

  1. 1Chain-of-Thought Prompting2022
  2. 2Self-Consistency2022
  3. 3Tree of Thoughts2023
  4. 4OpenAI o12024
  5. 5DeepSeek-R12025

All 110 papers, in 19 ladders →

Self-Consistency Improves Chain of Thought Reasoning in Language Models · Wang, Wei, Schuurmans, et al. · Google · 2022 · read the original paper on arXiv → · Vibe Engines · 2026
Finished this one? 0 / 110 Paper Breakdowns done
NextTree of Thoughts Next on the “Reasoning you can prompt, then train” ladder · rung 3 of 5

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns