How does an LLM actually work?
It's not magic. It's two phases — run one after the other, millions of times a day.
It starts by reading an enormous amount of text
Web pages. Books. Code. Articles. A vast slice of everything humans have written down.
The model doesn't see words. It sees tokens.
Type a short phrase, or pick one below, and watch it break apart.
It plays a simple game, over and over
Guess the next word. Check the real answer. Adjust. Repeat.
Each correction nudges billions of tiny dials
Over billions of rounds, the connection strengths — the “weights” — settle into stable patterns.
Training ends. The weights freeze.
The model has compressed patterns of language, facts, and reasoning into one fixed set of numbers.
You type a prompt. It becomes tokens again.
Same Lego bricks as before — now assembled by you, in real time.
It reads the whole prompt at once
Not left to right, like a person reading. All tokens, all at once, in parallel.
Attention: deciding which words matter to each other
Hover a word to see what it “attends to.” Toggle heads to see different relationships tracked in parallel.
It doesn't “know” the answer — it ranks the possibilities
Every candidate next-token gets a probability. It samples from this ranked list.
One token at a time, fed back in, again and again
It appends its chosen token, feeds the whole thing back in, and predicts the next one.
Generative Pre-trained Transformer
You've heard the acronym. Now you know exactly what each word means.
Raw prediction isn't enough — it gets a polish pass
Not a third phase. A refinement round on top of Phase 2, using human preferences instead of raw text.
The black box isn't sealed anymore
- Read a massive amount of text
- Broke it into tokens
- Played “guess the next token,” billions of times
- Weights settled into stable patterns
- Training ends — the model freezes
- Your prompt becomes tokens
- The model reads it all at once
- Attention links related words together
- It ranks the next-token probabilities
- One token at a time, looped, until done