AI Wiki中文/EN

Self-consistency: vote on answers, inspect shared errors

自洽采样

Compute exact plurality accuracy, normalize answers and model correlated samples.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Several routes can agree on an answer and share the same mistake

Five generated solutions end with 18, 18.0, 36/2, 16 and 16. Literal string voting chooses 16; numeric normalization reveals three votes for 18. Before asking whether voting helps, specify what counts as the same answer.

Self-consistency samples multiple reasoning paths and aggregates their final answers. Wang and colleagues, section 2, use plurality voting over parsed answers after chain-of-thought prompting. With more than two answer categories, plurality means the largest vote count, not necessarily more than half the votes. Their first version breaks ties by the answer encountered first. Wei and colleagues, sections 2–3.1, provide the underlying intermediate-step prompting setup.

Agreement is useful when the correct answer is favored by the sampling distribution and errors are sufficiently diverse. Agreement is not a correctness certificate. The experiment below computes exact voting probabilities for a synthetic three-answer generator and adds a shared-error mechanism.

Exact voting probabilities show how shared errors can limit repeated sampling.
Exact voting probabilities show how shared errors can limit repeated sampling.

Voting estimates an answer marginal

Let a sample contain reasoning text zz and an extracted answer aa. After fixing the prompt and sampling procedure, define the answer probabilities by:

pa=∑zp(z,a∣x),∑apa=1.p_a=\sum_z p(z,a\mid x),\qquad \sum_a p_a=1.

Parsing is part of this definition. Decide how to handle malformed answers, units, equivalent fractions and refusals. Dropping failed parses changes the effective distribution and budget; it should not be hidden inside the reported sample count. The program rejects invalid numeric strings rather than silently assigning them a valid answer.

For NN samples, count normalized answers and choose a plurality winner:

Ca=∑n=1N1{an=a},a^=arg⁡max⁡aCa.C_a=\sum_{n=1}^{N}\mathbf1\{a_n=a\},\qquad \widehat a=\arg\max_a C_a.

A tie rule completes the decision procedure. For a particular sequence the program uses first occurrence, matching the selected paper version. This differs from arbitrarily sorting answer strings or treating every tied category as a win.

For independent samples, the empirical frequency is unbiased and has variance:

E[Ca/N]=pa,Var⁡(Ca/N)=pa(1−pa)N.\mathbb E[C_a/N]=p_a,\qquad \operatorname{Var}(C_a/N)=\frac{p_a(1-p_a)}{N}.

Shrinking sampling variance does not correct the underlying answer probabilities. If the wrong answer has the largest pap_a, enough independent samples increasingly favor it.

For three categories, designate category 0 as correct. We can enumerate count triples and compute the exact chance that it wins:

AN=∑c0+c1+c2=NN!c0!c1!c2!∏j=02pjcj1{c0=max⁡jcj}∣{j:cj=max⁡kck}∣.A_N=\sum_{c_0+c_1+c_2=N}\frac{N!}{c_0!c_1!c_2!}\prod_{j=0}^2p_j^{c_j}\frac{\mathbf1\{c_0=\max_jc_j\}}{|\{j:c_j=\max_kc_k\}|}.

Why divide by the number of tied maxima when the actual tie rule is first occurrence? Conditional on tied categories having equal counts, their random IID ordering makes each equally likely to appear first. This formula averages that deterministic sequence-level rule over all sample sequences. It is not a replacement rule for a fixed observed batch.

For two categories and odd NN, this reduces to the familiar independent-majority probability:

ANbinary=∑k=(N+1)/2N(Nk)pk(1−p)N−k.A_N^{\mathrm{binary}}=\sum_{k=(N+1)/2}^{N}\binom Nk p^k(1-p)^{N-k}.

The common intuition that voting helps when p>1/2p>1/2 concerns this binary model. In a multiclass problem, a correct answer with probability 0.4 can still be the most likely category. Conversely, many different surface strings can conceal one common wrong answer until normalization merges them.

Our correlated model flips one batch-level coin. With probability ρ\rho, draw one answer and repeat it for all NN paths; otherwise draw IID answers. Each path keeps the same marginal distribution, but the voting accuracy becomes:

ANshared=ρp0+(1−ρ)AN.A_N^{\mathrm{shared}}=\rho p_0+(1-\rho)A_N.

For the indicator of a given answer, the pairwise correlation is ρ\rho. Its frequency variance corresponds to the effective sample count:

Neff=N1+(N−1)ρ.N_{\mathrm{eff}}=\frac{N}{1+(N-1)\rho}.

This identity belongs to the stated common-shock model; real language-model outputs need not follow it. It shows why counting paths alone overstates the information gained when they are correlated.

Compare exact counts with actual sampling

The complete program uses probabilities (0.4,0.35,0.25) for answers (18,16,20). It enumerates count triples, separately simulates 20,000 batches of nine answers with seed 37, and uses exact rational normalization for answer strings.

"""Original exact plurality calculations and sampled categorical answers; no LLM."""
from collections import Counter
from fractions import Fraction
from math import factorial
import json
import numpy as np


def normalized_answer(text):
    if not isinstance(text,str) or len(text)>60:raise ValueError("Short numeric answer required")
    try:return str(Fraction(text.strip()))
    except (ValueError,ZeroDivisionError):raise ValueError("Invalid numeric answer") from None


def vote(answers):
    if not answers:raise ValueError("At least one answer required")
    labels=[normalized_answer(x) for x in answers];counts=Counter(labels)
    return max(counts,key=counts.get)  # Counter preserves first occurrence for ties.


def plurality_accuracy(probabilities,n):
    p=np.asarray(probabilities,dtype=float)
    if (p.shape!=(3,) or not np.isfinite(p).all() or np.any(p<0)
        or not np.isclose(p.sum(),1) or type(n) is not int or not 1<=n<=100):
        raise ValueError("Three probabilities and an integer sample count1..100 required")
    total=0.
    for a in range(n+1):
        for b in range(n-a+1):
            counts=(a,b,n-a-b);largest=max(counts)
            if a!=largest:continue
            ties=sum(c==largest for c in counts)
            multiplicity=factorial(n)//(factorial(a)*factorial(b)*factorial(n-a-b))
            mass=multiplicity*float(np.prod([q**c for q,c in zip(p,counts)]))
            # Conditional on tied equal counts, each tied label is first equally often.
            total+=mass/ties
    return total


def common_shock_accuracy(p,n,rho):
    if not np.isfinite(rho) or not 0<=rho<=1:raise ValueError("rho must be in[0,1]")
    return rho*p[0]+(1-rho)*plurality_accuracy(p,n)


def demo():
    p=np.array([.4,.35,.25]);sizes=[1,3,5,9,21,51]
    rows=[dict(n=n,independent=plurality_accuracy(p,n),correlated=common_shock_accuracy(p,n,.4)) for n in sizes]
    rng=np.random.default_rng(37);draws=rng.choice(3,size=(20000,9),p=p)
    wins=sum(vote([str([18,16,20][i]) for i in row])=='18' for row in draws)
    return dict(probabilities=p.tolist(),rows=rows,rho=.4,
        correlation_limit=.4*p[0]+.6,simulation_n=9,simulation_trials=len(draws),
        simulated_accuracy=wins/len(draws),normalized_vote=vote(['18','18.0','36/2','16','16']),
        wrong_modal_accuracy_n51=plurality_accuracy([.25,.5,.25],51))


if __name__=='__main__':print(json.dumps(demo(),indent=2))

With independent samples, correctness is 0.4 for one draw, 0.48003128 for nine and about 0.63559566 for 51. At nine samples, the simulation gives 0.4834, close to the exact probability. These are results of the declared categorical model, not measured gains of an LLM.

With ρ=0.4\rho=0.4, the nine-sample probability is 0.448018768. Even with arbitrarily many samples, the model’s accuracy tends to 0.4×0.4+0.6=0.760.4\times0.4+0.6=0.76, since the correct category is the unique independent-sampling mode but a shared draw can still be wrong. If probabilities instead become (0.25,0.5,0.25), 51-sample correctness falls to about 0.01567782: more voting favors the wrong mode.

For three fixed categories, count enumeration has O(N2)O(N^2) triples; exact factorial arithmetic adds integer-operation costs. The implementation bounds NN by 100. Voting over an actual batch requires O(N)O(N) dictionary operations plus parsing. Generating the paths is usually the expensive part in a language model; this program does not measure generation cost.

Sampling diversity and useful disagreement are not identical

Different wording can repeat one mistaken premise. Increasing temperature may diversify text while lowering the chance of a correct answer. The parser can also merge semantically different answers or split equivalent ones, particularly when units, ranges or multiple requested quantities matter.

Wang’s section 2 distinguishes plurality from weighting each sampled answer by the likelihood of its entire path; the first version reports favoring plurality in its experiments. A path likelihood is not automatically a calibrated correctness score. Do not substitute a new weighting rule while retaining the same method name and evaluation claim.

The fixed answer set makes the toy tractable. Open-ended writing may lack a meaningful exact-match vote. A majority preference over paraphrases would be a different judge-dependent task. Report the number of generated and successfully parsed samples, tie rule, sampling settings and total budget.

Predict when another vote helps

  1. What does the toy vote return for 18, 18.0, 36/2, 16, 16?

Answer: 18. Exact rational normalization merges the first three. Literal string voting would incorrectly treat them as three unrelated categories and choose 16.

  1. Must a plurality winner receive more than half the votes?

Answer: No. Counts (4,3,3) select the first category with only 40% of ten votes. Majority and plurality coincide for two categories without a tie, not in general.

  1. What happens when ρ=1\rho=1 in the common-shock model?

Answer: Every batch repeats one draw. Accuracy stays p0p_0 for any sample count and Neff=1N_{\mathrm{eff}}=1; more copies add no independent evidence.

  1. Can voting amplify an error even with independent samples?

Answer: Yes. With (0.25,0.5,0.25) and the first category correct, the wrong second category is the mode. At 51 samples the computed correct-vote probability is about 0.01567782.

Read the parser and tie rule alongside the headline result

Wang’s section 2 and its footnotes specify answer extraction and first-encounter ties. Wei’s prompting setup explains where the intermediate paths come from. The comparison to test-time compute is then a budget question: whether additional paths, stronger verification or a different search strategy buys more verified success under the same constraints.

Make a prediction, then check

Does drawing more reasoning paths guarantee a more accurate answer?

Choose one answer

Learning objectives

  • Distinguish plurality, majority, answer parsing and correlated sampling.
  • Reproduce the finite example and state its experimental limits.

Prerequisites & connections

Explore related knowledge →

References

  1. Self-Consistency Improves Chain of Thought Reasoning in Language Models — v1
    Xuezhi Wang; Jason Wei; Dale Schuurmans; Quoc Le; Ed H. Chi; Denny Zhou · 2022
  2. Chain of Thought Prompting Elicits Reasoning in Large Language Models — v1
    Jason Wei; Xuezhi Wang; Dale Schuurmans; Maarten Bosma; Ed Chi; Quoc Le; Denny Zhou · 2022

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author. Read section2 and viewed PDF2/3: sampled paths, plurality on parsed answers, first-encountered tie rule and distinction from likelihood-weighted voting. Version1 results are not replaced by later abstracts. Viewed PDF2, sections2/3.1: intermediate explanations, input-rationale-answer demonstrations, eight exemplars and shuffled order; caveat about characterizing internal computation. No language model reproduced. Seven paired equations and four explained exercises. Exact multinomial enumeration checked against all ordered five-draw sequences, first-encounter tie convention, correlated-shock limit and seeded simulation. Wrong-mode amplification and numeric answer normalization explicit.

  • Exact multinomial enumeration checked against all ordered five-draw sequences, first-encounter tie convention, correlated-shock limit and seeded simulation. Wrong-mode amplification and numeric answer normalization explicit.
  • Four computed SVG variants per topic;11 numeric/geometry tests and36 responsive cases passed. Twelve selected final captures directly viewed. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.