← back
00 — opening
Last updated May 30, 2026

How a Frontier LLM Is Built.

One enormous run buys raw capability. A cheap stack of stages after it buys everything you actually talk to. Taken apart, phase by phase.

PRE-TRAINING tens of $M · months builds the brain > 99% of the compute POST-TRAINING ~$100K · days teaches manners < 1% of the compute base model — one pipeline, wildly lopsided —
Pre-training turns the internet into a next-token predictor. Post-training turns that predictor into something you can trust.
scroll
01 — the pipeline

One step does almost all the work. The rest is polish.

A state-of-the-art LLM in 2026 is not one thing trained one way. It is an assembly line of four stages. The single most useful fact about that line is how lopsided it is: one box costs almost all the money, and the three after it are what actually make the model feel smart. Step through them.

the four stages
PHASE 1 PRE-TRAIN tens of $M PHASE 2 SFT ~$100K PHASE 3 PREFERENCE ~$100K PHASE 4 REASONING RL growing
phase 1 / pre-training
Read the internet. Predict the next token.
compute, to scale
absolute · the whole budget post-training is a sliver
pre-training sft preference reasoning
the one-sentence version: Pre-training spends a fortune to turn the internet into a giant next-token predictor. Post-training spends almost nothing to turn that predictor into something you can actually talk to and trust. The whole right side is under 1% of the compute of the box on the left.
02 — the central divide

One builds capability. The other builds usability.

Everything in LLM training falls into one of two buckets. Get this split straight and the rest stops looking like alphabet soup. Pre-training reads trillions of tokens and learns one thing: predict the next token. Post-training takes the parameters pre-training already set and nudges them so the model answers instead of rambles.

PRE-TRAINING

One giant run

goal
Compress the internet into weights. Learn the shape of language and the world.
data
Trillions of tokens of raw, unlabeled web text. No questions, no answers.
objective
Predict the next token. One loss, run everywhere.
cost
Tens of millions of dollars. Months on tens of thousands of GPUs.
what it changes
Everything. This is where capability is born.
output
A base model: a fluent text completer that will not answer you.
POST-TRAINING

A cheap stack

goal
Turn the completer into a helpful, safe, reasoning assistant.
data
Curated: human demos, preference rankings, verifiable problems. Thousands to ~1M examples.
objective
Several. Imitate good answers, rank good over bad, reward correct reasoning.
cost
Under 1% of pre-training compute. Days, not months.
what it changes
Format, tone, safety, and hard reasoning. Almost no new facts.
output
The model you actually chat with.
why the split is so clean: Capability and usability are learned by different means. You cannot rank your way to knowing organic chemistry, and you cannot next-token-predict your way into a consistent, safe persona. Pre-training does the first. Post-training does the second.
03 — phase 1 · pre-training

Learning to predict the next token.

This is the expensive one. Take a transformer with billions of parameters, point it at trillions of tokens, and ask it to do exactly one thing over and over: given everything so far, guess what comes next. Get it wrong and a loss function pushes the weights to be a little less wrong. Do that across the whole internet and grammar, facts, code, arithmetic, and a usable world model all fall out as a side effect.

14.8T
tokens · DeepSeek-V3
671B total params, 37B activated per token
15.6T
tokens · Llama 3.1 405B
dense, ~30.84M H100 GPU-hours
2.788M
H800 GPU-hours · V3
FP8 training, no irrecoverable loss spikes
~20
tokens per parameter
Chinchilla compute-optimal rule

How do labs pick how big the model and how much data should be? Not by guessing. By scaling laws. Chinchilla fit a clean curve, loss as a function of parameters N and data D, and found the compute-optimal recipe is roughly 20 tokens of data for every parameter.

What the data actually looks like

People picture a clever curated dataset. It is mostly the opposite. Open sets like FineWeb are built from deduplication and filtering of raw Common Crawl, roughly 15T tokens from 114 web snapshots. Each row is just a document.

pre-training data fineweb-style row
{
  "text": "The mitochondrion is a double-membrane-bound organelle found in most eukaryotic cells. It generates most of the cell's supply of ATP...",
  "id": "urn:uuid:d66bc6fe-8477-4adf-b430-f6a558ccc8ff",
  "dump": "CC-MAIN-2024-10",
  "url": "https://en.wikipedia.org/wiki/Mitochondrion",
  "language": "en", "language_score": 0.97, "token_count": 717
}
One of ~25.9 billion rows. No labels, no questions. Just raw text to predict the next token of.

What the loss actually measures

At each position the model does not pick a token. It produces a probability for every token in its vocabulary, tens of thousands of them. The cross-entropy loss reads just one of those numbers: the probability it placed on the token that actually came next.

The loss is the negative log of that one probability. Put a high probability on the right token and the loss is near zero. Put a low one and the model was surprised, so the loss is large. Minimizing that number, averaged over trillions of tokens, is the whole of pre-training.

cross-entropy · how surprised the model was by the truth
After "The capital of France is", the true next token is Paris. Watch how the loss tracks the probability the model put on it.
0.90
P( Paris ) · the true token
0.11
loss = −ln(p) · nats
A perfect guess (p = 1) costs nothing; ln(1) = 0. The further the truth slips down the model's list, the steeper the penalty. Training spends all its effort pushing real next-tokens up.

The objective, in one screenful

The whole training signal is cross-entropy on the next token. Exponentiate it and you get perplexity. In essence, one step is this.

in essence · next-token cross-entropy
import torch.nn.functional as F

# One pretraining step: predict every next token at once.
logits  = model(tokens[:, :-1])     # (batch, seq-1, vocab)
targets = tokens[:, 1:]             # shift left by one
loss = F.cross_entropy(
    logits.flatten(0, 1),          # (batch*(seq-1), vocab)
    targets.flatten(),
)
loss.backward()                     # nudge billions of weights
Every token in the sequence is a training example at once. That parallelism is why pre-training scales.

Run that for trillions of tokens and the loss curve has a particular shape: it plunges early, when the model learns the cheap structure of language, then flattens into a long grind of diminishing returns. The flat part is where the real money goes.

pre-training loss
6 3 1 loss 0 15T tokens high loss · random guessing loss flattens · diminishing returns

A base model can't answer you

Architecture is part of the recipe. Llama 3.1 405B is dense, every parameter fires for every token, chosen for training stability. DeepSeek-V3 uses a Mixture of Experts, carrying 671B total parameters but spending only 37B activated per token. Either way, the output is the same kind of thing.

PROMPT

"The capital of France is"

you wanted
an answer.
BASE MODEL OUTPUT

"Paris, and the capital of Italy is Rome, and the capital of Spain is..."

you got
a text completer continuing the pattern.
the catch: A base model is a brilliant text completer, not an assistant. Ask it a question and it continues the pattern of your text instead of answering. Karpathy's name for this is an internet document simulator. Making it answer is the job of everything that follows, and it costs a rounding error by comparison.
04 — phase 2 · supervised fine-tuning

Teaching it to answer.

First stop in post-training. We have a model that completes text; we want one that responds to instructions. The fix is almost embarrassingly simple: show it thousands of examples of the behavior we want. Supervised fine-tuning trains the base model on curated pairs of (prompt, ideal answer). Same machinery, same cross-entropy loss. The only real change is the data.

~13K
demos · InstructGPT
the original instruction-tuning set
52K
examples · Alpaca
cheap data goes surprisingly far
939,344
examples · Tulu 3 SFT mix
18 sources, openly documented

What the data actually looks like

An SFT example is a short conversation: an id, a list of messages with roles, and where it came from. Here is a real-shaped row from the Tülu 3 mixture.

sft data tulu 3-style row
{
  "id": "oasst1_5921",
  "messages": [
    { "role": "user", "content": "Explain photosynthesis to a 10-year-old." },
    { "role": "assistant", "content": "Photosynthesis is how plants make their own food. They take in sunlight, water, and the air we breathe out, and turn it into sugar for energy and oxygen for us..." }
  ],
  "source": "ai2-adapt-dev/oasst1_converted"
}
One of 939,344 curated pairs in Tulu 3. The loss only counts the assistant tokens.

The objective, in one screenful

Here is the one twist that makes SFT work. You do not want the model graded on predicting the user's question, only on producing the answer. So it is the exact same cross-entropy as pre-training, masked to the assistant tokens.

in essence · masked cross-entropy
# SFT: identical cross-entropy, but only assistant tokens count.
logits  = model(input_ids[:, :-1])
targets = input_ids[:, 1:]
tok_loss = F.cross_entropy(logits.flatten(0, 1), targets.flatten(),
                           reduction="none")
loss = (tok_loss * response_mask[:, 1:].flatten()).sum() / response_mask.sum()
loss.backward()
Same loss, same gradients. The mask is the whole idea: imitate the answer, not the question.
sft teaches format, not facts: A million examples cannot add much new knowledge to a model that already read trillions of tokens. What they add is a habit: when you see a prompt, respond like a helpful assistant. The model is not learning chemistry here. It is learning the shape of answering. After SFT you have something genuinely useful, but it has no reliable sense of which of two decent answers is actually better. That judgment is the next phase.
05 — phase 3 · preference tuning

Aligning with what people prefer.

SFT teaches the model to answer. Preference tuning teaches it which answer is better. This is where tone, helpfulness, and safety get dialed in, and it is the stage most responsible for a model feeling polished. The classic recipe is RLHF, introduced at scale by InstructGPT.

the preference loop
model writes 2 answers human picks the better one reward model learns to score model updates toward reward — repeat for thousands of comparisons —

That optimization step is reinforcement learning. Classic RLHF uses PPO, which is powerful but heavy, with a KL penalty as a brake.

The shortcut that took over: DPO

That whole apparatus is a lot. DPO showed you can skip most of it. With a bit of algebra you can train directly on the preference pairs, with no separate reward model and no PPO loop. Preference data is a triple: a prompt, a chosen answer, and a rejected one.

preference data a dpo triple
{
  "prompt": "Write a haiku about coffee.",
  "chosen": "Bean falls, water hums, one quiet golden morning.",
  "rejected": "Coffee is a drink. It is brown. People enjoy it daily."
}
No scalar score, just the ranking. The model learns to rank chosen above rejected.

The objective, in one screenful

Push the chosen answer's probability up and the rejected one's down, but anchor both to a frozen reference model so the tuned model cannot wander off. The strength of that anchor is a single knob, beta.

in essence · the dpo loss
# DPO: no reward model. Push chosen above rejected, anchored to a
# frozen reference model by strength beta.
def dpo_loss(pi_chosen, pi_rejected, ref_chosen, ref_rejected, beta=0.1):
    chosen   = pi_chosen   - ref_chosen
    rejected = pi_rejected - ref_rejected
    return -F.logsigmoid(beta * (chosen - rejected)).mean()
Six lines replace a reward model and a full PPO loop. That simplicity is why open models adopted it fast.

When the judge is another model

Human labeling is slow and hard to scale. Constitutional AI swaps the human for the model itself. The model critiques and revises its own answers against a written constitution, and generates its own preference data. This RLAIF idea is core to how Claude is aligned, and part of a broad 2026 shift from human labels toward synthetic preference data.

preference moves tone, not knowledge: The facts were set in pre-training. What changes here is judgment: which phrasing is clearer, which response is safer, which answer a person would actually prefer. It is the difference between correct and good.
06 — phase 4 · reasoning rl

Learning to think before answering.

The newest phase, and the one that reshaped the competitive landscape in 2026. Preference tuning makes a model pleasant. It does not make it solve a hard math problem. For that you need a different reward: reasoning RL drops human preference entirely and rewards only one thing, getting the answer right, checked by a machine. This is RLVR.

The eye-opener was DeepSeek-R1. Its R1-Zero variant started from DeepSeek-V3-Base and applied pure RL with no SFT first at all. With nothing but verifiable rewards, the model taught itself to produce long chain of thought, to check its own work, even to pause and reconsider. The paper calls it an aha moment. On AIME 2024, accuracy climbed from 15.6% to 71% over the course of RL.

deepseek-r1-zero · accuracy climbs with pure rl
80 40 0 RL training steps 15.6% (start) 71% AIME (after RL)

What the data actually looks like

There are no human-written answers to imitate here. There is a problem, a known correct answer, and a rule for scoring.

reasoning rl data a verifiable-reward example
{
  "problem": "What is the smallest n such that n! has more than 100 digits?",
  "gold_answer": "70",
  "reward": "1.0 if final answer == gold_answer else 0.0"
}
No human judge. A verifier checks the answer. Right = 1, wrong = 0.

The objective, in one screenful

DeepSeek's method is GRPO. The clever part is what it removes. PPO needs a critic; GRPO throws it out. It samples a whole group of answers to the same prompt, grades each with the verifier, and uses the group's average score as the baseline.

in essence · grpo with verifiable rewards
# RLVR with GRPO: sample a GROUP of answers, grade each with a
# verifier (1/0), use the group mean as the baseline. No critic,
# no reward model.
group   = [model.generate(prompt) for _ in range(G)]   # e.g. G = 16
rewards = [verify(ans, gold) for ans in group]         # 1.0 or 0.0
baseline = sum(rewards) / G
advantages = [r - baseline for r in rewards]           # group-relative
loss = -sum(a * logprob(ans) for a, ans in zip(advantages, group)) / G
loss.backward()
The reward is a checker, not a human or a learned model. The baseline is just the group's own average.

Note how different this is from RLHF. There is no learned reward model to game, because the reward is ground truth. The flavor is closer to AlphaGo learning from the rules of the game by self-play than to a model learning human taste.

a second scaling axis: Pre-training scales by adding parameters and tokens. Reasoning RL teaches a model to spend more test-time compute, to think longer before answering. That is a knob you can turn at inference, not just at training, and it is why reasoning RL became the competitive differentiator after R1. The reasoning can then be cheaply distilled into smaller models.
07 — all four at a glance

Same model. Four very different jobs.

One pre-training run on the left of the line, three post-training phases on the right. The line between row one and the rest is the whole pre-training vs post-training divide.

phasedatasignalwhat it movescost
Pre-training Trillions of raw tokens Next-token cross-entropy Raw capability, knowledge Tens of $M, months
SFT Curated prompt, answer pairs Masked cross-entropy Format, instruction following ~$100K, days
Preference Chosen vs rejected pairs RLHF, DPO, or RLAIF Tone, helpfulness, safety ~$100K, days
Reasoning RL Problems with verifiable answers RLVR, GRPO, no reward model Hard reasoning, test-time compute Growing, varies
read it top to bottom: Row one builds the brain. Rows two through four teach it manners, judgment, and how to think out loud. The cost column collapses by two orders of magnitude after the first row, and never recovers.
08 — myths worth killing

A few things that aren't true.

Stubborn misconceptions that make this picture harder to hold than it needs to be. Click each to see what's actually going on.

"Fine-tuning teaches the model new facts."+
Mostly no. The facts were learned in pre-training, from trillions of tokens. SFT and preference tuning reshape behavior, the format, tone, and judgment, not the underlying knowledge. If a fact was not in the pre-training data, a few thousand fine-tuning examples will not reliably put it there.
"RLHF and reasoning RL are basically the same."+
Different at the root. RLHF optimizes a learned reward model that predicts human preference, so it is gameable and needs a KL brake. Reasoning RL (RLVR) optimizes against an objective verifier, closer to AlphaGo than to a taste model. One chases what people like, the other chases what is correct.
"You always need SFT before you can do RL."+
DeepSeek-R1-Zero proved otherwise. It ran pure RL straight on the base model, with no SFT first, and still developed strong chain-of-thought reasoning on its own. SFT first makes the output more readable, but it turned out not to be a hard prerequisite for the reasoning itself.
"Post-training is where most of the cost is."+
The opposite. Post-training is under 1% of pre-training compute. The fortune is spent on the one giant pre-training run. Everything that makes the model feel smart and safe is, by comparison, cheap.
"Bigger pre-training data is always the answer."+
Quality and deduplication often beat raw volume. FineWeb-Edu is a smaller, classifier-filtered slice of FineWeb that punches above its size, and Chinchilla showed that for a fixed budget the size-to-data ratio matters more than just piling on tokens.
09 — closing

The lopsidedness is the whole story.

A frontier model is one enormous bet followed by a handful of cheap corrections. Pre-training spends tens of millions to compress the internet into a next-token predictor that knows a great deal but cannot answer you. Then a stack costing under 1% as much teaches it to respond, to prefer the better answer, and to think before it commits.

Capability is bought once, at great expense. Usability is layered on top, almost for free. Keep that asymmetry in your head and every headline about training cost, alignment, and reasoning models lands in the right place.

Every number traces to one of these. The 2026 trend notes (reasoning RL as differentiator, MoE at the frontier, distillation, synthetic preference data) are qualitative, not hard figures.