Before the tokenizer even starts splitting, normalization runs. What does it do and why?
Normalization is the preprocessing step the tokenizer runs before pre-tokenization: Unicode normalization, lowercasing, accent stripping, whitespace collapsing. It makes equivalent strings produce identical token ids.
Imagine the same word 'cafe' can be typed two different ways on your keyboard: one way uses a single special character with the accent baked in, and the other way uses the plain letter 'e' followed by an invisible accent mark. To you, both look identical. To the tokenizer, they are different sequences of bytes and could end up with different token ids, which means the model would treat them as two different words. Normalization is the cleanup step that fixes this: it rewrites both forms into a single canonical form before tokenization even starts. Some normalizers also lowercase everything, strip accents entirely, or collapse repeated whitespace. The exact recipe is part of the tokenizer's configuration and has to match between training and inference. Modern OpenAI tokenizers do almost no normalization; some other tokenizers do a lot.
Detailed answer & concept explanation~6 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: define normalization as the first stage of the tokenizer pipeline, name the four Unicode normalization forms, explain why NFC matters for byte identity, contrast tiktoken's minimal normalization with Hugging Face's explicit normalizer config, and warn that training and inference normalization must match.
Real products, models, and research that use this idea.
- OpenAI's tiktoken (cl100k_base, o200k_base) applies essentially no normalization, treating input as raw bytes; this is documented in the tiktoken source.
- Hugging Face tokenizer.json files for BERT family models include explicit normalizer configurations: bert-base-uncased applies lowercase, NFD, and strip_accents; bert-base-cased applies NFD only.
- SentencePiece tokenizers (used by older Llama 2, T5, Gemini) replace whitespace with U+2581 and apply NFKC by default; the byte_fallback setting interacts with normalization to determine whether unusual characters can be encoded losslessly.
- The Hugging Face tokenizers library exposes pre-built normalizers (NFC, NFD, NFKC, NFKD, Lowercase, Strip, StripAccents, Replace, Sequence) that can be composed into a custom normalizer chain.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is the difference between NFC and NFKC sometimes important for an LLM tokenizer?
QIf tiktoken applies almost no normalization, how does GPT-5 handle the two encodings of cafe case?
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.
Assuming all tokenizers normalize the same way. tiktoken does almost nothing; Hugging Face tokenizers vary widely. Mismatched normalization between training and inference produces silent drift in token sequences.
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.