Time Masking for Temporal Language Models

Guy D. Rosin, Ido Guy, Kira Radinsky · OpenReview

TL;DR

This paper introduces TempoBERT, a novel temporal language model that incorporates time as an explicit context. By "time masking" during pre-training, TempoBERT learns to understand how language evolves, significantly improving performance on tasks like detecting semantic change in words and predicting the time a sentence was written.

What Problem Does This Paper Address?

Modern language models (LMs) like BERT are incredibly powerful, but they're trained on static snapshots of text. This means they struggle to keep up with the dynamic nature of language, which constantly evolves with our world. For instance, the meaning of words can shift over time, and understanding when a piece of text was written is crucial for many applications, from historical analysis to information retrieval. Existing LMs can't inherently adapt to these temporal changes, leading to a gap in their ability to truly understand and process evolving language.

Methods

The core innovation is time masking, a technique applied during the pre-training of language models. Instead of just masking words, TempoBERT prepends a special "time token" (e.g., <2021>) to each input sequence. This explicitly injects temporal information into the model's context.

The key aspects are:

  • Temporal Contextualization: Time tokens are added to the vocabulary and prepended to sentences. This allows the model to learn word representations that are sensitive to the specific time period.
  • Time Masking: During pre-training, the model is trained to predict these time tokens. This is done either as part of the standard Masked Language Model (MLM) objective or through a dedicated time masking process. This dedicated process involves masking time tokens with a specific probability, replacing them with a mask token, a random time token, or keeping them unchanged, allowing the model to learn temporal relationships more effectively.
  • Model Agnostic: This modification is applied to the input representation, making it compatible with existing transformer-based LMs like BERT without requiring architectural changes.

TempoBERT is then evaluated on two tasks:

  1. Semantic Change Detection: Identifying how word meanings evolve over time.
  2. Sentence Time Prediction: Predicting the time period a sentence was written.

Datasets

The paper uses several datasets for evaluation:

  • Semantic Change Detection:
    • LiverpoolFC Corpus: Reddit posts from the Liverpool Football Club subreddit, split into two short-term periods (2011-2013 and 2017). This dataset includes manually annotated semantic shift labels.
  • SemEval-2020 Task 1 Corpora: Datasets in English and Latin, covering long-term semantic change over centuries or millennia. These also include graded labels for semantic change.
  • Sentence Time Prediction:
    • New York Times Archive: A large corpus of New York Times articles from 1981 to 2020. This was used in two variants:
  • NYT-decades: Sentences grouped by decade (4 classes).
  • NYT-years: Sentences grouped by individual year (40 classes).

Key Insights and Ideas

  • Time is a Crucial Context: The paper strongly argues that time is a fundamental aspect of language understanding, not just an afterthought. Static LMs miss out on this vital dimension.
  • Simple Modification, Big Impact: Prepending a time token and using time masking is a surprisingly effective way to imbue LMs with temporal awareness without complex architectural changes.
  • Short-Term vs. Long-Term Change: TempoBERT excels at detecting short-term semantic shifts because its time-prediction capabilities are strong. For long-term changes, where writing styles differ drastically, the temporal signal might be less critical than the stylistic differences themselves.
  • Time Masking as Supervision: For sentence time prediction, time masking acts as a form of implicit supervision, allowing the model to learn temporal cues directly from the text content.
  • Efficiency of Temporal Models: The paper demonstrates that even smaller versions of TempoBERT (TempoBERT-tiny) can outperform larger, non-temporal baselines, suggesting that temporal understanding doesn't necessarily require massive model sizes.

Key Results

  • Semantic Change Detection: TempoBERT achieved state-of-the-art performance on the LiverpoolFC dataset, with a Pearson correlation of 0.637 (compared to ~0.490 for baselines). It also showed strong performance on the SemEval datasets, outperforming most baselines.
  • Sentence Time Prediction: TempoBERT significantly outperformed baseline methods on both NYT-decades (accuracy 52.71% vs. ~47% for best baseline) and NYT-years (accuracy 9.24% vs. ~6.5% for best baseline) datasets.
  • Time Masking Effectiveness: Experiments showed that increasing time masking probability generally improved performance for both tasks, with custom time masking outperforming standard MLM integration.
  • Model Size: TempoBERT-tiny, a smaller version, still outperformed strong baselines on the LiverpoolFC dataset, indicating efficiency in capturing temporal information.

Limitations and Future Work

  • Short-Term vs. Long-Term: While TempoBERT excels at short-term semantic change, its advantage diminishes for long-term changes where stylistic differences are more dominant. Future work could explore ways to better disentangle stylistic and semantic changes.
  • False Negatives in Semantic Change: The paper notes that while TempoBERT successfully detects changed words, it still struggles with accurately identifying unchanged words (i.e., fewer false negatives are desired).
  • Computational Resources: Experiments were limited by computational resources, particularly for time masking probability tuning.
  • Future Work: The authors suggest exploring different time granularities, investigating the impact of time masking on other NLP tasks, and further analyzing the trade-offs between model size and temporal understanding.

Summary updated

BibTeX
@inproceedings{rosin2022time,
  author = {Guy D. Rosin and Ido Guy and Kira Radinsky},
  title = {{Time Masking for Temporal Language Models}},
  booktitle = {WSDM},
  year = {2022},
  doi = {10.1145/3488560.3498529},
}
Figure