Multi-Head Attention with Disagreement Regularization

Jian Li, Zhaopeng Tu, Baosong Yang, Michael R. Lyu, Tong Zhang

Abstract

Multi-head attention (MHA) is a cornerstone of the Transformer architecture, designed to allow the model to jointly attend to information from different representation subspaces. However, empirical evidence suggests that without explicit guidance, different attention heads often learn redundant features, failing to fully utilize the model's capacity. This paper introduces disagreement regularization, a simple yet effective auxiliary loss term that encourages diversity among attention heads. By penalizing similarity in attended positions and representational outputs, the proposed method significantly enhances translation quality. Our results show that a Transformer-Base model equipped with disagreement regularization can achieve performance comparable to a Transformer-Big model while maintaining a significantly higher training speed.

Introduction

The success of the Transformer model in neural machine translation (NMT) is largely attributed to its multi-head attention mechanism. In theory, each head should capture a unique aspect of the input—such as syntactic relations, semantic roles, or long-range dependencies. Despite this design intent, there is no inherent mechanism in the standard training objective to ensure that heads do not converge on the same information.

The authors identify this lack of diversity as a bottleneck for model efficiency. When multiple heads focus on the same features, the model's effective capacity is reduced. To address this, they propose a regularization framework that "nudges" heads to disagree with one another during the training process, thereby forcing them to explore a broader range of linguistic patterns.

Methodology: Disagreement Regularization

The core contribution of this work is the addition of a disagreement regularization term $D(\cdot)$ to the standard maximum likelihood training objective. This term is designed to maximize the distance between the behaviors of different heads. The authors explore three specific implementations:

  1. Subspace Disagreement (Sub.): This method targets the "value" projections of the heads. By minimizing the cosine similarity between the linear subspaces mapped by each head, the model is forced to represent different information from the same input.
  2. Position Disagreement (Pos.): This targets the attention distributions. It penalizes heads that attend to the same positions in a sentence, effectively dispersing their focus across the input sequence.
  3. Output Disagreement (Out.): This focuses on the final vectors produced by each head before concatenation. It maximizes the cosine distance between these output representations.
Visualization of two attention heads attending to different words in a sentence, illustrating the concept of positional diversity.

Importantly, these regularization terms are only active during training. Because they do not introduce new parameters, the inference speed and model architecture remain identical to a standard Transformer.

Experimental Setup

The proposed methods were evaluated on two large-scale translation tasks:

  • WMT14 English-German (En-De): A standard benchmark with 4.5 million sentence pairs.
  • WMT17 Chinese-English (Zh-En): A larger-scale task with 20 million sentence pairs.

The primary evaluation metric used was the 4-gram BLEU score. The authors compared their regularized "Base" and "Big" models against standard Transformer baselines and other state-of-the-art NMT systems.

Key Results and Discussion

The experimental results demonstrate a consistent improvement across all tasks. On the Zh-En benchmark, adding disagreement regularization to the Transformer-Base model improved the BLEU score from 24.13 to 24.85. Similar gains were observed on the En-De task, where the score rose from 27.64 to 28.51.

Performance comparison of standard Transformer models versus those enhanced with disagreement regularization.

Efficiency and Model Capacity

One of the most significant findings is the efficiency gain. As shown in the results, a regularized Transformer-Base model (with 8 heads and a hidden size of 512) performs on par with a Transformer-Big model (16 heads, 1024 hidden size). While the regularization adds a minor training overhead (approximately 12%), the resulting Base model is nearly twice as fast to train as a standard Big model while achieving similar accuracy.

Representation vs. Position

The authors' ablation studies revealed that encouraging diversity in representations (Subspace and Output regularization) was generally more effective than encouraging diversity in attended positions. This implies that while heads may look at the same word, the most important factor is that they extract different features from it. Output regularization emerged as the most robust variant across different settings.

Conclusion

This paper highlights a critical redundancy in standard multi-head attention and provides a straightforward solution through disagreement regularization. By explicitly encouraging diversity, the method allows smaller models to punch above their weight, matching the performance of much larger architectures. Future work may explore the application of these diversity constraints to other Transformer-based tasks beyond machine translation, such as natural language understanding and generation.

Summary updated

BibTeX
@inproceedings{li2018multi,
  author = {Jian Li and Zhaopeng Tu and Baosong Yang and Michael R. Lyu and Tong Zhang},
  title = {{Multi-Head Attention with Disagreement Regularization}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2018},
  doi = {10.18653/v1/d18-1317},
}
Figure