Theoretical guarantees on the best-of-n alignment policy

Ahmad Beirami, Alekh Agarwal, Jonathan Berant, Alexander Nicholas D'Amour, Jacob Eisenstein, Chirag Nagpal, Ananda Theertha Suresh

Introduction

In the rapidly evolving landscape of Large Language Models (LLMs), alignment is the critical process of nudging a model to be more helpful, safe, or accurate. While complex techniques like Reinforcement Learning from Human Feedback (RLHF) are widely used, a much simpler and highly effective method is Best-of-$n$ (BoN) sampling. In this approach, $n$ independent samples are drawn from a reference model, scored using a reward function, and the highest-ranking sample is selected.

Despite its widespread adoption, the theoretical understanding of BoN has largely relied on unverified "lore." Specifically, many influential papers have claimed that the KL divergence—a metric measuring how much the aligned policy drifts from the original reference model—is exactly $\log(n) - (n-1)/n$. This paper rigorously debunks this common knowledge, proving that the standard formula is actually a loose upper bound. By providing a new, tighter estimator and proving that the win rate of Best-of-$n$ is strictly capped, the authors establish the first rigorous theoretical framework for this popular alignment technique.

Methodology

The authors approach the problem through a combination of rigorous mathematical proofs and empirical validation across various datasets, including synthetic toy models, the Alpaca instruction-following dataset, and machine translation prompts evaluated on the Gemma 9B IT model.

Their methodology centers on several core analytical steps:

  • PMF Derivation: They derive the exact Probability Mass Function (PMF) for the Best-of-$n$ policy. This allows for the exact calculation of its properties rather than relying on asymptotic approximations.
  • The "Gap" Analysis: The authors formally disprove the standard KL formula, demonstrating it is merely an upper bound. They characterize the "gap" between this bound and reality, proving that the gap grows unbounded if the model has high-probability outcomes (i.e., low entropy).
  • A New Estimator: To replace the flawed formula, they propose a practical estimator, $d_n(\epsilon_n)$, which uses the probability of the selected sample under the reference model to provide a much tighter approximation of the true KL divergence.
  • Win Rate Bounds: They derive a theoretical ceiling for how often a BoN policy can "win" against its own reference model.

Key Insights and Results

Disproof of Equality and the New Estimator

The authors definitively show that the true KL divergence can be significantly lower than the standard formula suggests. In various scenarios, the true KL plateaus, while the standard analytical formula predicts it will grow logarithmically to infinity as $n$ increases.

Exact KL vs. Analytical Formula

Their proposed estimator, $d_n(\epsilon_n)$, almost perfectly tracks the exact KL divergence across different setups, whereas the old formula overshoots significantly. This provides practitioners with a much more reliable tool for measuring model drift during inference-time alignment.

The Entropy Trap

The standard formula ($\log n - (n-1)/n$) assumes that every possible output is infinitesimally likely. In reality, LLMs often have "peaky" distributions. For example, given the prompt "What is the capital of France?", the model places a massive probability mass on the answer "Paris".

KL Divergence for a Peaky Distribution

In these low-entropy cases, the true KL divergence saturates very quickly. This means BoN is actually much more "efficient"—incurring far less drift for the same $n$—than previously thought.

The $n/(n+1)$ Limit and Practical Tradeoffs

The authors prove a fundamental "speed limit" for BoN: the win rate of a Best-of-$n$ policy against its reference model can never exceed $n/(n+1)$. This bounds how much we can expect to improve a model simply by over-sampling at inference time.

When analyzing the tradeoff between winning and drifting (Win Rate vs. KL), BoN proves to be remarkably close to the theoretical "win rate optimal" policy. It often outperforms more complex rejection sampling methods like "Rewind-and-Repeat" (sampling until a specific reward threshold is met). The study demonstrates that excellent alignment tradeoffs are achievable with $n < 1000$. Beyond this point, the marginal gains in win rate diminish significantly due to the $n/(n+1)$ bound.

Limitations and Future Work

While this paper provides a robust theoretical foundation for BoN, the authors note a few limitations:

  • Randomness of the Estimator: The proposed KL estimator is a random variable dependent on the specific sample drawn. While conjectured to be an upper bound in expectation, a formal proof remains an open challenge.
  • Perfect Reward Assumption: The theory assumes the reward function is a reliable ground truth. It does not account for "reward hacking," where a model achieves a high score by exploiting flaws in the reward model rather than generating genuinely better outputs.
  • Compute vs. Quality: Although BoN offers a better Reward-KL tradeoff than Rewind-and-Repeat, the latter can sometimes be more compute-efficient for reaching a specific, hard reward target.

Future work should explore hybrid methods that combine the predictable drift of Best-of-$n$ with the compute efficiency of threshold-based rejection sampling.

Summary updated

BibTeX
@inproceedings{beirami2025theoretical,
  author = {Ahmad Beirami and Alekh Agarwal and Jonathan Berant and Alexander Nicholas D'Amour and Jacob Eisenstein and Chirag Nagpal and Ananda Theertha Suresh},
  title = {{Theoretical guarantees on the best-of-n alignment policy}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=u3U8qzFV7w},
}
Figure