Your teammate mentions BPE at a code review. What are they talking about?
BPE is a sub-word tokenizer algorithm: start from bytes or characters, merge the most frequent adjacent pair, repeat until the vocabulary hits a target size. Output is a vocabulary plus a deterministic encoder.
Imagine you are inventing a shorthand for a long book. You start by writing every single letter separately. Then you notice that 't' followed by 'h' shows up everywhere, so you invent a single new symbol that means 'th' and replace every occurrence. Now you scan again and find that 'th' followed by 'e' is the next most common pair, so you invent a symbol for 'the' and replace those. You keep doing this until you have invented as many new symbols as you can afford. Frequent words end up with their own short symbols; rare words stay spelled out from smaller pieces. That is exactly what BPE does, except the alphabet starts from raw bytes instead of letters, and the merging happens automatically over billions of words of training text. The result is a vocabulary the language model uses to read every prompt for the rest of its life.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: state the algorithm in one breath, walk the training loop on a tiny example, separate training from inference, explain the byte-level twist and what it buys, and name three 2026 model families that ship with byte-level BPE.
Real products, models, and research that use this idea.
- OpenAI's tiktoken library implements byte-level BPE; cl100k_base is the encoding for GPT-4 and GPT-3.5-turbo, and o200k_base is the encoding for GPT-4o, o1, o3, GPT-5, and GPT-5.5.
- Meta's Llama 3 and Llama 4 tokenizers are tiktoken-style byte-level BPE with a 128K vocabulary, a deliberate switch from the 32K SentencePiece tokenizer used in Llama 2.
- Mistral models (Mistral Large 3, Mixtral) use a SentencePiece-based BPE tokenizer with a 32K vocabulary.
- The Hugging Face tokenizers library (Rust core, Python bindings) provides production-grade BPE training and inference and is the standard for custom-vocabulary work.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow is byte-level BPE different from classical character-level BPE?
QHow does BPE differ from WordPiece in selecting which pair to merge next?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Confusing the training phase that builds the merge table with the inference phase that applies it. Training picks the merges once; inference applies them deterministically to every new string.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.