How AI predicts the next word
Five short modules. No maths required; bring your scepticism.
Words become numbers
Two Darwins
Same two words. How does a machine, which has never met either Darwin, tell them apart?
Computers only speak numbers
Real models use thousands of numbers per word; we're showing six. These values are illustrative, not real model outputs.
Where do those numbers come from?
Nobody typed them in. They are weights: adjustable dials inside the model, and they start out random. Training is trial and error at colossal scale.
-0.44, 0.13, -0.09]
Guess; measure the miss; nudge every dial a tiny bit in the direction that reduces the miss; repeat, billions of times across the whole training corpus. You already know this idea from Excel: a trendline is two numbers fitted to data by minimising error. This is the same idea with billions of numbers. The probabilities you'll meet in Module 3 are calculated from these same trained dials. Values illustrative.
The map of meaning
One honest admission
The scale of it
Start with one book
Text is remarkably compact. Every word in a full novel weighs less than one photo on your phone. Hold onto that unit; we're about to stack it.
Book and library sizes in this module are illustrative estimates for teaching; the web-scale and GPT-3 figures are cited on screen.
Climbing the ladder
The bars are on a logarithmic scale. Drawn honestly, with your phone at one centimetre, the Common Crawl bar would run about 740 metres.
Common Crawl figures: Baack, S. (2024) "Training Data for the Price of a Sandwich", Mozilla Foundation, mozillafoundation.org/en/research/library/generative-ai-training-data/common-crawl/ ; Ilyankou et al. (2024) arXiv:2405.11039.
What goes in
Brown et al. (2020) "Language Models are Few-Shot Learners", arXiv:2005.14165; Baack, S. (2024), Mozilla Foundation, as previous screen.
How much reading is that?
Calculated from the GPT-3 token count; illustrative. To finish this morning, you would have needed to start around 800 BC, before Rome was founded.
Where did the pages go?
"So is it training on me right now?"
- Done in the past, once, at vast expense
- Read the enormous corpus you just climbed
- Produced the frozen model: billions of fixed weights
- Those weights do not change when you chat
- Your prompt goes in; the model predicts the next words
- Every reply is generated fresh, on the spot
- Afterwards, the model is exactly as it was
- Nothing you typed is woven into its weights
Whether a provider separately stores or reuses your prompts is a product and policy question; it is set by terms of service and settings, not by anything the model does on its own.
Rolling weighted dice
Probabilities in this module are illustrative, hand-crafted for teaching; they are not real model outputs.
Build a sentence, one draw at a time
Click a word to place it. We skip the small connecting words to save time; in the real model every word, even "the", gets its own weighted draw.
The temperature dial
One setting controls how the dice are rolled: play it safe, or give unlikely words a chance.
Prompt: "The crocodile lurked in the …"
Same prompt, three outputs
Prompt: "The crocodile lurked in the …", medium temperature, three separate runs
It cannot copy and paste an answer it does not store; each sentence is a fresh weighted draw over the whole vocabulary.
Where do the percentages come from?
No lookup happens anywhere in this chain; there is no table of facts to consult.
The confident machine
Probabilities in this module are illustrative, hand-crafted for teaching; they are not real model outputs.
Same machine, harder question
Prompt: "Give me a journal citation on buffalo management in the Northern Territory."
Every fragment above is plausible on its own: the name, the journal, the volume, the DOI. The whole is fiction. The dice never checked a shelf, because there is no shelf.
Why did that happen?
- Position on the map of meaning
- Patterns from the training text
- Weighted draw, one word at a time
- Fluent output
- Position on the map of meaning
- Patterns from the training text
- Weighted draw, one word at a time
- Fluent output
Read the two lists again; they are identical. The process that produced a correct answer and the process that produced the fake are the same process. There is no separate fact-checking step, and no slot anywhere in the machine that holds "true".
Why not just say "I don't know"?
The distribution always offers a next word. Watch how the honest answer competes:
Declining to answer is itself just a pattern, and it must be trained in; it competes with fluency and usually loses. Helpfulness training amplifies confident continuation; it is the amplifier, not the root cause. Values illustrative.
What helps
Ask for sources; then check them
A citation is a claim, not evidence. Search for the paper; if it does not exist, you have learned something important about the answer.
Prefer grounded modes
Tools that search or retrieve real documents before answering give the dice something solid to land on.
Fluency is not accuracy
Confidence and polish are properties of the writing, not the facts. The fake citation read beautifully.
The black box
We built it; we can measure it; we cannot fully explain it.
What we can and cannot see
- Every weight; all billions of dials are readable
- Every probability on every draw
- Every input and every output
- Why these particular numbers produce that behaviour
- Which internal patterns carry which ideas
- What the model will do on inputs nobody has tried
Working on the right-hand column is called interpretability research: reverse-engineering the features and circuits inside trained models. It is real, it is progressing, and it is early.