Tokenization interview question

Deep LearningTokenizationmedium

The table shows how two tokenizers split the same text. What do the ## and Ġ markers mean?

TokenizerTokens for "The unaffordable loan"
BERT WordPiece (uncased)the un ##af ##ford ##able loan
GPT-2 byte-level BPEThe Ġun aff ordable Ġloan
Illustrative segmentation; exact pieces depend on the trained vocabulary.
  1. A"##" marks a WordPiece piece that starts a new word, while "Ġ" marks a byte-level BPE piece that continues the previous word with no space between the two pieces.
  2. B"##" marks a WordPiece piece that continues the previous word, while "Ġ" marks a byte-level BPE token that begins with a space, so word boundaries live in the tokens.
  3. C"##" and "Ġ" mark rare tokens added after training to cover out-of-vocabulary words, so the model looks them up in a separate embedding table and gives them lower weight.
  4. D"##" marks a subword the model must predict during masked language modeling, while "Ġ" marks padding inserted between words to align sequences to equal length.
Show the answer and explanation

Correct answer: B, "##" marks a WordPiece piece that continues the previous word, while "Ġ" marks a byte-level BPE token that begins with a space, so word boundaries live in the tokens.

Explanation Tokenization

Subword tokenizers must record where words start; otherwise "un aff ordable" could not be turned back into "unaffordable". The two common conventions are mirror images:

TokenizerMarkerMeaningExample
WordPiece (BERT)## prefixpiece continues the previous wordun ##af ##ford ##able
Byte-level BPE (GPT-2, RoBERTa)Ġ prefixtoken starts with a space, i.e. a new wordĠun aff ordable
SentencePiece (T5, LLaMA 2, XLM-R)▁ prefixtoken starts with a space▁un aff ordable

Ġ is simply how GPT-2's byte-to-unicode mapping displays the space byte. Because the space is part of the token, "loan" at the very start of a text and " loan" after a space are different tokens with different ids, which explains some surprising prompt-formatting effects: a trailing space at the end of a prompt forces an unusual token boundary and can change the next-token distribution.

Why the distractors fail: one option swaps the meanings of the two markers. The markers do not denote rare tokens added after training, and there is no separate embedding table; they are ordinary vocabulary entries. They have nothing to do with which tokens are masked in MLM, and padding uses a special token, not Ġ.

Practical consequence: when aligning NER labels to subwords, word starts are detected from these markers (or from word_ids() in Hugging Face tokenizers).

Interview tip: if asked why a prompt behaves differently with a trailing space, explain that byte-level BPE folds the space into the following token, so a dangling space leaves the model in a position it rarely saw during training.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Deep Learning questions

  1. A retailer wants to cut the mobile-app download size of a product-image classifier (dense top-1 76.1%) by pruning it and shipping the weights in a compressed…
  2. A retailer's Stable Diffusion 1.5 pipeline uses classifier-free guidance, ε̂ = ε_uncond + w·(ε_cond − ε_uncond), with w = 7.5. For one latent element at one…
  3. An LLM interpretability team trains a sparse autoencoder (SAE) on residual-stream activations of size 4,096, with a 65,536-unit ReLU code layer and an L1…
  4. As an ablation, you delete every self-attention sublayer from a trained BERT-style encoder but keep the token and position embeddings, the feed-forward (FFN)…
  5. A grocery chain trains a CNN to grade bananas on a conveyor belt as unripe, ripe or overripe from camera images. Which augmentation is most likely to hurt the…