Masked language modeling is a self-supervised objective that removes tokens from an input sequence and trains a model to predict them. BERT applies this Cloze-style task by randomly masking 15% of sentence tokens, using surrounding context through attention. The prediction loss rewards successful reconstruction and produces embeddings that represent words together with their contexts. section 13.3.1
A typical processing sequence is:
- Tokenize text into vocabulary word pieces, including special markers such as [CLS] and [SEP]. section 13.3.1
- Randomly remove 15% of the tokens to create the prediction test. section 13.3.1
- Use surrounding tokens and attention to predict the missing content, optimizing the prediction loss. section 13.3.1
Tokenization example
The term “It’s” can become the word pieces “it”, “'”, and “s” before entering the masked-language-modeling pipeline. section 13.3.1
Figure 13.4 The Transformer encoder
Trace the Transformer encoder that converts tokenized text into contextual representations. section 13.3.1

