Inference-Time Scaling
More samples help only when the selection rule is right. When majority voting wins, when it loses, and how to spend a fixed budget.
Jump to a section
Same weights, more attempts
Sample several chain-of-thought answers to the same math problem, take the most common final answer, and accuracy goes up with no training at all. The self-consistency paper reports a gain of 17.9 percentage points on the GSM8K grade-school math benchmark over greedy chain-of-thought decoding.
That is inference-time scaling: spending more computation per question while the weights stay fixed. The model can write a longer chain of thought, draw several samples, score candidates, or critique and revise its own answer. Each method changes the decision procedure around the model, not what the model has learned. Reinforcement learning and distillation change the weights; these methods do not.
Every method answers three separate questions: how candidates are generated, how one is selected, and what the extra compute costs. A method that helps on math with checkable answers can do nothing, or reduce accuracy, on a task where the selection rule cannot tell good answers from bad ones.
Generate, then select
The common methods differ mainly in where the extra answers come from and who picks among them.
Longer chain of thought generates one longer response and trusts its own final answer. It fails when the reasoning is fluent but wrong.
Self-consistency samples reasoning paths at a temperature above zero, extracts each final answer, and returns the most frequent one. It fails when the model's errors are shared across samples, because a vote cannot outvote a systematic mistake.
Best-of-N generates candidates and asks a scorer to choose: a reward model, a verifier, or the model's own log-probabilities. It fails when the policy's outputs exploit the scorer's errors, so the highest-scoring candidate is not the best one.
Self-refinement runs a loop: answer, critique, revise. The Self-Refine paper reports an average improvement of about 20 points across seven tasks. It fails when the critique is unhelpful or confidently wrong, and then each revision moves the answer further from the truth.
When voting helps and when it hurts
Take the simplest case. Each independent sample is correct with probability , and otherwise lands on one competing wrong answer. With an odd number of samples , majority voting is correct when more than half the samples are:
For this approaches 1 as grows; for it approaches 0. At , one sample is right 60% of the time, five votes 68%, and 25 votes 85%. At the same 25 votes are right only 15% of the time. If the model is usually wrong in the same way, more samples make the vote more confidently wrong.
An oracle verifier that recognizes any correct sample does much better:
This rises for any . At , five samples already give 92%. The gap between the oracle curve and the voting curve is the value of a better selection rule, and real verifiers sit between them: they miss some correct answers and accept some wrong ones.
More samples help only with a good selector
Compare the two majority-vote curves. Above p = 0.5 voting converges on the right answer; below it, voting converges on the wrong one. An oracle verifier rises for any p.
The visual loads as you reach this section.
Inspect the plotted values
x,y,series 1,0.4,Oracle verifier (p = 0.4) 1,0.6,Majority vote (p = 0.6) 1,0.4,Majority vote (p = 0.4) 3,0.784,Oracle verifier (p = 0.4) 3,0.648,Majority vote (p = 0.6) 3,0.35200000000000004,Majority vote (p = 0.4) 5,0.9222400000000001,Oracle verifier (p = 0.4) 5,0.68256,Majority vote (p = 0.6) 5,0.3174400000000001,Majority vote (p = 0.4) 7,0.9720064,Oracle verifier (p = 0.4) 7,0.7102080000000001,Majority vote (p = 0.6) 7,0.28979200000000005,Majority vote (p = 0.4) 9,0.989922304,Oracle verifier (p = 0.4) 9,0.7334323199999999,Majority vote (p = 0.6) 9,0.26656768000000003,Majority vote (p = 0.4) 11,0.99637202944,Oracle verifier (p = 0.4) 11,0.7534981324799999,Majority vote (p = 0.6) 11,0.24650186752000006,Majority vote (p = 0.4) 13,0.9986939305984,Oracle verifier (p = 0.4) 13,0.7711560474624,Majority vote (p = 0.6) 13,0.22884395253760006,Majority vote (p = 0.4) 15,0.999529815015424,Oracle verifier (p = 0.4) 15,0.786896817389568,Majority vote (p = 0.6) 15,0.2131031826104321,Majority vote (p = 0.4) 17,0.9998307334055526,Oracle verifier (p = 0.4) 17,0.8010635103240192,Majority vote (p = 0.6) 17,0.19893648967598088,Majority vote (p = 0.4) 19,0.999939064025999,Oracle verifier (p = 0.4) 19,0.8139079785845882,Majority vote (p = 0.6) 19,0.1860920214154117,Majority vote (p = 0.4) 21,0.9999780630493597,Oracle verifier (p = 0.4) 21,0.8256221336382271,Majority vote (p = 0.6) 21,0.17437786636177277,Majority vote (p = 0.4) 23,0.9999921026977695,Oracle verifier (p = 0.4) 23,0.8363565593601072,Majority vote (p = 0.6) 23,0.16364344063989264,Majority vote (p = 0.4) 25,0.999997156971197,Oracle verifier (p = 0.4) 25,0.846232231024237,Majority vote (p = 0.6) 25,0.15376776897576294,Majority vote (p = 0.4)
The numbers above come from these two functions:
1from math import ceil, comb
2
3
4def majority_correct(n, p):
5 # two-answer case, odd n: correct when more than half the samples are correct
6 return sum(comb(n, k) * p**k * (1 - p) ** (n - k) for k in range(ceil(n / 2), n + 1))
7
8
9def pass_at_n(n, p):
10 return 1 - (1 - p) ** n
11
12
13assert round(majority_correct(5, 0.6), 3) == 0.683
14assert round(majority_correct(25, 0.6), 3) == 0.846
15assert round(majority_correct(25, 0.4), 3) == 0.154
16assert round(pass_at_n(5, 0.4), 3) == 0.922Many wrong answers change the vote
The two-answer formula is the pessimistic case. With free-form math answers, wrong samples usually scatter across different values. Plurality voting can then succeed even when : if 40% of samples say 12 and the other 60% split evenly among five wrong numbers, 12% each, then 12 still wins.
That makes answer extraction and normalization part of the algorithm. If 1/2, 0.5 and \frac{1}{2} count as three different answers, the correct vote is split three ways, and a wrong answer written consistently can win. The voting code further down shows exactly that: five samples, four of them equal to one half, and an unnormalized vote that picks 0.5 with only 40% agreement.
Spending the budget
Extra samples are not free, so a method is only meaningful next to its cost. Report accuracy against tokens or samples spent, plus latency, never accuracy alone. A 16-sample method beating a 1-sample method says little until both are plotted on the same compute axis.
Snell et al. studied how to allocate that compute. Choosing the strategy per problem, by estimated difficulty, between parallel sampling against a verifier and sequential revision, made test-time compute more than four times as efficient as a best-of-N baseline. In a FLOPs-matched comparison, a smaller model with extra test-time compute outperformed a model 14 times larger, on problems where the smaller model already had a non-trivial success rate. On the hardest problems, and under heavy inference load, spending the compute on pretraining was more effective.
The vote's agreement fraction is useful for routing within a budget: sample more when agreement is low, stop early when it is high. It is not a calibrated probability that the answer is correct.
In code
Majority voting needs a normalizer that maps equivalent answers to the same key. This version handles simple numeric forms only.
1from collections import Counter
2from fractions import Fraction
3
4
5def normalize(answer: str) -> str:
6 text = answer.strip().strip("$").replace("\\frac{", "").replace("}{", "/").rstrip("}")
7 try:
8 return str(Fraction(text).limit_denominator()) # "0.5", "1/2" -> "1/2"
9 except (ValueError, ZeroDivisionError):
10 return text.lower()
11
12
13def self_consistency(final_answers: list[str]) -> tuple[str, float]:
14 if not final_answers:
15 raise ValueError("Need at least one sampled answer")
16 counts = Counter(normalize(a) for a in final_answers)
17 answer, votes = counts.most_common(1)[0]
18 return answer, votes / len(final_answers) # agreement, not calibrated confidence
19
20
21answers = ["1/2", "0.5", "\\frac{1}{2}", "2/3", "0.5"]
22assert self_consistency(answers) == ("1/2", 0.8)
23assert Counter(answers).most_common(1)[0] == ("0.5", 2) # unnormalized: 2 of 5 votesWhere it goes wrong
Shared errors. Voting assumes errors are spread out. A misconception the model holds consistently survives any number of samples, and the agreement fraction will report it as confident.
Scorer exploitation. Best-of-N against a learned reward model selects the candidate the reward model likes most, which drifts away from the best candidate as grows and the search finds more of the reward model's errors.
Answers that cannot be extracted. Self-consistency needs a final answer that can be compared across samples. On an essay, a proof or a long piece of code there is no single key to vote on, and the method does not apply directly.
Uncounted cost. Sampling 16 reasoning paths costs roughly 16 times the generated tokens and, unless they run in parallel, the latency. A comparison that omits this is not a comparison.
Sources and further reading
- Wang et al., Self-Consistency Improves Chain of Thought Reasoning in Language Models: sampling diverse reasoning paths and voting over final answers.
- Snell et al., Scaling LLM Test-Time Compute Optimally: compute-optimal allocation between search and revision by problem difficulty.
- Madaan et al., Self-Refine: iterative feedback and refinement with a single model.
- Raschka, Building Reasoning Models from the Ground Up: a code-first course covering sampling, self-consistency, scoring and self-refinement on MATH-500.