Zubnet AIApprendreWiki › Masked Language Modeling
Training

Masked Language Modeling

MLM, Masked LM, Cloze Task
Un objectif d'entraînement auto-supervisé où des tokens aléatoires dans l'entrée sont remplacés par un token [MASK], et le modèle doit prédire les tokens originaux à partir du contexte. BERT a popularisé le MLM : masquer 15 % des tokens, utiliser l'attention bidirectionnelle pour regarder le contexte gauche et droit, et prédire les mots masqués. Ça crée des modèles puissants de compréhension de texte (par opposition aux modèles de génération de texte).

Pourquoi c'est important

Le MLM est l'objectif d'entraînement qui a créé BERT et toute la famille de modèles encoder qui alimentent encore la plupart des systèmes de recherche, classification et embedding en production. Comprendre le MLM vs. le causal language modeling (prédiction du prochain token) explique la division fondamentale entre les modèles de compréhension (BERT) et les modèles de génération (GPT) — et pourquoi chacun excelle à des tâches différentes.

Deep Dive

The process: take a text sequence, randomly select 15% of positions. For those positions: 80% are replaced with [MASK], 10% are replaced with a random token, 10% are kept unchanged. The model must predict the original token at each selected position. The 80/10/10 split prevents the model from learning to only pay attention to [MASK] tokens, which don't appear during actual use.

Bidirectional Context

The key advantage of MLM over causal LM: the model sees both left and right context when making predictions. For the sentence "The [MASK] sat on the mat," the model uses both "The" (left context) and "sat on the mat" (right context) to predict "cat." This bidirectional understanding is why BERT-style models produce richer representations than left-to-right models for understanding tasks.

MLM vs. Causal LM

The trade-off: MLM creates excellent understanding (good for classification, search, NER) but can't generate text fluently (predicting masked tokens isn't the same as generating a sequence). Causal LM (predict the next token left-to-right) generates fluently but understands less deeply (only sees left context). This split drove the encoder-vs-decoder divergence in NLP. Modern LLMs are all causal (decoder-only) because generation is more commercially valuable, but MLM-trained models remain the backbone of search and classification.

Concepts liés

← Tous les termes
← Mamba MCP →