Skip to main content

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

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.