Frontier Foundry

Tokenization

The Data Mines · Pretraining, Data & Scaling

Splitting text into the units (tokens) a model reads and writes.

Also called: tokenizer, byte-level, BPE, tokenizer-free. In the glossary.

Tokenization is cooling this week (×0.42 against the eight weeks before). What is moving.

How it works, as a machineThe Code Room · sentences

Follow one sentence from a line of the corpus to a row of ids the GPUs read, in a telegraph code room at the mouth of a training run.

  1. Clean the text
  2. Cut at the pattern
  3. Weigh the pairs
  4. Join the best pair
  5. Look up the ids
  6. Stamp the frame
Play Tokenization

Tokenization in plain words

Tokenization splits text into the small units, called tokens, that a model reads and writes. Common words become one token and rare ones are broken into pieces. Everything a model does is counted in tokens: how much it can read, how fast it answers and what it costs.

An analogy

A printer's case of metal type. There are single blocks for the commonest words, and unusual ones are assembled from smaller blocks. Every page is measured and priced by the number of blocks set, whatever the reader thinks a word is.

How Tokenization connects

3 typed relations in the knowledge graph

Builds on

  • Pretraining: The rows the hopper feeds are the batches a pretraining step reads.

Built on by

Often in the same sources

Quantization

See Tokenization in the knowledge graph

Who is behind Tokenization

people, labs, products and models

Named in its facts

What the sources say

2 parts · 9 sources · updated 2026-11-27

Tokenization turns text into the integer ids a model reads: the text is cleaned, cut into pre-tokens, joined by learned merge ranks into tokens, looked up in a vocabulary and framed with special tokens. It is light work, but it decides how many tokens a text costs and, at scale, it can starve the model of data or disagree with itself between training and inference.

How a sentence is cut into tokens

Raw text is cleaned, cut into pre-tokens by a fixed pattern, and each pre-token is joined into tokens by repeatedly merging the adjacent pair with the best learned rank.

  1. The normalizer desk cleans the raw text, with lowercasing or Unicode normalization, before anything is cut.
  2. The pre-token splitter cuts the text into pre-tokens with a fixed pattern; no merge crosses a cut.
  3. The pair-rank scale picks the adjacent pair with the best learned rank inside one pre-token.
  4. The merge bench joins that pair into one piece, and the scale looks again until no ranked pair remains.
64 bytes per operation
How many bytes a hand-written splitter that uses SIMD instructions decides in one register operation, in the maintainers' own description Hugging Face
1.0 to 1.35 times
How many more tokens the same input can map to after a lab changed its tokenizer, by content type, reported by the lab Anthropic
1.4x English, 1.33x Spanish, 1.28x Python
How much more a developer measured the same text to cost after the tokenizer change, by language, on his own counter Simon Willison
  • A tokenizer converts text into the list of integers a model reads, in four stages: normalization, pre-tokenization, the model stage and post-processing. Hugging Face
  • Normalization applies operations such as lowercasing or Unicode normalization to the raw text. Hugging Face
  • Byte-level BPE models use a regular expression to split the text into pre-tokens; merges happen inside a pre-token and never across the boundary between two of them. Hugging Face

When it breaksThe new vocabulary that made the same text cost more. A lab released a model with an updated tokenizer to improve performance. The same input text mapped to more tokens, roughly 1.0 to 1.35 times depending on the content, and a developer who counted his own documents found about 1.4 times for English and nearly none for Chinese. Since price is per token, the same page cost more. Anthropic

How tokens become ids a model reads

Merged tokens are looked up in the vocabulary, wrapped in the special tokens the model expects, and handed to the GPUs in batches. This is the part that can starve the model, or disagree with itself between training and serving.

  1. The vocabulary drawers map each merged token to its integer id.
  2. The special-token stamper adds the markers the model expects around the ids, so every row has the same frame.
  3. The id-row hopper hands framed rows of ids to the GPUs, which must never wait on it.
3 to 30 times faster
How much faster a rewritten tokenizer encodes than the previous version with one thread on one laptop chip, across ten model families, reported by its maintainers; the ids are unchanged Hugging Face
76% of linear
How well the rewritten tokenizer scales across eight workers Hugging Face
72,000 time steps
How many time steps an eight-word spoken sentence of about three seconds takes as raw 24 kHz audio, which is why audio is tokenized before a model reads it Neil Zeghidour
millisecond scale or less
How long tokenizing takes per request in a serving engine, in the speaker's experience Charles Frye
  • A serving engine wraps the model with a little pre- and post-processing, tokenizers before the scheduler and a detokenizer after it. Charles Frye
  • A serving engine can run several tokenizer processes but one detokenizer, because input tokens arrive at a much higher rate than output tokens are produced. Charles Frye
  • Tokenizing happens once per request, off the core model loop; the speaker says latency is mostly prefill and decode. Charles Frye

When it breaksThe tokenizer that starved the model. The maintainers of a widely used tokenizer library say tokenizing has not historically been the bottleneck. But as models get faster, training on massive datasets, serving many concurrent requests or processing long inputs repeatedly can press on the tokenizer until the model waits for its data, so GPUs idle while the CPU cuts text. Hugging Face

Open questionIs the tokenizer a bottleneck worth tuning?

  • As models get faster and workloads scale, training on huge datasets, many concurrent requests or long inputs can press on the tokenizer until it starves the model of data. Hugging Face
  • Existing tokenizers generally do not show up as a bottleneck for models of about twenty billion parameters or more; it can show up with a smaller model and a very large input context. Charles Frye

Sources

9 in all

More in Pretraining, Data & Scaling

The Data Mines: the whole area