[Paper Review] Adaptively Sparse Transformers
This paper introduces the adaptively sparse Transformer, which replaces standard softmax attention with learnable α -entmax to enable dynamic, context-dependent sparsity in attention heads. By automatically learning the α parameter per head, the model achieves improved interpretability and head diversity without sacrificing accuracy, with heads in deeper layers favoring denser attention patterns and specialized behaviors emerging naturally.
Attention mechanisms have become ubiquitous in NLP. Recent architectures, notably the Transformer, learn powerful context-aware word representations through layered, multi-headed attention. The multiple heads learn diverse types of word relationships. However, with standard softmax attention, all attention heads are dense, assigning a non-zero weight to all context words. In this work, we introduce the adaptively sparse Transformer, wherein attention heads have flexible, context-dependent sparsity patterns. This sparsity is accomplished by replacing softmax with $α$-entmax: a differentiable generalization of softmax that allows low-scoring words to receive precisely zero weight. Moreover, we derive a method to automatically learn the $α$ parameter -- which controls the shape and sparsity of $α$-entmax -- allowing attention heads to choose between focused or spread-out behavior. Our adaptively sparse Transformer improves interpretability and head diversity when compared to softmax Transformers on machine translation datasets. Findings of the quantitative and qualitative analysis of our approach include that heads in different layers learn different sparsity preferences and tend to be more diverse in their attention distributions than softmax Transformers. Furthermore, at no cost in accuracy, sparsity in attention heads helps to uncover different head specializations.
Motivation & Objective
- To address the lack of interpretability and head specialization in standard softmax-based Transformers, where all attention heads are dense and assign non-zero weights to all context words.
- To enable attention heads to dynamically choose between focused (sparse) and broad (dense) attention patterns based on context, improving model interpretability.
- To develop a differentiable, learnable mechanism for controlling attention sparsity that adapts per head and per context, avoiding manual hyperparameter tuning.
- To empirically validate that adaptive sparsity enhances head specialization and interpretability in sequence modeling tasks like machine translation.
- To demonstrate that sparsity can be introduced without performance degradation, maintaining or slightly improving accuracy.
Proposed method
- Replace standard softmax attention with α -entmax, a differentiable generalization of softmax that allows exact zero attention weights for low-scoring tokens.
- Introduce a learnable α parameter per attention head that controls the curvature and sparsity of the attention distribution, enabling dynamic adaptation between dense and sparse regimes.
- Use gradient-based optimization to jointly train the model and the α parameters, eliminating the need for manual hyperparameter search.
- Apply the bisection method to compute α -entmax efficiently during both forward and backward passes, ensuring differentiability and scalability.
- Train the model end-to-end on machine translation tasks using standard Transformer architecture, with attention heads learning diverse sparsity patterns automatically.
- Analyze attention distributions across layers and heads to identify specialization patterns and interpretability gains.
Experimental results
Research questions
- RQ1Can learnable, adaptive sparsity in attention heads improve interpretability of Transformer models without sacrificing performance?
- RQ2Do attention heads in different layers of the Transformer learn distinct sparsity preferences, and if so, how do these preferences correlate with model depth?
- RQ3Can adaptive α -entmax attention lead to more diverse and specialized head behaviors compared to standard softmax attention?
- RQ4Does the automatic learning of α parameters per head enable better head specialization than fixed sparsity or fixed α settings?
- RQ5Can dynamic sparsity patterns emerge that are non-contiguous and context-dependent, unlike fixed-span sparse Transformers?
Key findings
- Heads in deeper layers of the adaptively sparse Transformer tend to be denser on average than those in earlier layers, mirroring findings in adaptive span Transformers.
- The model achieves comparable or slightly improved translation accuracy compared to standard softmax Transformers, with no performance cost from sparsity.
- Attention heads exhibit higher diversity in their attention distributions, with distinct sparsity patterns emerging naturally across heads.
- The model uncovers crisper, more interpretable head behaviors, such as positional attention and subword joining, which are more clearly defined than in softmax-based models.
- Sparsity enables clearer identification of head specialization, such as heads focusing on syntactic dependencies or rare words, with reduced ambiguity in attention patterns.
- The automatic learning of α allows heads to dynamically adjust their attention shape—ranging from peaked to flat—based on context, enhancing model expressivity.
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.