NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Adaptively Sparse Transformers

Gonçalo M. Correia, Vlad Niculae, André F. T. Martins

Abstract: Gonçalo M. Correia, Vlad Niculae, André F. T. Martins. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP).

2019.

Introduction

In the field of Natural Language Processing, the Transformer architecture has become the dominant paradigm. Central to its success is the attention mechanism, which allows the model to weigh the importance of different words in a sequence. However, standard Transformers are often described as "attention gluttons" because the softmax function forces them to assign at least a minimal weight to every single word in a sequence, regardless of its relevance.

Correia et al. (2019) introduce the Adaptively Sparse Transformer, which replaces the standard dense softmax attention with a differentiable, sparse alternative called $\alpha$-entmax. This innovation allows individual attention heads to learn their own sparsity patterns—automatically choosing to attend to many words or just a few—improving model interpretability and head diversity without sacrificing translation accuracy.

The Problem: Attention Gluttony

Standard Transformers use the softmax function to normalize attention weights. Mathematically, softmax can never produce a true zero; it assigns a non-zero probability to every token in the context window. This leads to two primary issues:

  1. Noise and Dilution: Important linguistic relationships can be "washed out" by a long tail of irrelevant words.
  2. Interpretability: If every head attends to everything, it is difficult for researchers to discern which specific features or structures a head is actually tracking.

While previous attempts at "sparse" Transformers used fixed windows (e.g., looking only at the 5 preceding words), this paper enables the model to decide dynamically which words are worth attending to and which should be ignored entirely.

Methodology: The $\alpha$-entmax Slider

The core innovation is the use of $\alpha$-entmax, a function where $\alpha$ acts as a "sparsity slider."

  • The Slider: When $\alpha=1$, entmax is identical to softmax (dense). When $\alpha=2$, it becomes sparsemax (highly sparse).
  • Learning the Shape: The authors derived a closed-form expression for the Jacobian of $\alpha$-entmax with respect to $\alpha$, allowing the model to treat $\alpha$ as a standard learnable parameter. During training, the model uses backpropagation to "tune" the sparsity of every single attention head.
Comparison of attention patterns across different Transformer architectures. The Adaptively Sparse Transformer (Ours) allows for flexible, non-contiguous sparsity patterns per head.

Instead of a global setting, each head in each layer learns its own $\alpha$. This means one head might choose to be a broad "global" listener, while another becomes a laser-focused "local" specialist.

Key Insights and Results

The researchers evaluated their model on four standard Neural Machine Translation (NMT) benchmarks, including IWSLT 2017 and WMT 2014.

Emergent Specialization

The study revealed that the encoder is often bimodal: heads typically polarize, becoming either extremely sparse ($\alpha \approx 2$) or remaining relatively dense ($\alpha \approx 1.2$). Interestingly, the decoder and context attention heads tend to stay denser, likely because the auto-regressive nature of the decoder provides fewer tokens to look at, making it harder to ignore information.

Evolution of the sparsity parameter $\alpha$ during training for various heads in the encoder and decoder.

Sparsity also uncovers "hidden" roles. The authors identified a "BPE-merging head" that specifically learns to attend to sub-word units to reconstruct full words, and an "interrogation head" that focuses almost exclusively on question marks when an interrogative word (like "what") is present. Sparse models also show much higher Jensen-Shannon divergence between heads, meaning the heads are performing more unique, distinct tasks than those in a softmax Transformer.

Performance Metrics

  • Translation Quality: The Adaptively Sparse Transformer achieved slightly higher BLEU scores than the softmax baseline. For example, on WMT14 EN-DE, it scored 26.93 vs. softmax's 26.02.
  • Confidence: Sparse heads are more "confident." In positional tasks, the adaptive model assigned nearly 96% of its weight to the correct token, outperforming the softmax version.
  • Efficiency: While $\alpha$-entmax is more complex, the adaptive model trained at about 75% the speed of the softmax model, a manageable overhead for the resulting gains.

Conclusion

The Adaptively Sparse Transformer demonstrates that sparsity can be learned effectively, leading to more interpretable and diverse attention mechanisms. While $\alpha$-entmax currently carries a slight computational cost compared to highly optimized softmax implementations, the behaviors learned by these models could pave the way for designing faster, static sparse patterns for future large-scale models.

Summary updated

BibTeX
@inproceedings{correia2019adaptively,
  author = {Gonçalo M. Correia and Vlad Niculae and André F. T. Martins},
  title = {{Adaptively Sparse Transformers}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2019},
  url = {https://openreview.net/forum?id=2jg-eZUITDq},
}
Figure