mej7.comHow AI Works

What are tokens?

Author: Mehdi Sadriu, independent educator. Last reviewed: 25 November 2026. How we check claims: methodology.

A token is a vocabulary piece: sometimes a whole word, sometimes part of a word, sometimes punctuation. Before a transformer 'looks' at your sentence, a tokenizer turns the text into a list of integer IDs. Byte-pair encoding (Sennrich et al. (2016)) is a widely used way to build that vocabulary from data.

In one paragraph. Token: an atomic vocabulary item the model scores. Tokenization: text → list of token IDs.

A teaching split. Not a vendor tokenizer.

I love cats. → [I] [love] [cats] [.] (cartoon). A real BPE might glue or split differently.

Why not always whole words?

Languages have too many word forms, and new words appear. Subword units let the model reuse pieces ('play' + 'ing'). Rare names still split awkwardly. Different tokenizers split the same sentence differently — so 'token count' is tokenizer-specific.

Why does token count matter?

The context window is measured in tokens, not pages. Cost and speed often are too. A long word in one language can be many tokens in another.

What should you try next?

The Intermediate lab's Tokens page lets you type text and see a teaching split. It is not necessarily the same tokenizer as ChatGPT or Claude.

What is the math?

BPE starts from characters (or bytes) and repeatedly merges the most frequent adjacent pair into a new symbol, until a vocabulary size is reached (Sennrich et al., 2016). The model then maps each ID to a vector (an embedding).

Worked example

'unhappiness' might become ['un', 'happiness'] or ['unh', 'appiness'] depending on the vocabulary. The teaching conveyor on the Beginner hub is a cartoon of this idea, not a production tokenizer dump.

Check your understanding

Five questions. Answers are in the disclosure under each item, so this page still works if JavaScript is off.

1. A token is always exactly one English word.
Show answer

B. Subword tokenizers are the default.

2. BPE was introduced for NMT by…
Show answer

A. ACL 2016 paper.

3. Context windows are usually counted in…
Show answer

B. Not characters, not pages.

4. Different products can tokenize the same sentence differently.
Show answer

B. Vocabulary is part of the system.

5. After tokenization, each ID becomes…
Show answer

B. The residual stream starts there.

Further reading

  1. Neural Machine Translation of Rare Words with Subword Units — Sennrich et al. (2016). ACL.
  2. A Neural Probabilistic Language Model — Bengio et al. (2003). Journal of Machine Learning Research.