← back
00 · opening
Last updated May 30, 2026

How a Frontier LLM Is Built.

One enormous training run gives the model its raw capability. A few cheap stages after it turn that into the assistant you talk to. This page takes it apart, one phase at a time.

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 an assistant you can talk to and trust.
scroll
01 · the pipeline

One stage costs almost all the compute. Three cheap stages follow it.

A state-of-the-art LLM in 2026 is trained in four stages, one after another, like an assembly line. The most useful thing to know about that line is how lopsided it is. The first stage costs almost all the money. The three after it cost very little, yet they are what make the model feel smart. Step through them below.

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 short version: Pre-training spends a fortune to turn the internet into a giant next-token predictor. Post-training spends very little to turn that predictor into something you can talk to and trust. The three stages on the right, added together, use under 1% of the compute of the first box.
02 · the central divide

Pre-training builds what the model can do. Post-training makes it usable.

Every part of LLM training falls into one of two buckets. Once you see that split, the pile of acronyms gets much easier to sort. 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 your question instead of rambling on.

PRE-TRAINING

One giant run

goal
Compress the internet's text into the weights. Learn how language works and what the world is like.
data
Trillions of tokens of raw web text, with no labels, questions, or answers.
objective
Predict the next token. The same loss is applied to every token of every document.
cost
Tens of millions of dollars. Months on tens of thousands of GPUs.
what it changes
Everything. This is where the model gets its knowledge and skills.
output
A base model: a fluent text completer that will not answer you.
POST-TRAINING

A cheap stack

goal
Turn the text completer into an assistant that is helpful, safe, and able to reason.
data
Curated examples: human-written demos, rankings of answers, and problems with checkable answers. Thousands to ~1M examples.
objective
Several: imitate good answers, prefer good answers over bad ones, 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 chat with.
why the split is so clean: Capability and usability are learned in different ways. Ranking answers can't teach a model organic chemistry. It has to read about chemistry, and that is pre-training. Predicting the next token of web text can't give it a consistent, safe persona. That takes post-training.
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 one thing over and over: given everything so far, guess what comes next. When it guesses wrong, a loss function pushes the weights to be a little less wrong. Repeat that across the internet, and the model picks up grammar, facts, code, arithmetic, and a usable model of the world as side effects.

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 decide how big the model should be and how much data to feed it? They use scaling laws. The Chinchilla paper fit a smooth curve that predicts the loss from the number of parameters (N) and the amount of data (D). It found that the compute-optimal recipe is roughly 20 tokens of data for every parameter.

What the data looks like

You might picture a carefully hand-built dataset. Mostly it is raw web pages. Open sets like FineWeb take raw Common Crawl, a public archive of scraped web pages, and clean it with deduplication and filtering. The result is roughly 15T tokens from 114 web snapshots. Each row is one 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. There are no labels and no questions, only raw text for the model to predict, one token at a time.

What the loss measures

At each position, the model gives a probability to every token in its vocabulary, tens of thousands of them, rather than picking a single one. The cross-entropy loss looks at only one of those numbers: the probability the model gave to the token that came next in the text.

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. Pre-training is the job of making that number small, averaged over trillions of tokens.

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, because ln(1) = 0. The less probability the model gives the true token, the bigger the loss, and it climbs faster and faster as p nears zero. Training works to push up the probability of the real next token.

The objective, in one screenful

The only training signal is cross-entropy on the next token. Raise e to the power of that loss and you get perplexity. Here is one training step, with everything else stripped away.

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 position in the sequence is its own training example, and they are all computed at once. That parallelism is why pre-training scales so well.

Run that over trillions of tokens and the loss curve takes a typical shape. It drops fast at first, while the model learns the easy patterns of language. Then it flattens out, and each extra token buys a smaller improvement. Most of the money is spent on that long flat part.

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

The model's architecture is also part of the recipe. Llama 3.1 405B is dense: every parameter is used for every token, a choice made for training stability. DeepSeek-V3 uses a Mixture of Experts. It has 671B parameters in total, but only 37B are activated for each token. Either way, the result is the same kind of model, and it behaves like this.

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 very good text completer, but it is not an assistant. Ask it a question and it continues the pattern of your text instead of answering. Karpathy calls it an internet document simulator. Every stage after this one exists to make it answer, and all of them together cost very little by comparison.
04 · phase 2 · supervised fine-tuning

Teaching it to answer.

This is the first stage of post-training. We have a model that completes text, and we want one that follows instructions. The fix is surprisingly 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). It uses the same machinery and the same cross-entropy loss as pre-training. Only the data changes.

~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 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 row in the same format as 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

SFT has one twist. You want the model graded only on writing the answer, not on predicting the user's question. So it uses the same cross-entropy as pre-training, with a mask that counts only the assistant's 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()
The loss and the gradients are the same as in pre-training. The only new part is the mask, which makes the model learn from the answer and ignore the question.
sft teaches format, not facts: A million examples can't add much new knowledge to a model that has already read trillions of tokens. What they add is a habit: when you see a prompt, respond like a helpful assistant. The chemistry the model knows came from pre-training. SFT teaches it the form of an answer. After SFT the model is useful, but it has no reliable way to tell which of two decent answers is better. Teaching that 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 tuned, and it does more than any other stage to make a model feel 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

The step where the model updates toward the reward is reinforcement learning. Classic RLHF uses PPO, which works well but is heavy to run. It adds a KL penalty as a brake.

The shortcut that took over: DPO

That is a lot of machinery. 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. Each piece of 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."
}
There is no numeric score, only which answer won. The model learns to rank the chosen answer above the rejected one.

The objective, in one screenful

Push the chosen answer's probability up and the rejected one's down. Both are measured against a frozen reference model, which keeps the tuned model from wandering off. A single knob, beta, sets how strong that anchor is.

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 replaces the human with the model itself. The model critiques and revises its own answers against a written set of principles, the constitution, and produces its own preference data. This RLAIF idea is central to how Claude is aligned. It is also 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 prefer. An answer can be correct and still not be good, and this stage teaches the difference.
06 · phase 4 · reasoning rl

Learning to think before answering.

This is the newest phase, and in 2026 it is where labs compete hardest. Preference tuning makes a model pleasant, but that doesn't help it solve a hard math problem. For that you need a different reward. Reasoning RL drops human preference and rewards only one thing: getting the answer right, as checked by a program. This is called RLVR.

The surprise came from DeepSeek-R1. Its R1-Zero version started from DeepSeek-V3-Base and went straight to RL, with no SFT first at all. With only verifiable rewards to go on, the model taught itself to write long chain of thought, to check its own work, and even to stop and reconsider. The paper calls this an aha moment. On AIME 2024, its accuracy rose from 15.6% to 71% over the course of RL training.

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

What the data looks like

Here there are no human-written answers to imitate. Each example is a problem, its 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"
}
There is no human judge. A program checks the final answer: right scores 1, wrong scores 0.

The objective, in one screenful

DeepSeek's method is called GRPO. It is a simpler PPO with one part taken out. PPO needs a critic, a second network that predicts what score to expect. GRPO drops it. Instead, it samples a group of answers to the same prompt, grades each one with the verifier, and uses the group's average score as the baseline. Answers that beat the average are made more likely. Answers below it are made less likely.

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 comes from a checker instead of a human or a learned model. The baseline is the group's own average score.

This is very different from RLHF. In RLHF, the model can learn to fool the reward model. Here there is no reward model to fool, because the reward is the true answer. It is more like AlphaGo improving through self-play, where the rules of the game decide who won, than like a model learning human taste.

a second scaling axis: Pre-training gets better by adding parameters and tokens. Reasoning RL teaches a model to use more test-time compute. In plain terms, it learns to think longer before answering. That gives you a knob you can turn while the model is answering, not only while it is being trained. It is why reasoning RL became the main way labs set their models apart after R1. The reasoning can then be cheaply distilled into smaller models.
07 · all four at a glance

The same model, trained four different ways.

The first row is the one pre-training run. The next three rows are the post-training phases. The break between row one and the rest is the 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. In the cost column, the price drops by two orders of magnitude (about 100 times) after the first row, and it stays down.
08 · myths worth killing

A few things that aren't true.

These common misconceptions make the picture harder to understand than it needs to be. Click each one to see what is true instead.

✕"Fine-tuning teaches the model new facts."+
Mostly no. The model learned its facts in pre-training, from trillions of tokens. SFT and preference tuning change its behavior (format, tone, and judgment) and leave the underlying knowledge mostly alone. 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."+
They work differently. RLHF trains against a learned reward model that predicts human preference. The model can learn to fool that reward model, so RLHF needs a KL brake. Reasoning RL (RLVR) trains against an objective verifier that checks whether the answer is right, which makes it closer to AlphaGo than to a model learning taste. RLHF aims for what people like. RLVR aims for what is correct.
✕"You always need SFT before you can do RL."+
DeepSeek-R1-Zero showed you don't. It ran pure RL directly on the base model, with no SFT first, and still learned strong chain-of-thought reasoning on its own. Doing SFT first makes the output easier to read, but the reasoning itself does not require it.
✕"Post-training is where most of the cost is."+
It's the other way around. Post-training uses under 1% of pre-training compute. Almost all the money goes into the one giant pre-training run. Everything that makes the model feel smart and safe is cheap by comparison.
✕"Bigger pre-training data is always the answer."+
Quality and deduplication often beat raw volume. FineWeb-Edu is a smaller slice of FineWeb, kept by a classifier that scores how educational each page is, and it trains better models than its size would suggest. Chinchilla showed that for a fixed budget, getting the ratio of model size to data right matters more than piling on tokens.
09 · closing

Pre-training is expensive. Everything after it is cheap.

A frontier model comes from one enormous, expensive run followed by a few cheap adjustments. Pre-training spends tens of millions of dollars to compress the internet into a next-token predictor. That predictor knows a great deal but cannot answer you. Then a few stages costing under 1% as much teach it to respond, to prefer the better answer, and to think before it commits to an answer.

Capability is paid for once, at great expense. Usability is added on top for almost nothing. Keep that imbalance in mind and you will know where each headline about training cost, alignment, or reasoning models fits.

Every number on this page comes from one of these sources. The 2026 trend notes (reasoning RL as what sets labs apart, MoE at the frontier, distillation, synthetic preference data) are general observations, not hard figures.