BoNBoN Alignment for Large Language Models and the Sweetness of Best-of-n Sampling

Lin Gui, Cristina Garbacea, Victor Veitch

Introduction

Best-of-$n$ (BoN) sampling is a highly effective inference-time strategy to boost Large Language Model (LLM) performance by generating multiple responses and selecting the best one. However, scaling this to real-time applications is prohibitively expensive. This paper investigates the theoretical properties of BoN sampling and introduces BoNBoN Alignment, a novel fine-tuning method that trains a model to mimic this optimal behavior in a single step. The result is a model that achieves high-quality outputs without the "length explosion" commonly observed in alignment methods like DPO or RLHF.

The Alignment Balancing Act

Aligning LLMs with human preferences requires balancing two competing objectives: maximizing a target attribute (like helpfulness or safety) while minimizing drift in off-target attributes (like general capabilities or response length).

Currently, the field relies on two primary approaches:

  1. Best-of-$n$ (BoN) Sampling: Generate $n$ responses at inference time and pick the one with the highest reward. This yields excellent results but multiplies inference compute by $n$.
  2. Fine-tuning (RLHF, DPO, IPO): Train the model to natively output higher-reward samples. While efficient at inference, these methods often suffer from "reward hacking," where the model exploits the reward function by drastically altering off-target attributes—such as generating excessively long responses.

The authors bridge the gap between these approaches, asking whether we can achieve the high-quality, stable performance of BoN sampling without the massive inference cost.

Methods: Theory and Practice

1. The Theory of "Sweetness"

The authors establish that BoN sampling is more than just a clever heuristic; it is theoretically Pareto-optimal. When the goal is to maximize the win rate against a base model while keeping the KL divergence (the measure of policy drift) low, BoN sampling is essentially the best possible strategy. It strictly outperforms the standard exponential tilting typically used in RLHF for this specific trade-off.

KL Divergence vs. Win Rate for Best-of-n vs. Optimal Policy

2. BoNBoN Alignment

To bypass the cost of drawing $n$ samples during inference, the authors propose a new training objective designed to bake the BoN distribution directly into the model's weights. BoNBoN combines two distinct losses:

  • SFT-BoN: A supervised fine-tuning loss that anchors the model to the best of the $n$ samples.
  • IPO-BoN: A contrastive loss that leverages both the best and the worst of the $n$ samples.

Crucially, the authors derive an analytical value for the regularization parameter ($\beta$) in the IPO term, making the method nearly hyperparameter-free. The SFT term acts as a critical stabilizer, preventing the model from "cheating" by merely shifting probability mass away from bad responses and into weird, off-target outputs.

Experimental Setup

The method was evaluated on two standard alignment tasks: Anthropic Helpful and Harmless (HH) for single-turn dialogue, and OpenAI TL;DR for text summarization. The researchers used Pythia-2.8b as the base model and an off-the-shelf DeBERTa-v3-large reward model to rank samples and calculate win rates.

Key Results

  • Superior Trade-offs: In the Helpful/Harmless task, BoNBoN achieved an impressive 85% win rate while maintaining an average response length nearly identical to the base model. In stark contrast, standard DPO and IPO methods required doubling the response length to reach a comparable win rate.
  • Qualitative Stability: Contrastive methods like DPO or IPO often "cheat" to increase the likelihood ratio between good and bad samples, resulting in extreme verbosity. Sample responses demonstrate that while DPO/IPO models become overly repetitive to please the reward model, BoNBoN responses remain concise and on-topic.
Average Length vs. Win Rate and Qualitative Examples
  • Inference Efficiency: BoNBoN-aligned models successfully mimic the BoN sampling distribution. A single sample generated from a BoNBoN model performs as well as running actual BoN sampling with $n=8$ on the original base model.

Limitations and Future Work

Like all alignment methods, BoNBoN's success is bottlenecked by the quality of the reward model used to rank the initial samples; biased reward models will lead to biased alignment. Additionally, while the underlying theory assumes a continuous reward distribution, further refinement for low-cardinality or discrete settings could be beneficial. Finally, while the experiments on a 2.8B parameter model are promising, scaling these tests to 70B+ parameter frontier models will be necessary to confirm that these "sweetness" properties hold at the highest levels of LLM performance.

Summary updated

BibTeX
@inproceedings{gui2024bonbon,
  author = {Lin Gui and Cristina Garbacea and Victor Veitch},
  title = {{BoNBoN Alignment for Large Language Models and the Sweetness of Best-of-n Sampling}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=haSKMlrbX5},
}
Figure