Home Knowledge Base Byte-Pair Encoding (BPE)

Byte-Pair Encoding (BPE) is a subword tokenization algorithm that iteratively merges the most frequent character pairs — producing a vocabulary of subword units that balances vocabulary size with sequence length and handles unknown words gracefully.

Why Tokenization Matters

BPE Algorithm

1. Initialize vocabulary with individual characters. 2. Count frequency of all adjacent byte/character pairs. 3. Merge the most frequent pair → new token. 4. Repeat until vocabulary size V is reached (typically 32K–100K).

Example:

Tokenizer Variants

Tokenization Impact on Models

Vocabulary Sizes

ModelVocabularyTokenizer
GPT-250,257BPE
GPT-4100,277tiktoken BPE
LLaMA32,000SentencePiece
BERT30,522WordPiece

Tokenization is a foundational but often overlooked design decision — vocabulary size, granularity, and algorithm directly affect training efficiency, multilingual performance, and arithmetic reasoning.

tokenizer bpebyte pair encodingwordpiecesentencepiecesubword tokenization

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.