Dynamic Contextualized Word Embeddings

Valentin Hofmann, Janet B. Pierrehumbert, Hinrich Schütze

Abstract

Traditional word embeddings often fail to capture how meanings shift across different social groups and over time. This paper introduces Dynamic Contextualized Word Embeddings (DCWE), a framework that jointly models linguistic, social, and temporal contexts. By building upon pretrained language models like BERT and incorporating social graph information and temporal priors, DCWE provides a more nuanced representation of language. Our evaluation across four diverse datasets demonstrates that DCWE outperforms standard contextualized models in language modeling and sentiment analysis, while offering unique insights into the diffusion of semantic changes through social networks.

Introduction

Natural language processing has evolved from static word vectors to contextualized embeddings that handle polysemy. However, a significant challenge remains: word meanings are not only dependent on their immediate linguistic context but also vary across social communities and evolve over time. Existing "dynamic" models often lack the sentence-level granularity of models like BERT, while standard contextualized models are typically "blind" to the social and temporal metadata of the speaker. DCWE bridges this gap by integrating extralinguistic context directly into the embedding process.

Methodology

The DCWE framework extends Pretrained Language Models (PLMs) by redefining the input representation. Instead of a static lookup, a word's embedding is calculated as a function of the word itself, its social context ($s_i$), and its temporal context ($t_j$).

The DCWE architecture integrates social ($s_i$) and temporal ($t_j$) contexts into word embeddings before processing by BERT.

The core components include:

  • Vector Offsets: The model adds a dynamic "offset" to the base word embedding, capturing shifts specific to the time and social group.
  • Social Modeling: A Graph Attention Network (GAT) encodes social structures, learning representations for users or communities based on their interaction history.
  • Temporal Smoothness: An Ornstein-Uhlenbeck process acts as a random walk prior, ensuring that semantic shifts are modeled as gradual evolutions rather than abrupt jumps.
  • Two-Stage Processing: The dynamic embedding is computed first and then fed into BERT, mirroring cognitive theories that suggest extralinguistic information is processed early in language comprehension.

Datasets and Evaluation

The authors evaluate DCWE on four datasets:

  1. ArXiv (2001–2020): Scientific abstracts categorized by subject classes.
  2. Ciao (2000–2011): Product reviews with explicit trust networks.
  3. Reddit (2019–2020): Pandemic-era comments across various subreddits.
  4. YELP (2010–2019): Business reviews with friendship links.

Results and Discussion

DCWE consistently achieved lower perplexity in language modeling tasks compared to standard BERT-based models. In sentiment analysis, it provided statistically significant improvements in F1 scores on the Ciao and YELP datasets.

Beyond performance metrics, DCWE enables the visualization of semantic diffusion. The model distinguishes between two primary modes of change:

  • Random Walks: Gradual spread through social contact (e.g., technical terms in ArXiv).
  • Random Flights: Rapid, simultaneous shifts across the entire network due to external events (e.g., medical terms during the Covid-19 pandemic).
Semantic diffusion maps showing the spread of "network/learning" in ArXiv (top) and "mask/vaccine" in Reddit (bottom).

Conclusion and Limitations

DCWE represents a significant step toward socially and temporally aware NLP. While the model is computationally intensive and requires pre-defined social graphs, it successfully captures the "tightly interwoven" nature of time and social space in language change. Future work includes scaling the dynamic priors to larger vocabularies and applying the framework to downstream tasks like detecting emerging subcultures.

Summary updated

BibTeX
@inproceedings{hofmann2021dynamic,
  author = {Valentin Hofmann and Janet B. Pierrehumbert and Hinrich Schütze},
  title = {{Dynamic Contextualized Word Embeddings}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-long.542},
}
Figure