# What Are AI Tokens? Why Chatbots Read Chunks, Not Letters

How a frozen tokenizer turns your text into numbered subword chunks — and why that one step explains per-token pricing, higher costs for non-English languages, token-based context limits, and the model's trouble counting letters.

> tokenization · large language models · next-token prediction · About 7 min · Nov 16

## Key points

1. A token is a chunk of text with a numeric ID, produced by a tokenizer that runs before the model and is frozen after training; the model itself never sees letters.
2. Subword chunks win over whole words (too many entries, still incomplete) and over single letters (too many steps, too little meaning per step).
3. Byte-pair encoding builds the vocabulary from all 256 byte values by repeatedly merging the most frequent adjacent pair, so common text becomes compact tokens and rare text stays splintered.
4. Tokenization explains per-token pricing, token-based context windows, and the language gap: identical content needed about 1.6× as many tokens in Italian, 2.6× in Bulgarian, 3× in Arabic, and up to 15× in Shan as in English under the ChatGPT and GPT-4 tokenizers.
5. Counting letters is unreliable because the model must recall a word's spelling rather than read its characters; spacing letters into separate tokens makes counting possible again.
6. Token counts are model-specific, since each tokenizer splits text differently.

---

You paste a two-page contract into ChatGPT and it tells you the message is too long. Your API bill is counted in something called tokens. And when you ask a chatbot how many r's there are in "strawberry", it confidently says two.

Three unrelated annoyances, one cause: before the model does anything, a separate program chops your text into pieces called **tokens**, and the model never sees a single letter.

## A token is a chunk of text with an ID number

Think of a warehouse where every item has a shelf number and the staff can only say "shelf 4231", never "the small blue box". A language model works with numbers, so text is converted into numbers going in, and back into text coming out.

The program that converts is the **tokenizer**. Each chunk it produces is a **token**; the full list of chunks it knows is its **vocabulary**, anywhere from about 50,000 to a few hundred thousand entries; and each chunk's number is its **token ID**, which is all the model actually receives.

Here is a real example from OpenAI's documentation. The string `ChatGPT is great!` becomes six tokens:

```
["Chat", "G", "PT", " is", " great", "!"]
```

Notice three things, because they keep mattering. The space rides with the *following* word — the vocabulary holds `" is"`, not `"is"` plus a space. Capitalization is part of the entry, so `"Chat"` and `"chat"` are different tokens. And unusual strings get sliced: `ChatGPT` isn't in the vocabulary as one piece, so it falls apart into pieces that were frequent enough in training to earn their own slots.

The tokenizer is trained first, before the language model, and then frozen. It isn't part of the neural network, and it doesn't improve as you chat.

## Why not whole words? Why not single letters?

Both obvious designs fail, and seeing why makes the real one feel inevitable.

**Whole words** means a vocabulary of hundreds of thousands — plus names, typos, product codes, new slang — and it's still incomplete, so anything missed needs an awkward "unknown" fallback. Related words also become unrelated entries: `book`, `books` and `bookstore` each need their own slot despite sharing a core of meaning.

**Single letters** fixes coverage with about a hundred entries, but a thousand-word page becomes roughly six thousand separate steps, each carrying almost no meaning. The model would spend its capacity relearning that `e` usually follows `th`.

Real tokenizers take the middle path, called **subword tokenization**:

| Design | Vocabulary size | Sequence length | Where it breaks |
| --- | --- | --- | --- |
| Whole words | Enormous, still incomplete | Short | Unseen words, names, typos |
| Single letters | Tiny | Very long | Too little meaning per step; slow and costly |
| Subword chunks | Tens to hundreds of thousands | In between | Any text is representable; lengths vary by language |

Frequent words stay whole; rare words break into familiar pieces, so `annoyingly` might arrive as `annoying` + `ly`. The right picture is a parts bin, not a dictionary: a dictionary must contain every word, a parts bin only needs every *piece* you might assemble.

## How the tokenizer chooses its chunks: merge whatever repeats

Nobody designed these chunks by hand. They're harvested from data by **byte-pair encoding**, or BPE — a 1994 file-compression trick later repurposed for language models. The principle is compression: whatever repeats often gets a short name.

The modern version starts from bytes. Any text is a byte sequence in UTF-8, and a byte takes only 256 possible values, so a 256-entry base vocabulary can represent anything at all — no unknown-character escape hatch. This is byte-level BPE, introduced with GPT-2. Then comes the loop:

1. Count which adjacent pair of tokens occurs most often in a large sample of text.
2. Mint a new token for that pair, give it the next ID, and replace every occurrence.
3. Repeat tens of thousands of times.

A tiny illustration, starting from letters. Suppose the training text has `low` five times, `lower` twice, `newest` three times:

| Round | Most frequent pair | New token |
| --- | --- | --- |
| 1 | `l` + `o` (7 times) | `lo` |
| 2 | `lo` + `w` (7 times) | `low` |
| 3 | `e` + `s` (3 times) | `es` |

After two rounds, `low` is one token that also covers the front of `lower`, which now reads `low` + `e` + `r`. Run the loop fifty thousand times and you get GPT-2's 50,257 slots: 256 bytes, 50,000 merges, one end-of-text marker. Newer tokenizers are larger, around 100,000 entries for OpenAI's `cl100k_base` and around 200,000 for `o200k_base`.

The consequence to hold onto: **which chunks exist depends on what the training text looked like.** Common text gets compact chunks; rare text stays splintered.

## What tokenization explains about AI tools

### Why your bill is counted in tokens

API pricing is per token, with input and output priced separately, output usually dearer. For English, one token is roughly four characters or three-quarters of a word, so 100 tokens is about 75 words and a 1,000-word document is somewhere near 1,300 tokens. These are estimates, and they're tokenizer-specific: the same sentence can be 40 tokens under one model and 55 under another, so a price per million tokens doesn't settle what a job will cost.

### Why the same text costs more in some languages

English letters take one byte each in UTF-8; Chinese and Japanese characters typically take three. If those byte sequences never got merged into large chunks — because the tokenizer's training text was English-heavy — the content stays in small pieces and eats far more tokens. A 2023 study by Petrov and colleagues measured identical content across languages under the tokenizers used by ChatGPT and GPT-4: Italian needed about 1.6 times as many tokens as English, Bulgarian about 2.6, Arabic about 3, and Shan, a language of Myanmar, as much as 15 [5]. As the paper stresses, the disparity arises at the tokenizer, *before the model is invoked at all*. Users of those languages pay more for the same task, wait longer, and fit less content into the same context window.

![The same sentence tokenized in two languages, with coloured blocks marking each token: one side uses far more tokens for the same content.](https://aleksandarpetrov.github.io/tokenization-fairness/assets/tokenization_diff.jpg)

### Why the context window is counted in tokens

A model's **context window** is the fixed number of tokens it can hold at once — your prompt, any system instructions or attachments, and the reply. Because the unit is tokens, a "200,000-token window" isn't a fixed page count: it's a lot of English prose, less of a language using three-byte characters, and less again for code and URLs, which tokenize messily. When a chat says your message is too long, it's reporting a token count you can't see.

### Why counting letters is a weak spot

The model receives `strawberry` as one ID or a couple — never as eleven letters. To answer, it must recover the spelling from what it absorbed during training, not read characters off the input. That's recall, not counting, and recall can be right almost always and still slip on one word. The same limit explains shaky performance on reversing words, rhyming, anagrams and counting words in a paragraph.

There's a practical trick that follows from the mechanism: ask the model to spell the word with spaces between the letters, `s t r a w b e r r y`, and each letter usually lands in its own token. Counting now has something to count. It isn't a guarantee — and some systems increasingly hand such questions to a small piece of code — but the reason it helps is exactly this: you changed the input so the letters became visible items.

## Where the parts-bin picture stops working

**A token is not a unit of meaning.** It's a frequency artifact. `un` + `believ` + `able` doesn't mean the model has a concept called "un"; those boundaries fell where they fell because the sequences repeated. The same word with a leading space or in capitals can split differently.

**It's a resolution limit, not a wall.** The model does learn plenty about spelling, because chunks recur across millions of words. It isn't blind to letters; it reads them through chunks, which makes letter-level questions unreliable rather than impossible.

## The one-sentence version

A token is a frequent chunk of text with an ID number, chosen by repeatedly merging whatever pairs appear most often in training data — and that one decision, chunks rather than words or letters, is why AI is billed per token, why some languages cost several times more than English for the same request, why context limits are counted this way, and why counting letters is asking a model to do something its input format doesn't put in front of it.

From here, those IDs enter the model and become a prediction for the next token — the sampling loop described in [the previous article](https://eulore.ai/articles/what-is-generative-ai-3a95f306).

## Mind map

```mermaid
flowchart LR
  A["Your text"] --> B["Tokenizer: trained once, then frozen"]
  B --> C["Subword tokens with ID numbers"]
  C --> D["Model sees IDs, never letters"]
  D --> E["Next token ID predicted, decoded to text"]
  B --> F["BPE: merge the most frequent pair, repeat"]
  F --> G["Common text gets compact chunks"]
  G --> H["Billing per token"]
  G --> I["Non-English text costs more tokens"]
  G --> J["Context window measured in tokens"]
  E --> K["Letter counting is a weak spot"]
```

## Glossary

- Token：a chunk of text — a character, a word fragment, or a whole word — that the model treats as one unit and receives only as a number.
- Tokenizer：the separate program that learns a fixed split from training text, then applies it to everything you send; it is not part of the neural network.
- Vocabulary：the fixed list of chunks a tokenizer knows, from tens of thousands to a few hundred thousand entries.
- Token ID：the integer the model actually receives in place of a chunk.
- Subword tokenization：the middle path between whole words and single letters, keeping frequent words intact and breaking rare ones into reusable pieces.
- Byte-pair encoding (BPE)：the merge loop that builds a vocabulary by counting the most frequent adjacent pair, minting a token for it, and repeating.
- Byte-level BPE：starting from all 256 byte values so any text, including emoji and unknown scripts, can be represented without an "unknown" token.
- Context window：the fixed number of tokens a model can process at once, covering prompt, attachments and reply; being a token count, it doesn't map to a fixed number of pages.

## Sources

1. [OpenAI Help Center: Understanding and counting tokens — what tokens are, the four-characters-per-token rule of thumb, input vs. output tokens](https://help.openai.com/en/articles/4936856-understanding-and-counting-tokens)
2. [OpenAI API docs: Advanced usage — the "ChatGPT is great!" tokenization and what token counts affect](https://developers.openai.com/api/docs/guides/advanced-usage)
3. [OpenAI cookbook: How to count tokens with tiktoken — encodings such as cl100k_base and o200k_base, spaces grouped with word starts](https://developers.openai.com/cookbook/examples/how_to_count_tokens_with_tiktoken)
4. [Hugging Face LLM course: Byte-Pair Encoding tokenization — the merge loop, GPT-2's 50,257 slots, and byte-level BPE](https://huggingface.co/learn/llm-course/en/chapter6/5)
5. [Petrov et al., Language Model Tokenizers Introduce Unfairness Between Languages (NeurIPS 2023) — token-length gaps up to 15× between languages](https://arxiv.org/abs/2305.15425)
6. [Byte-Pair Encoding explainer — subword intuition and how merge rules are learned once and then fixed](https://philipmueller.dev/bpe-explainer/)

---

Original article: https://eulore.ai/articles/what-are-ai-tokens-59fb565e

> **Eulore** · Start small. Go deep.
>
> Eulore is an AI learning tool built around connected articles, each a 5–10 minute read. Ask questions as you go and help shape what comes next. That’s how this article was created.
>
> Start your own series → https://eulore.ai
