TL;DR
Standard Reinforcement Learning from Human Feedback (RLHF) uses KL-divergence to keep models from drifting too far from their base versions, but it treats all "wrong" tokens as equally bad. This paper introduces Wasserstein Policy Regularization (WPR), which uses Optimal Transport to penalize models based on semantic distance—allowing a model to choose "kitten" instead of "cat" with less penalty than choosing "table."
What Problem Does This Paper Address?
When we align Large Language Models (LLMs) using RLHF, we want the model to maximize rewards (be helpful/safe) while staying "close" to a reference model (to maintain general capabilities and avoid "reward hacking"). Currently, the industry standard is to use Kullback-Leibler (KL) divergence as a penalty.
The problem? KL-divergence is "blind" to meaning. It only compares the probability of the exact same token at the exact same position.
As illustrated above, if the reference model expects the word "cat" and the trained model suggests "kitten," KL-divergence treats that error just as harshly as if the model had suggested "table." Furthermore, KL-divergence can explode to infinity if the trained model assigns probability to a token that the reference model thought was impossible. This lack of semantic awareness makes the regularization rigid, often reducing output diversity and making the training process unstable.
Methods
The authors propose Wasserstein Policy Regularization (WPR). Unlike KL-divergence, the Wasserstein distance (also known as the Earth Mover's Distance) considers the "geometry" of the space. In this context, that space is the embedding space of the tokens.
Key technical highlights include:
- Entropy-Regularized Wasserstein Distance: To make the math computationally tractable, they use the "Sinkhorn distance," which adds an entropy term to the transport problem.
- Dual Formulation: They derive a dual version of the optimization problem. This is the "secret sauce" that allows them to turn a complex global distance calculation into a simple, per-token reward penalty that can be plugged into standard RL algorithms like PPO.
- Efficiency via Truncation: Calculating distances across a 50k+ token vocabulary is expensive. The authors use two tricks: nearest-$k_1$ truncation (only considering the closest neighbors in the embedding space) and top-$k_2$ truncation (only looking at the most probable tokens). This reduces the computational overhead to a mere 2.5% increase in training time.
Datasets
The researchers evaluated WPR across three distinct domains:
- TL;DR: Reddit post summarization.
- Anthropic HH-RLHF: A dataset focused on making dialogue agents "Helpful and Harmless."
- APPS: A benchmark for Python code generation.
- MT-Bench: Used for evaluating general conversational and instruction-following abilities.
Key Insights and Ideas
- Semantic Lenience: WPR is effectively more "lenient" than KL. Because it understands that some tokens are related, it doesn't over-penalize the model for exploring semantically similar paths. This leads to more coherent and diverse generations.
- Handling Support Mismatch: Wasserstein distance remains well-defined even when the probability distributions don't overlap, leading to much more stable training compared to KL-divergence.
- The "Aha" Moment in the Dual: The authors showed that the optimal dual variable $\phi$ acts as the perfect penalty. By using the Sinkhorn-Knopp algorithm to find this variable, they can adjust the reward on the fly based on how "semantically far" the model's choice was from the reference.
Key Results
WPR consistently outperformed KL-divergence and other popular alternatives (like $f$-divergences):
- Higher Win Rates: On the TL;DR dataset, WPR achieved a 0.924 win rate against the SFT baseline, significantly higher than the 0.848 achieved by standard KL-regularized PPO.
- Stability Across Temperatures: As shown in the figure above, WPR proved to be more robust across different sampling temperatures, whereas KL-based models and other $f$-divergences often saw performance degradation or higher variance at higher temperatures.
- Superior Coding: In the APPS benchmark, WPR improved the "pass@1" metric across all difficulty levels (Introductory, Interview, and Competition).
- Better Coherence: Qualitative analysis showed that the top-10 token candidates suggested by WPR-trained models were more semantically related to each other than those from KL-trained models.
Limitations and Future Work
While WPR is a significant step forward, the authors note a few areas for improvement:
- Hyperparameter Sensitivity: Like most RLHF methods, WPR still relies on a $\beta$ coefficient to balance reward vs. regularization. While WPR is more stable than others, finding the "perfect" $\beta$ still requires tuning.
- Embedding Dependence: The quality of the regularization depends on the quality of the token embeddings used to calculate the cost matrix. If the embeddings don't capture the nuances of a specific domain well, the regularization might be less effective.
- Cross-Tokenizer Challenges: Currently, the method requires the trained model and the reference model to share the same tokenizer. Extending this to different architectures with different vocabularies is a "nontrivial" next step.
Summary updated