Pretraining

1 min read

Pretraining teaches an LLM to predict the next token on massive text corpora — the foundational stage of the LLM pipeline.

Objective: given tokens t1,…,tnt_1, \dots, t_n, minimize:

L=−∑i=1nlog⁡P(ti∣t1,…,ti−1;θ)L = -\sum_{i=1}^{n} \log P(t_i | t_1, \dots, t_{i-1}; \theta)

This is cross-entropy loss on next-token prediction (cross-entropy = negative log-likelihood).

What the model learns:

  • Grammar, syntax, factual knowledge, reasoning patterns, coding ability
  • All from the single objective of predicting what comes next
  • The training data is the entire internet (+ books, code, etc.)

Scale:

  • Hundreds of billions to trillions of tokens
  • Models from 1B to 1T+ parameters
  • Training runs cost 1M–1M–100M+
  • Scaling Laws: performance improves predictably with more data, model size, and compute

What pretraining does NOT give you:

  • Instruction following (the model continues text, doesn't answer questions)
  • Safety/alignment
  • These come from Supervised Fine-Tuning and RLHF/DPO in later stages

The full pipeline: Pretraining → SFT → RLHF or DPO

See also: Tokenization, Scaling Laws, Autoregressive Generation

Linked from