Abstract
Aligning Large Language Models (LLMs) using Reinforcement Learning from Human Feedback (RLHF) or Direct Preference Optimization (DPO) requires a delicate balance between maximizing preference rewards and maintaining the model's original linguistic capabilities. This balance is governed by a Kullback-Leibler (KL) divergence penalty, weighted by a hyperparameter $\beta$. Traditionally, finding the optimal $\beta$ requires multiple, computationally expensive training sweeps. We present Decoding-time Realignment (DeRa), a method that allows practitioners to adjust alignment strength at inference time by mixing the logits of a base model and an aligned model. DeRa effectively transforms a static training-time hyperparameter into a dynamic inference-time slider, enabling efficient exploration of the alignment-performance frontier and the mitigation of the "alignment tax" on reasoning tasks.
1. Introduction
Modern LLM alignment involves fine-tuning a Supervised Fine-Tuned (SFT) model to better follow human instructions while ensuring it does not deviate too far from its original distribution. This deviation is controlled by the KL penalty. If the penalty is too high, the model fails to adopt the desired behaviors; if it is too low, the model may suffer from "reward hacking" or a collapse in fluency.
The primary bottleneck in this process is the sensitivity of the KL weight, $\beta$. Because the optimal $\beta$ varies by task and dataset, researchers must often retrain models from scratch for every candidate value. For massive models, this trial-and-error approach is prohibitively expensive. DeRa addresses this by providing a mathematical and practical framework to simulate different KL strengths during the decoding process.
2. Methodology: Decoding-time Realignment (DeRa)
DeRa is based on the theoretical insight that the optimal policy for an aligned model with a specific KL strength is equivalent to a geometric mixture of the SFT model's distribution and the aligned model's distribution.
In practice, DeRa approximates this by linearly combining the pre-softmax logits ($h$) of the reference (SFT) model and the aligned model during generation:
logits = λ * h_aligned + (1 - λ) * h_sft
Here, $\lambda$ serves as the control parameter for alignment strength:
- $\lambda = 0$: Returns the base SFT model.
- $\lambda = 1$: Returns the standard aligned model.
- $\lambda > 1$: Extrapolates the logits to simulate a model trained with a weaker KL penalty (stronger alignment).
- $0 < \lambda < 1$: Simulates a model with a stronger KL penalty (weaker alignment).
3. Experimental Evaluation
The authors evaluated DeRa across a diverse set of tasks to test its flexibility and accuracy as a proxy for retraining.
3.1 Summarization and Hallucination
Using the XSum and Reddit TL;DR datasets, the authors demonstrated that DeRa can identify when a model is over-regularized. By setting $\lambda > 1$, DeRa improved win-rates against reference models, following the same performance curves as models retrained from scratch with lower $\beta$ values.
In a custom Hallucination Dataset, DeRa allowed for precise control over factual consistency. While low $\lambda$ values resulted in hallucinations, a value of $\lambda \approx 2$ produced accurate prose. However, the authors noted that excessively high values ($\lambda \ge 5$) led to reward hacking, where the model simply copied prompt text verbatim to satisfy the reward function.
3.2 Rescuing Reasoning Capabilities
A common side effect of alignment is the "alignment tax," where a model's performance on objective reasoning tasks (like math) degrades as it becomes more conversational. The authors applied DeRa to the Zephyr-7b model. By using $\lambda = 0.5$ to simulate a stronger KL penalty, they were able to maintain high conversational scores on MT-Bench (7.23) while significantly recovering math reasoning abilities, boosting GSM8K accuracy from 12.74% to 30.02%.
4. Key Insights
- Predictive Extrapolation: Setting $\lambda > 1$ is not merely a heuristic; it accurately predicts how a model retrained with a lower KL penalty would behave. This makes DeRa an excellent tool for hyperparameter sweeping.
- Dynamic Control: DeRa enables a single deployed model pair to serve multiple alignment profiles. A system can be tuned for high creativity in one turn and high factual precision in the next simply by adjusting $\lambda$.
- Efficiency: Instead of running dozens of training jobs, researchers can use DeRa to find the "Goldilocks" zone on a validation set in minutes, then perform a single final training run if needed.
5. Limitations and Conclusion
While powerful, DeRa has two primary drawbacks. First, it doubles the inference cost, as it requires simultaneous forward passes for both the SFT and aligned models. Second, as an autoregressive approximation, its accuracy degrades at extreme extrapolation values ($\lambda > 5$).
To mitigate compute costs, the authors suggest using DeRa as a search tool for training or employing weight interpolation (merging model weights) as a cheaper, albeit slightly less performant, alternative. In conclusion, DeRa provides a robust mathematical framework for understanding and controlling the alignment of LLMs at inference time, offering a path toward more efficient and customizable AI development.
Summary updated