Tokenizer

A tokenizer is the component that turns text into the sequence of tokens a language model works with, and back again. Before a model sees a sentence, the tokenizer cuts it into pieces – whole words, parts of words, single characters or bytes – and replaces each piece with a number from a fixed vocabulary. Everything the model learns and produces passes through this step.

How text is cut up

Splitting text into whole words would require an enormous vocabulary and fail on new or misspelled words; splitting it into single characters would make sequences very long. Most modern models use subword methods in between. The most common, byte-pair encoding, began as a data-compression technique described by Philip Gage in 1994; in a paper published in 2016, Rico Sennrich and colleagues adapted it for machine translation. It starts from characters and repeatedly merges the most frequent adjacent pairs into new tokens, so that common words become single tokens while rare words are assembled from pieces. Related methods include WordPiece, used by Google’s BERT, and the unigram method, often applied through Google’s SentencePiece toolkit. Vocabularies have grown from about 50,000 tokens in GPT-2 (2019) to around 200,000 in some recent models. For English text, OpenAI’s rule of thumb is that a token is about three-quarters of a word; the ratio varies between tokenizers.

Tokenizer quirks

Because models see tokens rather than letters, some simple tasks become hard. Asked how many r’s are in “strawberry,” models long stumbled, since the word is represented as one or a few tokens rather than as individual letters (see Strawberry Problem). Numbers split into irregular chunks can make arithmetic harder; a 2024 study found that how digits were grouped into tokens changed the arithmetic results of GPT-3.5 and GPT-4. Rare tokens that barely appeared in training can trigger bizarre behavior (see Glitch Token). Tokenizers also affect fairness: trained mostly on English, they split other languages into many more tokens. A 2023 study found that the same text can require up to 15 times more tokens in some languages than in English, which means higher costs, slower responses and less room in the context window for speakers of those languages (see Token Tax and Low-Resource Language).

Beyond tokenizers

Researchers are exploring models that work directly on raw bytes, avoiding a fixed vocabulary. Meta’s Byte Latent Transformer, presented in 2024, groups bytes into variable-length patches, spending more computation where text is harder to predict. Such approaches could make models more robust to spelling and better at character-level tasks; whether they are fairer across languages is less clear, since byte encoding also makes many scripts several times longer than English. Most production models still rely on tokenizers.

Why it matters

The tokenizer is an unglamorous but consequential design choice. It determines what a model can easily see, how much a request costs and how evenly the benefits of AI are spread across the world’s languages – a reminder that seemingly technical decisions can have social effects.

Written with Claude, made by Anthropic, whose Claude models are priced per token; Anthropic’s 2026 tokenizer update for Claude Opus 4.7 can turn the same text into up to about 35 percent more tokens.

Related

Token · Strawberry Problem · Glitch Token · Token Tax · Low-Resource Language · Context Window · Next-Token Prediction

Sources: Philip Gage: A New Algorithm for Data Compression (The C Users Journal, archived) (February 1994) · Rico Sennrich, Barry Haddow, Alexandra Birch: Neural Machine Translation of Rare Words with Subword Units (arXiv) (2015; ACL 2016) · Taku Kudo, John Richardson: SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processing (arXiv) (2018) · OpenAI: What are tokens and how to count them? · OpenAI: tiktoken · Aaditya K. Singh, DJ Strouse: Tokenization counts (arXiv) (2024) · Aleksandar Petrov et al.: Language Model Tokenizers Introduce Unfairness Between Languages (arXiv; NeurIPS 2023) (2023) · Artidoro Pagnoni et al.: Byte Latent Transformer: Patches Scale Better Than Tokens (arXiv) (2024) · Anthropic: Introducing Claude Opus 4.7 (April 16, 2026)

Leave a Reply

Your email address will not be published. Required fields are marked *