BPE learned 50,000 merge rules during training. What is a merge rule, and where does it live at inference?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A merge rule is one entry in BPE's ordered learned list: 't' + 'h' = 'th'. Encoders replay merges greedily in learned order. Storage: merges.txt, tokenizer.json, or the tiktoken binary.
Imagine a cookbook where every recipe just says 'combine X with Y to make Z'. The cookbook has hundreds of recipes in a specific order. You start with a kitchen full of plain ingredients. To cook anything, you flip through the recipes in order and every time you see an ingredient pair you have in the kitchen, you combine them as the recipe says. Then you keep flipping. By the end, your kitchen has a few big assembled dishes instead of many small ingredients. BPE merges work the same way. The training process produced an ordered cookbook of pair-combine rules. The encoder reads the cookbook in order and combines every applicable pair in the input. Different tokenizer libraries print the cookbook in different file formats, but the cookbook itself is the same kind of object.
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.
3 min: define a merge rule as one entry in BPE's ordered list, walk through how encoding replays the list greedily, explain why the order matters, and list the storage formats in three or four major tokenizer libraries.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Thinking BPE encoding picks the highest-scoring merge at each step at inference time. Encoding is not re-running BPE training; it is replaying the learned merges in their training order, greedily, until no more apply.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.