Span Masking
Mask one token in "New [MASK] City" and the model barely has to think — the neighbours give it away. Span masking closes that shortcut by hiding several adjacent tokens at once, so a whole phrase has to be recovered from what sits outside it.
How it changes the objective
The pre-training task samples contiguous stretches of text rather than scattered single tokens, and two well-known variants show what that buys:
- Spans are sampled with their lengths drawn from a skewed distribution, so short spans are common and long ones rare.
- SpanBERT adds a span-boundary objective: each hidden token must also be predicted from the representations of the two tokens flanking the span, forcing those boundary states to summarise everything between them.
- T5 takes the text-to-text route — each masked span is replaced by a single sentinel token in the input and the decoder generates the missing pieces in order.
What it buys
Whole-word and entity-level masking were earlier steps in the same direction, and the pattern holds: the harder the reconstruction, the more the encoder is forced to represent. The gains show up precisely where spans matter — extractive question answering on SQuAD, coreference resolution, relation extraction.
Why it matters
The pre-training objective is the only lever that shapes what a model learns from unlabelled text, and an easy objective yields a thin representation. Standard token masking lets a model lean on local morphology and collocation; span masking removes that crutch and makes it use longer-range context. Choosing it is a bet about downstream work: if the task extracts or links multi-token expressions, pre-train with the objective that practised rebuilding them.
Span masking is a pre-training objective that hides a contiguous run of tokens — a whole phrase rather than scattered single tokens — and trains the model to reconstruct it from the surrounding text. Independent token masking leaves shortcuts: fragments of the same word or phrase remain visible. Removing the whole span forces reliance on wider context. It drives SpanBERT and T5, and transfers better to span-level tasks such as extractive question answering and coreference resolution.
Think of a reading exercise where words are blanked out. If single letters are hidden, you can guess them from the rest of the word without understanding anything. Blank out a whole phrase and you have to follow the passage to fill it in.
Span masking trains language software with the harder version of that exercise. Rather than hiding scattered single words, it hides a short run of consecutive words and asks the model to restore all of them from what surrounds the gap. The payoff shows up later: a model trained this way is better at questions whose answer is a phrase, not just a single word.