How LLMs Work
What Is a Token? How AI Reads Words
Tokens are the small pieces of text that language models read and write. Learn how a sentence is chopped up, with simple examples.
When you read, you see letters and words. An AI language model sees tokens.
A sentence cut into tokens, each with a number. The split and the numbers are made-up examples, not output from a real tokenizer.
A token is a small chunk of text. It might be a whole short word like "cat", part of a long word like "un" + "believ" + "able", or even a single punctuation mark.
Try it by hand
Take the sentence: Dogs love playing outside.
One possible split is: Dogs love playing outside . Another model might split "playing" into play and ing. Different models cut text in different ways.
Why not just use letters or words?
- Using only letters makes every sentence very long.
- Using only whole words fails when a new word appears.
- Tokens are a middle path: common words stay whole, rare words are built from parts. A 2015 paper on machine translation (Sennrich and colleagues) showed this idea works: encoding rare and unknown words as sequences of subword units, using a method called byte pair encoding, improved English to German and English to Russian translation by up to 1.1 and 1.3 BLEU points compared with a dictionary fallback.
Tokens become numbers
Each token has a number, like a locker number. The model works with those numbers, not the letters.
Why you hear about tokens
Companies often count usage and limits in tokens. A model can also only look at so many tokens at once. That limit is called its context window. Read more in what a context window is.
Quick activity
Write a sentence and cut it into pieces any way you like. Swap with a friend. Notice that you each made different pieces but could still rebuild the sentence. That is the idea behind tokens.
A worked example
Take the word "unbelievable". A model might cut it as un + believ + able. That helps in two ways. The model has seen un and able in thousands of other words, so it can guess the meaning even if it never met "unbelievable" in exactly that form. And it keeps its list of pieces small enough to work with.
Different models use different token lists, so the same sentence can be cut differently by two different AIs. The pictures in this guide are examples to show the idea, not the real cuts of any particular model.
Why tokens explain odd AI behaviour
- It may be one reason a model can struggle to count letters in a word. Researchers are still studying the causes.
- It is why long documents can fill up a context window: the limit is counted in tokens, not pages.
- It is why some languages use more tokens for the same text than others. A 2023 study from the University of Oxford (Petrov and colleagues) found that the same text translated into different languages can differ in token count by up to 15 times. For ChatGPT and GPT-4 at the time of that study, the cost to process German or Italian was about 50% higher than English, and for a few languages such as Dzongkha, Odia, Santali and Shan it was more than 12 times higher, because the services charged per token. Prices and tokenizers have changed since, so these numbers describe that study, not today.
Practice
- Choose a sentence of ten words.
- Cut it into pieces any way you like, making rare words into two or three parts.
- Give each piece a number in order of first appearance.
- Swap lists with a friend and rebuild each other's sentences from the numbers.
Notice how the same sentence can have several valid cuts but only one correct rebuild. That is exactly why a model needs to keep the numbers in order.