Inference-Time Scaling
Sample more, then select well. See exactly when majority voting helps, when it hurts, and why the selection rule matters as much as the samples.
Jump to a section
Why this matters
Inference-time scaling spends more computation per question while the model 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.
Keep three questions separate: 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 harm accuracy, on a task where the selection rule cannot tell good answers from bad ones.
Build the mental model
Sample the same math problem eight times at a temperature above zero. The reasoning paths differ, and some reach the right final answer. Self-consistency extracts each final answer and returns the most frequent one. Best-of-N instead asks a scoring function to choose. Self-refinement runs a loop: answer, critique, revise.
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)
Voting only helps when the correct answer is more common than any single wrong answer. If the model is usually wrong in the same way, more samples make the vote more confidently wrong. The chart below makes that exact.
Work through the math
Suppose each independent sample is correct with probability and, in a simplified two-answer case, otherwise lands on one competing wrong answer. With an odd number of samples , majority voting is correct when more than half the samples are correct:
For this approaches 1 as grows. For it approaches 0. An oracle verifier that recognises any correct sample instead gives
which rises for any . The gap between the two curves is the value of a better selection rule. Real verifiers sit between them: they miss some correct answers and accept some wrong ones.
Key takeaway: Sampling creates options; selection decides whether those options become accuracy. Report accuracy against tokens or samples spent, not accuracy alone.
| Method | Generates | Selects with | Main failure |
|---|---|---|---|
| Longer chain of thought | One longer response | The model's own final answer | Fluent but wrong reasoning |
| Self-consistency | N sampled paths | Majority vote over extracted answers | Shared systematic errors |
| Best-of-N | N candidates | A scorer, reward model or verifier | Scorer exploitation |
| Self-refinement | Sequential revisions | The model's own critique | Unhelpful or confidently wrong critique |
Many wrong answers change the vote
With free-form math answers, wrong samples often scatter across different values. Plurality voting can then succeed even when , because no single wrong answer outnumbers the correct one. The two-answer formula is the pessimistic case. That is why answer extraction and normalization matter: if 1/2, 0.5 and \frac{1}{2} count as three different answers, the correct vote is split.
Read the implementation
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
4def normalize(answer: str) -> str:
5 text = answer.strip().strip("$").replace("\\frac{", "").replace("}{", "/").rstrip("}")
6 try:
7 return str(Fraction(text).limit_denominator()) # "0.5", "1/2" -> "1/2"
8 except (ValueError, ZeroDivisionError):
9 return text.lower()
10
11def self_consistency(final_answers: list[str]) -> tuple[str, float]:
12 if not final_answers:
13 raise ValueError("Need at least one sampled answer")
14 counts = Counter(normalize(a) for a in final_answers)
15 answer, votes = counts.most_common(1)[0]
16 return answer, votes / len(final_answers) # agreement, not calibrated confidence
17
18answers = ["1/2", "0.5", "\\frac{1}{2}", "2/3", "0.5"]
19print(self_consistency(answers)) # ('1/2', 0.8)The agreement fraction is useful for routing (for example, sample more when agreement is low), but it is not a probability that the answer is correct.
Questions and trade-offs
- Conceptual: Does inference-time scaling change model weights? (No. It changes how outputs are generated and selected at fixed weights. RL and distillation change the weights.)
- Applied: When does majority voting make accuracy worse as N grows? (When a single wrong answer is more likely than the correct one, as in the two-answer case with p < 0.5.)
- Implementation: Why is answer normalization part of the algorithm, not a detail? (Equivalent answers written differently split the vote and change the selected answer.)
- Systems-level: How do you compare a method that uses 16 samples with one that uses 1? (Plot accuracy against tokens or samples spent, and include latency. Snell et al. show the best strategy can depend on problem difficulty.)
- Failure modes: What can go wrong with best-of-N against a learned reward model? (Selection can exploit reward-model errors, choosing answers that score highly without being correct.)
Check your understanding
From memory: write pass@N for an oracle verifier, explain why majority voting can approach zero accuracy, and name one task where self-consistency cannot be applied directly. Check against Stage 3.
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.
Oliver Perrin
Machine Learning Engineer · Founder, LiminalML
LiminalML brings together concept explanations, mathematical examples, and working visuals. Find more writing by Oliver on the LiminalML Substack.
Keep exploring the idea.
Ask a follow-up in a guided session, work through the self-check, or open the visual in Studio to build on it.
Related concepts
LLMs
Verifiers for Reasoning Models
One function scores the benchmark and rewards the policy. Measure its false positives before trusting either number.
LLMs
Temperature, Top-k & Top-p Sampling
Watch temperature reshape probabilities and distinguish that transformation from top-k, top-p, and sampling.
LLMs
GRPO and Verifiable Rewards
Replace PPO's value model with a group of sampled responses. Trace the advantage, the clipped update and the KL term that trained DeepSeek-R1.