Pre-training, data and scaling laws

Where capability comes from: data, compute and parameters, the Chinchilla result, and how to budget a run.

Advanced about 5 h

The picture

  1. 01

    Web-scale data

    filter, dedupe

  2. 02

    Pre-training

    next token

  3. 03

    Supervised tuning

    instructions

  4. 04

    Preference tuning

    RLHF / DPO

  5. 05

    Evaluation

    then serve

Three levers

Loss falls smoothly and predictably as you add parameters NN, training tokens DD and compute CC. The key relation for planning:

C≈6 N D FLOPsC \approx 6\,N\,D \ \text{FLOPs}

(about 2 FLOPs per parameter per token for the forward pass, 4 for the backward.)

The Chinchilla result

Earlier models were large but under-trained. Hoffmann et al. showed that for a fixed compute budget, parameters and tokens should grow together, roughly 20 tokens per parameter. A 70B model wants around 1.4T tokens. In practice, teams now train well past that point (small models on enormous token counts) because inference cost, not training cost, dominates once a model is deployed.

A budget calculator

def training_budget(params: float, tokens: float, gpu_flops: float = 3e14, mfu: float = 0.4, price_per_gpu_hour: float = 2.0):
    """params, tokens: absolute counts. gpu_flops: peak bf16 FLOP/s per GPU. mfu: model FLOPs utilisation."""
    flops = 6 * params * tokens
    gpu_seconds = flops / (gpu_flops * mfu)
    hours = gpu_seconds / 3600
    return {"flops": flops, "gpu_hours": hours, "usd": hours * price_per_gpu_hour}

print(training_budget(7e9, 1.4e11))        # a 7B model on 140B tokens
print(training_budget(7e9, 2e12))          # the same model trained far longer

Peak throughput figures vary by hardware and precision; treat these defaults as placeholders and substitute your own.

Data matters more than most architecture choices

A pre-training pipeline is mostly data engineering:

  1. Extraction and language identification from raw crawls.
  2. Quality filtering with heuristics and trained classifiers.
  3. Deduplication (exact and fuzzy), which reduces memorisation and improves loss per token.
  4. Decontamination against evaluation sets.
  5. Mixing: proportions of web, code, books, maths and multilingual data.

From base model to assistant

A pre-trained base model continues text; it does not follow instructions. Supervised fine-tuning teaches the instruction format, and preference optimisation shapes style and safety. You will implement both in the fine-tuning stage.

Emergent abilities and honesty about evals

Some capabilities appear to switch on at scale, but part of that is an artefact of discontinuous metrics: a smooth improvement in per-token accuracy looks like a sudden jump in exact-match scores. Be sceptical of single benchmark numbers, and of benchmarks the model may have seen.

Common mistakes

  • Using parameter count alone to compare models trained on very different token budgets.
  • Forgetting that evaluation sets leak into web data.
  • Ignoring inference cost when choosing model size.

Exercises

  1. Reproduce the 6ND6ND estimate for a model you know and compare to its published training cost.
  2. Train three nanoGPT sizes on a fixed token budget and sketch your own mini scaling curve.

You are done when you can…

  • Estimate training FLOPs and GPU-hours for a given model and token count
  • Explain what the Chinchilla result changed about how models are sized
  • Describe the data-quality steps that matter most in a pre-training pipeline