SDE & MLE Prep

Tokenization

Q: What is BPE and why does tokenization matter?

Byte-Pair Encoding starts from bytes/characters and repeatedly merges the most frequent adjacent pair into a new token until the vocabulary size (~32k–200k) is reached. Variants: WordPiece, Unigram (SentencePiece).

  • Trade-off: bigger vocab → shorter sequences but larger embedding/softmax matrices.
  • Consequences: arithmetic and character-level tasks are hard (digits split oddly), non-English text costs more tokens, whitespace and casing produce different tokens.