SIMETRIUM .COM token · BPE · UTF-8
EN|36 languages
token In the morning we drink hot tea and read the news . en · 21 ru · 24 ta · 39 o200k · tokens 10346 tokentokentokentoken tokentoken 74 6f 6b 65 6e 012345 B → 1 SYMBOL PLATE token → 10346 · o200k_base|V| = 199 998 RFC 3629 UTF-8 · byte-level BPE · Gage 1994
Letter case
A token has no symbol; it is written out in words: 1200 tokens, 128 000 tokens, and in prices “per 1M tokens”. The abbreviation tok appears in speeds: 60 tok/s. The space before a word is often part of the token itself, so “ token” and “token” are different tokens.
Do not confuse
A token is not a word and not a letter. It is a piece of bytes from the model’s vocabulary: sometimes a whole word with a space in front, sometimes a syllable, and sometimes half a letter. Do not confuse it with an access token, a password fob, or a crypto token.
A paper tape runs along carrying the phrase “In the morning we drink hot tea and read the news”, already marked into tokens of different colours. Under a steel stamp the tape is cut, and the severed pieces slide down a chute into a tray where others already lie. The board on the left shows how many tokens this phrase takes in English, Russian and Tamil. The word token itself is cast in metal whole, because in the GPT-4o vocabulary it takes a single token with the number 10346. Below it are its five bytes in UTF-8, and a slider moves through them from zero to five while a glint runs across the metal.
Unit passport · AI series · unit for counting text

token

Token
token · tok · 1 token ≈ 4 characters of English text ≈ ¾ of a word

Imagine you sent a neural network the same short phrase about morning tea, first in English and then in Tamil. The meaning is the same, the length is almost the same, yet the bill for the second would have been sixteen times larger if you were asking a 2019 model. Today’s model would charge less, but still almost twice as much. The model sees neither letters nor words: it sees tokens, pieces of text from its vocabulary, and it is paid for exactly those. Why some languages got large pieces and others small ones, you will find out below.

A token is used to measure almost everything in work with language models: the price of a request, the size of the context window, the speed of a reply and the amount of data a model was trained on. That is why this sheet has real tokenizers of three generations and thirty-six languages, a counter for your own text, a price calculator and a workshop where you can see why a table in JSON costs three times as much as the same table in CSV.

What it is
the unit for counting text in a language model: an element of its vocabulary, a piece of UTF-8 bytes
Notation
no symbol; written as a word: token, tok; in Chinese 词元
Definition
depends on the tokenizer: the same text gives a different number of tokens in different models
Vocabulary
from 30 522 for BERT and 50 257 for GPT-2 to 199 998 for GPT-4o and about 256 000 for Gemma
Typical values
≈ 500 — an A4 page of Russian text · 128 000 — a context window · 15 trillion — training of Llama 3
References
no standard for the token · RFC 3629 UTF-8 · Unicode 16.0 · ISO/IEC 10646
Count your own text 36 languages in the tokenizer How to save tokens
Counter and conversion
Tool · exact token count

Paste your text

You can paste a letter, a prompt, a piece of code or a table here. The count is done by the real OpenAI vocabularies, the same ones used in the models; the vocabulary loads on the first change to the text, about two megabytes. Below, the text is cut into tokens: each coloured rectangle is one token.

Tool · an estimate without text

Words and pages into tokens and money

When there is no text yet but you need a budget right now, enter the amount and choose a language. The conversion relies on the measured token density of each of the thirty-six languages, so it is an estimate accurate to ten or twenty percent, not an exact count.

Etymology

A sign, a coin and a piece of bytes

In a thousand years the word token has been an omen, a coin for the fare, a building block of a program and, finally, a unit for counting in neural networks. But in all its lives it has meant one thing: a small object that stands in for something larger. A coin stands in for money; a token in a model’s vocabulary stands in for a piece of text.

tokenOld Eng. tācen
tācen · sign, omen→token · coin→linguistics, 1906→model token
Old English tācen, “sign”, is related to German Zeichen and English teach: to teach is to show signs. Later tokens came to mean the coins that replaced money. In 1906 the American philosopher Charles Peirce separated type from token: a word as a pattern and each of its appearances in a text. From there the term passed into programming, and then into neural networks.
BPEByte Pair Encoding
file compression, 1994→machine translation, 2016→GPT vocabularies
“Byte-pair encoding” was devised by Philip Gage as a way to compress files: the most frequent pair of neighbouring bytes is replaced by one new code, and this is repeated as long as there is anything to replace. Twenty-two years later Rico Sennrich and colleagues in Edinburgh applied the same trick to words, and it turned out to make an excellent vocabulary for translation.
UTF-88-bit UCS Transformation Format
a · 1 byteя · 2猫 · 3🙂 · 4
The encoding in which almost the whole internet is written was sketched by Ken Thompson and Rob Pike in September 1992, reportedly on a napkin in a diner. A Latin letter takes one byte in it, a Cyrillic one two, a Chinese character three, and an emoji four. Modern tokenizers cut exactly the bytes, and that is where the inequality of languages begins.
What it is called in other languages
词元 cíyuán — in China, “a piece of a word”; in conversation more often just token, while 令牌 is kept for password tokens
トークン — Japanese, 토큰 — Korean: an English word written in a syllabic alphabet
رمز ramz — Arabic, “sign, symbol”; in engineering speech also توكن
token — Spanish, Portuguese, French, German (das Token); the French jeton is kept for coin tokens
टोकन — Hindi; টোকেন — Bengali; டோக்கன் — Tamil
token — Russian and Serbian; token — Turkish, Indonesian, Vietnamese, Swahili
tok/s
tokens per second, the speed at which a model prints its reply
$/1M tok
price per million tokens; input and output cost differently
BOS · EOS
beginning and end of sequence, service tokens for the start and end of a text
|V| · vocab
vocabulary size, how many different tokens a model knows
01 · Definition and the path of a word

The model reads not letters but numbers

A neural network can only handle numbers. So before it sees your question, the text passes through a tokenizer: it turns the text into UTF-8 bytes, then greedily glues the bytes into the longest pieces found in its vocabulary and replaces each piece with a number. The result is a chain of integers, for example 10346 for the word token. From then on the model works only with these numbers, and at the end the tokenizer turns the numbers of the reply back into text.

The vocabulary is compiled in advance, on an enormous heap of texts: frequent combinations get their own number, rare ones are assembled from pieces. That is why a token is not an exact measure like the metre, but a measure tied to a vocabulary. The same paragraph will take a different number of tokens in GPT-2 and in GPT-4o, and when comparing the prices of different models it is always worth asking whose tokens they are counted in. For estimates, averages serve: in English there are about four characters per token, or three quarters of a word.

N — number of tokens · C — characters · W — words · c — characters per token · p — price per million · v — generation speed
Interactive · four transformations of one word

How a word becomes a number

Choose a word and a vocabulary. The top row is the characters as you see them; the second is the UTF-8 bytes in hexadecimal; the third is the pieces into which the vocabulary has cut the bytes; the bottom is the numbers of those pieces. Pink marks tokens that cut a character in half: they hold only part of a letter.

Reference · benchmark values
≈ 4 charactersthis much English text falls on average to one token, about three quarters of a word 199 998ordinary tokens in the o200k_base vocabulary used by GPT-4o; GPT-4 has 100 256 of them, GPT-2 has 50 256 1 → 3the character 猫, “cat”, took three one-byte tokens in GPT-2 and one in GPT-4o 3 digitsthis many digits in a row are glued into one token by the GPT-4 and GPT-4o vocabularies: 123 456 789 0
The riddle solved

Why Tamil cost sixteen times more

A tokenizer’s vocabulary is assembled from what occurs most often in the training texts, and most of them are written in English. English words therefore get their numbers whole, together with the space in front. Tamil letters take three bytes each in UTF-8, and if the vocabulary has never seen a needed combination, all it can do is cut the text by one or two bytes. That is how our phrase about morning tea, twenty-one tokens in English, turned into 347 tokens in the GPT-2 vocabulary.

Each new generation of vocabularies was trained on more and more multilingual texts and made larger. In the GPT-4 vocabulary the same phrase needed 170 tokens, and in the GPT-4o vocabulary 39. The inequality has shrunk but not vanished: Tamil, Hindi, Korean and Greek still use more tokens than English, which means their speakers pay more and hit the context window sooner. Try any of the thirty-six languages in the lab below.

Interactive · three experiments with tokens

Cut, train, count

In the “Cut” experiment one phrase is translated into the thirty-six languages of the site, and real vocabularies of three generations cut it: GPT-2, GPT-4 and GPT-4o. Tap any piece to see its number and bytes. In the “Train” experiment you grow a vocabulary yourself: each move of the slider glues together the most frequent pair of neighbouring pieces, as the BPE algorithm does. And in the “Numbers” experiment you see how vocabularies tear dates, prices and long numbers to pieces, and why models are so bad at mental arithmetic.

Language of the phrase · 36 languages of the site
Vocabulary
What to train the vocabulary on
Merges done
What to cut

Chart · the language tax
How many times dearer than English
Each bar is a language, sorted by the GPT-4o vocabulary; the height is how many times more tokens it takes than the same phrase in English. The pink line is the GPT-2 vocabulary, the blue one GPT-4, the lime bar GPT-4o. The scale is logarithmic, the dashed line is the English level. Tap a bar to choose a language.
languages, ascendingtokens ÷ English
Chart · the BPE learning curve
A bigger vocabulary — a shorter text
The blue curve shows how many tokens the training text takes after each merge, the lime one how many characters fall to one token. The first merges shorten the text quickly, the last give almost nothing: this is why vocabularies are not made infinite. The glowing dot is your slider.
number of mergestokens in the text
02 · Orders of magnitude

From one “yes” to fifteen trillion

Drag the slider: it runs on a logarithm, and each division is ten times more than the one before. You will go from a short reply through a page, a novel and Wikipedia to the mountains of text on which modern models are trained. Note that in training any model has read tens of thousands of times more words than a person can speak in a whole lifetime.

left: 1 token · right: 10¹⁴ tokenstraining figures are from the developers’ reports, the rest is an estimate for the GPT-4o vocabulary
03 · Format workshop

One table, six prices

The five largest cities in the world with population and area — the data is the same, only the packaging changes. Choose a format and you will see the text itself and how many tokens it takes in each of the three vocabularies. The numbers here were counted by real tokenizers. Quotation marks, brackets, indents and repeated field names are all tokens you pay for, though they add no meaning.

The thick lime bar is the GPT-4o vocabulary, the blue one GPT-4, the pink one GPT-2.

Cheat sheet · eight habits of an economical prompt
04 · Tokenizers of the world

Every model has its own vocabulary

Vocabularies are growing: in six years they became four to five times larger, and almost every time for the sake of other languages and program code. Note that the multilingual models — BLOOM, mT5, Gemma — started right away with vocabularies of a quarter of a million tokens. The table collects the vocabularies whose sizes are published; where a number is rounded, there is a ≈ sign. Tap a row to read the details.

vocabularyyrmethodtokens

For work · how to count tokens in your own code

Three lines worth knowing

Counting tokens “by eye” from string length is risky: in JavaScript the length of a string is counted in sixteen-bit units, not in bytes and not in tokens. It is more reliable to take the same vocabulary as the model’s. Here is how it is done in the three most common environments.

The most accurate count comes in the API reply, in the usage field: how many tokens were on input, on output, and how many were taken from the cache. Check your estimates against it at least once for every new model.

05 · Writing rules
Correct
Name the vocabulary when you give a number: “1 240 tokens by o200k_base”.
Write the price with its basis: “2.50 ¤ per 1M input tokens” — per million.
Count input and output tokens separately: output is usually several times dearer.
Remember that 128K in different models means sometimes 128 000 and sometimes 131 072 tokens — the binary “thousand”.
Separate the number from the word with a space: 60 tok/s, 200 000 tokens.
Incorrect
Say “a token is a word”: a word can take anything from a fraction of a token to five tokens.
Divide any text by four: this rule holds only for English.
Write “128 KB of context”: the window is measured in tokens, not in kilobytes.
Write mtok or Mt: a lowercase m is “milli”, and Mt is a megatonne.
Compare the prices of models with different vocabularies without recounting the same text.
06 · Neighbouring units
07 · Historical section
SolidGoldMagikarp43453r50k_base · GPT-2
a vocabulary cell that nobody had read
Note

In early 2023 the researchers Jessica Rumbelow and Matthew Watkins noticed that the GPT-3 models could not repeat the simple word SolidGoldMagikarp. Ask, and the model would answer “distribute”, start insisting that there is no such word, or even take offence. The explanation was found in the vocabulary. That was the name of one of the most active members of the Reddit forum where people simply counted in turn to infinity, and his nickname appeared thousands of times in the texts from which the vocabulary was compiled. The nickname received its own token, number 43453.

But that forum hardly made it into the texts on which the model itself was later trained. The vocabulary cell existed, but the model almost never saw it and did not know what it meant. Such “glitch tokens” became a lesson: the vocabulary and the model must be trained on similar data. In the GPT-4 vocabulary this nickname is already cut into five ordinary pieces, and the model repeats it without trouble.

> repeat: SolidGoldMagikarp distributeGPT-3 · 2023
asked to repeat — got something else
Series · AI
units of language models

How a neural network is measured

The token is the first and smallest measure in this series. The context window and the price of a reply are built from tokens, models learn on tokens, and the number of parameters and operations shows how much labour goes into each of them. On the left is a console where these measures meet in one request; on the right are the sheets of the series.

usage · one request
Catalogue of quantities
the whole index →
the foundation · 7 units

The seven SI base units

on the topic of this sheet · information, codes and AI
The index lab: a glass of cabbage juice, a burner, a glass of water on a cold plate and a gear train
Index · all quantities on one page
The lab at the entrance to the index

A drop of acid changes the colour of the juice, salt colours the flame, water freezes at a tap. Below them are all Simetrium sheets, by discipline and alphabetically.

Open the index →
08 · Your language
every link is a real page in that locale

Read it in your own language

translated and checkeddraft translationqueued