A Common Pitfall of Margin-based Language Model Alignment: Gradient Entanglement

Hui Yuan, Yifan Zeng, Yue Wu, Huazheng Wang, Mengdi Wang, Liu Leqi

TL;DR

Margin-based alignment methods like Direct Preference Optimization (DPO) focus on maximizing the difference between preferred and rejected responses, but they often fail to control the absolute probability of either. This leads to a phenomenon called "gradient entanglement," where the model accidentally increases the likelihood of harmful responses or decreases the likelihood of ideal ones because their training gradients become too similar.

The Core Problem: Under-Specification in Margin-Based Losses

In the world of Large Language Model (LLM) alignment, Reinforcement Learning from Human Feedback (RLHF) is the standard. Most modern techniques, including DPO, rely on margin-based losses. These losses aim to ensure the "chosen" response has a higher probability than the "rejected" one.

However, the authors identify a critical "under-specification" flaw: these losses only optimize the gap between the two responses, ignoring their individual behaviors. This leads to two major unintended consequences as the margin increases:

  1. Safety Failures: The model might increase the margin by making the chosen response much more likely, but simultaneously (and unintentionally) making the rejected (e.g., unsafe) response more likely too.
  2. Performance Degradation: The model might decrease the probability of the rejected response but drag the probability of the ideal, chosen response down with it.

Unpacking Gradient Entanglement

The researchers introduce the concept of Gradient Entanglement to explain these failures. They mathematically demonstrate that in margin-based objectives, the change in probability for a chosen response is inextricably coupled with the gradient of the rejected response, and vice versa.

To study this, the authors:

  • Derived a General Gradient Condition: They created a unified mathematical framework that applies to almost all popular alignment algorithms (DPO, IPO, SimPO, KTO, etc.).
  • Conducted Theoretical Analysis: Using simplified model setups (like a learnable last linear layer), they proved that when responses share many identical tokens, their gradients become highly correlated (exhibiting a large inner product).
  • Performed Empirical Validation: They tracked the log-probabilities of chosen and rejected responses during training across various models and datasets to observe if they moved in "synchronized" directions.

Key Insights: The "Synchronized Movement" Trap

During training, DPO frequently causes both chosen and rejected probabilities to decrease simultaneously. While the relative gap between them grows, the model is actually becoming less likely to produce the "good" answer it was supposed to learn.

Training dynamics of DPO on Mistral 7B and Llama-3 8B

This synchronized movement is driven by token-level similarities:

  • Significant vs. Insignificant Tokens: Only the tokens that differ between two responses (significant tokens) create the "negative correlation" needed to push probabilities in opposite directions. Identical tokens (insignificant tokens) have nearly identical gradients, which "entangles" them and forces their probabilities to move together.
  • The Suffix Problem: As the shared "suffix" of two responses gets longer, gradient entanglement becomes more severe. This is a major issue for long-form generation, where the difference between a good and bad answer might be a single fact buried in the middle of a long paragraph.
  • High Cosine Similarity: The researchers found that the cosine similarity between the gradients of chosen and rejected responses is often extremely high (frequently >0.8). This confirms that the model "sees" these two different responses as very similar during the optimization process.

Algorithm-Specific Behaviors and Solutions

The paper's framework also explains why some algorithms perform better than standard DPO. By analyzing the training dynamics across various preference optimization algorithms, the authors found that explicit regularization is key to breaking the entanglement.

Comparison of log-probabilities across various alignment algorithms

Algorithms that add an explicit penalty—such as a Negative Log-Likelihood (NLL) term on the chosen response (like CPO or DPOP)—successfully break the entanglement. These methods provide extra signals that decouple the chosen response from the rejected one, ensuring the chosen response's probability actually increases rather than being dragged down.

Limitations and Future Work

The authors acknowledge that their theoretical setups use simplified architectures (like learnable logits or a single linear layer), which may not capture the full complexity of deep transformer layers.

For future work, they suggest:

  • Moving away from pure margin-based losses toward objectives that specify ideal behavior for individual responses.
  • Developing token-level alignment strategies that can focus specifically on the "significant" tokens that distinguish good answers from bad ones, rather than treating the entire sentence as a single unit.

Summary updated

BibTeX
@inproceedings{yuan2025common,
  author = {Hui Yuan and Yifan Zeng and Yue Wu and Huazheng Wang and Mengdi Wang and Liu Leqi},
  title = {{A Common Pitfall of Margin-based Language Model Alignment: Gradient Entanglement}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=YaBiGjuDiC},
}
Figure