AI Academy · Module 2: Inside Language Models

Tokens and Tokenization

Recognize subword tokens, token IDs, model-specific tokenization and the practical meaning of a context window.

Lesson 4 of 11 · Reference topic 5 · Advanced learner pilot · Educational review pending

← All AI Foundations lessons

Start with the big idea

A model typically receives token IDs rather than raw letters. One token might be a short word, a word fragment, punctuation or a piece of whitespace, depending on the tokenizer.

Understand it in more detail

Tokenization converts input text into discrete units and then IDs from a model's vocabulary. A tokenizer trained on one language or corpus may split the same phrase differently from another.

Subword methods such as byte-pair encoding or unigram language-model tokenization trade vocabulary size against the number of pieces needed to represent unfamiliar words. Byte-level approaches can often avoid unknown characters.

Context limits are usually measured in tokens rather than words, which matters for costs and how much conversation or source text can fit. Token IDs are arbitrary numeric labels, not numerical meanings.

Worked example

The word 'unbelievable' could be one token with one vocabulary, or several pieces with another. The exact split and token IDs cannot be asserted without running the specified tokenizer.

Teaching examples are illustrative unless an external source or real model measurement is explicitly identified.

A misconception to avoid

A token is not always a whole word, and the example token IDs in a teaching diagram should never be presented as exact values unless verified against that tokenizer.

Experiment: split a sentence into tokens

This interactive example compares simple word-and-punctuation splitting with a toy subword rule that divides longer Latin-letter words into smaller pieces. It is not a real model tokenizer, not BPE, and does not produce actual model token IDs or billing estimates. Spaces are shown as separate tokens to make the differences easy to observe.

Use invented sentences, not names or personal details. Text stays on this page.

Try another sentence:

Predict before changing the method: Which sentence will produce more pieces? Why might different real tokenizers produce different answers? This classroom method is intentionally limited to English-like Latin-letter inputs. It is not suitable for assessing how a model tokenizes Dari, Pashto, or other scripts.

Check your understanding

Think first, then open each answer to check your explanation. These self-checks do not record a score.

1. Can two different models split the same sentence differently?

Yes. They may use different vocabularies and tokenization algorithms.

2. Does token ID 1000 mean twice as much as token ID 500?

No. IDs are categorical vocabulary indices, not measurements.

Try it yourself

Write five sample phrases including punctuation and a compound word. Predict how subword boundaries might differ, then label the predictions as hypothetical until tested with a real tokenizer.

Explain it back: Summarize the main idea in your own words and name one limitation or risk.

Continue learning

Read an independent reference: https://huggingface.co/docs/transformers/tokenizer_summary. This link is for reference, not a requirement to create an account. External websites may have different privacy and access policies.

Educational pilot. Terminology, age suitability and activities are subject to expert review. These pages do not send your answers to a server.