Abstract
BERT-base models contain massive amounts of redundant information across their 144 attention heads. This research reveals that attention redundancy patterns are surprisingly task-agnostic and phase-independent, meaning the same heads remain redundant regardless of the input domain—even when processing random gibberish. By leveraging these stable patterns, we demonstrate a zero-shot pruning method capable of removing up to 85% of attention heads with minimal impact on model performance.
Introduction
Modern Natural Language Processing (NLP) relies heavily on the Transformer architecture and its multi-head self-attention mechanism. While effective, these models are computationally expensive and memory-intensive. Researchers have long suspected that many attention heads perform redundant work. This study provides a comprehensive analysis of redundancy across all 144 heads in a BERT-base model to determine if this redundancy is a predictable pattern that can be exploited for model compression.
Methodology
The core of this analysis is the Attention Redundancy Matrix, a 144x144 heatmap where each cell represents the dissimilarity between two specific attention heads.
To quantify this dissimilarity, the authors employed two levels of metrics:
- Token-Based Distances: Measuring similarity in how heads treat individual words (e.g., Jensen-Shannon distance, Cosine similarity).
- Sentence-Based Distances: Measuring similarity in how heads treat entire sequences (e.g., Distance Correlation, Canonical Correlation).
The study utilized the GLUE benchmark for evaluation and Wiki103 for pre-training. A "RANDOM" dataset of arbitrary token sequences was also included to test the limits of task-agnosticism.
Key Insights: Task-Agnosticism and Stability
A primary finding of this work is that redundancy patterns are remarkably task-agnostic. The model exhibits nearly identical clusters of redundant heads whether it is processing complex linguistic tasks or random noise. This suggests that redundancy is established during the pre-training phase and remains stable throughout fine-tuning.
Furthermore, the redundancy follows a hierarchical structure:
- Layers 1-4: Highly redundant, likely capturing superficial features.
- Middle Layers: More distinct and specialized.
- Final Layers: Converge toward task-specific outputs, becoming redundant again.
The authors also identified that hidden dropout (applied after the attention mechanism) is a significant driver of this redundancy, more so than the dropout within the attention layers themselves.
Pruning Results
By applying Spectral Clustering to the redundancy matrices, the authors developed a zero-shot pruning strategy. This method identifies "representative" heads and removes redundant ones before any task-specific fine-tuning.
- Efficiency: Redundancy matrices can be computed once (even using random tokens) to create a universal pruning mask.
- Performance: On most GLUE tasks (e.g., SST-2, MRPC, QQP), the model maintained comparable performance (less than 5% loss) even after pruning 75% to 85% of attention heads.
- Stability: The mean difference between redundancy matrices of pre-trained and fine-tuned models was only 0.035, confirming that fine-tuning has minimal impact on head similarity.
Conclusion and Future Work
This study demonstrates that attention redundancy in BERT is a stable, task-agnostic feature rather than a transient artifact. While highly effective for BERT-base, future research should investigate if these patterns hold for larger architectures like GPT-3 or RoBERTa-large. Additionally, while dropout was identified as a contributing factor, the fundamental mathematical drivers of this redundant structure warrant further investigation.
Summary updated