Pretraining is the phase in which a language model acquires its general capabilities through self-supervised training on a large text corpus, producing what is called a base model before any task- or behavior-specific adaptation. The phase consumes nearly all of a modern model's training compute and data: GPT-3-class runs train on hundreds of billions to trillions of tokens,2 and the loss trajectory of pretraining, governed by scaling laws, largely sets the ceiling for everything built afterward.3
Pretraining needs no labels: objectives such as next-token prediction and masked language modeling derive supervision from the text itself, which is what lets the corpus scale to a significant fraction of the public web. Everything after the phase, supervised fine-tuning, instruction tuning, preference-based RLHF, is collectively called post-training, and it consumes a small fraction of the compute.
Role in the network
Pretraining is not a component of the network but the first phase of the pipeline that produces one: it converts a randomly initialized Transformer into a base model. In pipeline order, a raw corpus is tokenized, pretraining fits the model to the corpus's own statistics, and post-training then adapts the result for use. The base model that emerges is a text continuer rather than an assistant: it completes sequences in the distribution of its training data, and only the later stages teach it to follow instructions, refuse harmful requests, or prefer one answer style over another.
The adaptation stage split into supervised fine-tuning, instruction tuning, and preference-based RLHF, collectively called post-training, leaving pretraining as the capability-forming phase. Mechanically the phase is ordinary maximum-likelihood training at unusual scale: sequences are scored under teacher forcing, backpropagation distributes the gradient, and an AdamW-family optimizer updates the weights, with the whole run distributed across a cluster for weeks at a time.312
The mathematics
For a decoder-only model, the pretraining objective is the corpus-wide sum of per-token log losses, each token scored against its preceding context:
$$\mathcal{L}(\theta) = -\sum_{x \in \mathcal{D}} \sum_{t=1}^{|x|} \log p_\theta(x_t \mid x_{<t})$$| Symbol | Shape | Meaning |
|---|---|---|
| \(\mathcal{D}\) | set of token sequences | the training corpus; \(D = \sum_x |x|\) counts its tokens |
| \(x\) | token sequence | one document |
| \(p_\theta(\cdot \mid x_{<t})\) | \(\mathbb{R}^{V}\) | model conditional over a vocabulary of \(V\) tokens |
| \(\theta\) | \(N\) parameters | the weights being trained |
Encoder models substitute the masked variant, whose inner sum runs only over corrupted positions, but the form is the same: self-supervision means every token of the corpus is simultaneously input and label.3
Two scaling relations govern the phase's planning. The first sizes the data to the model: compute-optimal analysis argued in 2022 that models should be trained on roughly twenty tokens per parameter,
$$D \approx 20\,N$$shifting the field's emphasis from parameter count toward data volume.3 The second prices the run. Kaplan et al. gave the standard approximation for transformer training compute,
$$C \approx 6\,N\,D \text{ FLOPs}$$in which each training token costs about \(2N\) FLOPs for the forward pass, one multiply-add per parameter, and about \(4N\) for the backward pass, with \(D\) tokens processed in total.4
Worked example: the budget of a 1B run
Take a model of \(N = 10^{9}\) parameters trained at the Chinchilla ratio, \(D = 20\,N = 2 \times 10^{10}\) tokens. The compute estimate is
$$C \approx 6 \times 10^{9} \times 2 \times 10^{10} = 1.2 \times 10^{20} \text{ FLOPs}$$On a cluster delivering \(10^{16}\) effective FLOP/s, the wall-clock time is \(1.2 \times 10^{20} / 10^{16} = 1.2 \times 10^{4}\) seconds, that is 12,000 seconds, or \(12{,}000 / 3{,}600 = 3.3\) hours. Cross-check by throughput: each token costs \(6N = 6 \times 10^{9}\) FLOPs, so the cluster processes \(10^{16} / (6 \times 10^{9}) = 1.67 \times 10^{6}\) tokens per second, and \(2 \times 10^{10} / (1.67 \times 10^{6}) = 1.2 \times 10^{4}\) seconds, the same figure. For contrast, GPT-3 trained its 175 billion parameters on 300 billion tokens, about 1.7 tokens per parameter, an order of magnitude below the ratio the 2022 analysis prescribed, which is the precise sense in which the models of its period were undertrained.23
Intuition
Self-supervision is the engine of the phase: because the corpus supplies its own labels, training is bounded by data volume and compute rather than by annotation, and the prediction task forces the model to internalize whatever regularities the text reflects, from syntax to factual associations. The loss trajectory matters beyond the run itself because post-training reshapes behavior far more than it adds capability: alignment stages steer what pretraining formed, so the ceiling of the final model is largely set on the pretraining cluster.39 A second intuition concerns the data rather than the objective: at fixed scale, what separates one run from another is the corpus, and developers increasingly credit deduplication and quality filtering as the real differentiator between models.310
Variants and extensions
The objective varies while the phase stays fixed: next-token prediction dominates decoder-only pretraining, masked language modeling trains encoders, and span-corruption hybrids sit between them.3 The compute-optimal ratio itself is a training-time optimum, not a deployment-time one: LLaMA deliberately overtrained, putting 1.0 trillion tokens through its 7-billion-parameter model, roughly 140 tokens per parameter, because a smaller overtrained model is cheaper to serve for the life of the deployment.11 As of 2026 the phase has further differentiated, with continued-pretraining and domain-focused mid-training stages inserted between general pretraining and post-training in frontier pipelines, extending the base run with code, mathematics, or language-specific mixtures before alignment begins.
Adoption
Pretraining is universal: every modern large language model descends from a base model produced by one self-supervised run. Corpora are assembled from filtered Common Crawl snapshots and curated mixtures such as the Pile, measured in tokens, and cleaned with deduplication and quality filters.10 Runs are optimized with AdamW-family algorithms over weeks of cluster time, with warm-up and decay learning-rate schedules.312 The phase is also where the field's planning instruments apply: scaling-law fits forecast the final loss from parameter count, data volume, and compute before the run starts, which is what turned pretraining from experimentation into capital allocation.4
Limitations and critiques
The phase inherits every property of its data: memorized text can be extracted from the trained model, and the corpus's biases and licensing status become the model's, which is why filtering decisions are treated as capability decisions. The twenty-tokens-per-parameter rule is itself a fit to a training regime, valid for single-epoch training on abundant data rather than a law of nature, and deployment economics routinely override it.311 Scale brings a supply problem: one analysis estimated that the stock of high-quality public text would be exhausted by frontier-scale runs in the mid-2020s, pushing labs toward deduplication, multi-epoch training, licensed corpora, and synthetic data.13 Finally, the phase concentrates capability formation in a single expensive run, so its cost, in money and energy, is the structural reason only a few organizations train frontier base models.
History
Pretrained components predate pretrained networks: word vectors had been pretrained since word2vec in 2013, supplying reusable input embeddings trained on unlabeled text.5 The modern paradigm arrived in 2018. ELMo in February pretrained a bidirectional LSTM and transferred its contextualized representations into downstream models;8 ULMFiT showed that a language model pretrained on general text could be fine-tuned to beat task-specific models;1 and GPT-1 and BERT established the pretrain-then-adapt pattern at Transformer scale, on the decoder-only and encoder-only sides respectively.67 GPT-3 in 2020 made the phase a matter of industrial scale, training 175 billion parameters on hundreds of billions of tokens,2 and the scaling-law literature then priced the phase: Kaplan et al.'s power laws in 2020,4 the Chinchilla correction in 2022,3 and, the same year, InstructGPT's demonstration that a comparatively cheap post-training stage could make a small aligned model preferable to a base model a hundred times its size, cementing the two-phase pipeline the field has kept since.9
See also
References
-
Howard, J., and Ruder, S., "Universal Language Model Fine-tuning for Text Classification," arXiv:1801.06146, January 2018. ↩
-
Brown, T., et al., "Language Models are Few-Shot Learners," arXiv:2005.14165, May 2020. ↩↩↩
-
Hoffmann, J., et al., "Training Compute-Optimal Large Language Models," arXiv:2203.15556, March 2022. ↩↩↩↩↩↩↩↩↩↩↩
-
Kaplan, J., et al., "Scaling Laws for Neural Language Models," arXiv:2001.08361, January 2020. ↩↩↩
-
Mikolov, T., Chen, K., Corrado, G., and Dean, J., "Efficient Estimation of Word Representations in Vector Space," arXiv:1301.3781, January 2013. ↩
-
Radford, A., Narasimhan, K., Salimans, T., and Sutskever, I., "Improving Language Understanding by Generative Pre-Training," OpenAI, June 2018. ↩
-
Devlin, J., Chang, M.-W., Lee, K., and Toutanova, K., "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding," arXiv:1810.04805, October 2018. ↩
-
Peters, M., et al., "Deep contextualized word representations," arXiv:1802.05365, February 2018. ↩
-
Ouyang, L., et al., "Training language models to follow instructions with human feedback," arXiv:2203.02155, March 2022. ↩↩
-
Gao, L., et al., "The Pile: An 800GB Dataset of Diverse Text for Language Modeling," arXiv:2101.00027, December 2020. ↩↩
-
Touvron, H., et al., "LLaMA: Open and Efficient Foundation Language Models," arXiv:2302.13971, February 2023. ↩↩
-
Loshchilov, I., and Hutter, F., "Decoupled Weight Decay Regularization," arXiv:1711.05101, November 2017. ↩↩
-
Villalobos, P., et al., "Will we run out of data? Limits of LLM scaling based on human-generated data," arXiv:2211.04325, October 2022. ↩