← Course
0/15

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

Horizontal bar chart of next-token probabilities, 6 candidates, highest first.Each row is a candidate next token and its temperature-adjusted probability; the top candidate is benefits at 82 percent. Activate a row to append that token to the sentence. benefits82% healthcare13% a3% education1% disability1% housing0%

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

0.80 · balanced
0.1 · one token dominates1.5 · spread out

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).

01

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.

02

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.

03

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.