Masked language modelling (MLM)
Masked language modelling is a pre-training task in which some words in a passage are hidden and the model learns to predict them from the words on both sides.
Take a sentence, hide some of its words behind a special mask token and ask the model to fill in the blanks. That is masked language modelling. Because the missing word can be guessed from the words before it and after it, the model learns to use the whole passage at once. Hugging Face's documentation gives a simple example: asked to complete The Milky Way is a <mask> galaxy, a model trained this way ranks spiral as the most likely answer.
The method became famous with BERT, a Google model described in a paper first posted in October 2018. BERT hid 15% of the word pieces in each training sequence at random. Of those, 80% were replaced with the mask token, 10% with a random word and 10% were left unchanged, because the mask token never appears when the model is later fine-tuned for real tasks. The authors credited the idea to the Cloze task, a fill-in-the-blank reading test described by Wilson Taylor in 1953. BERT was pre-trained this way on BooksCorpus (800 million words) and English Wikipedia (2,500 million words), alongside a second task of predicting whether one sentence follows another.
The contrast is with next-token prediction, the objective behind GPT and today's chatbots, where the model reads left to right and predicts what comes next. That makes generating text natural. A masked model looks both ways, which suits tasks that need an understanding of a whole passage, such as classifying it, matching it against a search query or pulling facts out of it, but it is not built to write long text one word after another.
In practice, masked language modelling lives on in encoder models such as BERT and its many descendants, which sit quietly inside search engines, document classifiers and embedding systems. When a news story says a chatbot was pre-trained on trillions of tokens, it is describing next-token prediction; when it describes a BERT-style model, it is usually this.
Masked language modelling hides words in the middle of a passage and lets the model use context on both sides to recover them. Next-token prediction lets the model see only the words so far and asks it to predict the next one, which is how generative models such as GPT are trained. That was the rate the BERT authors used in all their experiments. Of the chosen positions, 80% get the mask token, 10% a random token and 10% stay unchanged, so the model does not learn to rely on a mask symbol that never appears during fine-tuning. It can fill in blanks, but it is not designed to write long passages word by word. Text generation is the job of causal, left-to-right models; masked models are mainly used to understand and represent text for search, classification and extraction. Yes. The training labels are the hidden words themselves, so no one has to annotate the data, which is what allowed BERT to be pre-trained on billions of words of ordinary text.Common questions
What is the difference between masked language modelling and next-token prediction?
Why does BERT mask 15% of tokens?
Can a masked language model generate text?
Is masked language modelling self-supervised?
Search for "masked language modeling", "BERT pre-training objective" or "MLM vs causal language modeling" to see how the objective works and where it is used. Reliable sources include the original BERT paper on arXiv, the Hugging Face documentation for fill-mask and masked language modelling tasks, and university course notes on natural language processing. Blog posts often blur encoder and decoder models, so check which objective a model was actually trained with in its paper or model card.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.