Skip to main contentSkip to navigationSkip to footer
DigiTransact AI Education Centre Start Learning

Level 3 · Module 16 · 10 minutes

Tokens: how a language model reads text

What you will learn
  • Define a token and explain why models use tokens rather than letters.
  • Explain why letter-level tasks can be unreliable.
  • Explain what a context window is.

A large language model works with tokens, not with letters or words exactly as you see them. A token is a small piece of text. It can be a whole word, part of a word, a punctuation mark or a space with a word attached. Before any other work, the text of a prompt is split into these pieces.

From tokens to numbers

Each token is matched to a number called an identifier. The tokeniser is the part of the system that splits text and looks up identifiers. Its rules are fixed when the system is built. Common words are often a single token, while rare or long words may be split into several pieces. The same word can be tokenised differently depending on the surrounding text and the rules of that system.

Once the text is a list of numbers, the neural network can process it. The model does not receive a clean dictionary of meanings. It receives these pieces and must learn from them during training.

Why counting and spelling are hard

If a model sees pieces rather than individual letters, tasks that depend on letters are awkward. Counting the letters in a word, reversing a word or noticing a small spelling error may be unreliable, especially for unusual words. It is not that the model is careless. The input format hides some of the letter information.

The context window

A model can attend to only a limited number of tokens at one time. This limit is called the context window. It includes the prompt, any instructions and the reply being produced. When text goes beyond the limit, older or extra material is dropped, summarised or handled in some other way. Long documents can therefore lose details or be cut off.

Token counts also affect cost and speed in commercial services, because more tokens mean more computation. A long prompt is not free.

A teaching picture, not a commercial system

Lessons show a short sentence split into a few coloured pieces. Real commercial models use tokenisers with very large vocabularies, meaning very large lists of tokens, and handle very long inputs. The principle is accurate, but the small example is a simplification for learning.

Common misconception

A language model reads text letter by letter, the way a person reads a page. It reads tokens, which are pieces of text mapped to numbers. Letters are not always visible as separate units, which is why letter-level tasks such as counting or reversing can be unreliable.

Guided practice

Take three sentences and split them into word pieces by hand, allowing punctuation and spaces to belong to pieces. Circle a word you think might be split into two tokens. Then write how far a model could read through a long document if only part of it fits the window. This is a paper exercise; no model is trained.

Knowledge check

1. What is a token?

2. Why can a language model struggle to count the letters in a word?

3. What is the context window?

Independent practice

Write a short example from your own work or daily life and decide whether it is AI, ordinary software or a mixture. Then explain why. Save it in your notes; no account is required.

Last reviewed: · Report a problem

Last updated: