Module 01 · How AI Works · Interactive lesson
How an
LLM Works
A large language model does one thing, over and over: predict the next token. Below is a teaching toy — you build a sentence, and at every step the model shows you how likely each candidate token is. Click a bar to append it, or let the model sample one. The same loop, scaled up on real text, is what powers tools like Claude.
Teaching toy — hand-authored probabilities, not a real model
Next-token probabilities
0/12 appended
Each bar is the model's probability for that token coming next. Click one to append it; bars re-rank for the new context.
The sentence so far
The veteran is eligible for
Low temperature sharpens the distribution — the top token wins almost every time, so output is predictable. High temperature flattens it — less likely tokens get a real shot, so output is more varied and creative (and riskier).
Everything is tokens
A model doesn't see words — it sees tokens, little chunks of text. To generate, it reads the tokens so far and scores every possible next token. That's the whole job.
Predict, append, repeat
Pick one token, add it to the text, and ask again. Each click here is one step of that loop. Real models do it thousands of times a second over a vocabulary of ~100k tokens.
Temperature is a dial
The raw scores never change — temperature only reshapes how we turn them into probabilities. Turn it down for facts and forms; turn it up for brainstorming and prose.
Why this matters
Once you see that generation is just next-token prediction under a temperature dial, a lot of model behavior stops being mysterious — why it can hallucinate confidently, why lowering temperature makes it more reliable for a benefits form, and why a guardrail has to check the output, not trust the process.
Mission first, people always.