[Paper Review] SparseBERT: Rethinking the Importance Analysis in Self-attention
This paper proposes SparseBERT, a method that rethinks self-attention importance by discovering that diagonal elements in the attention matrix are the least important, enabling their removal without performance loss. Using a Differentiable Attention Mask (DAM) with Gumbel-sigmoid, the model learns sparse, structured attention patterns end-to-end, achieving 91.3% sparsity with 80.9% GLUE score on the development set.
Transformer-based models are popularly used in natural language processing (NLP). Its core component, self-attention, has aroused widespread interest. To understand the self-attention mechanism, a direct method is to visualize the attention map of a pre-trained model. Based on the patterns observed, a series of efficient Transformers with different sparse attention masks have been proposed. From a theoretical perspective, universal approximability of Transformer-based models is also recently proved. However, the above understanding and analysis of self-attention is based on a pre-trained model. To rethink the importance analysis in self-attention, we study the significance of different positions in attention matrix during pre-training. A surprising result is that diagonal elements in the attention map are the least important compared with other attention positions. We provide a proof showing that these diagonal elements can indeed be removed without deteriorating model performance. Furthermore, we propose a Differentiable Attention Mask (DAM) algorithm, which further guides the design of the SparseBERT. Extensive experiments verify our interesting findings and illustrate the effect of the proposed algorithm.
Motivation & Objective
- To re-evaluate the importance of different attention positions in self-attention mechanisms during BERT pre-training.
- To investigate whether diagonal elements in the attention matrix are truly essential for model performance.
- To develop a learnable, differentiable mechanism for discovering efficient, sparse attention patterns.
- To design a sparse Transformer architecture (SparseBERT) that maintains performance while reducing computational cost.
- To validate that removing diagonal attention improves sparsity without harming downstream task accuracy.
Proposed method
- Proposes a Differentiable Attention Mask (DAM) algorithm that learns attention patterns end-to-end using a soft, differentiable mask.
- Introduces a Gumbel-sigmoid function to differentially sample binary attention masks during training, enabling gradient-based optimization.
- Optimizes the attention mask as part of the pre-training process, jointly learning the mask and model parameters.
- Uses a learnable temperature parameter to control the softness of the mask, allowing for discrete attention patterns via straight-through estimation.
- Applies structured sparsity constraints to ensure the resulting attention patterns are interpretable and efficient (e.g., local, global, or hybrid patterns).
- Employs a weighted loss combining model accuracy and sparsity regularization to balance performance and efficiency.
Experimental results
Research questions
- RQ1Are diagonal elements in the self-attention matrix truly important for model performance, or can they be safely removed?
- RQ2Can a differentiable, end-to-end method learn sparse attention patterns that match or exceed the performance of handcrafted sparse attention mechanisms?
- RQ3How does the importance of attention positions (e.g., diagonal, neighbors, special tokens) vary across attention heads during pre-training?
- RQ4To what extent can sparsity be increased by removing diagonal attention without degrading downstream task performance?
- RQ5How does one-stage differentiable mask learning compare to two-stage pruning in terms of performance and sparsity control?
Key findings
- Diagonal elements in the self-attention matrix are the least important, as their removal causes no performance drop across multiple tasks.
- SparseBERT with 91.3% sparsity achieves 80.9% average GLUE score on the development set, demonstrating high efficiency without accuracy loss.
- The proposed DAM algorithm learns diverse, structured attention patterns across heads, with neighborhood and special tokens (e.g., [CLS], [SEP]) receiving higher attention than diagonals.
- Removing diagonal attention increases sparsity from 70.4% to 71.2% in strided masks and up to 93.5% in DAM-sampled masks, with no drop in performance.
- One-stage differentiable mask learning outperforms two-stage pruning in terms of downstream accuracy, though it offers less direct control over sparsity via hyperparameter λ.
- Theoretical analysis confirms that diagonal elements are not necessary for universal approximation in self-attention mechanisms.
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.