Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Pruned
Preprint
Abstract
Multi-head self-attention is a key component of the Transformer, a state-of-the-art architecture for neural machine translation. In this work we evaluate the contribution made by individual attention heads in the encoder to the overall performance of the model and analyze the roles played by them. We find that the most important and confident heads play consistent and often linguistically-interpretable roles. When pruning heads using a method based on stochastic gates and a differentiable relaxation of the L0 penalty, we observe that specialized heads are last to be pruned. Our novel pruning method removes the vast majority of heads without seriously affecting performance. For example, on the English-Russian WMT dataset, pruning 38 out of 48 encoder heads results in a drop of only 0.15 BLEU.Keywords
All Related Versions
This publication has 10 references indexed in Scilit:
- Training Tips for the Transformer ModelThe Prague Bulletin of Mathematical Linguistics, 2018
- Colorless Green Recurrent Networks Dream Hierarchically2018
- The representational geometry of word meanings acquired by neural machine translation modelsMachine Translation, 2017
- What do Neural Machine Translation Models Learn about Morphology?2017
- Visualizing and Understanding Neural Machine Translation2017
- Assessing the Ability of LSTMs to Learn Syntax-Sensitive DependenciesTransactions of the Association for Computational Linguistics, 2016
- Does String-Based Neural MT Learn Source Syntax?2016
- Neural Machine Translation of Rare Words with Subword Units2016
- On Pixel-Wise Explanations for Non-Linear Classifier Decisions by Layer-Wise Relevance PropagationPLOS ONE, 2015
- The Stanford CoreNLP Natural Language Processing Toolkit2014