Abstract
Best-of-N (BoN) sampling with a reward model is an effective strategy for aligning Large Language Models (LLMs) with human preferences at decoding time. However, BoN sampling is susceptible to reward hacking: since the reward model is an imperfect proxy, excessive optimization can compromise performance on the true objective. While Regularized BoN (RBoN) sampling has been proposed to mitigate this, previous implementations relied on heuristics. This study analyzes RBoN through the lens of robust optimization, showing that regularization maximizes the worst-case outcome over proxy reward perturbations. We introduce Stochastic RBoN (SRBoN), a theoretically grounded approach, and Sentence Length Regularized BoN (RBoN$_L$), a simple yet highly effective method. Empirical evaluations on AlpacaFarm and Anthropic's HH-RLHF datasets demonstrate that these strategies significantly improve alignment and mitigate reward hacking.
Introduction
Aligning Large Language Models (LLMs) often involves a Reward Model (RM) that acts as a proxy for human preference. A common inference-time strategy is Best-of-N (BoN) sampling, where $N$ responses are generated and the one with the highest RM score is selected.
The primary challenge is that Reward Models are imperfect. If optimization is too aggressive (i.e., increasing $N$ too much), the model eventually "hacks" the reward—finding linguistic patterns that the RM favors but humans find unhelpful or harmful. While "Regularized BoN" (RBoN) exists to mitigate this by keeping the model close to a reference distribution, the theoretical underpinnings of why it works have remained unclear until now.
Proposed Methods
This research bridges the gap between sampling strategies and Robust Reinforcement Learning, categorizing various approaches based on their use of reward and similarity functions.
1. Stochastic RBoN (SRBoN)
The authors propose a stochastic version of regularized sampling. By relaxing the requirement to pick a single "best" answer and instead allowing for a probability distribution, they apply the Legendre-Fenchel transformation. This proves that SRBoN is mathematically equivalent to a max-min optimization problem: it maximizes the expected reward under the "worst-case" perturbation of the reward signal. Two variants are explored:
- SRBoN$_{KL}$: Uses KL-divergence to keep the model close to the base model's probabilities.
- SRBoN$_{WD}$: Uses Wasserstein distance (Earth Mover's Distance) to focus on semantic similarity in embedding space.
2. Sentence Length Regularization (RBoN$_L$)
Observing that many reward models exhibit a "shortness bias" or other length-related artifacts, the authors propose a simple heuristic: $R(x, y) - \beta/|y|$. This penalizes the reward based on the token length $|y|$, providing a computationally cheap way to counteract specific alignment biases without complex distribution matching.
Experimental Setup
The study utilizes two major benchmarks for evaluation:
- AlpacaFarm: A simulation framework for instruction-following models.
- Anthropic’s HH-RLHF: Focusing on "Harmlessness" and "Helpfulness."
The experiments used Mistral-7B and Qwen2.5-7B as base models. Performance was tested against multiple reward models (OASST, SHP, PairRM), using Eurus-RM-7B as the "gold standard" evaluator to detect reward hacking.
Key Insights and Results
Regularization as an Adversarial Shield
The theoretical proof confirms that regularization is functionally an adversarial defense. It assumes the reward model is partially inaccurate and optimizes for the best outcome in the face of that uncertainty.
The Performance of RBoN$_L$
Surprisingly, the simple RBoN$_L$ (length regularization) performed remarkably well. In AlpacaFarm tests using the OASST reward model, RBoN$_L$ achieved a 52.0% win rate against standard BoN. This suggests that a significant portion of reward hacking in current models is tied to simple sentence length biases.
Robustness of Wasserstein Regularization
SRBoN$_{WD}$ showed superior stability across different settings compared to KL-based versions. KL-regularization (SRBoN${KL}$) can fail if the reference model and reward model are poorly correlated; if the base model is biased toward unhelpful answers, forcing the aligned model to stay "near" it drags down performance. SRBoN${WD}$ is less dependent on these specific probability distribution quirks.
Conclusion
This work demonstrates that regularized sampling strategies are not just heuristics but are grounded in robust optimization. While standard BoN performance eventually plateaus or drops due to hacking as $N$ increases, regularized versions maintain a stable "true" reward.
Future work remains to address the computational cost of BoN sampling at inference time and the sensitivity of the regularization strength parameter ($\beta$), which currently requires a validation set to tune. Additionally, exploring how these biases manifest in non-English languages is a critical next step for global AI alignment.
Summary updated