Abstract
The safe and effective deployment of Large Language Models (LLMs) involves a critical step called alignment, which ensures that the model's responses are in accordance with human preferences. Prevalent alignment techniques, such as DPO, PPO and their variants, align LLMs by changing the pre-trained model weights during a phase called post-training. While predominant, these post-training methods add substantial complexity before LLMs can be deployed. Inference-time alignment methods avoid the complex post-training step and instead bias the generation towards responses that are aligned with human preferences. The best-known inference-time alignment method, called Best-of-N, is as effective as the state-of-the-art post-training procedures. Unfortunately, Best-of-N requires vastly more resources at inference time than standard decoding strategies, which makes it computationally not viable. In this work, we introduce Speculative Rejection, a computationally-viable inference-time alignment algorithm. It generates high-scoring responses according to a given reward model, like Best-of-N does, while being between 16 to 32 times more computationally efficient.
Introduction
To ensure Large Language Models (LLMs) are both safe and helpful, researchers employ alignment techniques. Predominant methods like Direct Preference Optimization (DPO) and Proximal Policy Optimization (PPO) typically involve a post-training phase that modifies model weights. While effective, this adds significant complexity to the deployment pipeline.
An alternative approach is inference-time alignment, most notably Best-of-N (BoN) decoding. In BoN, $N$ independent responses are generated for a single prompt, and a separate Reward Model (RM) selects the highest-scoring output. BoN is often considered a "gold standard" for alignment performance. However, achieving state-of-the-art results often requires $N$ to be very large (e.g., $N > 1000$), making it computationally prohibitive due to massive memory requirements for the KV cache and wasted compute on low-quality responses.
The Speculative Rejection Algorithm
This paper introduces Speculative Rejection (SR), a method that achieves the performance of large-scale BoN with significantly higher efficiency. SR treats decoding as a survival-of-the-fittest tournament, pruning unpromising sequences mid-generation based on early reward signals.
The process operates in three distinct phases:
- Early Generation: The model begins generating tokens for a massive initial batch on a single GPU, maximizing hardware utilization when memory overhead is low.
- Speculative Rejection: At predefined "decision tokens," the Reward Model evaluates the partial responses. A cutoff threshold is determined based on a rejection rate ($\alpha$).
- Pruning: The bottom $\alpha$ fraction of sequences are terminated. Their KV cache memory is immediately freed, allowing the remaining "survivors" to continue generating without exceeding GPU memory limits.
As the generation progresses, the batch size dynamically shrinks, ensuring the GPU remains efficiently utilized while focusing resources on the most promising candidates.
Key Insights: Partial Reward Correlation
The fundamental insight enabling Speculative Rejection is that Reward Models can accurately predict the final quality of a response from its initial segments. The authors observed a strong positive correlation between partial scores (e.g., at token 256) and the final scores of completed sequences.
By leveraging this correlation, SR effectively "simulates" a massive cluster run on a single GPU by aggressively filtering out "losers" early and concentrating compute on the top 1% of candidates.
Experimental Results
The researchers evaluated SR using the AlpacaFarm benchmark, testing across models like Mistral-7B and Llama-3-8B with various Reward Models. Performance was judged by GPT-4-Turbo win-rates.
- Efficiency Gains: Speculative Rejection achieved reward scores equivalent to standard BoN while using 16 to 32 times fewer GPU resources.
- Speedups: The method demonstrated up to a 76.9x speedup on Mistral-7B tasks compared to the BoN baseline.
- Quality Preservation: SR (with $\alpha=0.5$) consistently outperformed BoN-120 and remained competitive with much higher $N$ values, all while operating on a single 80GB GPU.
Conclusion and Future Work
Speculative Rejection makes high-quality inference-time alignment computationally viable. Future research directions include developing adaptive rejection rates that adjust $\alpha$ based on prompt sensitivity. Additionally, training Reward Models specifically as Value Functions—designed to predict future rewards from partial strings—could further enhance the accuracy and efficiency of the pruning process.
Summary updated