Repulsive Attention: Rethinking Multi-head Attention as Bayesian Inference

Bang An, Jie Lyu, Zhenyi Wang, Chunyuan Li, Changwei Hu, Fei Tan, Ruiyi Zhang, Yifan Hu, Changyou Chen

Introduction

Multi-head attention (MHA) is a cornerstone of modern Transformer architectures, designed to allow models to attend to information from different representation subspaces simultaneously. However, empirical evidence suggests that many attention heads often learn redundant features, a phenomenon known as "attention collapse." This paper introduces Repulsive Multi-head Attention (RMA), a novel framework that reinterprets MHA as a Bayesian inference process to enforce diversity among heads.

The Problem: Attention Collapse

While the theoretical benefit of MHA lies in its ability to capture diverse linguistic patterns, standard training via Stochastic Gradient Descent (SGD) lacks an explicit mechanism to prevent heads from converging to the same local minima. This redundancy limits the representational capacity of the model and raises questions about the efficiency of large-scale Transformers. Furthermore, the field has lacked a rigorous theoretical explanation for why multi-head attention outperforms single-head models and how many heads are truly necessary for a given task.

Methodology: MHA as Bayesian Inference

The authors propose viewing the parameters of each attention head as "particles" sampling from a posterior distribution. Under this Bayesian framework, MHA performs a Monte Carlo approximation of an underlying inference problem.

To prevent heads from clustering around a single mode of the posterior, the authors employ Stein Variational Gradient Descent (SVGD) or Stochastic Particle Optimization Sampling (SPOS). These techniques introduce a kernel-based repulsive force into the gradient update. While the standard likelihood gradient pulls heads toward high-performance regions, the repulsive term pushes them apart, ensuring they cover distinct modes of the parameter space and capture diverse features.

Visualizing Diversity

The impact of this repulsive force is most evident in the attention maps. In standard MHA, multiple heads often focus on the same salient "anchor" words (e.g., "amazing"). In contrast, RMA forces heads to attend to different, yet informative, parts of the input (e.g., "downfall" or "service"), leading to a more holistic understanding of the text.

Comparison of attention maps between standard MHA and Repulsive Multi-head Attention. RMA heads capture a broader range of cues compared to the redundant focus of standard heads.

Key Results and Reduced Redundancy

RMA was evaluated across diverse tasks, including sentiment analysis (Yelp), machine translation (IWSLT14, WMT14), and general language understanding (GLUE).

  • Performance Gains: RMA consistently outperformed standard MHA and traditional regularization methods. For example, it achieved a +0.8 BLEU improvement on IWSLT14 De-En and a +3.2 point gain on the CoLA task within the GLUE benchmark. On the Yelp sentiment task, accuracy improved from 69.3% to 71.7%.
  • Efficiency: A "base" Transformer equipped with RMA can often match or exceed the performance of a "big" Transformer, suggesting that diversity is more valuable than raw parameter count.

A critical finding is the reduction in head redundancy. In standard models, many heads can be pruned at test time with minimal impact on performance. In RMA, heads are more "essential," as evidenced by the distribution of performance drops when heads are removed.

Histograms showing the BLEU drop when individual attention heads are pruned. The shift toward higher drops in RMA indicates that heads have learned unique, non-redundant information.

Conclusion

By rethinking multi-head attention through the lens of Bayesian particle optimization, Repulsive Attention provides both a theoretical foundation for MHA and a practical method to enhance model expressivity. This approach effectively mitigates attention collapse, leading to more robust and parameter-efficient NLP models. Future work may explore more sophisticated, task-specific priors to further refine the sampling process.

Summary updated

BibTeX
@inproceedings{an2020repulsive,
  author = {Bang An and Jie Lyu and Zhenyi Wang and Chunyuan Li and Changwei Hu and Fei Tan and Ruiyi Zhang and Yifan Hu and Changyou Chen},
  title = {{Repulsive Attention: Rethinking Multi-head Attention as Bayesian Inference}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  doi = {10.18653/v1/2020.emnlp-main.17},
}
Figure