Tokenisation Explained: 5 Odd Behaviours It Causes

⚡ TL;DR: Tokenisation splits text into chunks and maps each to an integer. Models never see letters or words — only these IDs. It explains why models miscount letters, why some languages cost more to process, and why you are billed per token.

Between your sentence and the language model sits a step almost nobody explains: converting text into numbers. Tokenisation is that step, and understanding it demystifies several odd behaviours at once.

What tokenisation actually produces

Tokenisation diagram splitting a sentence into eight tokens, each shown with an illustrative integer ID beneath it
Text becomes tokens, tokens become IDs. The integer IDs shown here are illustrative — each tokeniser has its own vocabulary and numbering.

Notice that tokens are not words. “Tokenisation” splits into “Token” + “isation”. “Unbelievably” splits into three pieces. Common words stay whole; rarer ones fragment into parts the tokeniser has seen before.

✅ Why sub-word chunks? One token per word needs an enormous vocabulary and still fails on anything unseen. One token per character keeps the vocabulary tiny but makes sequences very long. Sub-word tokenisation takes the middle: common words are single tokens, and any unknown word can still be built from smaller pieces. Nothing is ever out-of-vocabulary.

A rough rule for English: one token is about four characters, or ¾ of a word. 100 tokens is roughly 75 words.

How the vocabulary is built

Most models use Byte Pair Encoding, and the algorithm is simple enough to describe in a sentence: start with individual characters, repeatedly find the most frequent adjacent pair, and merge it into a new token — until you reach your target vocabulary size.

🧪 Byte Pair Encoding in miniature

Suppose your training text is mostly the words low, lower, lowest.

Start with characters: l o w e r
The pair l o occurs most often → merge into lo
Now lo w occurs most often → merge into low
Then e r appears often → merge into er

You end up with tokens like low, er, est. “Lower” is two tokens, “lowest” is two — and a word never seen before, like “lowness”, still tokenises fine as low + ness.

Frequency in the training text decides everything. That is why common English words are single tokens and rarer words fragment.

Five behaviours tokenisation explains

Models miscount letters. Ask how many r’s are in “strawberry” and a model may get it wrong — not from stupidity but because it never sees the letters. It sees two or three token IDs. Counting characters inside a token is like counting the letters in a word you only ever heard as a single sound.

Reversing words is hard for exactly the same reason.

Some languages cost far more. Tokenisers are trained mostly on English, so English is efficient. The same sentence in Thai, Hindi or Burmese can take two to four times as many tokens — meaning higher cost, slower responses, and less room in the context window, for identical content.

Whitespace matters. ” the” and “the” are usually different tokens. A stray space can change tokenisation and, occasionally, output.

You are billed per token. Not per word or character. This is also why the context window is measured in tokens — “128k context” means 128,000 tokens, roughly 96,000 English words.

Tokenisation and cost

ContentRoughly
1 token~4 characters of English
100 tokens~75 words
1,000 tokens~1.5 pages of prose
CodeMore tokens per character — punctuation and indentation add up
NumbersOften split digit by digit, which is part of why arithmetic is hard

⚠️ Do not estimate tokens by counting words

If you are budgeting for an API, count properly — use tiktoken for OpenAI models, or the tokeniser that ships with whichever model you are using. Word counts can be out by 50% or more on code, non-English text, or anything with unusual formatting.

What happens next

Token IDs are not yet meaningful — ID 5771 has no more relationship to ID 5772 than any other pair. The next step converts each ID into a vector that does carry meaning, and that is embeddings, the following post in this sequence.

🔑 Key Takeaways

  • Tokenisation splits text into sub-word chunks and maps each to an integer ID.
  • Byte Pair Encoding builds the vocabulary by repeatedly merging the most frequent pair.
  • Roughly 4 characters per token in English; other languages can cost several times more.
  • Models cannot see letters, which is why they miscount characters and struggle with arithmetic.
  • Cost and context windows are measured in tokens — count them properly, do not estimate.

Further reading

OpenAI’s tiktoken library lets you tokenise text yourself and see exactly how a string splits, and Hugging Face’s Byte Pair Encoding chapter walks through the merge algorithm step by step.

Where to go next

Scroll to Top