Whole Word Masking › The Subword Masking Problem
Language AI HandbookAll chapters Whole Word Masking › The Subword Masking ProblemOne section · Sections in this chapter2 / 13 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Modern language models use subword tokenization to handle vocabulary efficiently. Algorithms like WordPiece and BPE, along with SentencePiece, break words into smaller units based on frequency or likelihood, balancing vocabulary size against the ability to represent any input without unknown-token fallbacks. Common words like "the", "is", and "run" remain intact as single tokens. Moderate-frequency words decompose into recognizable pieces: "transformation" becomes ["transform", "##ation"]. Rare or highly specific words may split into many fragments: "photosynthetically" might become four or five subword pieces.
This design is essential for handling open vocabularies and morphologically diverse text. A fixed-word vocabulary of 30,000 entries would fail on technical jargon, proper nouns, or even common words in inflected forms. Subword tokenization sidesteps this problem elegantly. But subword tokenization interacts badly with random masking because it creates a fundamental asymmetry between single-token and multi-token words.
Think of it as two different exam questions for the same concept. The first question shows you a word with the last three letters blanked out: "transfor___". The second question hides the entire word: "The _________ was complete." Both questions test knowledge about the same word, but they test very different things. The first tests your knowledge of English morphology, the second tests your understanding of the sentence's meaning. When you train BERT with random subword masking, a significant fraction of the "questions" the model faces are of the first type: morphology lookups rather than semantic reasoning.
This decomposition creates an asymmetry in the masking process. When we randomly select 15% of tokens for masking, we are selecting subword tokens, not words. A multi-token word might have some subwords masked while others remain visible. The visible subwords leak information about the masked ones. The degree of leakage depends on how much information a prefix or suffix carries about the rest of the word, and for many common English morphological patterns, this information is substantial.
Why Partial Masking Weakens Learning
Consider how BERT processes the sentence "The transformation was remarkable." Using WordPiece tokenization:
["The", "transform", "##ation", "was", "remark", "##able", "."]
If random masking selects only "##ation", the input becomes:
["The", "transform", "[MASK]", "was", "remark", "##able", "."]
The model sees "transform" immediately adjacent to the mask. How many English words start with "transform-"? Only a handful: transformation, transformed, transforming, transformer. The prediction task collapses from choosing among 30,000 vocabulary items to distinguishing between 3-4 suffixes. With a bit of context bias (this is probably a noun form given the sentence structure), the model can essentially narrow it down to one answer without consulting the rest of the sentence at all.
This is problematic for several reasons:
-
Weak learning signal: The model learns to pattern-match subword combinations rather than understand context deeply. It does not need to reason about meaning, just morphology. Gradient updates during backpropagation reflect this: they encode "##ation follows transform-" rather than "this word fits here because of its semantic role."
-
Uneven difficulty: Single-token words like "was" face the full prediction challenge when masked, while multi-token words get easy hints. The model develops uneven representations, with single-token words anchored more firmly in their semantic contexts and multi-token words understood more through their morphological structure.
-
Distributional mismatch: During fine-tuning, the model sees complete words. Pre-training on partial words creates a subtle distribution shift. The model has learned to rely on subword co-occurrence statistics that simply do not apply during inference, where every word appears complete.
-
Gradient dilution across multi-token words: When only one subword of a word is masked, only that subword's prediction contributes to the loss. The model updates its parameters based on a small, easy prediction, rather than the harder full-word prediction that would produce richer gradient signal.
The problem compounds across training. Early in training, the model might struggle with suffix prediction. But it quickly learns the most common suffix patterns for each root, at which point those examples become nearly loss-free and contribute almost nothing to further learning. The model has overfit to morphological patterns and underlearned semantic patterns, precisely the opposite of what we want for a general-purpose language model.
Quantifying Information Leakage
To understand exactly how much information leaks when sibling subwords are visible, we need a way to measure uncertainty. How hard is the prediction task? Information theory gives us a precise tool: entropy.
The intuition behind entropy
Imagine you are playing a guessing game. If someone picks a number between 1 and 1,000, you have high uncertainty: you need many guesses or much information to identify the answer. If they pick between 1 and 2, you have low uncertainty: one yes-or-no question resolves it. Entropy quantifies this precisely: it measures how many "bits" of information you need to identify the answer. More possible answers with similar probabilities means higher entropy; fewer possibilities or more concentrated probability means lower entropy.
For language model predictions, entropy captures how "spread out" the model's probability distribution is over the vocabulary. When the model is very confident about one token, entropy is low. When it is nearly equally uncertain between many tokens, entropy is high. A good training signal comes from high-entropy situations: the model must work hard to make the right prediction, and the resulting gradient update carries rich information about what the model still needs to learn.
The entropy formula
Given a masked position, the model outputs a probability distribution over all possible tokens. We want to quantify how uncertain that distribution is. The conditional entropy of this prediction is:
where:
- : the conditional entropy of the masked token given visible context, measured in bits (if using ) or nats (if using natural log)
- : the masked token the model must predict
- : the visible tokens surrounding the masked position
- : the vocabulary of all possible tokens
- : the probability the model assigns to token being the correct prediction given the context
The formula works by taking each possible token, weighting its log-probability by the probability itself, and summing. The negative sign ensures we get a positive number (since log probabilities are negative). When probability concentrates on one token, that token's contribution is large and negative, but all others contribute near zero, so the total sum (before negation) is a large negative number, and after negation the entropy is small. When probability spreads uniformly across many tokens, many moderate contributions sum to a large negative number, and entropy is high.
Why does this formula make sense? Notice that measures how "surprising" token would be: common tokens have probabilities near 1, making their log near 0 (unsurprising), while rare tokens have small probabilities and large negative logs (very surprising). Entropy is the expected surprise under the model's own distribution. High entropy means the model expects to be frequently surprised, so it is uncertain and must rely on context to narrow down the answer.
Entropy bounds tell us about task difficulty
Two extreme cases illuminate the formula's behavior:
-
Maximum entropy: When all tokens are equally likely, each has probability , and entropy reaches . For a vocabulary of 30,000 tokens, that is about 14.9 bits: a difficult prediction requiring deep contextual reasoning.
-
Minimum entropy: When one token has probability 1.0 and all others have probability 0, entropy equals 0. The prediction is trivial; the model is certain before even reasoning about context.

The visualization shows how dramatically entropy drops when the effective vocabulary shrinks. Partial masking constrains predictions to just a few valid suffixes, collapsing entropy from nearly 15 bits to around 2.6 bits. This roughly 6x reduction in uncertainty means the model can achieve low loss without deep contextual understanding. The shaded region at the lower left represents the regime of weak training signal where partial masking operates: probability mass concentrated among a tiny number of morphologically constrained options.
Why partial masking destroys the training signal
Now we can quantify the information leakage problem precisely. When "transform" is visible and we mask only "##ation", what happens to the entropy?
The visible prefix constrains the possibilities dramatically. The only valid continuations are tokens that can follow "transform-" in English words: {##ation, ##ed, ##ing, ##er, ##s, ##able}. The effective vocabulary shrinks from 30,000 to perhaps 6 options. Even with a uniform distribution over these 6, entropy drops from 14.9 bits to about 2.6 bits: a five-fold reduction in prediction difficulty before the model even looks at the surrounding sentence.
In practice, it is even worse. The model learns that ##ation is by far the most common suffix after "transform-", so might be 0.7 or higher. The entropy collapses further to perhaps 1.0-1.5 bits. The model has learned a morphological lookup table and uses it to bypass contextual prediction.
This explains why partial masking produces weak gradients. The model achieves low loss not by understanding context, but by memorizing subword co-occurrence patterns. It learns morphology instead of semantics. After enough training, the attention mechanism learns to route heavily toward the visible sibling subwords of any masked token, essentially building a lookup mechanism that short-circuits contextual reasoning. Whole Word Masking closes this shortcut entirely by removing the sibling subwords from the visible context.