Information Aggregation for Multi-Head Attention with Routing-by-Agreement

Jian Li, Baosong Yang, Zi-Yi Dou, Xing Wang, Michael R. Lyu, Zhaopeng Tu

Abstract

Standard Multi-Head Attention (MHA) in Transformer models typically aggregates information from different heads using a simple linear transformation. This paper proposes replacing this static operation with a dynamic "routing-by-agreement" mechanism, inspired by Capsule Networks. By treating head outputs as "parts" that vote for a "whole" representation, the model can more effectively fuse diverse features. Experimental results on machine translation tasks (WMT14 En-De and WMT17 Zh-En) demonstrate significant BLEU score improvements. Furthermore, linguistic probing tasks reveal that this approach significantly enhances the model's ability to capture complex syntactic and semantic properties with minimal impact on decoding speed.

Introduction

In the Transformer architecture, Multi-Head Attention is the primary mechanism for capturing dependencies across sequences. Each attention head acts as an independent "expert" focusing on a specific subspace of the data. However, the standard practice of concatenating these outputs and applying a fixed linear layer creates a potential information bottleneck. This static aggregation treats the combination of features as a fixed operation, potentially losing the nuanced information captured by individual heads. This research explores replacing this linear layer with a dynamic process that assigns information based on how well individual head outputs agree with a global consensus.

Methodology

The researchers cast information aggregation as a "parts-to-wholes" problem. They treat the output of each attention head as an "input capsule" (a part) and the final aggregated representation as "output capsules" (the whole).

The routing-by-agreement mechanism for aggregating information from multiple attention heads.

Two specific routing mechanisms were explored:

  1. Simple Routing: An iterative process where the model calculates the dot-product "agreement" between a head's proposal and the current state of the output. Weights are dynamically adjusted based on this consensus.
  2. EM Routing: An advanced version using the Expectation-Maximization algorithm. It treats routing as fitting a mixture of Gaussians, where output capsules are the Gaussians and input heads are the data points, allowing for better handling of clusters of similar "votes."

To maintain computational efficiency, the authors introduced "Effective Aggregation," applying routing only to the first two layers of the encoder. This strategy balances performance gains with the need for high-speed processing.

Experimental Setup

The approach was evaluated using two primary methodologies:

  • Linguistic Probing Tasks: A suite of 10 classification problems designed to test the model's grasp of sentence length, word content, tree depth, syntax, and semantics.
  • Machine Translation: Benchmarking on the standard WMT14 English-to-German (En-De) and WMT17 Chinese-to-English (Zh-En) datasets.

Key Results and Discussion

The "Effective Aggregation" method demonstrated clear superiority over standard linear aggregation. On the WMT14 En-De benchmark, it improved the Transformer-Base BLEU score by +0.95 and the Transformer-Big score by +0.38.

Comparison of the proposed NMT systems against existing state-of-the-art models on En-De and Zh-En benchmarks.

Linguistic probing further validated the depth of these improvements. EM routing outperformed the baseline in 9 out of 10 tasks, with a notable 3-point increase in "Tree Depth" (TrDep) scores. This suggests that dynamic routing allows the model to better internalize hierarchical sentence structures. Crucially, the "Effective Aggregation" strategy achieved these results with almost no impact on decoding speed, addressing a common concern with iterative routing mechanisms.

Conclusion

This work demonstrates that how information is combined is just as critical as how it is extracted. By treating Multi-Head Attention aggregation as a dynamic filtering process rather than a static linear operation, models can capture significantly more complex linguistic properties. Future research may explore applying this mechanism to other Transformer components, such as cross-attention layers or feed-forward networks, to further enhance representational power.

Summary updated

BibTeX
@inproceedings{li2019information,
  author = {Jian Li and Baosong Yang and Zi-Yi Dou and Xing Wang and Michael R. Lyu and Zhaopeng Tu},
  title = {{Information Aggregation for Multi-Head Attention with Routing-by-Agreement}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2019},
  doi = {10.18653/v1/n19-1359},
}
Figure