Evaluation lab · San Francisco · London · Zürich
Reinforced Labs Request a briefing
Glossary

Best-of-n sampling

Also called: best-of-n, BoN, rejection sampling, reranking

Best-of-n sampling draws n responses and returns the one a reward model or verifier scores highest, trading inference compute for quality without training.

Best-of-n sampling generates independent responses to a prompt and keeps the single response that a reward model or verifier rates highest. It improves output quality at inference time without changing the model's weights, and it is often used as a strong, simple baseline for RLHF.

How it works

Sample , score each with , and return . The selected outputs can also be used as fine-tuning data, which is sometimes called rejection-sampling fine-tuning or expert iteration.

How far does it move the distribution?

Best-of-n defines a new policy, and its distance from the base model has a well-known formula:

where is the number of samples. Beirami et al. (2024) showed this widely used expression is an upper bound rather than an exact value in general, but it remains a handy guide. KL grows only logarithmically in , so best-of-n is a gentle optimiser.

Worked example

With the KL is at most nats; with it is about nats. Quadrupling compute buys less than three times the KL. On a verifiable task where the model is right 20 percent of the time, the chance that at least one of 8 samples is correct is , the same quantity as pass@k. A perfect verifier would turn that into 83 percent accuracy; a learned reward model will pick a wrong answer some of the time.

Limits

  • Inference cost scales linearly with .
  • Selection exploits reward-model errors: Gao et al. (2022) found that gold-standard quality under best-of-n rises and then falls as grows, a clean demonstration of reward overoptimisation.
  • It cannot produce anything the base model would not already sample.

Why it matters

Best-of-n is the cleanest way to measure how much a reward model or verifier is worth before investing in RL, and its log-n KL formula gives a common axis for comparing it with RL methods under the KL penalty. For evals, it is a reminder that reported scores should state how many samples and what selection rule were used, since best-of-16 and single-sample numbers are not comparable.

Sources

  1. Reiichiro Nakano, Jacob Hilton, Suchir Balaji, et al.. WebGPT: Browser-assisted question-answering with human feedback, 2021. arxiv.org
  2. Leo Gao, John Schulman, Jacob Hilton. Scaling Laws for Reward Model Overoptimization, 2022. arxiv.org
  3. Ahmad Beirami, Alekh Agarwal, Jonathan Berant, et al.. Theoretical guarantees on the best-of-n alignment policy, 2024. arxiv.org

Know the number before you ship.

A 45-minute working session with an evaluation engineer. Bring one use case; leave with a threat model, a draft eval plan with sample sizes, and an honest read on where you stand.