Topic 2 of 5 · 4 min read
Learning by predicting missing text
Goal: Explain how next-token training turns into stored, lossy knowledge and why rare facts are recalled less reliably than common ones.
Pre-training asks one question billions of times, "what token comes next?", and the weights that answer it best end up holding a compressed, lossy copy of what the text said. Nobody writes the facts in. They fall out of getting predictions right.
Check yourself · 1 of 3
What does a language model predict during pre-training?
Why it matters
This explains two things users notice. The model knows a lot, because predicting text well requires knowing the world the text describes. And it sometimes invents details, because what it holds is a blur of patterns, not a database of records.
How training works
- Text is cut into tokens, small pieces of words.
- The model sees a stretch of tokens and predicts a probability for each possible next one.
- A loss number measures how much probability it gave the true next token.
- Training nudges the weights, the model's numbers, so that true tokens get slightly more probability next time.
- This repeats over trillions of tokens.
To predict "The capital of France is ___" the model needs the fact. To predict the next line of code it needs the syntax. To finish a proof it needs the logic. The loss rewards all of this at once.
Why recall is lossy
The weights are far smaller than the text they learned from, so they cannot store it word for word. They keep what is common and consistent and blur the rest.
- A fact seen in thousands of documents, such as a capital city, is sharp.
- A fact seen once, such as a minor person's birthday, is faint, and the model may produce something plausible but wrong.
- A text repeated very often can be memorised close to verbatim.
The model has no flag that says "I am unsure here". A faint memory and a firm one come out in the same fluent voice.
Before and after
Weak: "Give me the exact page number and quote where that 1998 paper defines the term."
Better: "Summarise what that 1998 paper is generally known for. I will check any quote or page number in the source."
The first asks for a rare, exact detail, which is where lossy storage fails. The second asks for the common gist, then checks the details.
What goes wrong
- Trusting precise rare details. Dates, citations, numbers and names of obscure people are the weakest.
- Thinking it looks things up. In plain pre-training there is no lookup; it reconstructs from patterns.
- Expecting consistency. The same fact asked two ways may come out two ways.
Tools such as search or retrieval fix this by putting the real text in front of the model, so it reads rather than recalls.
Examples
Common versus rare
Ask any strong model for the boiling point of water at sea level and it answers correctly, since the fact appears everywhere. Ask for the third author of a little-cited 2011 workshop paper and it may give a plausible name that is wrong. Same model, same confidence in tone, very different reliability.
A small code branch: the loss in one line
The training signal is the negative log of the probability given to the true next token.
import math
p_true = 0.02 # model gave 2% to the real next token
loss = -math.log(p_true) # about 3.9, high: a poor guess
Lower loss means the model put more probability on what the text actually said.
Key points
- Pre-training repeats one task, predicting the next token, and knowledge is a by-product of doing it well.
- The weights are much smaller than the training text, so stored knowledge is compressed and lossy.
- Common, consistent facts are recalled reliably; rare, exact details are often blurred or invented.
- The model gives no built-in signal of how sure it is, so a guess sounds like a fact.
- Supplying the source text turns recall into reading and removes most rare-fact errors.
Common mistakes
- Treating a model like a database of facts that it can look up exactly.
- Asking for exact quotes, page numbers or citations from memory.
- Assuming that a confident tone means the fact was common in training.
- Thinking training copies documents in, rather than adjusting shared weights.
Check yourself · 2 of 3
Why is a model more reliable on a famous fact than on an obscure one?
Check yourself · 3 of 3
What does "lossy" mean for knowledge stored in model weights?
Practice items, not counted towards your mastery.
Start here
- Andrej Karpathy: Deep Dive into LLMs like ChatGPT (opens in a new tab)VideoFree
A three-hour walk through pre-training data, tokens, base models and post-training, from a practitioner.
- FineWeb: decanting the web for the finest text data at scale (opens in a new tab)ArticleFree
A worked example of turning Common Crawl into training data: filtering, deduplication and what each step changes.
- Training Compute-Optimal Large Language Models (Chinchilla) (opens in a new tab)PaperFree
The study showing that, for a fixed compute budget, model size and training tokens should grow together.
More for this topic
- Stanford CS336: Language Modeling from Scratch (opens in a new tab)CourseFree
A free university course that covers data, training and scaling in depth, with lecture notes.