ExLM: Rethinking the Impact of $\texttt{[MASK]}$ Tokens in Masked Language Models

Kangjie Zheng, Junwei Yang, Siyue Liang, Bin Feng, Zequn Liu, Wei Ju, Zhiping Xiao, Ming Zhang

Abstract

Masked Language Models (MLMs) like BERT are foundational to modern NLP but face a fundamental limitation: "corrupted semantics." When tokens are masked, the underlying meaning of a sentence becomes ambiguous, forcing the model to predict from independent, often conflicting possibilities. This paper introduces ExLM (Enhanced-context MLM), which addresses this by expanding hidden states and using a Directed Acyclic Graph (DAG) to capture inter-token dependencies. Our experiments demonstrate that semantic corruption, rather than the presence of "unreal" [MASK] tokens, is the primary performance bottleneck. ExLM achieves state-of-the-art results on the GLUE benchmark and molecular property prediction tasks, offering a more parameter-efficient approach to sequence modeling.

Identifying the Bottleneck: Unreal Tokens vs. Corrupted Semantics

Masked Language Models are typically trained by replacing a percentage of input tokens with a special [MASK] symbol. This process introduces two distinct problems:

  1. Unreal Tokens: The model encounters [MASK] tokens during pre-training that never appear during real-world fine-tuning.
  2. Corrupted Semantics: Masking destroys the underlying meaning of the context. For example, in "I am very [MASK]", the missing word could be "happy" or "sad," creating semantic multimodality.

While previous research (like ELECTRA) focused on fixing the "unreal token" problem, this paper discovers that corrupted semantics is the true bottleneck. To prove this, the authors designed a "Repeated MLM" experiment. By repeating every token in the input $k$ times before masking, they ensured that even with a high mask ratio, the semantics of the sentence were preserved because a copy of the word usually survived elsewhere in the sequence.

Extracted figure from page 2 of ExLM: Rethinking the Impact of [MASK] Tokens in Masked Language Models

The ExLM Architecture

To solve the corrupted semantics problem, the authors propose ExLM (Enhanced-context MLM). Unlike standard MLMs that generate one hidden state per [MASK], ExLM generates $k$ multiple hidden states (clones) for each mask. This allows the model to simultaneously entertain different semantic branches.

Key architectural innovations include:

  • States Expansion & 2D RoPE: Multiple hidden states are generated for each mask, distinguished by a 2D Rotary Position Embedding (RoPE).
  • Dependency Capture via DAG: The model uses a transition matrix to build a Directed Acyclic Graph (DAG) among the expanded states. This explicitly models how the choice of one missing word affects another (e.g., if one mask is "awful," a subsequent mask is more likely to be "sorry").
  • State Alignment: A CUDA-accelerated Dynamic Programming algorithm is used during pre-training to map expanded states to target tokens.
Comparison between standard MLM, where masked tokens are predicted independently, and ExLM, which captures inter-token dependencies using a transition matrix.

Key Results and Insights

ExLM was evaluated across two distinct domains: textual representation (GLUE, SQuAD 2.0) and molecular representation (SMILES/MoleculeNet).

  • Textual Performance: ExLM achieved an average GLUE score of 86.2, significantly outperforming BERT (83.1) and RoBERTa (85.2) when trained on the same data. It also reached 84.6 F1 on SQuAD 2.0.
  • Molecular Modeling: On the MoleculeNet benchmark, ExLM averaged a 76.1 ROC-AUC, beating standard SMILES-BERT models and remaining competitive with specialized 3D molecular models.
  • Efficiency and Confidence: While ExLM has a 1.9x training overhead due to DAG computations, it is far more parameter-efficient than vanilla MLMs. Entropy analysis shows that ExLM's predictions are significantly more confident when faced with ambiguous, heavily masked text.

Conclusion and Future Work

ExLM demonstrates that the primary weakness of MLMs is not the presence of artificial tokens, but the loss of semantic context during masking. By treating expanded states as a "semantic buffer" and modeling dependencies, ExLM effectively manages ambiguity. Future work may extend this approach to other sequence-based fields such as protein design, recommendation systems, and computer vision.

Summary updated

BibTeX
@inproceedings{zheng2025exlm,
  author = {Kangjie Zheng and Junwei Yang and Siyue Liang and Bin Feng and Zequn Liu and Wei Ju and Zhiping Xiao and Ming Zhang},
  title = {{ExLM: Rethinking the Impact of $\textbackslash\{\}texttt\{[MASK]\}$ Tokens in Masked Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=IYOPfJwduh},
}
Figure