Lesson 1

AI Tokens Explained

Definition: A token is a chunk of text encoded as a numeric ID. Models process these chunks—which can be whole words, word pieces, individual characters, spaces, or punctuation—rather than reading letter-by-letter.

Stage 1: The Live Tokenizer

Type in the box below to explore this page's simplified segmentation rule. It splits longer letter sequences for illustration; a real model's tokenizer may divide the same text differently. Click any token to inspect it.

AI Token Pipeline:
25 Tokens

Note: This is an educational approximation. Real models use complex subword algorithms (like BPE) which map chunks to exact numeric IDs.

Stage 2: The Context Window Budget

Models have a finite input-and-output token budget called the context window. This toy bucket drops the oldest chunks to visualize one truncation strategy. Real applications may truncate different content, summarize it, retrieve it later, or reject an overlong request.

Bucket: 0 / 15 Tokens
Model's Active Memory

Stage 3: The Prediction Engine

At its core, a generative AI model is just a massive probability calculator. It looks at the current tokens and calculates the percentage chance of every possible next token. You are the AI now: Pick the most statistically probable next token to continue the sentence. (Percentages are synthetic toy numbers for illustration).

LearningaboutAIis

Calculate next token probabilities:

Stage 4: The Economics of Language

Tokens are not equivalent to words. Segmentation and token count depend on the specific tokenizer and text: some languages, scripts, symbols, or code may use more or fewer tokens than an English rendering under a particular model.
Note: The counts below come from this page's educational approximation, not a real tokenizer. They cannot establish the relative efficiency or cost of a language.

Input String
The weather is very nice today.
13
Tokens
Required
Token Breakdown
The·weather·is·very·nice·today.

Frequently Asked Questions

Why don't models just read letters?

Tokenizer design is a model-specific engineering tradeoff among vocabulary size, sequence length, coverage, and efficiency. Tokens may be words, subwords, characters, bytes, or combinations; character-level and byte-level approaches also exist.

Do all models use the same tokens?

No. Different models use different token dictionaries (vocabularies). A word might be 1 token in GPT-4 but 3 tokens in an older model.

Why does AI struggle with spelling or counting letters?

Subword tokenization can make character-level tasks less direct because generation operates over token IDs, but tokenized text still encodes the underlying spelling. Performance depends on the model, tokenizer, training, and whether it uses suitable reasoning or tools.

How does tokenization affect price?

Some API providers price usage by input and output tokens. For a particular model and tokenizer, two equivalent texts can have different token counts, which may affect cost and processing time. No language is inherently more expensive: the result varies by tokenizer, text, model, and provider pricing.

worldweb.ai

A living library for understanding artificial intelligence.

Built for curious humans, not machines.