SDE & MLE Prep

How LLMs Are Trained

Q: Walk through the LLM training pipeline.

web-scale text --> tokenizer --> PRETRAINING (next-token prediction, trillions of tokens)
                                      |
                                      v   base model: knows a lot, doesn't follow instructions
                     SUPERVISED FINE-TUNING (instruction -> response demonstrations)
                                      |
                                      v
         PREFERENCE TUNING (RLHF with a reward model + PPO, or DPO / variants)
                                      |
                                      v   assistant model: helpful, harmless, follows instructions
                     (+ RL on verifiable tasks: math, code, tool use, reasoning)
  • Pretraining objective: minimize cross-entropy of the next token (causal LM). Compute ≈ 6 · params · tokens FLOPs.
  • Scaling laws (Kaplan, Chinchilla): loss falls as a power law in params, data and compute; compute-optimal training uses ~20 tokens per parameter (modern models often train far beyond that to make inference cheaper).
  • Data quality (dedup, filtering, mixing code/math) matters as much as size.