When you type “bank”, an AI doesn’t know whether you mean money or a river. Watch it figure that out, layer by layer, measured from a real model.
This is a simplified illustration of model computation. It does not show a mind, feelings, or a literal stream of thoughts.
“I waited by the bank.”
River bank? Money bank?
On its own, the model can’t be sure.
Add a few words:
The river was rising, so I waited by the bank.
Which meaning will the model land on?
Back to the beginning. First, our sentence is chopped into pieces called tokens.
TextThe river was rising, so I waited by the bank
How many pieces do you think this becomes?
Each token is really a number, an entry in a vocabulary of 50,257. The model never sees letters.
4647850373739611523314134884162623331
These tokens come from GPT-2’s own tokenizer, the same model measured on the rest of this page. “Try your own” uses that tokenizer (r50k_base) through the open-source gpt-tokenizer package. Other models split text differently.
A token can be a whole word, part of a word, a space and a word together, or a punctuation mark. Common words are usually one token. Rare words break into several. Each piece is really a number: its place in a vocabulary of 50,257.
TakeawayAI doesn’t read words. It reads chunks of text, and each chunk is a number.
One tiny word. 768 numbers. Here is “bank” in two different sentences.
Measured from GPT-2 small · the word “bank”
You can’t meaningfully read those numbers one by one. Together, though, they act like coordinates describing how the model currently represents that piece. They are often called an embedding. They were learned in training, so pieces used in similar ways end up with similar numbers. And they are looked up the same way every time, whatever the sentence around them.
TakeawayBefore context, both meanings of “bank” are literally identical to the model.
This is what you watched at the top of the page, slowed down. Press play, or step through the layers.
The river was rising, so I waited by the bank
Start: before any re-reading
Start: “bank” is the same in every sentence.
Nothing has been re-read yet. Each token only knows itself.
No lean yet
This is the part most explanations skip. The numbers pass through a stack of layers: 12 in GPT-2 small, many more in today’s large models. In every layer, each token looks back at the tokens before it, a step called attention, and pulls in what it needs. Then its numbers are rewritten. Meaning is not looked up once. It is rebuilt, layer after layer.
A hint about a rising river pulls “bank” toward the river meaning from the very first layer. A check to deposit pulls it toward money. With no hint at all, GPT-2 drifts toward money, the more common use of “bank” in the text it learned from.
TakeawayThis is where context changes what a word represents.
One more experiment
What if “river” comes after “bank”?
After a long and busy morning, I waited by the bank. The river was rising.
Will “river” change what “bank” means?
You’ve watched the model work out what “bank” means. But understanding the sentence isn’t enough. It still has to decide what comes next, and you can read that decision forming, layer by layer.
The river was rising, so I waited by the bank of the ___
The final answer is “river”. When do you think it takes the lead?
Measured from GPT-2 small. Layers 1 to 11 are read out with the “logit lens”, an approximation: each layer’s numbers are run through the model’s final step early. Layer 12 is the model’s real output. Orange marks the final answer wherever it appears.
In the first layers, the guesses are generic words. Around the middle, the right idea appears. By the last layers, one answer has pulled ahead. The answer is not retrieved from a list. It is built up as the text is re-read.
TakeawayThe answer doesn’t suddenly appear. You can watch it become more likely.
Surely AI knows 2 + 2, right?
Complete it: “Two plus two equals ____”
The model picks one piece, adds it to the text, and starts the whole trip again.
Measured from GPT-2 small · real probabilities along one path
The river was rising, so I waited by the bank of the
To add 5 more pieces, how many layer passes does the model run?
Scores for the next piece
After the last layer, the model scores every token in its vocabulary of 50,257. One is selected and added to the text. Then the whole trip runs again, through every layer, to pick the one after that. A single paragraph of reply takes about a hundred of these trips.
That is the whole journey for our sentence: text, then 11 pieces, then 768 numbers for each, then 12 rounds of re-reading, then “river”, and then all of it again for the next word.
TakeawayEvery reply is built this way: one piece at a time, re-reading everything each time.
What you watched is a model computation, illustrated for people. Numbers are looked up, re-read and rewritten through 12 layers, then a next piece is scored and selected, over and over. There is no mind or feeling in the picture.
Whether any of it deserves the word “thinking” is a question about words as much as machines. What the measurements show is narrower and more useful: in a language model, meaning is built up by re-reading, and every answer is chosen one piece at a time.
Similar-looking answers can come from very different processes. A model produces an output; the application around it decides what happens next. See how a business puts AI outputs to work →That demo uses a different model. This guide shows a general language model.
GPT-2 small is from 2019. It has 124 million parameters and 12 layers, small enough to measure on a laptop, which is why it is used here. Today’s large models are built on the same core design, the transformer, with many more layers and far more parameters. Exact sizes are often not published.
Some newer models also write out intermediate steps before they answer, then read those steps back as more text. That is a second loop on top of the one shown here, and it is still text being scored and selected.
Researchers who study model internals, a field called interpretability, keep finding more structure than one page can show, such as internal features for specific concepts and steps that happen inside a single pass. The picture here is the starting point.
More AI demos: all playgrounds. Thinking about building with AI? Can I vibe code it myself?
Knowing how the model works is the start. The useful part is deciding where it helps, and wrapping it in rules you control.