Contextual Representation Learning beyond Masked Language Modeling

Zhiyi Fu, Wangchunshu Zhou, Jingjing Xu, Hao Zhou, Lei Li

Abstract

While Masked Language Modeling (MLM) has established itself as the standard for pre-training transformer-based encoders like BERT, it is constrained by a reliance on "local anchors"—the specific tokens selected for masking. This dependency often results in slow convergence and a susceptibility to embedding bias. This paper introduces TACO (Token-Alignment Contrastive Objective), a novel pre-training approach that encourages all tokens within a sequence to align with a shared global semantic signal. By integrating this global objective with traditional MLM, TACO achieves up to a 5x speedup in pre-training efficiency and improves average GLUE scores by up to 1.2 points.

Introduction

The success of models like BERT is largely attributed to the MLM objective, where models learn to predict missing tokens based on their surrounding context. However, this process has a fundamental efficiency bottleneck: the model only learns contextualized representations by aligning them with the static embeddings of the few tokens that happen to be masked in a given pass.

The authors identify two primary limitations in this paradigm:

  1. Embedding Bias: Because MLM uses static embeddings as anchors, the quality of early-stage learning is heavily dependent on the quality of initial embeddings. If the initial embeddings for semantically related words are distant, the model struggles to bridge their contextual relationship.
  2. Lack of Global Cohesion: When multiple words are masked, the model attempts to push surrounding tokens toward different local anchors. This can fragment the global meaning of the sentence and cause the model to overlook broader semantic dependencies.

Methodology: The TACO Objective

To address these issues, the authors propose TACO, which introduces a Token-alignment Contrastive Objective to complement the standard MLM loss. The core innovation lies in how TACO isolates and aligns "global semantics."

For any given token, its contextualized representation ($h_i$) can be viewed as the sum of its static embedding ($e_i$) and the information gained from the rest of the sentence. The authors define this "global bias" ($g_i$) as:

$$g_i = h_i - e_i$$

TACO utilizes a contrastive learning framework (specifically the InfoNCE loss) to align these global biases across the sequence:

  • Positive Pairs: Tokens within the same text span (e.g., within a window of 5 tokens) are encouraged to exhibit similar global biases.
  • Negative Pairs: Tokens from different sequences within the same batch are pushed apart in the representation space.

By minimizing this loss alongside MLM, the model ensures that every token—not just those that are masked—contributes to and reflects a consistent global semantic signal.

Experimental Setup

The models were pre-trained on standard large-scale corpora, including BooksCorpus (800M words) and English Wikipedia (4B words). Evaluation was conducted using the GLUE (General Language Understanding Evaluation) benchmark, covering tasks such as sentiment analysis (SST-2), linguistic acceptability (CoLA), and natural language inference (MNLI, QNLI, RTE).

Key Results and Discussion

Efficiency and Performance

TACO demonstrates significant improvements in both training speed and downstream performance:

  • Massive Speedup: On the BERT-small architecture, TACO reached the performance level of a 250k-step MLM baseline in just 50k steps—a 5x speedup.
  • GLUE Improvements: BERT-small saw an average GLUE score increase of 1.2 points, while BERT-base achieved a 2x speedup and a 0.9 point improvement.
  • Data Efficiency: Models trained with TACO using only 25% of the available data outperformed MLM models trained on the full 100% dataset across several tasks.

Robustness to Embedding Bias

The authors found that MLM's contextual score (the gap between intra-sentence and inter-sentence similarity) stagnates during the first 5,000 steps of training because random initial embeddings provide poor anchors. TACO bypasses this "cold start" problem by forcing global alignment from the first step. Furthermore, TACO proved less sensitive to embedding quality, maintaining high performance even when initial embeddings were frozen.

Conclusion and Future Work

TACO provides a simple, "plug-and-play" auxiliary loss that significantly enhances the efficiency of contextual representation learning. By shifting the focus from local anchors to global semantic alignment, it mitigates the biases inherent in standard MLM.

While highly effective for encoder-only models, future research is required to determine TACO's impact on decoder-only (GPT-style) or encoder-decoder (T5-style) architectures. Additionally, while the $h - e$ subtraction is an effective probing method for isolating context, more sophisticated extraction techniques may further refine the global semantic signal.

Summary updated

BibTeX
@inproceedings{fu2022contextual,
  author = {Zhiyi Fu and Wangchunshu Zhou and Jingjing Xu and Hao Zhou and Lei Li},
  title = {{Contextual Representation Learning beyond Masked Language Modeling}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.193},
}
Figure