LLM pretraining explained simply: pretraining is the long, expensive first phase of building a large language model, in which the model reads vast amounts of text and learns to predict the next word. That single task, repeated billions of times, teaches the model grammar, facts, reasoning patterns and the structure of language itself. The central question is why pretraining matters so much, and the answer is that almost everything a model can do later, from answering questions to writing code, is learned here; fine-tuning afterwards only steers abilities that pretraining already created.
Pretraining is also the phase that costs the most and is hardest to fix. A mistake in the data, the architecture or the training setup cannot be patched afterwards, it is baked into the model. That is why the teams that build foundation models spend months preparing data and testing small-scale runs before committing to a full training run.
Key takeaways
- LLM pretraining explained: a model learns by predicting the next token across vast text, and that simple task builds grammar, facts and reasoning.
- Data quality decides the outcome more than data size; cleaning, deduping and balancing the corpus is the highest-leverage work.
- Tokenisation turns text into numbers the model can process, and the vocabulary shapes cost, speed and multilingual ability.
- Scale follows predictable patterns: model size, data and compute must grow together, and growing one alone wastes the others.
- Pretraining creates capability, fine-tuning steers it; a model cannot be fine-tuned into doing what pretraining never taught it.
What pretraining actually is
Pretraining is self-supervised learning on text. The model is shown a sequence of words and asked to predict the next one, then it is told how wrong it was and adjusts its internal parameters to do better next time. There are no human labels and no right answers supplied in advance; the text itself is the teacher. After enough examples, the model becomes good at predicting what comes next, and that skill turns out to be remarkably general.
The reason a next-word prediction task produces such broad ability is that predicting well requires understanding. To predict the next word in a sentence about a contract, the model must grasp the legal concepts involved. To continue a piece of code, it must understand the programming language. Each prediction is a small test of comprehension, and billions of them add up to a model that can handle tasks it was never explicitly taught. Best for: building general capability that many different applications can then specialise.
The data: what models read and why it matters
A pretraining corpus is a mixture of many kinds of text: web pages, books, encyclopaedias, code, scientific papers and conversations. The mix matters, because the model learns the style and content of what it reads most. A corpus heavy on web forums produces a model fluent in informal language; a corpus with more books and papers produces one better at formal reasoning. Teams choose the mixture deliberately, based on the capabilities they want.
Cleaning the data is the most important and least glamorous part of the work. Duplicates are removed, because repeated text teaches the model to memorise rather than generalise. Low-quality pages, spam and boilerplate are filtered out. Personal information is removed where it can be found. And the data is checked for contamination, so that test questions the model will later be judged on do not appear in its training text. The GPT-3 paper, published in 2020, described training on 300 billion tokens drawn from filtered web text, books and Wikipedia. Best for: any team building a model, because data quality is the cheapest way to improve the result.
Tokenisation: turning text into numbers
A model cannot read letters; it reads tokens, which are chunks of text, usually parts of words, each mapped to a number. Tokenisation splits every document into tokens before training begins, and the choice of vocabulary decides how efficiently text is represented. Common words become single tokens, rare words are split into pieces, and the vocabulary size is a trade-off: a larger vocabulary represents text in fewer tokens but needs a larger embedding table.
Tokenisation also affects cost and capability in ways users feel directly. A model charges and counts by the token, so a language that splits into many tokens costs more to use. A vocabulary built mostly from English will handle other languages poorly, splitting their words into many fragments. Best for: multilingual products and cost-sensitive applications, where token efficiency directly affects the bill.
The architecture: the transformer
Almost every modern language model is built on the transformer architecture, introduced in the 2017 paper Attention Is All You Need by researchers at Google. The transformer’s core idea is attention: when processing a word, the model looks back at the other words in the sequence and decides which ones matter for understanding it. That lets the model handle long-range dependencies, such as a pronoun referring to a noun many sentences earlier, which older architectures struggled with.
The transformer also parallelises well, which is why it scales. Older recurrent models processed text one word at a time, in order, which made training slow. A transformer processes a whole sequence at once, so thousands of examples can be trained in parallel across many accelerators. That property is what made pretraining at today’s scale possible at all. For a fuller account of how these models are organised, see our guide to the original transformer paper. Best for: any large-scale language work, because no other architecture has matched the transformer’s combination of capability and scalability.
How training actually runs
A pretraining run is an exercise in distributed computing. The model may have tens or hundreds of billions of parameters, far too many for one accelerator, so the work is split across a cluster: different layers on different devices, different batches of data on different devices, and gradients shared between them. A run can last weeks or months and consume an enormous amount of electricity, which is why the planning and testing before a run matter so much.
Training is monitored constantly. The loss, a number that measures how wrong the model’s predictions are, should fall steadily; a sudden spike usually means something broke, such as a bad batch of data or a numerical instability. Checkpoints are saved regularly, so a failure does not lose weeks of work, and the model is evaluated at intervals on held-out tasks. For the hardware side of these runs, see our guide to GPU cluster architecture. Best for: organisations with the compute budget and engineering depth to run large distributed training.
Comparing pretraining choices
| Choice | Options | Trade-off | What goes wrong |
|---|---|---|---|
| Data mixture | Web, books, code, papers | Capability follows the mix | Skewed mix creates a lopsided model |
| Data cleaning | Filtering, dedup, decontamination | Quality beats quantity | Dirty data teaches memorisation and bias |
| Vocabulary size | Small vs large token vocabulary | Efficiency vs embedding cost | Poor multilingual and rare-word handling |
| Model size | Small vs large parameter count | Capability vs training and serving cost | Oversized model on too little data |
| Training length | More tokens vs fewer tokens | Capability vs compute budget | Undertrained model wastes its size |
| Parallelism strategy | Data, tensor, pipeline splits | Speed vs engineering complexity | Idle accelerators and slow runs |
The table shows that pretraining is a system of trade-offs, not a single dial. The most common mistake is growing one dimension alone: a much larger model trained on the same amount of data, or much more data fed to a model too small to use it. The best results come from growing model size, data and compute together, in proportion. For how that balance is decided in practice, see our guide to LLM pipeline parallelism.

Scaling: why size, data and compute must grow together
Research on scaling has shown that model capability follows predictable patterns as size, data and compute grow. The practical lesson is balance: a model with many parameters but too little training data will underperform a smaller model trained on more data, and both will underperform a model where the three are matched. The GPT-3 model of 2020, with 175 billion parameters trained on 300 billion tokens, was a landmark of its time, but later work showed that smaller models trained on far more tokens could match or beat it.
For a team deciding what to build, that means the question is not how big a model can be afforded, but how much data and compute can be afforded alongside it. A balanced smaller model is usually the better investment than an unbalanced larger one, because it is cheaper to serve afterwards and easier to fine-tune. Best for: teams choosing between building a model and buying or fine-tuning an existing one.
What pretraining cannot do
Pretraining gives a model broad ability, but it does not give it judgement about what a user wants. A pretrained model will continue text in the style of its training data, which may mean answering a question with another question, or producing a plausible-sounding answer that is wrong. It has no built-in sense of truth, safety or helpfulness, and it will happily repeat biases present in its training data.
That is why pretraining is followed by further stages: supervised fine-tuning on examples of desired behaviour, and alignment techniques such as reinforcement learning from human feedback. Those stages do not add new knowledge so much as they teach the model how to use what pretraining already gave it. A model that never learned a fact during pretraining cannot be fine-tuned into knowing it. Best for: anyone deciding whether to pretrain, fine-tune or prompt an existing model.
LLM pretraining checklist
- The data mixture is chosen deliberately for the capabilities the model needs, not assembled by accident.
- Duplicates, spam, boilerplate and personal information are filtered before training begins.
- Test data is checked against the training corpus so evaluation is not contaminated.
- Tokenisation is designed for the languages and domains the model must serve.
- Model size, data volume and compute budget are balanced, not grown one at a time.
- Loss and capability are monitored during training, with regular checkpoints and held-out evaluation.
- The team has a plan for the stages after pretraining: fine-tuning and alignment.
- The decision to pretrain, rather than fine-tune or prompt an existing model, is written down with its costs.
Frequently asked questions
What is LLM pretraining?
It is the first and longest phase of building a language model, in which the model learns by predicting the next token across vast amounts of text. That simple task teaches grammar, facts and reasoning, and creates the general capability that fine-tuning later steers.
How is pretraining different from fine-tuning?
Pretraining creates general capability from raw text, with no human labels. Fine-tuning then specialises the model on examples of desired behaviour for a particular task.
Why does data quality matter more than data size?
Because the model learns the style and content of what it reads. Dirty, duplicated or biased data teaches memorisation and bias, while clean, balanced data teaches general ability. Cleaning is the highest-leverage work in a pretraining project.
What is a token in LLM pretraining?
A token is a chunk of text, usually part of a word, that the model processes as a single unit. Common words are usually one token, rare words split into several. Tokenisation decides how efficiently text is represented and how much using the model costs.
How long does pretraining take?
It depends on the model size and the compute available, but large runs take weeks or months on clusters of many accelerators. That is why teams test at small scale first and monitor training constantly.
Do I need to pretrain my own model?
Almost certainly not. Pretraining is justified only when an existing model cannot serve the need, for example a specialised language or domain with no good foundation model. Most teams should fine-tune or prompt an existing model instead.







