Paper Breakdowns  /  Llama 3
Paper 76~10 min readMeta AI 2024worked math + runnable code
Paper Breakdown

The Llama 3 herd,
explained.

The most interesting number in the Llama 3 paper isn't the parameter count — it's 15 trillion tokens. Scaling law orthodoxy says an 8-billion-parameter model should see about 160 billion tokens; Llama 3 fed it nearly a hundred times that. That looks wasteful, until you remember the model is trained once and answered billions of times. The right thing to optimize isn't the training bill — it's the lifetime bill. And once you count inference, over-training a small model is the frugal choice. Here's the arithmetic behind the herd.

Video breakdown
The animated walkthrough is in production.
Read the full breakdown below in the meantime ↓
01

A herd, not a hero

Llama 3 is a family — an 8B, a 70B, and a flagship 405B — all dense, decoder-only transformers. Architecturally it is almost boringly conventional: the same transformer block, rotary position embeddings, grouped-query attention to shrink the KV cache, a bigger vocabulary. No exotic mechanism, no mixture-of-experts in the main models. If you were grading on novelty, you'd shrug.

But the paper's real contribution is a method thesis: quality at a given size comes overwhelmingly from data — how much, and how clean — and from a willingness to spend training compute lavishly to make the deployed model small. Llama 3 trained on ~15T tokens with aggressive filtering, dedup, and quality classifiers, and it deliberately pushed the smaller models far past the "optimal" token count. To see why that isn't a mistake, we need the scaling law it's departing from.

The one-sentence version

Spend extra training compute to over-train a small model on far more data than Chinchilla suggests, because the model is trained once but served billions of times — and inference, not training, dominates the lifetime bill.

02

The Chinchilla point

The Chinchilla scaling laws answered a specific question: given a fixed training compute budget, how should you split it between model size and training tokens to get the best model? Their empirical answer was a clean rule of thumb — scale parameters and tokens together, roughly 20 tokens per parameter. Under that rule an 8B model "should" see about 160B tokens; anything past that is, by Chinchilla's accounting, a poor use of the training budget, since the same FLOPs would buy more quality spent on a larger model.

Llama 3's 8B saw ~15T tokens — call it ~94× the Chinchilla-optimal count. By the training-compute yardstick, that is deep into diminishing returns: those last trillions of tokens each nudge quality only a little. So why do it? Because Chinchilla optimizes the wrong bill.

03

Trained once, served forever

Chinchilla counts only the training FLOPs. But a production model's compute has two parts, and they're paid on wildly different schedules. Training is a one-time cost. Inference is paid per query, forever, and a popular model answers billions of them. For a heavily-served model the inference total swamps the training total.

Both costs scale with parameters. Training a dense transformer costs about 6ND FLOPs (N params, D tokens); each token of inference costs about 2N FLOPs. Crucially, inference cost is proportional to N, the thing you deploy. So a smaller model is permanently cheaper to run — every query, forever. Over-training is the price you pay once, in training, to buy a smaller N at a target quality, and thereby cut the inference cost you pay always. This is the inference-optimal frontier, and it sits at a smaller model + more tokens than Chinchilla's training-optimal one.

04

The lifetime bill

Write the total lifetime compute as training plus inference over Q queries (each generating about t tokens):

Clife  =  Ctrain + Cinfer  =  6ND  +  2N·t·Q

First term: one-time training on D tokens. Second term: inference, paid per query, and it grows without bound as Q grows. Both are proportional to N — so shrinking the model helps both, but it helps the inference term Q times as often.

Now the key move. Over-training raises D (the training term) to buy a smaller N at fixed quality. That trade is worth it once the inference term dominates — i.e. once the model is served enough. Set the two terms equal to find the crossover query count:

6ND = 2N·t·Q*  ⟹  Q* = 3D / t

Past Q* queries, inference has cost more than the entire training run — so any parameter you can shave off (paid for with extra tokens D) is repaid many times over. With D≈15T and t≈10³, Q*≈4.5×10¹⁰: beyond ~45 billion queries, inference rules the bill. A widely-deployed model blows past that quickly, which is exactly why over-training the small models is the frugal choice. The runnable version below computes the over-training ratio and shows inference overtaking training.

RUN IT YOURSELF

Over-train, then count the bill

The whole argument is arithmetic. Chinchilla says ~20 tokens per parameter, so an 8B model is "optimal" at 160B tokens — but Llama 3 fed it 15T, an over-training ratio near 94×. Training costs 6ND once; inference costs 2N per token, per query, forever, and it scales with the parameter count you deploy — so an 8B is permanently cheaper to run than a 70B. Compute the ratio, compare per-query cost across sizes, and watch inference overtake training at high query volume. Change the token count or query volume and see the trade-off move.

CPython · WebAssembly
05

What shipped

Llama 3 delivered open-weight models competitive with the best closed models of its moment, and its choices read as a lesson in what actually moves quality at scale:

ChoiceWhy it mattered
~15T training tokensOver-training the 8B/70B far past Chinchilla-optimal to make small, cheap-to-serve models strong.
Data quality over clevernessHeavy dedup, filtering, and quality classifiers — most gains came from the data pipeline, not architecture.
Standard dense transformerGQA, RoPE, a 128K-token vocabulary — proven parts, scaled and fed well, beat exotic mechanisms.
A herd of sizes8B / 70B / 405B so deployers pick the inference-optimal model for their query volume.

The 405B flagship showed how far a straightforward dense recipe scales; the 8B and 70B showed that the practically important models are the small over-trained ones that most people actually run. Both halves make the same point: at scale, data and serving economics are the levers, not architectural novelty.

06

Why it mattered

Llama 3 crystallized a shift in how the field thinks about scaling. Chinchilla was framed as "the" scaling law, but it answered a training-only question. Llama 3 (and its Llama 2 predecessor) made the inference-optimal view standard practice: because deployment cost, not training cost, dominates the lifetime of a popular model, the industry now routinely over-trains smaller models on trillions of tokens. The "right" model size shrank, and token counts exploded.

It also mattered as open weights. A frontier-class model whose weights anyone could download and fine-tune reset the ecosystem — it became the default base for countless downstream models, from multimodal systems to domain fine-tunes, precisely because a strong, cheap-to-serve base is the most useful thing you can hand the community. The paper's quiet lesson is that the frontier isn't only pushed by new mechanisms; sometimes it's pushed by taking a known recipe and being ruthless about data, scale, and the bill you'll actually pay.

Worth knowing

Over-training isn't free quality — returns per token diminish, and some capabilities need a bigger model no matter how much data you pour in. The herd exists because the inference-optimal size depends on how heavily you plan to serve it.

Frequently asked

Quick answers

What is Llama 3?

Meta AI's 2024 family of open-weight dense transformers — 8B, 70B, and a 405B flagship — trained on ~15 trillion tokens with heavy data curation.

Why 15 trillion tokens for an 8B?

Chinchilla says ~160B is training-optimal, but the model is served billions of times, so over-training it to be small and cheap to run lowers the far larger inference bill.

Compute-optimal vs inference-optimal?

Compute-optimal minimizes training cost; inference-optimal minimizes cost per served query, which favors a smaller model trained on more tokens.

Is over-training always right?

Only when inference dominates the lifetime compute — a lightly-used model may never repay the extra training, and quality gains per token diminish.

Finished this one? 0 / 101 Paper Breakdowns done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns