Abstract
Aligning large language models (LLMs) with human preferences is a cornerstone of modern AI safety and utility. While KL-constrained reinforcement learning (RL) is theoretically optimal for this task, the simpler "Best-of-$N$" sampling strategy often yields comparable results in practice. This paper provides a formal theoretical bridge between these two paradigms. By applying the Large Deviation Principle (LDP) to simplified memoryless models with linear rewards, the authors demonstrate that Best-of-$N$ and KL-constrained RL are asymptotically equivalent. Specifically, as sequence lengths grow, the distributions produced by both methods converge, provided the number of samples $N$ scales exponentially with the KL divergence budget.
Introduction
In the field of LLM alignment, practitioners generally choose between two distinct paths. The first, KL-constrained Reinforcement Learning (RL), involves optimizing a model to maximize a reward signal while penalizing the Kullback-Leibler (KL) divergence from a reference model. This ensures the aligned model remains close to its original distribution, preventing "reward hacking." The second, Best-of-$N$ sampling (also known as rejection sampling or reranking), involves generating $N$ independent samples from the reference model and selecting the one with the highest reward.
Despite the mathematical rigor of RL, Best-of-$N$ is frequently used due to its simplicity and surprising competitiveness. Until now, the empirical similarity between these two approaches lacked a formal mathematical explanation. This research addresses this gap by characterizing the asymptotic behavior of both methods as sequence lengths ($m$) and sample sizes ($N$) tend toward infinity.
Theoretical Framework
To make the analysis mathematically tractable, the authors adopt a simplified environment characterized by two primary assumptions:
- Memoryless Models: The language model is treated as a memoryless source, where tokens are generated independently (akin to a series of coin flips) rather than through complex transformer-based dependencies.
- Linear Rewards: The reward function is assumed to be additive, meaning the total reward for a sequence is the sum of individual scores assigned to each token.
Under these conditions, the authors identify the optimal RL solution as a mismatched tilted distribution—a member of the exponential family. By utilizing the Large Deviation Principle (LDP), they analyze the "rare event" behavior of high-reward sequences, allowing for a direct comparison between the distribution produced by RL and the distribution resulting from selecting the maximum of $N$ samples.
The Connection: $N = \exp(\Delta)$
The core contribution of the paper is the discovery of a precise relationship between the number of samples $N$ in a Best-of-$N$ strategy and the KL budget $\Delta$ in the RL framework. The authors prove that if $N$ is set such that $N = \exp(\Delta)$, the two methods converge to the same expected reward and the same probability distribution as the sequence length $m$ increases.
This convergence is rooted in the statistical property of exchangeability. While Best-of-$N$ sampling breaks the independence of tokens found in the reference model, the resulting joint distribution remains exchangeable (the probability is invariant to the order of tokens). This property allows the authors to apply powerful concentration inequalities to prove that the Best-of-$N$ distribution approaches the "tilted" RL distribution.
Key Results
- Asymptotic Equivalence: Theorem 2 in the paper formally establishes that the KL divergence between the Best-of-$N$ distribution and the optimal RL distribution vanishes as $m \to \infty$, assuming the exponential scaling of $N$ relative to the KL budget.
- Rate Function Characterization: The research provides a full characterization of the "rate function" for rewards. This function describes the exponential rate at which the probability of achieving a specific reward level decays, offering a tool to predict alignment performance.
- Empirical Validation: To test the theory, the authors conducted simulations using synthetic ternary sources (a three-letter alphabet). Even at modest sequence lengths and small alphabet sizes, the numerical results closely tracked the theoretical predictions, with the Best-of-$N$ expected types aligning nearly perfectly with the RL-aligned distribution curve.
Limitations and Future Directions
While this work provides a vital theoretical foundation, it relies on assumptions that simplify the complexities of real-world LLMs. Modern transformers are not memoryless; they possess intricate long-range dependencies. Furthermore, human preference rewards are often non-linear and multidimensional, which may deviate from the additive reward model used here.
Future research should aim to:
- Extend the current proofs to models with memory, such as Markov chains or more sophisticated stochastic processes.
- Investigate the impact of non-linear reward models on the asymptotic equivalence.
- Explore the "small alphabet" phenomenon, where the KL divergence between these methods remains surprisingly low even when the alphabet size $K$ is very small, a result not fully captured by the current asymptotic theory.
Conclusion
This paper demystifies the success of Best-of-$N$ sampling in LLM alignment by showing it is not merely a heuristic, but a strategy that asymptotically mirrors the optimal KL-constrained RL solution. By establishing the $N = \exp(\Delta)$ relationship, the authors provide a mathematical justification for why simple sampling can compete with complex RL, offering a clearer path for choosing and tuning alignment strategies in practice.
Summary updated