ElemedexA pocket encyclopedia of AI architectures

Glossary (TM) › Language and language models

TM060

Masked language modeling

Also: MLM, cloze objective

In Spanish: Modelado de lenguaje enmascarado

A pretraining task in which some words of a text are hidden and the model must reconstruct them from the context on both sides.

In masked modeling, one takes a sentence, covers some of its tokens, and asks the model to guess them. Nobody grades the answers: the correct one is already in the original text, which is why this counts as self-supervised learning. BERT hid 15% of the tokens, usually replacing them with a special [MASK] symbol (Devlin et al., 2019, p. 4174).

The cat [MASK] on the mat. → sat (high probability), slept, lay…

Unlike next-token prediction, which only lets the model look to the left, masking lets every position use the whole context, left and right. That yields better representations for classification or search, but a model trained this way cannot write fluently: it did not learn to continue a text, only to repair gaps (Alammar & Grootendorst, 2024, p. 19).

The idea has an explicit human precedent: the cloze test, used in the psychology of reading since the 1950s to measure comprehension by restoring deleted words (Taylor, 1953). That the same task serves both to assess readers and to train machines invites the question of what it actually measures: comprehension, or command of the distributional regularities of words?

Sources

  • Alammar, J., & Grootendorst, M. (2024). Hands-on large language models: Language understanding and generation. O’Reilly Media. §
  • Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019). BERT: Pre-training of deep bidirectional transformers for language understanding. In J. Burstein, C. Doran, & T. Solorio (Eds.), Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers) (pp. 4171–4186). Association for Computational Linguistics. https://doi.org/10.18653/v1/N19-1423 §
  • Taylor, W. L. (1953). “Cloze procedure”: A new tool for measuring readability. Journalism Quarterly, 30(4), 415–433. https://doi.org/10.1177/107769905303000401 §