Improving Contextual Representation with Gloss Regularized Pre-training

Yu Lin, Zhecheng An, Peihao Wu, Zejun MaNAACL 2022

Abstract

Traditional pre-training objectives like Masked Language Modeling (MLM) often fail to capture the fine-grained semantic relationship between a word and its specific context. This paper introduces Gloss Regularized BERT (GR-BERT), which leverages dictionary definitions (glosses) as semantic anchors. By aligning contextual embeddings with human-annotated definitions, GR-BERT bridges the gap between pre-training and inference. The model achieves state-of-the-art results in lexical substitution and significant improvements in sentence similarity tasks, effectively addressing the "anisotropy" problem in BERT's embedding space.

Introduction: The MLM Discrepancy

The standard training paradigm for models like BERT relies on Masked Language Modeling (MLM), where a model predicts a hidden word based on its surrounding context. While effective, this approach suffers from a fundamental discrepancy: during pre-training, the model only sees the masked context, whereas during inference, it processes the full context, including the target word itself.

This discrepancy leads to a neglect of contextual word similarity. For instance, in the sentence "Tom is a [bad] guy," an ideal model should recognize that "bad" is semantically similar to "dangerous" or "nasty" in this specific environment. However, standard BERT often "hallucinates" inappropriate proposals like "good" because it hasn't explicitly learned to model the Pointwise Mutual Information (PMI) between the target word and its synonyms within that context. Mathematically, the authors argue that BERT fails to capture the specific semantic bond between words in a given environment, leading to a representation space that is "anisotropic"—where embeddings cluster in a narrow cone, degrading performance on downstream tasks.

Figure 3: Comparison of probability distributions for masked context (a), ideal contextual similarity (b), and standard BERT's full-context prediction (c).

Methodology: Gloss Regularized Pre-training

To address these limitations, the authors propose Gloss Regularized Pre-training (GR-BERT). The core innovation is the introduction of an auxiliary Gloss Matching task that uses dictionary definitions to ground the model's internal representations.

The Gloss Regularizer

The model is trained to ensure that the contextual embedding of a word ($h$) is mathematically close to the embedding of its dictionary definition ($e_t$), known as a "gloss." A separate Gloss Encoder processes these definitions into "gloss vectors," which serve as semantic anchors for the main model. This alignment forces the model to ground its learned semantics in human-annotated truth.

Model Architectures

The authors explore two primary architectures for implementing this regularization:

  1. Multi-Task (MT) Model: A single context encoder performs both the standard MLM task and the new Gloss Matching task simultaneously using a joint loss function.
  2. Separate Context Encoder (SC) Model: This more advanced variant uses two distinct encoders—one for the masked context and one for the full context. By calculating the difference between the masked context representation ($h_c^{(1)}$) and the full context representation ($h_s^{(2)}$), the model explicitly models the PMI term, mirroring the theoretical decomposition of word probability in context.
Figure 5: The framework of Gloss Regularized BERT (a) and the loss function configurations for the MT and SC models (b).

Key Results and Insights

GR-BERT demonstrates significant improvements across several natural language understanding tasks:

  • Lexical Substitution (LS): On the LS14 (CoInCo) dataset, GR-BERT improved the "best" replacement score significantly. When combined with standard post-processing techniques, it reached a new state-of-the-art score of 15.2.
  • Sentence Textual Similarity (STS): One of the most striking results is in unsupervised sentence similarity. GR-BERT improved the average Spearman correlation from 56.70 to 65.75 for BERT-base and from 56.57 to 67.47 for RoBERTa-base. This suggests that gloss regularization effectively spreads out embeddings, making them much more effective for sentence-level comparisons.
  • Data Efficiency: In supervised settings with limited training data (20%), GR-BERT outperformed standard BERT by 3.44 points, highlighting the value of semantic regularization when task-specific data is scarce.

Conclusion

By incorporating dictionary definitions as semantic anchors, GR-BERT successfully bridges the gap between masked pre-training and full-context inference. The model's ability to capture contextual word similarity leads to superior performance in lexical substitution and sentence-level tasks. While limited by current dictionary coverage, the approach offers a promising path toward more grounded and meaningful contextual representations. Future work will focus on scaling the word-gloss dataset and expanding the approach to a broader range of NLP applications.

Summary updated

BibTeX
@inproceedings{lin2022improving,
  author = {Yu Lin and Zhecheng An and Peihao Wu and Zejun Ma},
  title = {{Improving Contextual Representation with Gloss Regularized Pre-training}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.findings-naacl.68},
}
Figure