deep · 6 min
Pretraining
Next-token prediction over a huge pile of text. Where a model's knowledge comes from.
updated 23 Sept 2026
Where does a model's knowledge come from? Nobody typed in that Paris is the capital of France. And why does that knowledge stop at some date, so that a model can be sure about 2018 and blank about last month?
Both answers come from the first and biggest stage of building a model. It's one simple exercise, repeated an absurd number of times.
The exercise
Take a sentence from some web page:
The capital of France is Paris.
Split it into tokens and it turns into several practice questions at once. Predict "capital" from "The". Predict "of" from "The capital". And so on up to: predict "Paris" from "The capital of France is". Every position in every document is a question with a known answer. Nobody has to label anything, because the text is its own answer key.
For each question, the model guesses, we check the guess against what actually came next, and we nudge every parameter a tiny bit so the right token gets a little more likely. That's next-token prediction, used as the training signal.
Now do it over a pile of text that's hard to picture. GPT-3 (2020) was trained on 300 billion tokens. A person reading that much non-stop, day and night, would need over 2,600 years. Over that many examples, the model gets good at predicting its training text, and it also starts making sensible predictions on text it has never seen.
The pile
So what goes into the pile? Mostly the public web. The usual starting point is Common Crawl, an archive of web pages collected in regular snapshots. Raw web text is a mess (menus, ads, duplicated pages, lists of keywords), so a lot of the work is cleaning it.
The clearest public account of that cleaning is Hugging Face's FineWeb (2024). They pulled the readable text out of the raw HTML themselves, because Common Crawl's ready-made text files kept too much menu junk. Then they filtered and removed duplicates, step by step:
Builders also mix sources on purpose, and not in proportion to size. GPT-3's training was 60% filtered Common Crawl, 22% a curated web set called WebText2, 16% books and 3% Wikipedia. Sources judged better got shown more often: GPT-3 saw Wikipedia about 3.4 times over, but less than half of its Common Crawl text.
That's the cutoff answered, by the way. The model knows what was in the pile, and the pile was collected up to some date. GPT-3's web text covered 2016 to 2019. Anything after the crawl isn't in there unless you put it in the prompt.
Better text beats more text
Does the cleaning matter much? The last step of that funnel is a good test. The FineWeb team had a large model rate 460,000 web pages for how educational they were, trained a small classifier on those ratings, and kept only the educational pages. That threw away more than nine tenths of the data.
A small model (1.71 billion parameters) trained on the smaller, cleaner set did clearly better on knowledge and reasoning tests: on MMLU it went from 33% to 37%, and on ARC from 46% to 57%. Less text, better chosen.
But cleaning can backfire too. Removing duplicates sounds like it can only help. The team first did it across all 96 snapshots at once, which removed up to 90% of the older snapshots, and the model trained on what was left didn't get better. When they looked closer, the 10% of old data that survived was worse than what got removed: more ads, more keyword lists. Removing duplicates within each snapshot separately worked better.
How big, how much
Pretraining is also a budget decision. You have a fixed amount of computing power, and you can spend it on a bigger model or on more text for a smaller one.
In 2022, DeepMind trained over 400 models of different sizes on different amounts of text to find the best split. Their answer was to grow both together: each time you double the model, double the training tokens. By that rule, the big models of the day were too big for how little text they saw. GPT-3 had 175 billion parameters and Gopher 280 billion, and both saw 300 billion tokens. DeepMind's Chinchilla used the same compute as Gopher but was 4 times smaller, at 70 billion, and saw 1.4 trillion tokens. It beat Gopher, GPT-3 and several bigger models.
There's a catch the Chinchilla authors point out themselves. The rule finds the best model for a fixed training budget. But a smaller model is also cheaper every time someone uses it afterwards, so the best model to train isn't automatically the best one to serve.
What comes out
The result of pretraining is a base model, and it's a very good document continuer. Give it the start of a web page and it writes a plausible rest of the page. That isn't the same as being a helpful assistant. Ask it a question and it treats your question as the start of some document, and carries on however that kind of document usually goes.
So how much does the next stage add? One experiment suggests: less knowledge than you'd think. Meta took a 65-billion-parameter base model and tuned it on just 1,000 carefully picked question-and-answer examples. People rated its answers as good as or better than GPT-4's in 43% of cases (in a 2023 comparison). A thousand examples can't teach much about the world. What they mostly teach is how to present what's already there. (Not everyone agrees that's still true of modern training, which comes up in post-training.)
Why models act the way they do
Once you see pretraining as practice questions, a few habits make sense.
Common things get more practice than rare ones. Every time a fact shows up in the pile, that's another question about it. A topic on thousands of pages gets far more practice than one on a single obscure page. Ask about the obscure one and you're more likely to get a wrong answer that sounds sure of itself (hallucination).
The internet is full of wrong and low-quality text. Filtering removes some of it, not all.
It learns slowly. Pretraining uses far more text than a person sees in a lifetime. A few hundred pages of your company's docs are a drop in that ocean, which is one reason training isn't a practical way to add them. For when extra training is worth it, see fine-tuning.
You usually can't check what's in there. Big labs treat their training data as a trade secret, and many "open" models release their weights but not their data.
And test questions leak in. Benchmarks live on the web, and the web goes into the pile. GPT-3's authors tried to remove benchmark questions from their data, but a bug left some in. A model that scores well on a public benchmark may partly be remembering it, which is a good reason to test on your own examples.
So, back to our two questions. The knowledge comes from practice on what people wrote, weighted by how often they wrote it. And it stops where the crawl stopped. What turns that document continuer into something that answers you is the next stage, post-training.
Further reading
- Language Models are Few-Shot Learners, Brown et al. (OpenAI), 2020. The GPT-3 paper. Section 2.2 has the data mix, the crawl dates and the leaked-benchmark bug.
- Large Language Models explained briefly, 3Blue1Brown, 2024. The training loop and the scale of it, in pictures.
- The FineWeb Datasets, Penedo et al. (Hugging Face), 2024. The most detailed public account of turning the web into training data, with an experiment for every step. The deduplication story is in section 3.4.
- Training Compute-Optimal Large Language Models, Hoffmann et al. (DeepMind), 2022. The Chinchilla paper. Read the abstract and Table 1.
- LIMA: Less Is More for Alignment, Zhou et al. (Meta), 2023. The 1,000-example experiment, and the case that knowledge comes from pretraining.