TL;DR
Best-of-N is the simplest way to spend extra compute to get a better answer. You ask a language model for N independent answers to the same prompt, score each one with a reward model or a checker, and return the one with the highest score. The model itself is never changed.
The cost is linear in N, but the gain is not. The first few extra samples help a lot and the returns shrink, and a weak scorer can lead you to a bad answer that merely looks good.
Where you'll see it: as an inference-time alignment step in chat systems, as a baseline that every reward model is judged against, and as a baseline for test-time compute scaling, and for maths and code, where a checker can verify an answer.
Intuition
Buying more tries
Suppose you are hiring for a job and you can interview candidates one at a time. Each candidate is drawn from the same applicant pool, so you cannot control who shows up, but you can keep the best one after interviewing N of them. The pool does not get better. You simply get to look at more people before you pick. Best-of-N is that process applied to model outputs: the model is the applicant pool, the reward model is the interviewer, and N is how many people you see.
Two things follow. First, if the pool is bad at a task, picking the best of a bad pool is still bad. Second, the value of each extra interview falls off: going from one candidate to two is a big jump in the quality of the pick, while going from ninety-nine to one hundred barely changes it.
Why it works at all
A language model does not give one answer. Sampling with a non-zero temperature gives a spread of answers, some better and some worse. A reward model gives each answer a score that is correlated with quality. If the scores were perfect, you would only need N large enough to hit one good answer. Best-of-N exploits the spread that sampling already gives you, so no training is needed at the moment of use.
flowchart LR P[Prompt x] --> S[Sample N answers from the base model] S --> Y1[answer 1] S --> Y2[answer 2] S --> YN[answer N] Y1 --> R[Reward model scores each one] Y2 --> R YN --> R R --> B[Return the highest score]
The math
Setup
Let be the probability that the base language model writes response to prompt . Let be the score that a reward model gives that response. Best-of-N draws responses independently from the base model and returns
Here is the -th sample and is the one returned. Nothing about changes. The only control is .
How the best score is distributed
Write for the cumulative distribution function of the reward when is drawn from the base model. Because the samples are independent, the best score is at most exactly when every score is at most :
This is the key identity. Differentiating gives the density of the best score, and the expected best score follows:
where is the density. Each extra sample multiplies the CDF by another factor of , so the maximum moves right, but by less each time.
How far the answer moves from the base model
The distribution of the returned answer is , where the density of picking is the base probability times a weight that depends only on how good is relative to the rest. Let . Under the base model is uniform on . The returned answer has distributed as the maximum of uniforms, which has density . So the likelihood ratio between and is , and the KL divergence is
Under , has a Beta distribution, and its mean log is . That gives the closed form
This is the cost of the selection measured in nats. It grows with , so it is very cheap in KL terms, and it is the quantity that makes the reward-hacking story below precise.
Worked examples
Four samples come back with reward scores , , and .
- Compare the scores: the largest is .
- Return the answer that produced . The other three are discarded.
- Cost: four forward passes of the base model plus four reward-model calls.
Interpretation: the chosen answer is not guaranteed to be correct. It is only the best of the four under the scorer. If the scorer is wrong about that answer, best-of-N returns the mistake with confidence.
Suppose rewards are standard normal, so , the standard normal CDF. Plug into the formula above and evaluate the integral numerically.
- : the expected best score is , the mean of one draw.
- : , which is exactly .
- : .
- : .
Interpretation: going from to is ten times the compute and buys about extra standard deviation. Each step gives less. The growth is roughly like for large , which is why a fixed budget of samples is never a complete answer.
A model solves a hard maths problem with probability per sample, and a checker can tell correct from incorrect perfectly. The chance that at least one of samples is correct is
- : .
- : .
- : .
Interpretation: with a checker you can turn a 10 percent solver into one that is almost always right, given enough samples. These values are analytic, not from a run. The catch is that real checkers are not perfect, and the next sections explain what happens then.
Tradeoffs and failure modes
Best-of-N is attractive because it needs no training and no change to the model. It is also easy to misuse.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Strong, well-matched reward model | Works well, gains are real | Use best-of-N and tune N to your budget |
| Reward model trained on a different distribution than the outputs it scores | The model learns to produce answers the scorer likes but that are not better, so the scorer is exploited | Retrain the scorer on samples from the policy, or switch to an objective that stays close to the base model |
| Large N with a noisy scorer | Selection picks the luckiest error, so quality can fall as N grows past some point | Cap N, or use [[process-reward-model |
| Verifiable task (unit tests, exact answers) | Little risk from scorer error | Best-of-N is cheap and strong here |
| Open-ended writing with no reliable scorer | Scores are weak proxies for quality | Human preference training (Reinforcement Learning from Human Feedback (RLHF)), or Direct Preference Optimization |
| Budget for many samples, but a repeated task | Paying N times per request forever | Distil the best-of-N behaviour into the model with rejection-sampling fine-tuning, or use Beam Search over steps |
The most important failure is reward overoptimisation. Gao et al. (2022) studied how the true quality of a best-of-N policy changes as N grows while the proxy score keeps rising. The proxy score keeps improving, while the gold score eventually stops tracking it and can fall. The KL formula above is a useful yardstick: as KL grows with , you are moving further from the base model, and the scorer's errors have more room to matter.
Latency is less of a problem than cost. The N samples can run in parallel, so wall-clock time need not grow with N, but the compute bill does.
History
Choosing the best of several candidates is much older than language models. Machine translation and speech recognition have long used n-best lists: the decoder produces several hypotheses and a second model reranks them. Best-of-N is the same idea with a learned reward in place of a reranker.
In the era of learned reward models for text, best-of-N was used as a simple way to get better summaries and answers without further training. Stiennon et al. (2020) trained reward models from human comparisons to judge summaries. Gao et al. (2022) then measured how far selection against such a scorer can go before the scorer is exploited.
In 2024, Snell et al. studied best-of-N as a baseline among several ways to spend compute at inference time, such as beam search against a process reward model. They found that the most effective method depends on how hard the prompt is, and that a process reward model trained on the PRM800k data was easy to exploit.
Check yourself
QuestionIn one sentence, what does best-of-N change, and what does it leave alone?Show answer
It changes which answer is returned: N samples are drawn and the highest-scoring one is kept. It leaves the model's weights and its sampling distribution untouched, so the base model's capabilities are not improved, only exploited.
QuestionA scorer gives standard normal rewards. What is the expected best score of N = 4 samples, to about two decimal places?Show answer
Numerical integration of with gives about . Compare with for and for . The increments shrink, which is the diminishing-returns pattern.
QuestionWhy does the KL divergence from the base model grow like log N, and why does that matter for reward hacking?Show answer
The returned answer has a likelihood ratio of against the base model, and its expected log is . KL grows slowly, so selection stays close to the base model in a precise sense. But the scorer's errors are concentrated in exactly the tail that selection picks from, so a fixed small KL can still expose a large error in the proxy score.
QuestionA coding model solves a task with probability 0.2 per sample, and unit tests act as a perfect checker. How many samples do you need for at least a 90 percent chance of a correct answer?Show answer
Solve , so . Taking logs, , so suffices. Check: , giving . Interpretation: with a perfect checker the cost is linear in N, so the question becomes how much compute the task is worth.
QuestionYour reward model was trained on outputs from a different model. Why might best-of-N with a large N make answers worse, not better?Show answer
Selection finds the sample the scorer rates highest. If the scorer is wrong in a way that correlates with features the policy happens to produce, the largest N finds the most extreme case of that error. Quality can then fall as N rises, which is the overoptimisation curve. The fix is a scorer that matches the outputs it judges, or a cap on N.
Sources
- Snell, Lee, Xu, Kumar (2024), Scaling LLM Test-Time Compute Optimally: https://arxiv.org/abs/2408.03314
- Gao, Schulman, Hilton (2022), Scaling Laws for Reward Model Overoptimization: https://arxiv.org/abs/2210.10760
- Stiennon et al. (2020), Learning to summarize from human feedback: https://arxiv.org/abs/2009.01325
- Order statistic (Wikipedia): https://en.wikipedia.org/wiki/Order_statistic