[Paper Review] Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Pruned
The paper analyzes encoder-head importance in Transformer NMT, showing few heads are crucial and many can be pruned with minimal BLEU loss using a differentiable L0-like gating method. It also characterizes heads by positional, syntactic, and rare-word roles.
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.
Motivation & Objective
- Determine how much translation quality depends on individual encoder heads.
- Identify consistent, interpretable roles of important heads (positional, syntactic, rare-word).
- Assess across encoder self-attention, decoder self-attention, and decoder-encoder attention which heads are most impactful.
- Demonstrate a pruning approach to remove redundant heads while preserving performance.
Proposed method
- Compute head importance with layer-wise relevance propagation (LRP) to rank heads by contribution to top-1 logit.
- Characterize heads by three functions: positional (attend to adjacent token), syntactic (attend to tokens in a dependency relation), rare-words (attend to least frequent tokens).
- Evaluate head confidence via average maximum attention weight excluding EOS.
- Introduce a differentiable relaxation of L0 regularization using Hard Concrete gates to prune heads during continued training after converged full-model training.
- Apply gates to encoder self-attention (and later all attention types) and fine-tune to assess impact on BLEU.
- Compare pruning from trained/pruned models versus training from scratch with a small head count.
Experimental results
Research questions
- RQ1How much translation quality depends on individual encoder heads?
- RQ2Do encoder heads exhibit consistent, interpretable roles across language pairs and domains?
- RQ3Which attention types (encoder self-, decoder self-, decoder-encoder attention) are most sensitive to head count?
- RQ4Can we prune a large fraction of heads with minimal BLEU loss without retraining from scratch?
- RQ5How do pruned heads’ roles relate to positional/syntactic/rare-word functions?
Key findings
- A small subset of heads is highly important for translation quality.
- Important heads have specialized, interpretable functions (positional, syntactic relations, rare-word focus).
- Positional heads predominantly attend to adjacent tokens and align with top importance heads (high confidence and LRP relevance).
- Syntactic heads attend to specific dependency relations (e.g., nsubj, dobj, amod, advmod) and show higher-than-baseline accuracy in relation to syntactic structure.
- A single “rare-words” head in the first layer tends to focus on the least frequent tokens, indicating a distinct specialized role.
- A novel pruning approach using differentiable head gates (Hard Concrete) can prune most heads with minimal BLEU loss; for EN-RU OpenSubtitles, pruning from 48 to 4 encoder heads incurs only 0.25 BLEU loss.
- On WMT EN-RU, 10 encoder heads suffice to stay within 0.15 BLEU of the full model; many heads can be removed without major impact.
- Pruning all attention types shows decoder-encoder attention is most critical; encoder self-attention can be pruned more aggressively, especially in OpenSubtitles data.
- Pruned models trained from a converged full model retain key heads and can preserve function across layers, though retraining from scratch with the same sparse structure underperforms pruning-based sparsification.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.