How models are made training pipeline · stage 1
Pre-training: how a model comes to know a bit of everythingpractitioner-perspective methodology · key facts carry official sources
What pre-training optimises, how corpora reach trillions of tokens, how compute and data are budgeted, and how the scaling-law story changed. The practitioner-depth version; the one-page explainer lives on the Learn site — cross-linked, not duplicated.
What this guide covers
Pre-training is making a model learn to continue text on massive amounts of it.
The Learn site has an explainer page on “what it is”; this guide is about the decisions practitioners make:
how corpora are assembled, how compute is budgeted, how training volume is set, how vocabularies are cut.
Every key fact has a public paper or official model card as its source,
listed at the end of the page; this site only transcribes and cross-checks — it runs no benchmarks.
The objective: next-token prediction
The objective behind mainstream LLMs is boringly single: given the preceding text, predict the probability distribution of the next token.
The GPT-3 paper (arXiv 2005.14165) pushed this route to 175 billion parameters and
showed that at sufficient scale abilities grow on their own without being taught explicitly.
BERT's “fill-in-the-blank” route (bidirectional masking) lost on generation tasks.
Since then, open-weight families are almost all autoregressive decoder architectures.
Practitioner corollary: everything a model “knows” is a by-product of continuation statistics.
It was never trained for any specific task. That explains why it is general,
and also why it fabricates with a straight face.
Data: scale, cleaning, deduplication
Web corpora (Common Crawl) are dirty: duplicates, junk pages and machine-generated text are mixed in.
The T5 paper's C4 appendix set out widely followed cleaning rules:
deduplicate, filter low-quality lines, filter by language.
The LLaMA paper states plainly that it trained only on publicly available data, treating the “data recipe” itself as a contribution.
That curation matters more than scale has a controlled experiment behind it.
Princeton's DCLM report (arXiv 2406.11794) held the training budget fixed and changed only the data-filtering method —
model performance varied enormously. Feeding more loses to feeding right.
Hugging Face's FineWeb (arXiv 2406.17557) turned this cleaning pipeline into an open 15T-token corpus,
with an ablation published for every cleaning step, directly reproducible.
Deduplication is hard graft: the same web article can appear dozens of times inside Common Crawl.
Duplicates waste compute and make the model memorise training text verbatim —
a major source of benchmark contamination.
Budgeting compute and data: the scaling-law plot twist
In 2020 Kaplan et al. (arXiv 2001.08361) gave the first scaling laws:
loss falls smoothly with parameters, data and compute — parameters first, spend the money on bigger models.
In 2022 Chinchilla (arXiv 2203.15556) overturned that budget with finer experiments:
at fixed compute, parameters and data should grow together, optimally about 20 tokens per parameter.
Many big models trained under the old consensus were “under-fed”.
This result directly rerouted open weights.
The LLaMA line (1.0T tokens for 7B, 1.4T for 70B) is exactly “small model + over-abundant data”.
The Llama 3.1 official model card states 15T tokens — by Chinchilla's yardstick a far-past-optimal “over-training”.
Why over-train knowingly? Because scaling laws optimise training cost,
while the model will be inferred against repeatedly. Feed a small model more data: training costs a bit more, inference gets much cheaper.
Open-weight models have to run on tens of millions of users' GPUs — the math has to be done this way.
The run: learning rate and context extension
A pre-training run is not one straight line. The learning rate ramps up then down (cosine annealing is common),
and the final phase often “anneals” on high-quality data. Most families keep their exact recipe private;
this site writes only what has been officially published and leaves the rest unwritten.
Context length is usually stretched after training — standard practice.
The LLaMA 2 paper states it extended 4K to 32K with position interpolation; the Llama 3.1 model card lists 128K.
Stretching relies on techniques such as changing the frequency base of RoPE positional encoding.
State the cost honestly: “length seen during training” and “nominal length” are not equal in ability.
A 128K label does not mean needle-in-a-haystack still works accurately at 128K — evaluate by length buckets yourself.
The vocabulary: how tokenization is set
Models do not see characters, they see tokens. The mainstream splitter is BPE (arXiv 1508.07909):
start from characters and iteratively merge the most co-occurring fragments into subwords.
Vocabulary size is a trade-off: a big table saves tokens on non-English text like Chinese;
a small table cuts finer and sequences get longer.
Llama uses a 128K vocabulary (official model card); OpenAI's o200k_base reaches 200K (tiktoken official repository).
The same sentence can differ several-fold in token count across vocabularies.
Before comparing “context length” or “price per token”, check the vocabulary yardstick — otherwise the numbers are not comparable.
How this differs from the Learn site
The Learn site's pre-training and
three-stage training pages are user-perspective explainers;
this guide is the practitioner deep version: decisions, costs, and how the consensus changed.
Same term, different depth on each side, cross-linked without duplication.
For the cost magnitude of data and compute see this site's [Data and compute guide](data-compute.html);
for the open training stack see [The open training stack](training-stack.html).
Sources
- GPT-3 paper (arXiv 2005.14165, autoregressive objective at 175B parameters; abstract page re-checked 2026-10-21):https://arxiv.org/abs/2005.14165
- Kaplan scaling-laws paper (arXiv 2001.08361; abstract page fetched directly 2026-10-20):https://arxiv.org/abs/2001.08361
- Chinchilla paper (arXiv 2203.15556, the compute-optimal result of ~20 tokens per parameter; abstract page fetched directly 2026-10-20):https://arxiv.org/abs/2203.15556
- LLaMA paper (arXiv 2302.13971, training 7B–65B on public data; abstract page fetched directly 2026-10-20):https://arxiv.org/abs/2302.13971
- LLaMA 2 paper (arXiv 2307.09288, 7T/2T token training and context extension; abstract page fetched directly 2026-10-20):https://arxiv.org/abs/2307.09288
- Llama 3 official model card (the official 15T-token, 128K-context figures; fetched directly, HTTP 200, 2026-10-20):https://huggingface.co/meta-llama/Llama-3.1-8B
- C4 corpus notes (T5 paper arXiv 1910.10683 appendix, web-corpus cleaning rules; abstract page fetched directly 2026-10-20):https://arxiv.org/abs/1910.10683
- FineWeb technical report (arXiv 2406.17557, Hugging Face's open 15T-token corpus reproducing the pipeline; abstract page fetched directly 2026-10-20):https://arxiv.org/abs/2406.17557
- DCLM technical report (arXiv 2406.11794, Princeton's experiments showing data curation matters more than scale; abstract page fetched directly 2026-10-21):https://arxiv.org/abs/2406.11794
- BPE tokenisation paper (arXiv 1508.07909, the original subword segmentation method; abstract page fetched directly 2026-10-20):https://arxiv.org/abs/1508.07909
- OpenAI tiktoken official repository (the official implementation and docs of the o200k_base vocabulary; fetched directly, HTTP 200, 2026-10-20):https://github.com/openai/tiktoken
Base source snapshot: 2026-10-20; item-specific additions and check scope appear in the text and source labels. Check original specifications, methods and conditions.