Byte-Pair Encoding for Subword Tokenization

A data-driven tokenization algorithm that iteratively merges the most frequent pairs of symbols (characters or character sequences) to build a compact subword vocabulary, balancing vocabulary size and sequence length.

Method

Start with character vocabulary; count pair frequencies; merge the most frequent pair and update corpus; repeat until desired vocabulary size. Encoding greedily applies merges. WordPiece and SentencePiece (Unigram LM) are closely related alternatives with different training objectives.

Applications

Neural machine translation, large language models, multilingual NLP, any text processing pipeline needing open-vocabulary handling and compact representations.

Advantages

Handles rare and unseen words; reduces vocabulary size vs. words.

Limitations

Can produce unintuitive segmentations; language-specific behavior; fixed vocabulary after training; less ideal for some morphologically rich or low-resource languages without careful design.

Alternatives

WordPiece, SentencePiece (Unigram), character-level models, morphological analyzers, byte-level tokenization.

Editorial clarification

Primary method selected from the source bundle; related approaches are alternatives, not aliases.

Sources

Educational reference only, not professional advice.

All algorithms