How AI works

What happens to your message

Context, tokens, numbers with meaning, and attention.

6 min2 / 4

You type a question and press Enter. Less than a second later, the first words of an answer appear. In between, your message goes through four steps. You do not need to remember the technical names, but knowing the steps explains a lot of everyday AI behaviour.

1 ContextYour message plus instructions, history and files.
→
2 Text is cut into small pieces.
→
3 MeaningEach piece becomes numbers on a map of meaning.
→
4 AttentionThe pieces are connected, layer after layer.
→
5 Next tokenProbabilities for what comes next.
All of this runs for every single token of the answer.

Step 1: everything is packed together

The model receives much more than your last message. The app adds its own instructions, your project instructions, memory notes, earlier messages in the chat, attached files and results from tools such as web search. All of this together is the context.

The model itself has no memory between messagesWith every new message, the whole context is sent again from the start. That is why a new chat “forgets” the old one, why very long chats get slower, and why features like memory work by adding notes to the context.

Step 2: text becomes tokens

Models do not read letters or whole words. They read tokens: small pieces of text from a fixed vocabulary. A short common word is often one token, a long or rare word is split into several pieces, and spaces and punctuation count too. In English, 100 tokens are roughly 75 words. Many other languages, including German and Portuguese, need more tokens for the same meaning.

Token counter

Type or paste any text. Each coloured piece is one token; a dot stands for a space. Simplified: real tokenizers use a learned vocabulary, so the exact split differs.

94 characters · 11 words · about 23 tokens

Unbelievably,·the·tokenizer·splits·long·words·like·“internationalization”·into·several·pieces.
Why tokens matter to youUsage limits, context size and API prices are all counted in tokens. Tokens also explain a classic weakness: counting letters in a word. The model sees “straw” and “berry”, not s-t-r-a-w-b-e-r-r-y, so tasks about single letters are harder than they look.

Step 3: tokens become numbers with meaning

Each token is turned into a long list of numbers, called an . You can picture it as a position on a giant map of meaning. Words with related meanings end up close together: “dog” near “cat”, “Lisbon” near “Porto”. During training the model learned where everything belongs on this map.

Step 4: attention connects the pieces

Now the model looks at all tokens at once and works out which ones matter for each other. This is called attention. In the sentence below, the word “it” only makes sense if the model links it to the right noun. Click the buttons and watch the focus move.

The trophy did not fit into the suitcase because it was too big
The darker the bar, the more attention “it” pays to that word. Change one word at the end and the focus jumps. Simplified illustration.

This happens again and again in many stacked layers, and each layer refines the picture: early layers handle grammar and word meaning, later ones handle ideas, tone and what the question is really asking. This design is called a Transformer. It was introduced in 2017 and is the “T” in ChatGPT.

What about pictures and files?

Images are cut into small patches, and each patch is turned into numbers, just like text tokens. A PDF is turned into text, and often also into images of its pages, so tables and charts can be read. After that, everything travels the same route through the model.

Try it now: Paste the same short paragraph in English and in your language into the token counter above. Which version needs more tokens?

Check yourself

1. What does the model receive when you send a message in a long chat?
2. Why do models struggle to count letters in a word?
3. What is an embedding?
4. In “The trophy did not fit into the suitcase because it was too small”, what does attention link “it” to?

Tip: use ← and → to move between lessons.