Inference-Time Search and Best-of-n
What sampling more candidates actually buys — exponentially decaying failure for linear cost, an unbiased pass@k estimator, and the exact KL price of best-of-n.
With a perfect verifier
Let each of independent samples be correct with probability , and suppose a verifier identifies a correct sample whenever one is present. Then
and the number of samples needed to reach target is
Estimating pass@k honestly
Evaluating by drawing exactly samples is high-variance. The standard estimator draws and computes a combinatorial correction.
Draw i.i.d. samples of which are correct. Then
is an unbiased estimator of the probability that a uniformly random subset of of those samples contains at least one correct sample.
What best-of-n costs in distribution
Selecting the best of samples changes the distribution you are sampling from. That shift has an exact closed form, and it is the quantity that governs reward hacking.
Let be a base policy and a reward whose distribution under is continuous (so ties have probability zero). Let be the distribution of the highest-reward sample among i.i.d. draws from . Then
Key idea
The divergence grows like — slowly, but without bound, and it depends on nothing about the reward except that it is continuous. So best-of- gives a principled exchange rate between compute and distribution shift, and lets you compare test-time selection against a KL-regularised fine-tune on the same axis: costs about nats, about .
This matters because distribution shift away from the base policy is exactly the regime where a learned reward model stops being trustworthy — it was fit on samples from the base policy, and best-of- is deliberately sampling where those were rare.
Imperfect verifiers
Suppose each sample is correct with probability , the verifier accepts a correct sample with probability , and accepts an incorrect sample with probability \varphi > 0. If the system returns a uniformly chosen accepted sample, then as the probability that the returned answer is correct tends to
\frac{p}{p + (1-p)\varphi} \;<\; 1 .What this does not say
Independence across samples is assumed throughout. Samples from one model at one temperature are not independent in the relevant sense — they share the model's systematic errors — so overstates the benefit exactly as it did for majority voting. And nothing here addresses which search to run: best-of- over complete solutions, beam search over steps, or tree search with backtracking all spend the same compute differently, and the comparison between them is empirical.
Results stated on this page
- PropositionBest-of-n with a perfect verifierproof includedFailure probability falls as (1−p)ⁿ, so success improves exponentially in samples while cost grows linearly.
- PropositionThe unbiased pass@k estimatorproof includedFrom n samples with c correct, 1 − C(n−c, k)/C(n, k) is an unbiased estimate of the probability that k draws contain a correct one.
- TheoremThe KL divergence of best-of-nproof includedBest-of-n sampling against a continuous reward has KL divergence exactly log n − (n−1)/n from the base policy.
- PropositionAn imperfect verifier caps the gainproof includedWith false-positive rate φ, selected-answer precision is bounded regardless of n, and for large n the verifier's errors dominate.