← Tokens courseTOKENS · CHAPTER 1 OF 13 · 4 min READ · FREE

What is a token?

The story

Think about a child learning to read. Before she reads whole books, she learns letters. Then short words. Then she starts to recognise common chunks like "ing", "the", "tion". She does not read letter by letter, and she does not need a separate memory for every word in the dictionary. She uses a mix of chunks.

An AI language model works in a very similar way. It cannot read like we do. It needs the text cut into pieces first. Those pieces are called tokens.

The one plain idea

A token is a small piece of text that the AI treats as one unit. It might be a whole word, part of a word, a single letter, a space, or a punctuation mark.

Everything an AI language model does, it does with tokens. It reads tokens. It writes tokens. It is limited by tokens. It is billed by tokens.

The kitchen-table picture

Imagine a box of Lego. You can build almost anything, but you never build from raw plastic. You build from bricks. Common shapes come as a single brick. Rare shapes have to be built from several small bricks.

Tokens are the bricks. Common words like "the" or "coffee" are usually one brick. A rare word like "unbelievably" may be several bricks: perhaps "un", "believ", "ably". The exact split depends on the model.

Worked example

Take the sentence: "I love shopping online."

One plausible split into tokens looks like this:

PieceIloveshoppingonline.
Tokens11111

That is about 5 tokens. Now a harder sentence: "Antidisestablishmentarianism is long." A tokenizer will probably split the long word into several pieces, so the sentence may come to 8 or 9 tokens. The exact numbers depend on the model, so treat both counts as illustrative.

A common rule of thumb for ordinary English: one token is roughly four characters, or about three quarters of a word. So 100 tokens is roughly 75 words. This is a rough average, not a law. Code, numbers, and other languages behave differently (see Chapter 8).

Two meanings of the word "token"

You may have heard "token" in crypto. Crypto tokens are digital assets on a blockchain. AI tokens are a different thing. They are not coins you own. They are pieces of text. Same word, different world. In this course, "token" always means the AI kind unless we say otherwise.

No-code exercise

Open any free AI chat or any public tokenizer demo page that a model provider offers. Paste in three things: a plain English sentence, a long rare word, and a sentence in another language you know. Write down how many tokens each one uses. Which surprised you?

Self-check

  1. In one sentence, what is a token?
  2. Is a token always a whole word? Give one example that shows it is not.
  3. Is an AI token the same as a crypto token?
  4. Roughly how many words are 100 tokens in English?

Answers. 1) A small piece of text the model treats as one unit. 2) No. A long or rare word is often split into several tokens. 3) No. They share a name only. 4) About 75.

CURIOUS? TEST THE CLUES

Curiosity check

Pick an answer and see why. No scores, no pressure. All shop examples are invented practice scenarios.

01 Is a token always a whole word?
02 Do these illustrative token counts guarantee your bill?
Course sources and freshness

Sources to read next

These are public, well-known references behind facts named in this course. Check them for current detail.

  • Vaswani et al., "Attention Is All You Need" (2017). The transformer paper.
  • Sennrich, Haddow, Birch, "Neural Machine Translation of Rare Words with Subword Units" (2015). Byte pair encoding for language models.
  • Philip Gage, "A New Algorithm for Data Compression" (1994). The original pair-merging idea.
  • Petrov et al., "Language Model Tokenizers Introduce Unfairness Between Languages" (NeurIPS 2023).
  • Radford et al., "Language Models are Unsupervised Multitask Learners" (GPT-2, 2019). Byte-level BPE and its 50,257-piece vocabulary.
  • Kudo and Richardson, "SentencePiece" (2018).
  • Rumbelow and Watkins, "SolidGoldMagikarp (plus, prompt generation)" (2023). Glitch tokens.
  • Your chosen provider's current tokenizer tool and price page, for live counts and prices.