Best-of-N sampling

Best-of-N sampling is a technique in which a model generates several answers to the same prompt and a separate scorer, such as a reward model, verifier or test suite, picks the single best one.

Best-of-N sampling is one of the simplest ways to get better answers from a model without retraining it. The model is asked the same question N times with sampling switched on, so each attempt comes out a little different. A separate judge then scores every candidate. The judge might be a reward model trained on human preferences, a verifier trained to recognise correct solutions, a set of unit tests for code, or a checker for a maths answer. The highest-scoring candidate is returned and the rest are thrown away. The model itself does not change; the gain comes entirely from spending more computation at the moment of answering.

Karl Cobbe and colleagues used the approach in Training Verifiers to Solve Math Word Problems, published in October 2021, the paper that introduced the GSM8K maths benchmark. At test time they generated many candidate solutions and kept the one their trained verifier ranked highest. WebGPT, described in December 2021, used the same idea under the name rejection sampling: it drew several answers and kept the one a reward model scored best, and people preferred its answers to those written by its human demonstrators 56% of the time.

The technique now turns up in benchmark footnotes. In September 2024 OpenAI reported that its o1 model scored 83% on the AIME maths exam when taking the consensus of 64 samples, and 93% when it re-ranked 1,000 samples with a learned scoring function. That second figure is best-of-N at large scale. It shows what is possible with heavy computation, not what a single answer will look like, so a score should always be read alongside the number of samples behind it.

There are two costs. The first is money and time: generating N answers costs roughly N times as much as generating one. The second is that the method is only as good as its judge. Gao, Schulman and Hilton studied best-of-n sampling against an imperfect proxy reward model in 2022 and found that optimising too hard against the proxy can make true performance worse, an example of Goodhart's law. In August 2024, Charlie Snell and colleagues reported that allocating test-time compute adaptively, prompt by prompt, was more than four times as efficient as a plain best-of-N baseline.

In practice, best-of-N is the entry point to test-time compute: easy to build, easy to run in parallel and usable with any model. It works best where answers can be checked automatically, such as code that must pass tests or maths with a single correct result. Where quality is a matter of judgement, the choice rests on a reward model with blind spots of its own.

Common questions

What is the difference between best-of-N and self-consistency?

Best-of-N uses a separate scorer, such as a reward model or a verifier, to pick one answer from the candidates. Self-consistency uses no scorer at all: it takes the final answer that appears most often across the samples. Self-consistency therefore needs answers that can be compared exactly, such as a number, while best-of-N works for any output that something can score.

What does the N in best-of-N mean?

N is the number of candidate answers generated for each prompt. Best-of-16 means 16 answers are produced and one is kept. A larger N raises the chance that at least one candidate is good, but it also multiplies the cost of generation.

Is best-of-N the same as pass@k?

No. Pass@k counts a problem as solved if any of k attempts is correct, using the benchmark's answer key, which is not available in real use. Best-of-N must commit to one answer without knowing which is right, so with the same number of samples it can at best match pass@k.

Why do AI labs report best-of-N scores?

They show how much extra performance can be bought by spending more computation when answering. Such scores are not comparable with single-attempt results, so check how many samples were drawn and what chose between them before comparing models.

Finding more

Search for "best-of-n sampling", "rejection sampling reward model", "verifier reranking" or "test-time compute scaling" to follow the technique and its limits. The most reliable sources are the research papers on arXiv that state the number of samples and the scorer used, and lab technical reports whose benchmark tables explain their footnotes. Treat headline benchmark scores with care when the number of attempts behind them is not given.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.