# Self-consistency: how voting over sampled reasoning paths lifts accuracy, and where it stops

Self-consistency samples many chains of thought for one question and keeps the answer most of them reach. Thirty GSM8K-style problems show why the vote climbs from 55.9% to 75.9% with 40 paths, why some questions can never be won, and what each extra path costs.

<div data-sim="specx" data-spec="{&#34;head&#34;:&#34;Self-consistency: how majority voting over sampled reasoning paths lifts accuracy&#34;,&#34;sub&#34;:&#34;Thirty grade-school maths problems in the style of GSM8K. Each sampled chain of thought reaches the right answer with probability p; wrong samples pile onto one tempting wrong answer or scatter. Set the number of paths and watch the vote&#39;s accuracy and cost.&#34;,&#34;params&#34;:[{&#34;id&#34;:&#34;k&#34;,&#34;label&#34;:&#34;Sampled reasoning paths (k)&#34;,&#34;min&#34;:1,&#34;max&#34;:64,&#34;step&#34;:1,&#34;value&#34;:40,&#34;note&#34;:&#34;The paper sampled 40 paths per question&#34;},{&#34;id&#34;:&#34;tok&#34;,&#34;label&#34;:&#34;Output tokens per path&#34;,&#34;min&#34;:50,&#34;max&#34;:1500,&#34;step&#34;:10,&#34;value&#34;:250,&#34;unit&#34;:&#34;tokens&#34;,&#34;note&#34;:&#34;A GSM8K chain of thought is a few hundred tokens&#34;},{&#34;id&#34;:&#34;price&#34;,&#34;label&#34;:&#34;Output price&#34;,&#34;min&#34;:0.1,&#34;max&#34;:80,&#34;step&#34;:0.1,&#34;value&#34;:10,&#34;unit&#34;:&#34;$ / 1M tokens&#34;},{&#34;id&#34;:&#34;cut&#34;,&#34;label&#34;:&#34;Agreement needed to stop early&#34;,&#34;min&#34;:0.3,&#34;max&#34;:1,&#34;step&#34;:0.05,&#34;value&#34;:0.6,&#34;note&#34;:&#34;Questions whose winning answer gets at least this share of votes are treated as confident&#34;}],&#34;data&#34;:{&#34;columns&#34;:[&#34;prob&#34;,&#34;p&#34;,&#34;conc&#34;],&#34;rows&#34;:[[1,0.97,0.9],[2,0.94,0.8],[3,0.92,0.8],[4,0.89,0.7],[5,0.86,0.8],[6,0.83,0.6],[7,0.8,0.7],[8,0.77,0.8],[9,0.74,0.6],[10,0.71,0.7],[11,0.68,0.6],[12,0.65,0.8],[13,0.62,0.7],[14,0.59,0.6],[15,0.56,0.5],[16,0.54,0.7],[17,0.51,0.4],[18,0.48,0.6],[19,0.46,0.9],[20,0.43,0.4],[21,0.41,0.5],[22,0.38,0.35],[23,0.36,0.6],[24,0.33,0.4],[25,0.31,0.55],[26,0.28,0.45],[27,0.25,0.5],[28,0.21,0.6],[29,0.17,0.7],[30,0.12,0.8]],&#34;note&#34;:&#34;Modelled on GSM8K with PaLM-540B (Wang et al., 2022): p = chance one sampled path (T 0.7) is right, mean 55.9% near the paper&#39;s 56.5% greedy score; conc = share of wrong paths on the same wrong answer. Measure both by sampling 20 to 40 paths per question.&#34;},&#34;pre&#34;:[{&#34;id&#34;:&#34;cbar&#34;,&#34;label&#34;:&#34;Mean concentration of wrong answers&#34;,&#34;expr&#34;:&#34;mean(conc)&#34;,&#34;hide&#34;:true}],&#34;row&#34;:[{&#34;id&#34;:&#34;q&#34;,&#34;label&#34;:&#34;share on the top wrong answer&#34;,&#34;expr&#34;:&#34;conc*(1 - p)&#34;,&#34;fmt&#34;:&#34;p&#34;,&#34;tex&#34;:&#34;q_i = c_i\\,(1-p_i)&#34;},{&#34;id&#34;:&#34;r&#34;,&#34;label&#34;:&#34;share scattered over other answers&#34;,&#34;expr&#34;:&#34;1 - p - q&#34;,&#34;fmt&#34;:&#34;p&#34;,&#34;hide&#34;:true},{&#34;id&#34;:&#34;mu&#34;,&#34;label&#34;:&#34;expected vote margin per path&#34;,&#34;expr&#34;:&#34;p - q&#34;,&#34;tex&#34;:&#34;\\mu_i = p_i - q_i&#34;},{&#34;id&#34;:&#34;sd&#34;,&#34;label&#34;:&#34;spread of the margin per path&#34;,&#34;expr&#34;:&#34;sqrt(p + q - mu^2)&#34;,&#34;tex&#34;:&#34;\\sigma_i = \\sqrt{p_i + q_i - \\mu_i^2}&#34;,&#34;hide&#34;:true},{&#34;id&#34;:&#34;maj&#34;,&#34;label&#34;:&#34;majority-vote accuracy&#34;,&#34;expr&#34;:&#34;ifelse(ge(k,2), Phi((k*mu - 0.5*r)/(sqrt(k)*sd)), p)&#34;,&#34;fmt&#34;:&#34;p&#34;,&#34;tex&#34;:&#34;A_i(k) \\approx \\Phi\\!\\left(\\frac{k\\mu_i - r_i/2}{\\sqrt{k}\\,\\sigma_i}\\right),\\; r_i = 1-p_i-q_i&#34;},{&#34;id&#34;:&#34;win&#34;,&#34;label&#34;:&#34;correct answer wins as k grows&#34;,&#34;expr&#34;:&#34;gt(p, q)&#34;,&#34;fmt&#34;:&#34;i&#34;,&#34;tex&#34;:&#34;\\lim_{k\\to\\infty} A_i(k) = [\\,p_i \u003e q_i\\,]&#34;},{&#34;id&#34;:&#34;conf&#34;,&#34;label&#34;:&#34;confident at the cut&#34;,&#34;expr&#34;:&#34;ge(max(p, q), cut)&#34;,&#34;fmt&#34;:&#34;i&#34;},{&#34;id&#34;:&#34;majm&#34;,&#34;label&#34;:&#34;accuracy at m paths&#34;,&#34;expr&#34;:&#34;ifelse(ge(m,2), Phi((m*mu - 0.5*r)/(sqrt(m)*sd)), p)&#34;,&#34;hide&#34;:true}],&#34;derived&#34;:[{&#34;id&#34;:&#34;single&#34;,&#34;label&#34;:&#34;Accuracy of one sampled path&#34;,&#34;expr&#34;:&#34;mean(p)&#34;,&#34;fmt&#34;:&#34;p&#34;,&#34;tex&#34;:&#34;\\bar p = \\tfrac{1}{n}\\sum_i p_i&#34;},{&#34;id&#34;:&#34;acc&#34;,&#34;label&#34;:&#34;Majority-vote accuracy with k paths&#34;,&#34;expr&#34;:&#34;mean(maj)&#34;,&#34;fmt&#34;:&#34;p&#34;,&#34;tex&#34;:&#34;A(k) = \\tfrac{1}{n}\\sum_i A_i(k)&#34;},{&#34;id&#34;:&#34;gain&#34;,&#34;label&#34;:&#34;Gain over one path (points)&#34;,&#34;expr&#34;:&#34;acc - single&#34;,&#34;fmt&#34;:&#34;p&#34;},{&#34;id&#34;:&#34;ceiling&#34;,&#34;label&#34;:&#34;Ceiling as k grows without limit&#34;,&#34;expr&#34;:&#34;mean(win)&#34;,&#34;fmt&#34;:&#34;p&#34;,&#34;tex&#34;:&#34;A(\\infty) = \\tfrac{1}{n}\\sum_i [\\,p_i \u003e q_i\\,]&#34;},{&#34;id&#34;:&#34;n_lost&#34;,&#34;label&#34;:&#34;Questions where a wrong answer wins the vote&#34;,&#34;expr&#34;:&#34;n - sum(win)&#34;,&#34;fmt&#34;:&#34;i&#34;},{&#34;id&#34;:&#34;share_conf&#34;,&#34;label&#34;:&#34;Questions confident at the cut&#34;,&#34;expr&#34;:&#34;mean(conf)&#34;,&#34;fmt&#34;:&#34;p&#34;},{&#34;id&#34;:&#34;tokens&#34;,&#34;label&#34;:&#34;Output tokens per question&#34;,&#34;expr&#34;:&#34;k*tok&#34;,&#34;fmt&#34;:&#34;i&#34;,&#34;tex&#34;:&#34;T = k\\,t&#34;},{&#34;id&#34;:&#34;cost&#34;,&#34;label&#34;:&#34;Cost per 1,000 questions ($)&#34;,&#34;expr&#34;:&#34;k*tok*price/1000&#34;,&#34;tex&#34;:&#34;C = 1000\\,k\\,t\\,\\pi_{out}/10^6&#34;},{&#34;id&#34;:&#34;accm&#34;,&#34;label&#34;:&#34;Accuracy after m paths&#34;,&#34;expr&#34;:&#34;mean(majm)&#34;,&#34;fmt&#34;:&#34;p&#34;}],&#34;iterate&#34;:{&#34;state&#34;:[{&#34;id&#34;:&#34;m&#34;,&#34;label&#34;:&#34;Paths sampled so far&#34;,&#34;init&#34;:&#34;1&#34;}],&#34;update&#34;:[{&#34;id&#34;:&#34;m&#34;,&#34;expr&#34;:&#34;m + 1&#34;}],&#34;max&#34;:64,&#34;per&#34;:1,&#34;track&#34;:&#34;accm&#34;},&#34;chart&#34;:{&#34;title&#34;:&#34;Vote accuracy against the accuracy of one path&#34;,&#34;x&#34;:{&#34;var&#34;:&#34;t&#34;,&#34;label&#34;:&#34;Chance one sampled path is right (p)&#34;,&#34;from&#34;:0.02,&#34;to&#34;:0.98},&#34;y&#34;:{&#34;from&#34;:0,&#34;to&#34;:1},&#34;series&#34;:[{&#34;label&#34;:&#34;One path&#34;,&#34;expr&#34;:&#34;t&#34;,&#34;dash&#34;:true},{&#34;label&#34;:&#34;Majority of k paths&#34;,&#34;expr&#34;:&#34;ifelse(ge(k,2), Phi((k*(t - cbar*(1 - t)) - 0.5*(1 - t)*(1 - cbar))/(sqrt(k)*sqrt(t + cbar*(1 - t) - (t - cbar*(1 - t))^2))), t)&#34;},{&#34;label&#34;:&#34;Majority of 5 paths&#34;,&#34;expr&#34;:&#34;Phi((5*(t - cbar*(1 - t)) - 0.5*(1 - t)*(1 - cbar))/(sqrt(5)*sqrt(t + cbar*(1 - t) - (t - cbar*(1 - t))^2)))&#34;,&#34;dash&#34;:true}],&#34;fit&#34;:{&#34;x&#34;:&#34;p&#34;,&#34;y&#34;:&#34;maj&#34;,&#34;label&#34;:&#34;Questions: vote accuracy with k paths&#34;}},&#34;level&#34;:&#34;intermediate&#34;,&#34;bars&#34;:{&#34;title&#34;:&#34;Majority-vote accuracy per question with k paths&#34;,&#34;y&#34;:&#34;maj&#34;,&#34;label&#34;:&#34;prob&#34;},&#34;steps&#34;:[{&#34;title&#34;:&#34;Sample one path&#34;,&#34;text&#34;:&#34;One chain of thought sampled at temperature 0.7 is right {single:p} of the time on these questions.&#34;,&#34;show&#34;:[&#34;single&#34;]},{&#34;title&#34;:&#34;Sample k paths&#34;,&#34;text&#34;:&#34;Draw k = {k} independent paths per question and keep only each path&#39;s final answer. That costs {tokens} output tokens, or ${cost} per 1,000 questions.&#34;,&#34;show&#34;:[&#34;tokens&#34;,&#34;cost&#34;]},{&#34;title&#34;:&#34;Count the votes&#34;,&#34;text&#34;:&#34;Each path adds one vote to its answer. The correct answer gets p of the votes on average, the most tempting wrong answer q, and the rest scatter, so the vote margin per path is p minus q.&#34;},{&#34;title&#34;:&#34;Take the majority&#34;,&#34;text&#34;:&#34;The answer with the most votes wins. Averaged over the questions the vote is right {acc:p}, a gain of {gain:p} over one path.&#34;,&#34;show&#34;:[&#34;acc&#34;,&#34;gain&#34;]},{&#34;title&#34;:&#34;Find the ceiling&#34;,&#34;text&#34;:&#34;More paths only sharpen what the model already believes: where the wrong answer is more likely than the right one, voting makes it win. Here {n_lost} questions are lost for good and the ceiling is {ceiling:p}.&#34;,&#34;show&#34;:[&#34;n_lost&#34;,&#34;ceiling&#34;]},{&#34;title&#34;:&#34;Use the agreement&#34;,&#34;text&#34;:&#34;The winning answer&#39;s vote share is a confidence signal. {share_conf:p} of the questions reach the agreement cut of {cut}; the rest are the ones to send to a stronger model or a human.&#34;,&#34;show&#34;:[&#34;share_conf&#34;]}]}"><p>Interactive simulation. It needs JavaScript; the text below explains what it shows.</p></div>

## What you are looking at

Each row is one grade-school maths question in the style of GSM8K. Two numbers describe how a model behaves on it when you sample its chain of thought at temperature 0.7. The column p is the chance that one sampled path ends at the correct answer. The column conc is the share of the wrong paths that land on the same wrong answer, the tempting mistake; the remaining wrong paths scatter over many different answers.

The mean of p is 55.9%, close to the 56.5% that PaLM-540B scored on GSM8K with greedy chain-of-thought decoding in the self-consistency paper. With the default of k = 40 sampled paths, the majority vote is right on 75.9% of the questions, a gain of 20.0 points. The paper reports 74.4% for the same model and setting, a gain of 17.9 points.

The chart puts the model and the data together. The dashed diagonal is one path, the solid curve is the vote over k paths and the second dashed curve is the vote over 5 paths, each drawn for the average wrong-answer concentration. The dots are the thirty questions with their vote accuracy at the current k. The bars show the same per-question accuracy, so you can see which questions the vote fixes and which it makes worse. Press play on the iteration to add paths one at a time and watch the accuracy climb: 55.9% with one path, 69.6% with 5, 72.5% with 10, 74.6% with 20 and 75.9% with 40.

## The algorithm

Self-consistency (Wang et al., 2022) replaces greedy decoding in chain-of-thought prompting with three steps: sample m reasoning paths, read the final answer a_i from each, and return the answer with the most votes:

$$\hat a = \arg\max_a \sum_{i=1}^{m} \mathbb{1}(a_i = a)$$

The paper sampled 40 paths per question, at T = 0.7 with top-k 40 for PaLM-540B and T = 0.7 without truncation for GPT-3.

To see why voting helps, count votes for one question. Each path votes for the correct answer with probability p, for the tempting wrong answer with probability q = conc × (1 − p), and for some scattered answer with the remaining probability r = 1 − p − q. The vote margin of one path, correct minus tempting, has mean μ = p − q and standard deviation σ = √(p + q − μ²). Over k independent paths the margin grows like kμ while its noise grows only like √k σ, so the chance that the correct answer comes out on top is approximately

$$A(k) \approx \Phi\!\left(\frac{k\mu - r/2}{\sqrt{k}\,\sigma}\right)$$

The r/2 term is a small correction for the scattered answers, which can tie or beat the correct one when k is small. With one path the vote is just that path, so the simulation uses A(1) = p exactly. I checked the approximation against a direct simulation of the vote with 10 scattered wrong answers: on this set it gives 69.6% at k = 5 against 69.0% simulated, 72.5% against 72.7% at k = 10, and 75.9% against 76.1% at k = 40.

The same formula shows the limit. If p is above q, the margin is positive and A(k) goes to 1. If the tempting wrong answer is more likely than the right one, A(k) goes to 0: more paths make the vote more confidently wrong.

Worked example, question 16: p = 0.54 and conc = 0.7, so q = 0.7 × 0.46 = 0.322, r = 0.138, μ = 0.218 and σ = √(0.54 + 0.322 − 0.0475) = 0.902. With k = 40 the score is (40 × 0.218 − 0.069) / (√40 × 0.902) = 1.516, and Φ(1.516) = 93.5%. One path solves this question 54% of the time; 5 paths 69.4%; 40 paths 93.5%. Question 19 goes the other way: p = 0.46 but q = 0.486, so its vote accuracy falls from 46% to 43.1% at 40 paths.

## Things to try

- Move k from 1 to 5. Most of the gain arrives early: accuracy goes from 55.9% to 69.6%, while the cost per 1,000 questions goes from $2.50 to $12.50 at 250 tokens per path and $10 per million output tokens.
- Push k to 64. Accuracy only reaches 76.4%, and the cost is $160 per 1,000 questions. The last 24 paths buy half a point.
- Look at the ceiling. Eight questions have q above p, so in the long run only 73.3% of the questions can be won. At k = 40 the vote is still above that limit because near-tie questions such as 19 and 23 are still close to coin flips; as k grows they are lost too.
- Raise conc on a few of the easy questions until q passes p and watch their bars drop. A model that makes the same mistake every time is not helped by voting, only one that makes different mistakes.
- Move the agreement cut. At 0.6, 46.7% of the questions have a winning answer expected to collect at least 60% of the votes; at 0.8 only 23.3%. The low-agreement questions are the ones to escalate.

## How it works in real systems

Self-consistency is the simplest form of test-time compute: spend more tokens at inference instead of training a bigger model. In agents it appears as voting over several plans or several tool-call results, and as the self-consistency score inside the value function of Language Agent Tree Search. It needs a final answer that can be compared exactly, such as a number, a label or a choice; for free text you need a judge or a similarity measure to group answers.

The cost is linear in k, so production systems rarely run 40 paths on every request. Common patterns are adaptive sampling (stop once the leading answer has an unbeatable lead), using the vote share as a confidence score to route low-agreement questions to a larger model, as in the [cascade simulation](/ai-simulations/llm-cascade-threshold-cost-accuracy), and lowering the [sampling temperature](/ai-simulations/sampling-temperature-top-p) when paths are too diverse to agree. Voting differs from [pass@k](/ai-simulations/pass-at-k-vs-pass-power-k), which counts a question as solved if any of the k attempts is right and needs a verifier to pick it out; majority voting needs no verifier but is capped by the questions where the model's most common answer is wrong. For retries that learn from failure, see [Reflexion](/ai-simulations/reflexion-retries-written-lessons), and for a longer explanation with code, the [self-consistency article](/articles/self-consistency-majority-vote-reasoning).

## Sources

- [Wang et al., Self-Consistency Improves Chain of Thought Reasoning in Language Models (arXiv 2203.11171)](https://arxiv.org/abs/2203.11171)
- [Self-consistency paper, full text with sampling settings and GSM8K results](https://arxiv.org/pdf/2203.11171)
- [Yao et al., Tree of Thoughts, which uses CoT-SC as a baseline (arXiv 2305.10601)](https://arxiv.org/pdf/2305.10601)
- [Zhou et al., Language Agent Tree Search, which uses a self-consistency score in its value function (arXiv 2310.04406)](https://arxiv.org/pdf/2310.04406)
