TL;DR
This paper introduces a novel similarity analysis framework to compare various contextual word representation models (like BERT, GPT, ELMo) based on their internal representations and attention mechanisms, without relying on external linguistic annotations. The study reveals surprising similarities across different architectures, while also highlighting how model families and layer depth influence representation similarity, and how fine-tuning impacts higher layers more significantly.
What Problem Does This Paper Address?
The rapid advancement of contextual word representation models (e.g., ELMo, BERT) has led to significant improvements in NLP tasks. However, understanding why these models work so well and how their internal mechanisms differ remains a challenge. Traditional methods for analyzing these models often rely on "probing classifiers," which train separate models to predict linguistic properties from the representations. This approach requires linguistic annotations, can be indirect, and makes it difficult to directly compare different models or their components. This paper aims to bridge this gap by developing methods to directly measure the similarity of internal representations and attention patterns across diverse models and architectures, offering a more direct and annotation-free way to understand their inner workings.
Methods
The authors propose a suite of similarity measures to analyze contextual word representations. These measures fall into several categories:
- Neuron-level similarity: Compares individual neurons across layers and models to assess how information is localized.
- Mixed neuron-representation similarity: Measures how well a neuron in one model can be represented by a linear combination of neurons in another layer.
- Representation-level similarity: Assesses the similarity of entire layer representations using techniques like Canonical Correlation Analysis (CCA) and linear centered kernel alignment (CKA). These methods focus on the distributed nature of information.
- Attention-level similarity: Analyzes the similarity of attention weights in Transformer models, using measures like Jensen-Shannon divergence and Pearson correlation.
These methods allow for comparisons at different granularities, from individual neurons to entire layer representations and attention heads, without requiring external linguistic labels.
Datasets
The primary dataset used for extracting representations and attention weights for similarity analysis is the Penn Treebank development set. The authors mention using this dataset following the setup of previous work (Liu et al., 2019a) to ensure comparability. For evaluating the effect of fine-tuning, they use four tasks from the GLUE benchmark: MNLI, QNLI, QQP, and SST-2.
Key Insights and Ideas
- Family Resemblance: Models within the same family (e.g., different BERT variants, different GPT versions) exhibit higher similarity, both in terms of individual neurons and overall representations. This suggests that architectural choices and training objectives within a family lead to more consistent internal representations.
- Cross-Architecture Surprises: Despite vastly different architectures (RNNs vs. Transformers) and objectives (masked vs. autoregressive), different models often show surprisingly similar representations at the layer level. This suggests that some fundamental patterns of information processing might be shared across diverse NLP models.
- Neuron vs. Representation Similarity: While overall layer representations can be similar across architectures, individual neurons often behave very differently. This highlights a distinction between the distributed "gist" of a layer's representation and the specific roles of individual neurons.
- Layer-wise Localization: Information tends to become more localized in higher layers of the network. This is evidenced by measures that capture localized information (like
neuronsim) showing increasing scores in upper layers. - Fine-tuning's Impact: Higher layers are significantly more affected by fine-tuning on downstream tasks than lower layers. This leads to a decrease in localization in the top layers after fine-tuning.
Key Results
- Intra-model vs. Inter-model Similarity: Heatmaps consistently show a strong "block diagonal" pattern for neuron-level similarity (
neuronsim), indicating high similarity within models and low similarity across models. In contrast, representation-level similarities (likeckasim) show significant similarities across models, suggesting shared representational structures. - Lower Layers are More Stable: Lower layers across different architectures tend to be more similar than higher layers, likely because they are closer to the input and process more general linguistic features.
- Attention vs. Representation: Attention-level similarities largely mirror representation-level findings, with intra-model similarity being high. However, attention patterns can be harder to interpret and may be less reliable for understanding model behavior.
- Efficient Fine-tuning: The observation that lower layers change less during fine-tuning motivates a strategy of freezing these layers. Experiments show that freezing bottom layers can maintain comparable performance to full fine-tuning while significantly reducing computation (over 50% savings by freezing six layers).
Limitations and Future Work
- Dataset Dependence: While the study shows consistent results across Penn Treebank and Universal Dependencies, the authors acknowledge that using different datasets could potentially alter findings, especially for cross-family comparisons where training data might differ.
- Interpretation of Attention: The authors note concerns about the reliability of attention weights for interpreting model importance and suggest that characterizing the effect of these concerns on their similarity measures is beyond the current scope.
- Combining Approaches: The authors suggest future work could combine their similarity analysis with probing classifiers to understand which linguistic properties are captured by similar components across models.
- Loss Surfaces and Convergence: Comparing similarity analysis results with model loss surfaces and studying whether high similarity implies convergence to a similar solution are also proposed future directions.
- Model Efficiency: The similarity analysis can be used to identify components that don't change much during fine-tuning, potentially leading to more efficient model pruning strategies.
Summary updated