Introduction
Transformer-based models like BERT and GPT have revolutionized Natural Language Processing, yet the internal mechanisms of their hundreds of attention heads often remain a "black box." Standard practice typically involves using the output of the final layer as a sentence representation, assuming it contains the most refined information. This research challenges that assumption, investigating whether individual attention heads specialize in specific linguistic features and demonstrating that selective utilization of these heads can significantly improve model performance.
Methodology: Probing and Utilization
The researchers developed a two-step framework to analyze and leverage the internal representations of Transformer models. First, they perform Head-wise Probing, treating the output of every individual attention head as a standalone "mini-sentence embedding." Simple classifiers are trained on these embeddings to determine how well each head predicts specific linguistic properties, such as syntactic depth or verb tense.
Following this analysis, the authors create Reconstructed Embeddings. By ranking heads based on their probing accuracy for a given task, they concatenate the "top-n" most influential heads to form a new, optimized sentence representation ($h^n$). This process is illustrated in Figure 1.
Key Insights: Specialization and Model Personalities
The study's analysis reveals critical findings regarding the internal organization of linguistic knowledge:
- The "Last Layer" Fallacy: The final layer is rarely the most informative for specific linguistic tasks. In models like BERT-Large, the most capable heads for syntax and semantics are often found in the middle or upper-middle layers, with performance sometimes declining in the final layer.
- Layer-wise Hierarchy: There is a clear progression of information. Surface and syntactic features (like sentence length and tree depth) are concentrated in lower to middle layers, while semantic information (like subject/object number) moves toward the upper layers.
- Architectural Differences: Model families exhibit distinct "personalities." The GPT family tends to distribute tasks across many cooperating heads, whereas the BERT family relies on a smaller set of highly specialized heads.
Figure 3 visualizes these patterns through accuracy heat maps, showing the distribution of knowledge across the layers and heads of various pre-trained models.
Performance and Downstream Utility
The practical benefits of this selective approach are significant. Utilizing the "top-n" influential heads resulted in a median accuracy increase of 19.22% across all probing tasks compared to using the standard last layer. For instance, in the "Word Content" task, BERT-Base performance improved from 25.2% to 73.1%.
Beyond probing, this method translates to real-world gains. On the MRPC paraphrase detection task, using the most influential heads provided a 3.1% accuracy boost for BERT-Large over standard fine-tuning. Interestingly, the heads identified as influential in the pre-trained state remain critical after fine-tuning, with the fine-tuning process often amplifying the signals in these specific regions.
Conclusion
This research demonstrates that attention heads in Transformers are not redundant but highly specialized. By moving beyond the "last layer" convention and selectively harvesting influential heads, researchers can create more potent sentence representations for both linguistic analysis and downstream NLP applications. Future work may explore dynamic head modulation to further optimize these representations without increasing computational overhead.
Summary updated