Pre-tokenization splits text before BPE merges. Why is that boundary important?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Pre-tokenization is the regex step that splits raw text into coarse chunks before BPE merging. It enforces hard boundaries: merges can never cross them, which shapes what the vocabulary can contain.
Imagine BPE is a robot that walks through your text and glues adjacent pieces together into bigger units. Without any rules, the robot might glue 'hello' and 'world' together into a single weird unit because the space between them is just another character. Pre-tokenization is the step that draws walls in the text first: here is one word-ish chunk, here is the next, here is a punctuation mark on its own. The merge robot can glue pieces together inside a chunk but never across a wall. The walls are drawn by a specific regular expression that the tokenizer's designers picked very carefully, because the choice of walls limits what kinds of merged tokens can ever exist in the vocabulary.
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: define pre-tokenization, place it in the pipeline between normalization and merging, explain the hard-boundary constraint on the merge algorithm, describe the regex pattern at a high level, contrast cl100k_base and o200k_base regexes briefly, and connect to the leading-space token effect.
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.
Confusing pre-tokenization with tokenization. Pre-tokenization is the splitting step that runs before BPE merges; the merges then operate within each pre-tokenization chunk separately.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.