Deriving Contextualised Semantic Features from BERT (and Other Transformer Model) Embeddings

Jacob Turton, Robert Elliott Smith, David VinsonACL 2021

TL;DR

This paper bridges the gap between opaque, powerful transformer language models like BERT and interpretable semantic features. By successfully deriving a set of 65 core semantic features (Binder features) from BERT's contextual embeddings, the research offers a way to understand why these models make certain predictions and how semantic information is represented across BERT's layers. This work is crucial for building more transparent and trustworthy AI systems.

What Problem Does This Paper Address?

Modern Natural Language Processing (NLP) models, particularly those based on the transformer architecture like BERT, have achieved state-of-the-art performance on many tasks. A key innovation is their ability to generate "contextualized embeddings" – vector representations of words that change based on the surrounding text. This addresses the limitation of older "static" embeddings (like Word2Vec) which assigned a single vector to each word, failing to capture polysemy (multiple meanings) and homonymy.

However, these powerful contextual embeddings are often described as "black boxes." While we can see how words relate to each other in the embedding space (e.g., through distance or dimensionality reduction), understanding the meaning behind each dimension or how specific semantic concepts are encoded remains a challenge.

Previous work by Binder et al. (2016) proposed an intuitive embedding space where each dimension corresponds to one of 65 core semantic features (e.g., "visual," "auditory," "pleasant"). This system is highly interpretable, but it was only developed for a small vocabulary of 535 words. While prior research showed these features could be derived from static embeddings and extrapolated, the question remained: can we derive these interpretable features directly from the rich, contextualized embeddings produced by models like BERT? This paper aims to answer that question, offering a path to both interpretable contextual embeddings and insights into BERT's internal workings.

Methods

The core of the methodology involves using a feed-forward neural network to predict Binder feature scores from BERT embeddings.

  1. Deriving Static Binder Embeddings from BERT: For Experiment 1a, the researchers treated BERT embeddings as static by averaging embeddings from 250 randomly sampled sentences for each word in the Binder dataset. This allowed them to predict Binder feature values from these averaged embeddings. They compared BERT with other transformer models (RoBERTa, XLNet, GPT-2) and a strong static baseline (Numberbatch).
  2. Investigating Layer-wise Representation: A key aspect was analyzing how semantic features are represented across BERT's different layers. They examined the R-squared scores (a measure of how well features are predicted) for each layer and used k-means clustering to group features with similar representation patterns across layers.
  3. Incorporating Context (Experiment 1b): To explore the impact of context, they moved beyond random sentence sampling. For Experiment 1b, they hand-selected sentences that best matched the word-sense inferred from the Binder feature scores. This aimed to reduce noise from irrelevant word senses and improve performance.
  4. Predicting Contextualized Features (Experiment 2): For a more direct test of contextualized features, they used a dataset of property-object word pairs (Van Dantzig et al., 2011). They extracted embeddings for the property word in its specific context (paired with an object) and trained a neural network to predict five semantic features. This was compared to using averaged embeddings across different contexts for the same property word.
  5. Indirect Evaluation via Word Sense Disambiguation (WSD) (Experiment 3): Lacking a ground-truth dataset for contextualized Binder features, they used the WSD task as an indirect evaluation. They predicted Binder features for words in context pairs from the WiC dataset and then used these derived embeddings to predict word senses. The performance was compared to raw BERT embeddings.

Datasets

  • Binder et al. (2016) dataset: This dataset contains scores for 535 words across 65 core semantic features, derived from human participants. This is the primary dataset for deriving and evaluating Binder features.
  • One Billion Word Benchmark (BWB): Used to source random sentences for extracting BERT embeddings in Experiments 1a and 1b.
  • Van Dantzig et al. (2011) dataset: A dataset of 774 property-object word pairs, each with human-annotated scores for five semantic features (Visual, Auditory, Haptic, Gustatory, Olfactory). Used in Experiment 2 to derive contextualized features.
  • Word in Context (WiC) dataset: A dataset for Word Sense Disambiguation (WSD), used in Experiment 3 for indirect evaluation of contextualized Binder embeddings.

Key Insights and Ideas

  • BERT Embeddings Encode Binder Features: The research successfully demonstrates that interpretable Binder semantic features can be derived directly from BERT's embedding space, outperforming static embeddings like Numberbatch. This suggests BERT captures rich semantic information that aligns with human-defined features.
  • Semantic Information Evolves Across BERT Layers: Semantic features are not uniformly distributed across BERT's layers. While later layers generally perform better, certain features show peaks in earlier or middle layers, indicating a hierarchical processing of semantic information.
  • Context Matters (Even Implicitly): Hand-selecting sentences that match a word's inferred sense (Experiment 1b) significantly improved the prediction of Binder features compared to random sampling. This highlights that even without explicit contextual labels, BERT's embeddings capture some degree of context.
  • Contextualized Embeddings Outperform Static Ones for Specific Features: In Experiment 2, embeddings derived from specific word-pair contexts outperformed averaged (static) embeddings when predicting semantic features, demonstrating BERT's ability to capture context-specific semantic nuances.
  • Binder Features Offer Interpretability for WSD: The derived Binder embeddings performed comparably to raw BERT embeddings on the Word Sense Disambiguation task, suggesting that these interpretable features can be useful for downstream NLP tasks.

Key Results

  • Experiment 1a (Static): BERT and other transformer models significantly outperformed the Numberbatch baseline in deriving Binder features (p<0.05). BERTBASE achieved the best single-layer performance.
  • Experiment 1b (Contextualized Sentences): Using hand-selected sentences improved performance across all models compared to Experiment 1a.
  • Experiment 2 (Contextualized Pairs): Contextualized property embeddings significantly outperformed property-mean (static) embeddings for predicting the five semantic features. BERT LARGE achieved the highest mean R-squared score (0.729).
  • Experiment 3 (WSD): Derived Binder embeddings (from Experiments 1a and 1b) performed comparably to raw BERT embeddings on the WiC dataset, achieving accuracy and F1 scores around 0.67 and 0.71 respectively. The five-feature Van Dantzig embeddings performed worst.

Limitations and Future Work

  • Binder Dataset Limitations: The Binder dataset, while valuable, has a limited vocabulary (535 words) and lacks explicit contextual information for its word scores. This limits the ability to fully test contextualized embeddings.
  • Ground Truth for Contextualized Features: The paper acknowledges the absence of a ground-truth dataset for contextualized Binder features. Experiment 3 used WSD as an indirect measure, but a direct evaluation would be ideal.
  • Future Work:
    • Creating Contextualized Binder Datasets: The authors suggest that producing a Binder-style feature set for words explicitly in context would be a crucial next step for a definitive ground-truth test.
  • Domain-Specific Features: For applications in specific domains, researchers may need to construct domain-specific feature sets and vocabularies.
  • Fine-tuning for Prediction: Further improvements in predictive power might be possible by fine-tuning transformer models directly on the Binder feature prediction task, rather than just using extracted embeddings.
  • Improving Interpretability: The work highlights the potential of using psychological research to improve the understanding and interpretability of deep learning models.

Summary updated

BibTeX
@inproceedings{turton2021deriving,
  author = {Jacob Turton and Robert Elliott Smith and David Vinson},
  title = {{Deriving Contextualised Semantic Features from BERT (and Other Transformer Model) Embeddings}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
}
Figure