Mixture of Attention Heads: Selecting Attention Heads Per Token

Xiaofeng Zhang, Yikang Shen, Zeyu Huang, Jie Zhou, Wenge Rong +1 more
10/11/2022
95 citations
cs.CL
transformer-attentionmoe

Official code: yikangshen/MoA (54 stars, Python, BSD-3-Clause, last commit 2022-10-10).

Abstract

Mixture-of-Experts (MoE) networks have been proposed as an efficient way to scale up model capacity and implement conditional computing. However, the study of MoE components mostly focused on the feedforward layer in Transformer architecture.

Show full abstract

This paper proposes the Mixture of Attention Heads (MoA), a new architecture that combines multi-head attention with the MoE mechanism. MoA includes a set of attention heads that each has its own set of parameters. Given an input, a router dynamically selects a subset of $k$ attention heads per token. This conditional computation schema allows MoA to achieve stronger performance than the standard multi-head attention layer. Furthermore, the sparsely gated MoA can easily scale up the number of attention heads and the number of parameters while preserving computational efficiency. In addition to the performance improvements, MoA also automatically differentiates heads' utilities, providing a new perspective to discuss the model's interpretability. We conducted experiments on several important tasks, including Machine Translation and Masked Language Modeling. Experiments have shown promising results on several tasks against strong baselines that involve large and very deep models.

View on arXivView PDF

Code Implementations(1)

yikangshen/MoAOfficial100%
BSD-3-Clause

Mixture of Attention Heads

547Python, ShellOct 10, 20224 years agoBSD-3-Clause

Similar Papers

Cite this paper

@article{zhang2022mixture,
  title  = {Mixture of Attention Heads: Selecting Attention Heads Per Token},
  author = {Xiaofeng Zhang and Yikang Shen and Zeyu Huang and Jie Zhou and Wenge Rong and Zhang Xiong},
  year   = {2022},
  eprint = {2210.05144},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2210.05144}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2210.05144.svg)](https://codeofpaper.com/paper/2210.05144)

Discussion