4.2.1 · D5Tokenization & Language Modeling
Question bank — Tokenization fundamentals
A quick reminder of the terms we will lean on: a token is the atomic text unit a model processes; a vocabulary is the finite set of all tokens; BPE builds by repeatedly merging the most frequent adjacent pair; fertility is tokens-per-word; OOV ("out of vocabulary") is a piece of text the tokenizer cannot represent from known tokens.
True or false — justify
More vocabulary is always better because the model can represent more words.
False. A larger shortens sequences but scatters training signal across many rare tokens, so their embeddings are undertrained — there is a sweet spot near 30K–100K (see the trade-off figure above), not "bigger is better".
Character-level tokenization has zero OOV problem.
True — every string is made of characters, so nothing is unrepresentable. The cost is paid elsewhere: sequences balloon and the attention in the Transformer becomes expensive.
BPE can produce an <unk> token for a normal English word.
In practice no for byte-level BPE (GPT-2 style), because every byte is a base token so any string decomposes. Classic character-BPE can emit
<unk> — see the step-by-step in the edge-case section below.Tokenization is a fully reversible, lossless pipeline.
Not always. Splitting and numericalization are reversible, but the normalization step (lowercasing, accent removal) can destroy information, so may not equal .
Two strings that decode to the same text must have had the same token IDs.
False. Different tokenizations can concatenate to the same string (e.g.
["low","est"] vs ["l","o","w","est"]), so decoding is many-to-one; only encoding is deterministic per tokenizer.The <pad> token changes the meaning the model computes for a sentence.
It should not — padding only fills batches to equal length so all sequences share a shape, and it is masked out, so attention must ignore it. If it does affect output, the mask is broken. (The padding mechanism itself is covered in sequence length & padding, where a figure shows short sentences topped up with
<pad> to a common length.)BPE merges the pair that is most frequent in the original corpus text.
False, and this is the classic trap. It merges the most frequent pair in the current tokenization, which changes after every merge — you must recount pairs each iteration, exactly as the merge-loop figure shows.
A token always corresponds to a whole word.
False. A token may be a full word, a subword ("ing"), a single character, or a byte. Word-tokens are just one convenient case that emerges when a word is frequent.
Spot the error
"To tokenize a new word, BPE searches for the single closest word in the vocabulary."
Wrong — BPE greedily applies its learned merge rules in order to the character sequence; there is no nearest-word search. It composes the word from subwords, never matches to a whole word.
"We should lowercase all text during normalization to shrink the vocabulary."
Overgeneralized. Lowercasing loses case information (
US the country vs us the pronoun, proper nouns), which many modern tokenizers deliberately keep — it is optional, not mandatory."Fertility of 1.0 means the tokenizer is perfect."
Misleading. Fertility 1.0 means one token per word, which requires a huge word-level vocabulary and reintroduces the OOV and rare-word problems — the goal is balance (~1.3–1.5 for BPE), not minimum fertility.
"GPT-2 uses the Ġ symbol because spaces are illegal in tokens."
No — Ġ encodes the leading space so whitespace position survives round-tripping. Spaces are perfectly legal; Ġ exists for reversibility and to distinguish "word" from " word".
"Since coverage is 98%, the tokenizer is fine."
98% coverage means 1 in 50 tokens is
<unk>, which badly degrades meaning. The parent note's rule of thumb is — 98% is a red flag, not a pass."BPE and WordPiece produce identical tokens because both merge pairs."
False. BPE merges by raw frequency; WordPiece (see WordPiece & SentencePiece) merges the pair that most increases likelihood, so their merge orders and resulting tokens differ.
"Pre-tokenization and the BPE algorithm are the same step."
They are distinct. Pre-tokenization sets boundaries words cannot cross (splitting on whitespace/punctuation); BPE then operates within each of those pieces. Confusing them causes merges across word boundaries.
Why questions
Why does BPE start from characters (or bytes) rather than from words?
So the base vocabulary is tiny and closed — every possible input can be built up from it. Starting from words would reintroduce OOV for anything unseen. See the BPE algorithm.
Why do frequent words end up as single tokens while rare words stay split?
Because BPE merges high-count pairs first, so common sequences get "absorbed" into one token early, while rare sequences never reach the top of the count list and remain as their subword pieces — exactly the word-vs-subword picture above.
Why is subword tokenization better than word tokenization for morphology?
Because a shared suffix like "est" becomes one reusable token, so "newest" and "widest" share structure and the model can generalize — word tokenization treats them as unrelated atomic symbols.
Why does the choice of tokenizer affect the memory and speed of a Transformer?
Attention cost grows as in sequence length ; a tokenizer with high fertility produces longer sequences, quadratically increasing compute. (The padding note sequence length shows the same quadratic bite when short sentences are padded up to the batch maximum.)
Why can the same tokenizer be unfair across languages?
A BPE learned mostly on English gives non-Latin scripts high fertility (many tokens per word), so those languages get longer sequences and worse coverage — the motivation for multilingual tokenization.
Why do we reserve fixed low IDs like 0 and 1 for <pad> and <unk>?
So special tokens have stable, reserved slots independent of the learned vocabulary, keeping the ID scheme consistent across models and simplifying masking and lookup (vocabulary & OOV discusses how these reserved slots bound the OOV rate).
Edge cases
What does BPE do with an emoji or unseen Unicode character it never saw in training?
Byte-level BPE falls back to the raw UTF-8 bytes (all 256 bytes are base tokens), so it still encodes it — possibly as several byte-tokens. Character-BPE would emit
<unk> instead (walked through next).Walk the exact mechanism: how does character-BPE end up emitting <unk>?
Its base vocabulary is only the characters seen during training. When encoding new text it first maps each character to a base token — but a never-seen character (say
𝔸) has no base token, so there is nothing to start merging from; the tokenizer substitutes the fallback <unk> for it. Byte-BPE avoids this because all 256 byte values are always present.What is the sequence length of the empty string ""?
Zero content tokens, though many pipelines still wrap it with the
<bos> (start) and <eos> (end) markers defined at the top, giving a length of 2. The tokenizer never crashes on empty input — it just returns an empty (or special-token-only) list.If a corpus contains a word exactly once, will BPE ever merge it into a single token?
Almost never — a single occurrence is unlikely to make any of its pairs the most frequent, so it survives as separate subwords. This is exactly the desired anti-rare-word behavior.
What happens if two adjacent pairs are tied for most frequent — say both ("e","s") and ("s","t") occur 4 times?
BPE breaks the tie by a fixed deterministic rule (commonly lexicographic order of the pair), so here
("e","s") — which sorts before ("s","t") — is merged first; then counts are recomputed and ("s","t")/("es","t") is handled on the next round. The outcome is reproducible, but a different implementation's tie rule can pick the other pair and produce a slightly different vocabulary.Can add or remove spaces?
Yes if space handling is imperfect. GPT-2 avoids this with Ġ so spaces round-trip exactly; a tokenizer that strips leading/trailing whitespace in normalization will not restore it, so the recovered string differs from .
What is the fertility of a word that is fully out-of-vocabulary and gets split into every character?
Very high — it equals the number of characters (plus any byte-splits). A spike in fertility on new text is a symptom that the domain drifted from the training data.
Recall One-line self-test
BPE recounts pairs after every merge — true or false? ::: True; the "current tokenization" changes each step, so counts must be recomputed.