Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

~13 min readNeurIPS 2020

GPT-3,
explained.

By 2020, the recipe for a new task was fixed: gather a labeled dataset, then fine-tune. GPT-3 asked a wilder question — what if you just made the model enormous, and then, instead of training it, simply showed it a few examples in the prompt? At 175 billion parameters, something new fell out: the model could learn a task from the words you handed it, with no fine-tuning at all.

The delta

What changes against T5: the fine-tune disappears

Rungs 1 and 2 both end with a gradient step on your task. BERT fine-tunes a head; T5 fine-tunes the whole model on a task expressed as text. GPT-3's claim is that at sufficient scale you can skip that entirely: put a few worked examples in the prompt, and the model performs the task without any weight update at all. No labelled training set, no optimiser, no checkpoint per task.

In the ladder's units: T5's largest was 11B parameters; GPT-3 is 175B, a ~16× jump, trained on roughly 300B tokens. Hold those two numbers together, because rungs 4 and 5 are an argument about precisely that ratio: 175B parameters against 300B tokens is about 1.7 training tokens per parameter. Nothing in this paper suggests that ratio is a choice at all — it reads as a consequence of using the compute available.

The interface change is the lasting one. Once the way to get behaviour out of a model is to write text at it, prompting becomes an engineering discipline, and everything on the reasoning ladder becomes possible.

01

The fine-tuning bottleneck

BERT had made a recipe famous: pre-train a big model once, then fine-tune it on each specific task with a labeled dataset. It worked brilliantly — but it had a cost that was easy to overlook. Every new task needed its own curated collection of thousands of labeled examples, and its own round of training that nudged the model's weights.

Humans don't work that way. You can be told "translate these to French" and shown one or two examples, and you're off — no dataset of ten thousand pairs, no retraining of your brain. The GPT-3 authors framed this squarely: the fine-tuning recipe was powerful but narrow, and it scaled poorly to the long tail of tasks nobody had built a dataset for. They wanted a model that could pick up a task the way a person does — from a short description and a handful of examples.

02

The bet: don't change the model — make it bigger

GPT-3's architecture is almost boringly familiar: it's the same autoregressive Transformer decoder as GPT-2, trained on the same humble objective — predict the next word, over and over, across a huge slice of the internet. The paper introduces essentially no new architecture. Its one radical move is scale.

GPT-2 had 1.5 billion parameters. GPT-3 has 175 billion — over a hundred times larger — trained on roughly 300 billion tokens of text. The hypothesis was that capability wasn't waiting on a cleverer design but on size, and that at some scale, new behaviors would simply emerge. The title says it all: Language Models are Few-Shot Learners. Scale was the whole idea.

The through-line

GPT-3 is the loudest evidence for the "scaling hypothesis" — that predictable gains come from making models, data, and compute bigger. It's the same bet the Scaling Laws and Chinchilla papers formalize; GPT-3 is where it stopped being a curve on a chart and started feeling like magic.

03

Zero-shot, one-shot, few-shot

The paper's central move is to stop fine-tuning entirely and instead put the "training" inside the prompt. It measures three settings, all with the model's weights frozen:

Zero-shot — you give only a task description. One-shot — you add a single worked example. Few-shot — you add several (often 10–100) examples before the real question. In every case the model just reads the prompt and continues it.

Few-shot prompt — teaching by example, in the text itself
sea otter  =>  loutre de mer
cheese  =>  fromage
plush giraffe  =>  girafe en peluche
otter  =>  ?
loutre  ·  model continues the pattern

Nothing here updates a single weight. The examples are just text the model reads on its way to generating the answer. And yet, at 175B, accuracy climbs steadily as you go from zero- to one- to few-shot — the extra examples genuinely help. Smaller models barely benefit; the effect grows with scale.

04

How it works under the hood

GPT-3 is a stack of 96 Transformer-decoder layers, 12,288-dimensional embeddings, 96 attention heads, and a context window of 2,048 tokens. Each layer is the standard decoder block: masked self-attention (each token attends only to tokens before it) followed by a feed-forward network. Trained on next-token prediction, it becomes a probability machine — given everything so far, what word comes next?

That single objective is deceptively powerful. To predict the next word well across the whole internet, the model has to implicitly pick up grammar, facts, translation, arithmetic, and reasoning patterns — because all of those show up in text. Few-shot prompting simply conditions that machine: the examples in the prompt shift the probabilities so the most likely continuation is the answer in the format you demonstrated.

05

The 175B, derived by hand

"175 billion parameters" sounds like a press-release number, but you can compute it from the architecture on a napkin. A Transformer layer's weights are dominated by four attention projections (each d×d) and two feed-forward matrices (d×4d and 4d×d), giving ≈ 12·d² parameters per layer:

The same formula reproduces the whole model family the paper trained (embedding matrix ≈ 50257·d added; it matters for the small ones, vanishes at scale):

ModelLayersdmodel12·L·d² + embeddingsPaper says
GPT-3 Small1276885M + 39M = 0.12B125M
GPT-3 XL2420481.21B + 0.10B = 1.31B1.3B
GPT-3 13B40514012.7B + 0.26B = 12.9B13B
GPT-3 175B9612288173.9B + 0.6B = 174.6B175B

Training cost falls out just as cleanly. Each token requires roughly 6 FLOPs per parameter (2 for the forward pass, 4 for backward), and GPT-3 saw 300B tokens:

That's several thousand petaflop/s-days. These two rules — 12·L·d² and 6·N·D — are the napkin math practitioners still use to size and price every model since.

06

In-context learning: the surprise

The headline phenomenon has a name: in-context learning. The model appears to "learn" the task from the examples in its context window, during a single forward pass, with no gradient descent and no weight change anywhere. Whatever adaptation is happening lives entirely in the activations as the model processes the prompt.

This was genuinely unexpected. Learning, in machine learning, had always meant updating weights. GPT-3 showed a second, temporary kind of learning that happens at inference time, purely from what's in front of the model. It reframed the interface to AI: you no longer train a model for a task, you describe the task and show examples. That's the birth of prompting as a discipline.

Worth knowing

In-context learning is why "prompt engineering" exists. Because the model adapts to whatever pattern you put in context, the wording, ordering, and choice of examples measurably change the answer — a lever you pull with text, not training runs.

How it works

How GPT-3 was built and evaluated, step by step

GPT-3 introduces almost no new architecture, so the method is mostly in the data, the training run and the way tasks are posed at test time.

Source · tokens Share of the 300B training tokens Epochs Common Crawl, filtered · 410B quality-filtered, fuzzy-deduplicated 60% 0.44 WebText2 · 19B 22% 2.9 Books1 · 12B 8% 1.9 Books2 · 55B 8% 0.43 Wikipedia · 3B 3% 3.4 more than one pass under one pass
The mix is set by judged quality, not size: the small curated sources are repeated several times, while most of the filtered crawl is never seen.
  1. Filter Common Crawl with a classifier. Forty-one monthly Common Crawl shards from 2016 to 2019, about 45 TB of compressed plaintext, were scored by a logistic-regression classifier trained to tell curated text (WebText, Wikipedia and a web-books corpus, as positives) from raw Common Crawl (negatives), using Spark's standard tokenizer and hashed term-frequency features. A document was kept when a random Pareto draw with shape α = 9 exceeded one minus its score, so high-scoring pages usually survive and a minority of low-scoring pages still get through, for diversity.
  2. Deduplicate. Fuzzy, document-level deduplication within and across sources, using MinHash locality-sensitive hashing (Spark's MinHashLSH with 10 hashes) on the same features, cut the data by about 10%. What remained of Common Crawl was 570 GB, roughly 410B tokens.
  3. Weight the mix by quality, not by size. Training draws from five sources at fixed rates, shown in the figure. Sources judged higher quality are sampled more often than their size alone would give, so Wikipedia and WebText2 are seen roughly three times while Common Crawl and Books2 are seen less than half a time: a deliberate trade of a little overfitting for a higher share of good text.
  4. Tokenize and pack. GPT-2's byte-level BPE, with a vocabulary of 50,257. Every training sequence fills the full 2,048-token context; shorter documents are packed together, separated by an end-of-text token, with no special masking between them.
  5. Use GPT-2's architecture, with sparse layers. A decoder-only Transformer with pre-normalization and GPT-2's modified initialization, except that layers alternate between dense attention and locally banded sparse attention, in the style of the Sparse Transformer. Eight sizes were trained, from 125M to 175B parameters, all on the same 300B tokens.
  6. Optimize. Adam with β1 = 0.9, β2 = 0.95 and ε = 10^−8; the gradient norm is clipped at 1.0; weight decay is 0.1. The learning rate warms up linearly over the first 375M tokens, then follows a cosine decay to 10% of its peak over 260B tokens. The batch grows linearly from 32k tokens to full size over the first 4 to 12B tokens; for the 175B model the full batch is 3.2M tokens and the peak learning rate 0.6 × 10^−4. Training ran on V100 GPUs in a Microsoft cluster, with each model split across GPUs both within each matrix multiply and across layers.
  7. Try to decontaminate. Overlaps with benchmark test sets were searched for and removed before training, but a bug left some in, and the run was too expensive to repeat. The paper measures the damage afterwards instead.
  8. Evaluate in context. For each test example, K demonstrations are drawn at random from the task's training set and placed before it, separated by one or two newlines, with K anywhere from 0 to as many as fit in 2,048 tokens, typically 10 to 100. Multiple-choice tasks compare the model's likelihood of each answer; free-form tasks use beam search with width 4 and a length penalty of 0.6. No weights change at any point.
The math

The training objective, and how answers are scored in context

L(θ) = −Σt log pθ(xt | xt−2048, …, xt−1)
ĉ = argmaxc (1/|c|) · Σt log pθ(ct | demos, query, c<t)
ĉ = argmaxc pθ(c | demos, query) / pθ(c | Answer:)
  • xt — the next BPE token; the context is at most 2,048 tokens. This is the only training objective.
  • demos — K solved examples placed in the prompt; query — the unsolved one. θ is identical for every task: demonstrations enter only through what the model is conditioned on.
  • c — a candidate answer; 1/|c| — per-token normalization, so a long answer is not penalized merely for having more tokens.
  • The third form, used on a few datasets such as ARC, OpenBookQA and RACE, divides by the answer's probability after a bare Answer: prompt. An option that is likely in general, such as a short common word, then gets no credit unless the question itself raises its probability.

At the extremes: with K = 0 the model sees only a natural-language task description, which is zero-shot. As K grows the prompt fills the 2,048-token window, which is the hard ceiling on few-shot learning. Nothing in either scoring rule involves a gradient.

The evidence

What GPT-3 was tested on, and what it showed

All eight sizes were evaluated with frozen weights on more than two dozen datasets in zero-, one- and few-shot settings. The comparison points are fine-tuned systems that trained on thousands of labeled examples.

BenchmarkGPT-3 175BReference
LAMBADA, predict a passage's last word76.2% zero-shot, 86.4% few-shotPrior state of the art: 68.0%
TriviaQA, closed book64.3% / 68.0% / 71.2% (zero / one / few-shot)Fine-tuned retrieval system (RAG): 68.0%
SuperGLUE71.8 few-shotFine-tuned BERT-Large: 69.0; state of the art: 89.0
Arithmetic, few-shot2-digit addition 100%; 3-digit 80.4%; 4-digit 25.5%; 5-digit 9.3%Never explicitly taught
Spotting GPT-3 news articles of about 200 wordsPeople were right 52% of the timeChance: 50%
WiC, word sense in two sentences49.4% few-shotChance: 50%

Few-shot GPT-3 was often competitive with fine-tuned models and sometimes matched them; zero-shot alone beat the LAMBADA state of the art by about 8 points. It also translated with no fine-tuning on parallel text, unscrambled words and answered trivia closed-book. The trend mattered more than any single score: accuracy rose with model size in every setting, and the gap between few-shot and zero-shot widened with scale, which is the evidence that in-context learning is something larger models grow into.

The negative results are as informative. Tasks that compare two sentences stayed weak: WiC sat at chance, and ANLI was near chance for all but the largest model. Arithmetic decayed quickly with more digits, and a search of the training data for the 3-digit problems found few matches, suggesting the successes were not recall. The contamination study rebuilt each benchmark without any test example sharing a 13-gram with the training data; for most benchmarks the clean scores barely moved, and a few results, including PIQA and Winograd, were flagged.

Since then

What the authors admit, and what happened next

The paper's own limitations section is longer and franker than most: few-shot performance is still well short of fine-tuned state-of-the-art on many tasks; the model is weak on tasks requiring comparison of two sentences; it has no notion of which of its outputs are true; and the authors flag both the training-data contamination problem and the energy cost of the run. They also state plainly that the model reproduces the biases of its corpus.

The admission most relevant to this ladder is quieter: they note the model is trained once, and that they could not afford to retrain it to explore alternatives. A single un-repeatable run is not a measurement of how to spend compute — which is the gap rung 4 sets out to fill.

How it held up: in-context learning held up completely and is now the primary interface to every frontier model. The specific sizing did not. Within two years the same compute was understood to be badly allocated, and GPT-3's 1.7 tokens per parameter became the canonical example of an under-trained model — the comparison rung 5 uses to make its case.

SOLVE IT YOURSELF

Size and price any GPT on a napkin

The two estimation rules from the derivation, as runnable functions: rebuild the paper's model-family table from just layers and width, then price the training run with 6·N·D. Change the config to a modern model's shape and the same napkin math still lands within a few percent.

YOUR TASK

Write the body of train_flops. Everything else in the file is already written; this is the function the paper is about. Press ▶ Run to check it against the 5 assertions below — they start red.

WHAT IT HAS TO SATISFY — 5 ASSERTIONS
  1. Derives 175B within 1 percent
  2. Derives the small model near 125M
  3. 6ND reproduces the paper FLOPs
  4. The embedding matrix adds params on top of the core
  5. Training compute is linear in tokens (2x tokens = 2x FLOPs)
CPython · WebAssembly
08

What it couldn't do

The paper is unusually candid about limits. GPT-3 makes things up — fluent, confident text that is simply wrong. It loses the thread over long passages, contradicting itself. It stumbles on tasks needing real multi-step reasoning, and its arithmetic falls apart past a few digits. Because it learned from the open internet, it also absorbed the web's biases around gender, race, and religion.

There's a deeper gap too: GPT-3 is trained only to continue text, not to follow instructions or be helpful. Ask it a question and it might answer — or it might continue with more questions, because that's a plausible continuation. Aligning that raw next-word engine to human intent was the unfinished business that InstructGPT and RLHF picked up next, and which ultimately produced ChatGPT.

09

Why it still matters

GPT-3 is the hinge between two eras. Before it, you adapted models by training them; after it, you adapted them by talking to them. In-context learning turned the prompt into the primary interface for AI, and made "few-shot" and "zero-shot" everyday vocabulary. Every prompt you write to a modern assistant is a descendant of this paper.

It also settled, loudly, that scale delivers — the conviction that drove the models that followed. GPT-3 wasn't aligned, wasn't a chatbot, and got plenty wrong. But it proved that a big enough next-word predictor is a general-purpose, promptable engine, and everything from InstructGPT to today's frontier models is a refinement of what GPT-3 first made undeniable.

The line to today

GPT-3 (capability) → InstructGPT (align it to follow instructions with RLHF) → ChatGPT (wrap it in a chat interface). If GPT-3 is the engine, the papers after it are the steering, the seatbelt, and the dashboard.

Questions

Questions people ask about GPT-3

What data was GPT-3 trained on, and in what proportions?

Five sources, sampled at fixed rates during a 300-billion-token run: filtered Common Crawl (about 410 billion tokens, 60% of the mix), WebText2 (19 billion, 22%), Books1 (12 billion, 8%), Books2 (55 billion, 8%) and English Wikipedia (3 billion, 3%). The rates were set by judged quality rather than size, so the smaller, cleaner sources were repeated: Wikipedia about 3.4 times and WebText2 about 2.9 times, while Common Crawl and Books2 were each seen less than half a time. The authors accepted a little overfitting on the repeated sources in exchange for a higher share of high-quality text.

How did OpenAI filter Common Crawl for GPT-3?

In three steps. First, a logistic-regression classifier was trained to separate curated text, from WebText, Wikipedia and a books corpus, from raw Common Crawl, and every crawled document got a quality score. A document was kept when a random Pareto draw with shape 9 exceeded one minus its score, which keeps mostly high-scoring pages but lets some out-of-distribution pages through. Second, fuzzy deduplication with MinHash locality-sensitive hashing removed near-duplicate documents within and across sources, cutting the data by about 10%. Third, the filtered crawl was mixed with the curated sources at higher sampling rates. About 45 TB of compressed crawl text became 570 GB.

Does GPT-3 actually learn from the examples in its prompt?

Not in the sense of updating weights: the parameters are identical for every task, and the demonstrations only change what the model is conditioned on. The GPT-3 paper calls this in-context learning and shows it improves with both the number of examples and model size, but it does not explain the mechanism. Later work studied it directly. Olsson and colleagues at Anthropic (2022) linked it to induction heads, attention circuits that find and copy patterns seen earlier in the context. Min and colleagues (2022) found that replacing the labels in demonstrations with random ones often hurt surprisingly little, which suggests the examples teach format and label space more than the input-label mapping.

Were GPT-3's benchmark results contaminated by its training data?

Partly, and the paper says so. The team tried to remove overlaps between the training data and benchmark test sets before training, but a bug left some in, and retraining was too expensive. So after training they built a clean version of each benchmark by dropping every test example that shared a 13-token sequence with the training data, and compared scores on the clean and full versions. For most benchmarks the difference was negligible, which suggests the overlap did not inflate results much. A few results, including PIQA and Winograd, were marked as potentially affected. An n-gram test catches only near-verbatim overlap, so paraphrased or reformatted test material would slip through it.

What kind of sparse attention does GPT-3 use?

The paper says only that its layers alternate between dense attention and locally banded sparse attention patterns, similar to the Sparse Transformer of Child and colleagues (2019). In a banded layer each token attends to a window of nearby positions instead of every earlier position, which cuts the attention computation in those layers, while the dense layers in between keep full access to the 2,048-token context. The paper gives no ablation of this choice and no further detail, so it is not possible to say from the paper how much it mattered. Apart from that, the architecture is GPT-2's, including pre-normalization and its modified initialization.

How many examples fit in a GPT-3 few-shot prompt?

As many as fit in the 2,048-token context window together with the test question, which the paper says is typically 10 to 100 examples, depending on how long each example is. Demonstrations are drawn at random from the task's training set for each test example and separated by one or two newlines. More examples usually helped but not always, so when a separate development set existed the authors tried a few values of K on it and used the best on the test set. The window, not the model's willingness to use more examples, is the hard limit on few-shot learning in GPT-3.

Check yourself

4 questions to test what you just read

Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.

Common Crawl contributes 410B tokens at 60% of a 300B-token run. How many passes over it is that, and how many over Books2 (55B tokens at 8%)?

Show answer

Common Crawl: 0.60 × 300B = 180B tokens drawn from 410B, about 0.44 of one pass. Books2: 0.08 × 300B = 24B drawn from 55B, also about 0.44 (the paper lists 0.43). Both are sampled less than once, while Wikipedia is repeated about 3.4 times.

A task's demonstrations average 150 tokens each. Roughly how many fit in GPT-3's prompt with room left for the test question?

Show answer

The window is 2,048 tokens. Leaving about 150 for the query and its answer, (2,048 − 150) / 150 ≈ 12 demonstrations. That ceiling is why few-shot in GPT-3 means 10 to 100 examples, not thousands.

With a full batch of 3.2M tokens, about how many optimizer steps does a 300B-token run take?

Show answer

300 × 10^9 / 3.2 × 10^6 ≈ 94,000 steps, a few thousand more in practice because the batch ramps up from 32k tokens over the first 4 to 12B tokens. Few steps with huge batches is what lets a run this size spread across many GPUs.

Using the Pareto rule (keep a document when a draw with shape 9 exceeds 1 minus its score), how much likelier is a document scored 1.0 to be kept than one scored 0.5?

Show answer

numpy's Pareto draw exceeds x with probability (1 + x)^−9. A score of 1.0 needs a draw above 0: probability 1. A score of 0.5 needs a draw above 0.5: 1.5^−9 ≈ 0.026. Top-scored pages always survive; middling ones rarely, but not never.

Where this sits

Pre-training, and the scaling laws

The ladder where rung 5 overturns rung 4. Read `scaling-laws` before `chinchilla` — the second measures the same axis in the same units and gets a different answer.

  1. 1BERT2019
  2. 2T52020
  3. 3GPT-32020
  4. 4Scaling Laws2020
  5. 5Chinchilla2022
  6. 6Textbooks Are All You Need2023
  7. 7Muon2024

All 110 papers, in 19 ladders →

Finished this one? 0 / 110 Paper Breakdowns done
NextScaling Laws Next on the “Pre-training, and the scaling laws” ladder · rung 4 of 7

Explore the topic

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

More Paper Breakdowns