Introduction
Multi-headed attention is the driving force behind the Transformer architecture, which has revolutionized natural language processing (NLP). Theoretically, deploying multiple attention "heads" in parallel allows a model to simultaneously focus on different aspects of a sequence—such as grammar, semantics, or specific keywords. However, these models are computationally expensive and memory-intensive.
This raises a fundamental question: Do we actually need all these heads at inference time? While Multi-Head Attention (MHA) is theoretically more expressive than single-head attention, it has remained unclear whether models fully utilize this capacity or if many heads are simply redundant. Recent research demonstrates that a vast majority of attention heads in models like BERT and Transformer-based translation systems can be pruned at test time with little to no loss in accuracy, leading to significant inference speedups.
Methodology
To test head redundancy, researchers evaluated models across several standard benchmarks, including WMT 2014 English-to-French (for a large Transformer model) and MultiNLI (for a fine-tuned BERT-base model). They also utilized out-of-domain test sets like MTNT and MNLI-mismatched to verify if head importance remains consistent across different data distributions.
The study employed three main strategies:
- Individual Ablation: Removing one head at a time and measuring the impact on performance metrics (BLEU score for translation, accuracy for BERT).
- Single-Head Reduction: Attempting to reduce entire layers to just one "best" head to determine if the layer truly required multi-headedness.
- Iterative Pruning: Developing a proxy "Importance Score" based on the gradient of the loss with respect to a mask variable. This allowed the researchers to rank all heads and greedily prune them to observe performance degradation as the network thinned out.
Key Findings
Massive Redundancy
Surprisingly, in many cases, removing a single head actually improved performance. For the WMT encoder, only 8 out of 96 heads caused a statistically significant drop in performance when removed.
Universal Importance
Heads that are important for one task or dataset tend to be important for others. This suggests that "important" heads are learning fundamental linguistic features rather than over-fitting to a specific test set.
Pruning Thresholds and Efficiency Gains
The authors found they could prune up to 20% of heads in WMT and 40% of heads in BERT without any noticeable drop in performance. Actually pruning these heads (rather than just masking them) resulted in a 17.5% increase in inference speed for BERT on GPU hardware at higher batch sizes. Remarkably, many layers in BERT and the WMT encoder could be reduced to a single attention head without impacting test performance.
Encoder-Decoder Sensitivity and Early Specialization
Not all parts of the Transformer are equally robust to pruning. The encoder-decoder attention layers—where the model looks at the input sentence while generating the output—are much more sensitive to pruning than self-attention layers. Pruning more than 60% of encoder-decoder heads in the translation model led to a catastrophic collapse in translation quality.
Furthermore, by analyzing training dynamics, the authors found that the model decides which heads are "important" very early in the training process (within the first 10 epochs). After this point, the unimportant heads remain largely irrelevant.
Limitations and Future Work
The primary limitation of this approach is that pruning occurs after training. The model still requires the full complement of heads and parameters during the computationally expensive training phase.
Future work should investigate whether these insights can be used to design more efficient training regimes—perhaps by dynamically "dropping" heads during training or using importance scores to guide neural architecture search. Additionally, while the inference speedup is significant, MHA only accounts for about one-third of the model's parameters; the feed-forward layers remain a major bottleneck that this specific pruning method does not address.
Summary updated