Skip to content
Middle+0 views

What tokenizers do you know, and how does BPE work?

Practice

AI answer

The main options are word-, character-, and subword-level tokenization. Subword methods include BPE, WordPiece, and Unigram; byte-level variants, such as byte-level BPE, are also used. Word-level tokenization is simple but handles rare words and new forms poorly; character-level tokenization is robust to unknown words but produces long sequences. Subword methods balance these properties.

BPE starts with basic units (often bytes or characters), then repeatedly merges the most frequent adjacent pair in the training corpus, adding it to the vocabulary. During tokenization, it applies the saved merges in a specified order. As a result, frequent words can become a single token, while rare ones can be split into known subwords. Specific details, such as the initial alphabet and how spaces are handled, depend on the implementation.