Alleviating the Inequality of Attention Heads for Neural Machine Translation

Zewei Sun, Shujian Huang, Xinyu Dai, Jiajun Chen

Abstract

Transformer models in Neural Machine Translation (NMT) often exhibit a significant imbalance in the contribution of their multi-head attention (MHA) components. A small subset of "super heads" typically dominates the learning process, leaving many others redundant or underutilized. This paper proposes HeadMask, a training-time intervention that masks specific attention heads to force the model to distribute information processing more broadly. Our results show that HeadMask not only improves BLEU scores across several low-resource language pairs but also significantly enhances model robustness by flattening the head importance distribution.

Introduction: The Inequality of Attention

The success of the Transformer architecture relies heavily on Multi-Head Attention (MHA), which theoretically allows models to capture diverse linguistic features simultaneously. However, empirical evidence suggests that many heads are redundant; a large portion can often be pruned post-training without substantial performance loss.

The authors characterize this as a symptom of "imbalanced training." Much like a soccer player who relies solely on their dominant foot, a Transformer may become "addicted" to a few heads that happen to receive better updates early in training. This creates a bottleneck where the model's overall capacity is limited by its failure to utilize the full breadth of its parameters.

Figure 1: BLEU score impact when masking different groups of heads sorted by importance. Masking the most important heads (1-18) causes a severe performance drop, while masking the least important ones (127-144) has negligible impact.

Methodology: The HeadMask Intervention

To mitigate this inequality, the authors introduce HeadMask, a technique applied during training to "level the playing field." Two primary strategies are explored:

  1. Random Masking: In each training batch, a fixed number of heads are randomly disabled. This prevents the model from relying on any single head 100% of the time, encouraging the distribution of the informational load across all available heads.
  2. Importance-Based Masking: A more targeted two-pass approach. The model first identifies the most "important" heads using a gradient-based Taylor expansion metric. These "superstar" heads are then masked for a second pass, forcing the update of parameters in the remaining, weaker heads to compensate for the missing information.

Experimental Results

The researchers evaluated HeadMask on four low-resource language pairs: Chinese-English (NIST Zh-En), Romanian-English (WMT16 Ro-En), Vietnamese-English (IWSLT15 Vi-En), and Turkish-English (WMT17 Tr-En).

Improved Translation Quality and Robustness

On the Zh-En task, the Random-18 method achieved a BLEU score improvement of +0.87 over the baseline. Similar gains were observed across other language pairs (e.g., +0.68 BLEU for Ro-En). Crucially, models trained with HeadMask proved more resilient; when important heads were intentionally masked at test time, these models experienced significantly smaller performance drops compared to the baseline, indicating they had successfully learned to utilize a wider array of features.

Flattening the Importance Distribution

Statistical analysis confirms that HeadMask successfully redistributes the workload. The variance of head importance in the Zh-En task dropped from 77.28 in the baseline to 33.21 with random masking, and as low as 9.13 with importance-based masking. This "flatter" distribution correlates strongly with the observed improvements in translation quality.

Figure 6: Head importance distributions for the baseline and HeadMask variants. Both random and importance-based masking significantly reduce variance, leading to a more balanced and robust model.

Discussion and Conclusion

The study highlights that reducing the inequality between attention heads leads to better generalization. Interestingly, random masking often outperformed the more complex importance-based masking. The authors suggest that aggressively masking the most important heads might occasionally be "too harsh," potentially hindering the model's ability to learn highly complex patterns.

While HeadMask introduces some computational overhead—particularly the importance-based variant—the gains in translation quality and model robustness make it a compelling strategy for training more efficient and reliable NMT systems. Future work will explore the scalability of this approach to larger models and massive datasets.

Summary updated

BibTeX
@inproceedings{sun2022alleviating,
  author = {Zewei Sun and Shujian Huang and Xinyu Dai and Jiajun Chen},
  title = {{Alleviating the Inequality of Attention Heads for Neural Machine Translation}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2022},
  url = {https://openreview.net/forum?id=RU-mT0N5MGq},
}
Figure