AI & Machine Learning

Tokenizer

Also known as: tokeniser, LLM tokenizer, text tokenizer

A tokenizer is the part of an AI language model system that breaks text into tokens, small chunks such as whole words, parts of words, or punctuation, and converts them into numbers the model can process.

Every AI price, context limit, and speed figure is measured in tokens. While tokenizers are invisible to most users, they explain some odd AI behaviour, such as miscounting letters in a word, and why some languages cost more to process than English.

Tokenizer, explained at three levels

At home

Imagine building every word out of Lego pieces. Common words like 'the' are a single piece, while rare words snap together from smaller ones, so 'unbelievable' might be 'un,' 'believ,' and 'able.' A tokenizer is the tool that breaks your text into these pieces, called tokens, and gives each one a number. The AI never sees letters, only that string of numbered pieces.

At work

A tokenizer is the component that splits text into tokens, the word pieces an AI language model actually reads and writes, and converts them into numbers. It matters to businesses because every AI price, context limit, and speed figure is counted in tokens. The same document can produce different token counts with different providers, which changes what it costs to process.

Real-world examples

At home

Sophie noticed an AI chatbot used up its limit faster when she wrote in French than in English. Her nephew explained that the tokenizer split French words into more pieces.

At work

Marcus is a developer at an Ottawa translation service. He measured token counts per language with each AI provider's tokenizer, which changed which vendor was cheapest for their multilingual documents.

Common confusions

  • A token is the same as a word. — Tokens are often word pieces. Short common words may be one token, while long or rare words split into several.
  • All AI models count tokens the same way. — Each model family has its own tokenizer, so the same text can cost different amounts across providers.

For analysts

When budgeting AI costs, I'd measure real token counts for your actual documents and languages. Rough word-based estimates can be far off, especially for multilingual or code-heavy content.

History & origin

Early language systems split text into whole words, which struggled with rare words and typos. Philip Gage described byte pair encoding (BPE) as a data compression method in 1994. Rico Sennrich, Barry Haddow, and Alexandra Birch at the University of Edinburgh adapted BPE for neural machine translation in 2016, splitting rare words into common pieces. Google's WordPiece, used in BERT in 2018, and SentencePiece by Taku Kudo and John Richardson in 2018 offered alternatives. OpenAI's GPT-2 in 2019 used byte-level BPE so any text could be represented. Later models increased vocabulary sizes to handle more languages and code efficiently. In my view, the tokenizer is the hidden layer behind many 'why is AI so dumb about this?' moments.