Foundations Guide 02 of 25

From Transformer to assistant: pretraining, scaling laws, and RLHF

Every model your team calls went through much the same pipeline. Knowing which stage taught it what tells you which problems prompting, retrieval, or fine-tuning can actually fix.

  • 10 min read
  • Updated 
  • 8 sources

Key takeaways

  • Pretraining on trillions of filtered tokens gives a model its knowledge and fluency; post-training mostly shapes how it behaves, formats answers, and decides what to refuse.
  • Chinchilla showed parameters and training tokens should grow together; labs now train small models far past that point because they are cheaper to serve.
  • Reinforcement learning from human feedback (RLHF) turned document completers into assistants: labelers preferred a 1.3B-parameter InstructGPT over the 175B-parameter GPT-3.
  • Reinforcement learning on checkable answers now drives much reasoning progress; Cursor says Composer 1.5’s post-training used more compute than pretraining its base model.
  • Add missing knowledge with retrieval, shape behavior with fine-tuning, and make outputs verifiable so you can evaluate them.
On this page 7 sections

In March 2022, OpenAI reported that human labelers preferred answers from a 1.3-billion-parameter model over those of the 175-billion-parameter GPT-3, more than 100 times its size. The small model, InstructGPT, had been trained further on human demonstrations and preference rankings. The result captures how every large language model (LLM) your team uses was built: next-token prediction over trillions of tokens first, then rounds of training that turn it into an assistant.

Few teams will ever train one, but every team needs a picture of how it was trained, because each stage leaves fingerprints. The knowledge cutoff, fluent fabrication, over-cautious refusals, and strong coding next to shaky judgment all trace back to specific training choices.

This guide walks the pipeline, then maps each stage to problems your team can fix.

What are the stages of training an LLM?

The shape is stable across labs. Pretraining builds raw capability, and midtraining sharpens it on curated data. Post-training then adds supervised fine-tuning (SFT) and reinforcement learning (RL), first from human feedback (RLHF) and increasingly from verifiable rewards (RLVR).

StageLearns fromWhat it changes
PretrainingTrillions of tokens of web pages, code, books, and papersKnowledge, fluency, raw capability
MidtrainingCurated math, code, reasoning, and long documentsSpecialist skills, long context
Supervised fine-tuningExample prompts with ideal answersFormat, tone, instruction following
Preference tuningRankings of better vs. worse answersHelpfulness, refusals, safety behavior
RL with verifiable rewardsProblems with checkable answersMulti-step reasoning, persistence

The boundaries blur in practice. Meta ran six rounds of post-training on Llama 3, each cycling between fine-tuning and preference optimization. Closed frontier labs now disclose little, so the fullest public recipes come from open-weight labs such as Meta, DeepSeek, and the Allen Institute for AI (Ai2).

Pretraining: next-token prediction at industrial scale

The objective is simple. The model sees a run of tokens and assigns probabilities to the next one; how badly it predicted the actual token is the training signal, so no human labels are needed. Across trillions of tokens, the model must absorb grammar, facts, code conventions, and some reasoning patterns, because each one improves its predictions.

Meta’s Llama 3 report describes training a 405-billion-parameter model on 15.6 trillion tokens. That run consumed 3.8 × 10²⁵ floating-point operations (FLOPs) on up to about 16,000 Nvidia H100 graphics processing units (GPUs). Its data runs to the end of 2023, which leaves the first fingerprint every deployed model carries: a knowledge cutoff.

Most of the effort goes into data rather than model design. Meta’s team removed duplicates across web addresses, whole documents, and individual lines, and filtered junk and adult content with heuristics. It dropped domains dense with personally identifiable information (PII), then used small classifier models to score quality. The final blend was about half general knowledge, a quarter math and reasoning, 17% code, and 8% multilingual text.

Reliability engineering dominates here too. During one 54-day stretch of the 405B run, Meta recorded 419 unplanned job interruptions, roughly 78% of them traced to confirmed or suspected hardware faults. Training a frontier model is a reliability engineering problem as much as a research one.

Midtraining and long context

Between raw pretraining and assistant training sits a phase most diagrams omit. Llama 3 only reached its 128K-token context window late, stretching it from 8K tokens in six stages, since attention cost grows with the square of sequence length. The final stretch upsampled the highest-quality sources as the learning rate decayed to zero.

Ai2 made this phase explicit in Olmo 3, released on 20 November 2025 with the datasets and checkpoints for every stage. After a pretraining mix of about 5.9 trillion tokens, its models midtrain on 100 billion tokens of math, science, code, and reading-comprehension data. They then train on about 50 billion tokens of long documents to extend the context window.

What comes out is a base model. It continues documents rather than answering questions. Hand it a question and it may produce three more, because that is what such text often looks like online.

Scaling laws: how labs decided how big to go

Before committing a full budget, labs train many small models and extrapolate. In January 2020, Jared Kaplan and colleagues at OpenAI showed that test loss falls as a smooth power law in parameters, training tokens, and compute. Some of those trends held across more than seven orders of magnitude, while choices such as depth vs. width barely mattered within a wide range.

Their allocation advice favored size. An eightfold larger model needed only about five times more data, and compute-efficient training meant stopping well before the loss stopped improving. The paper’s discussion section was blunt: “Big models may be more important than big data.”

DeepMind’s Chinchilla paper, posted on 29 March 2022, overturned that advice. After training more than 400 models, Jordan Hoffmann’s team concluded that parameters and training tokens should grow in equal proportion. By that measure, GPT-3, Gopher, and Jurassic-1 were all undertrained, each having seen roughly 300 billion tokens.

The proof was a matched experiment. Chinchilla, with 70 billion parameters trained on 1.4 trillion tokens, used the same compute as the 280-billion-parameter Gopher and beat it. Its average on Massive Multitask Language Understanding (MMLU), a broad knowledge test, was 67.5%, more than seven points above Gopher’s. That works out to about 20 training tokens per parameter, against roughly one for Gopher.

Why labs now train past the compute-optimal point

The Chinchilla rule finds the lowest loss for a fixed training budget. It ignores the separate bill of serving the model every day after launch. Meta sized the 405B Llama 3 model to be roughly compute-optimal, then deliberately trained the 8B and 70B models much longer, because that makes them stronger at the same inference cost.

That practice helps explain why small models improved so quickly: each parameter now carries far more training. Compute-optimal describes a training budget, not which model suits your workload.

One caveat: scaling laws forecast loss, not capabilities. Llama 3’s team needed a second step, calibrated partly on its older Llama 2 models, to map predicted loss on benchmark tasks to accuracy.

Instruction tuning and RLHF: from autocomplete to assistant

Turning a document completer into an assistant is a post-training story. OpenAI’s InstructGPT paper, posted on 4 March 2022, set out the recipe that later labs built on:

  1. Supervised fine-tuning. About 40 contractors wrote ideal responses, and GPT-3 was fine-tuned on roughly 13,000 training prompts.
  2. Reward model. Labelers ranked several outputs per prompt, across about 33,000 prompts, and a separate reward model learned to score answers the way they ranked them.
  3. Reinforcement learning. The reward model scored fresh answers, and proximal policy optimization (PPO) pushed the model toward higher scores, with a penalty for straying far from its starting point.

That recipe produced the result in the opening: labelers preferred the 1.3-billion-parameter InstructGPT to the 175-billion-parameter GPT-3. On closed-domain tasks such as summarization, the rate of made-up content fell from 41% to 21%.

It was also cheap. Training the 175B model with PPO took 60 petaflop/s-days, against 3,640 for pretraining GPT-3, or under 2% of the budget. Scores slipped on some academic benchmarks, which the authors called an alignment tax and reduced by mixing pretraining data back into the updates.

The lesson worth keeping is that post-training mostly changes how a model uses what it knows, not what it knows. The 175B InstructGPT and GPT-3 shared an architecture and pretraining, yet labelers preferred InstructGPT about 85% of the time.

Constitutional AI and cheaper preference training

Human labels are slow, costly, and subjective; InstructGPT’s trained labelers disagreed with each other roughly a quarter of the time. Anthropic’s Constitutional AI, published on 15 December 2022, replaced human harmlessness labels with a short written list of principles, 16 per training stage.

The model critiques and revises its own drafts against those principles and is fine-tuned on the revisions. Then a model, not a person, picks the less harmful of two answers, and a preference model trained on those picks supplies the RL reward. Anthropic called this reinforcement learning from AI feedback (RLAIF); humans still supplied the helpfulness labels.

The aim was an assistant that explains its objections instead of stonewalling. The engineering win is auditability: the policy lives in a document people can read and debate, not in scattered labeling decisions.

For Llama 3, Meta chose rejection sampling and direct preference optimization (DPO) over PPO. DPO trains directly on pairs of preferred and rejected answers, with no reward model or RL loop in that step. Meta found it cheaper at scale and better at instruction following than PPO-style RL, which tends to be less stable.

Reinforcement learning with verifiable rewards: where reasoning gains come from

Preference rewards have a ceiling. A learned reward model can be gamed, and it only knows what raters liked. RLVR instead rewards outcomes a program can check: the math answer matches, the code passes its tests, the output obeys the stated constraints.

DeepSeek’s R1 paper, published in Nature on 17 September 2025, is one of the most detailed public accounts. Starting from its DeepSeek-V3 base model and skipping supervised fine-tuning, the team used group relative policy optimization (GRPO), a leaner PPO variant that scores each answer against others sampled for the same question. The reward covered only answer correctness and format, yet R1-Zero’s average first-try accuracy on the 2024 American Invitational Mathematics Examination (AIME) rose from 15.6% to 77.9%.

No one gave it worked examples of reasoning. Longer chains of thought, self-checking, and trying alternative approaches emerged because they earned reward. The authors even saw a sudden rise in how often the model wrote wait before reconsidering a step.

Pure RL had costs. R1-Zero’s reasoning was hard to read, mixed English and Chinese, and lagged on writing and open-ended questions. The final R1 pipeline added a small cold-start dataset, further RL and fine-tuning rounds, and a last RL stage that mixed rule-based and preference rewards. DeepSeek avoided neural reward models for reasoning because they invited reward hacking, and confined preference rewards to the last 400 of that final stage’s 1,700 steps.

A fully open version of this recipe is Olmo 3: supervised fine-tuning, then DPO, then RLVR, with RL prompts spanning math, code, chat, and instruction following. RL is no longer a short finishing pass. In December 2025, Ai2 built Olmo 3.1 Think 32B by resuming the Olmo 3 Think 32B RL run for another 21 days on 224 GPUs.

The compute balance is shifting

In 2022, InstructGPT’s post-training was a small fraction of the pretraining bill. As of 2026, that is no longer true for some products. On 9 February 2026, Cursor reported that its Composer 1.5 coding model came from scaling RL 20 times further on the same base model. Its post-training compute exceeded what was spent pretraining that base.

Composer is a specialized coding model on an existing base, so this shows where marginal compute now flows, not that pretraining has stopped mattering. It also shows a product company differentiating a model mainly through post-training.

Which training stage explains what you see?

When a model misbehaves, ask which stage produced the behavior. That tells you which lever can move it.

What you observeStage responsibleWhat actually helps
It does not know your products, data, or recent eventsPretraining data and cutoffRetrieval or tool calls, not fine-tuning first
It states false things fluentlyNext-token objective rewards plausible textGrounding in sources and evaluations that check facts
It refuses reasonable requests or hedgesPreference tuning and safety policyClearer task context or a different model
It is strong on code and math, shaky on judgmentRLVR favors checkable tasksCheckable sub-steps; humans on the rest
One base model behaves differently across productsPost-training plus the surrounding harnessYour own evals, not model names

What this means for your team

  • Put knowledge in context and behavior in weights. Missing facts call for retrieval or tools. Fine-tuning fits format, tone, or a narrow task repeated thousands of times.
  • Test a smaller model first. Small models trained far past compute-optimal carry more capability than their size suggests. Run your eval set on one before defaulting to the largest model.
  • Make outputs checkable. Verifiable rewards drove much of the recent reasoning progress. Tests, valid schemas, and totals that reconcile let you evaluate, monitor, and later tune your own system too. Evals before vibes.
  • Expect reward hacking in your own loops. Tune prompts or models against an LLM judge and the system can learn the judge’s blind spots, as DeepSeek found with learned reward models. Keep a human-graded holdout set.
  • Read the training disclosures. Model cards usually list the knowledge cutoff and context length. If you must audit training data for regulatory or provenance reasons, fully open releases like Olmo 3 are among the few options.

The training pipeline explains what a model is good at before you touch it. InstructGPT is the reminder worth keeping: a smaller model shaped for the task can beat a far larger one that is not. When SurgeX Labs chooses a model for a system, the comparison runs on an eval set built from the real task, not on a leaderboard.

Sources

  1. Scaling Laws for Neural Language Models (opens in new tab) — OpenAI (arXiv), 2020 arxiv.org

  2. Training Compute-Optimal Large Language Models (opens in new tab) — DeepMind (arXiv), 2022 arxiv.org

  3. Training language models to follow instructions with human feedback (opens in new tab) — OpenAI (arXiv), 2022 arxiv.org

  4. Constitutional AI: Harmlessness from AI Feedback (opens in new tab) — Anthropic (arXiv), 2022 arxiv.org

  5. The Llama 3 Herd of Models (opens in new tab) — Meta AI (arXiv), 2024 arxiv.org

  6. DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning (opens in new tab) — DeepSeek-AI (Nature), 2025 nature.com

  7. Olmo 3: Charting a path through the model flow to lead open-source AI (opens in new tab) — Allen Institute for AI (Ai2), 2025 allenai.org

  8. Introducing Composer 1.5 (opens in new tab) — Cursor, 2026 cursor.com

Where this shows up in our work

Building this? Talk to an engineer.

If this guide maps to a system you’re planning, send a short brief. A senior engineer replies within one business day.