AIAny. ← Back to AIAny

Lesson notes · one model · one job · no supervision

Language Models are Unsupervised Multitask Learners

GPT-2 trains on one exercise only: guess the next word. This page follows one real sentence from its training set to show how that single exercise, done well enough on 40 GB of internet text, quietly turns into translation, question answering and summarization — tasks nobody set.

Subject Zero-shot task transfer Date Feb 14, 2019 Venue OpenAI technical report Scale 1.5B params · 40 GB WebText

Alec Radford · Jeffrey Wu · Rewon Child · David Luan · Dario Amodei · Ilya Sutskever — OpenAI.

The core idea

The tasks are already in the text.

In 2019, the standard way to get a model to translate, answer questions or summarize was to build one model per task, each trained on its own hand-labeled dataset. This paper bet on something stranger: ordinary internet text is already full of people doing those tasks — quoting a French phrase and glossing it, asking a question and answering it, writing an article and then its summary.

So train one model to do nothing but predict the next word, on text varied enough to contain all those little demonstrations, and the skills come along on their own — because predicting the next word through a demonstration means performing the task. No task labels, no fine-tuning. The model is GPT-2; the surprise is how far this gets.

The task is not in the objective. The task is in the data.

PART A

One machine, one job

What GPT-2 does all day, and how the job is graded

Step 1 · Try the job yourself

One game, played on 40 GB of internet text: guess the next word.

Before any definitions, let's play one round of the only game GPT-2 ever plays. Below is a snippet of real internet text — it comes from WebText, the training set, and the paper reprints it in Table 1. Someone on the web actually wrote this. Read it and guess the missing word:

Read the sentence, then pick your guess for the blank

“I'm not the cleverest man in the world, but like they say in French: Je ne suis pas un ______

That's the whole job. A language model is a machine that reads some text and puts a probability on every possible next token; GPT-2 does this once per position, left to right, over billions of positions of internet text. Here's the round you just played, drawn as a diagram — this shape comes back again and again:

…in French: Je ne suis pas un context so far GPT-2 a language model P(next token | context) imbecile fou génie one bar per token
Context in, probabilities out. The amber box on the left is the phrase “like they say in French:” — hold onto it; in Part B that little amber cue turns out to be doing a lot of work.

The snippet is quoted in Table 1 of the paper as a naturally occurring English↔French demonstration found in WebText. We'll keep this one sentence for the whole lesson.

Step 2 · How the game is scored

The grade is the probability you gave to what actually came next.

You played one round and we told you the writer's word. GPT-2 plays billions of rounds with no one to tell it anything — but it doesn't need anyone: the next word of the text is the answer key.

Scoring works like this. At each position, look up the probability the model gave to the token that really came next. High probability, small penalty; low probability, big penalty. Let's score three positions of our sentence by hand, with made-up probabilities (the real ones aren't published, so ours are for teaching):

Look up each true next word's probability

After “…Je” the writer wrote “ne”; after “…Je ne”, “suis”; after “…Je ne suis”, “pas”. Suppose the model gave those words:

P(ne) = 0.55 P(suis) = 0.72 P(pas) = 0.80

Multiply them — that's the probability of the whole stretch

A sentence is just “this word, then this word, then this word”. So its probability is the product of the step-by-step ones:

0.55× 0.72× 0.80= 0.317

Take the average negative log — that's the loss

Long products get tiny fast, so we work with logs instead: −ln 0.55 = 0.60, −ln 0.72 = 0.33, −ln 0.80 = 0.22. Average them:

(0.60 + 0.33 + 0.22) / 3= 0.38 per token

What you just computed has a name — the cross-entropy loss, the average penalty per token — and pushing it down is the entire training signal. Written compactly, the probability of a text x made of tokens s₁ … sₙ is:

one factor per position — this is just row 2's multiplication, written for any text

Keep this for step 5

The loss is an average over every position. No position is exempt. That boring-sounding fact is the hinge the whole paper turns on, and we'll lean on it hard in Part B.

Eq. (1) in the paper, §2. Framing everything as next-token prediction over one long sequence is what lets a single model score — and, by sampling from it, generate — any string.

Step 3 · The machine and its diet

A familiar Transformer — the new ingredient is 40 GB of curated text.

So the game is “guess the next token” and the grade is the average loss. Two questions remain before the interesting part: what plays the game, and on what text? Neither answer is where the novelty lives — which is itself worth knowing.

The player is a Transformer decoder — the same architecture we walk through block by block in our Attention Is All You Need explainer, so we're keeping its lid closed here. If you haven't seen inside one, all you need today is: it reads tokens left to right and is very good at using long context. The paper changes almost nothing about it (the small tweaks are in the fine print below). GPT-2 comes in four sizes; the name usually means the biggest, at 1.5 billion parameters.

The diet is the real design decision. The team wanted text that is big, diverse, and written by people who cared — diverse, because the core idea's bet needs the text to contain demonstrations of many tasks. A raw crawl of everything was rejected as mostly unintelligible. Instead they scraped every link posted on Reddit that earned at least 3 karma, using upvotes as a free, crowd-sourced “a human found this worth reading” filter:

the player — step 1's box, lid ajar ⋮ ×48 identical blocks · 1.5B params · context 1024 the diet — WebText 45M outbound Reddit links filter: ≥ 3 karma 8M pages · 40 GB Wikipedia removed — it hides in test sets
Left: the step-1 box with its lid cracked open — 48 identical blocks, and that's as deep as this page goes. Right: the cinnabar filter is the paper's quiet trick — Reddit upvotes as a free quality rating for the whole web.
Why the diet matters more than the machine

The bet from the core idea only works if the training text actually contains demonstrations of many tasks. A news-only or books-only corpus wouldn't. 8 million pages of “stuff humans upvoted” is exactly the kind of messy, varied text where people translate, quote, ask, answer and summarize — on their own, for their own reasons.

Architecture tweaks vs. GPT-1 (§2.3): LayerNorm moved to each sub-block's input, an extra LayerNorm after the final attention block, residual weights scaled by 1/√N at init, context 512 → 1024 tokens. The four sizes (Table 2): 117M/12 layers, 345M/24, 762M/36, 1542M/48. Input is byte-level BPE, vocab 50,257 — sub-word chunks that can encode any string, so nothing is ever out-of-vocabulary (and “dog.”/“dog!”/“dog?” stop wasting three vocabulary slots). Wikipedia was excluded because it overlaps too many evaluation sets (§2.1).

PART B

The teacher hidden in the text

Why predicting words forces learning tasks — the heart of the paper

Step 4 · Read the training text closely

Ordinary web pages are full of tiny worked examples of tasks.

The machine is standard and the grade is one number — the novelty is supposed to be in those 40 GB. So let's do what the paper does in Table 1: actually read some WebText, and notice what's hiding in it.

Here are three snippets. All three are real quotes from the training set, found by the authors — nobody wrote them to train a model. In each, we've marked the cue (the part that announces “a translation is coming”) in amber, and the answer (the translation the writer then helpfully provides) in coral:

Exhibit 1 · our sentence from step 1

“I'm not the cleverest man in the world, but like they say in French: Je ne suis pas un imbecile [I'm not a fool].”

English states the idea → the amber cue announces French → the coral span delivers it. A complete translation pair, in the wild.

Exhibit 2 · quotation with gloss

…Soheil Eid, Tory candidate…, wrote in French: “Mentez mentez, il en restera toujours quelque chose,” which translates as, “Lie lie and something will always remain.”

Direction flipped: French first, then “which translates as,” then English. Same lesson, opposite way round.

Exhibit 3 · one-word version

“I hate the word ‘perfume,’” Burr says. “It's somewhat better in French: ‘parfum.’

Even a single word can be a demonstration. Now multiply by 8 million pages.

amber — the cue: text that announces the task coral — the answer the text itself supplies

And it isn't just translation. Forum posts hold questions followed by answers. News sites publish articles followed by “TL;DR:” and a summary. Interviews contain “in other words…” rephrasings. The paper's term for all of this is naturally occurring demonstrations: the web is full of people showing their work, cue and answer side by side.

The observation under the whole paper

A sufficiently varied pile of human text doesn't just mention tasks — it demonstrates them, millions of times, in-line. WebText's diversity (step 3) wasn't a nice-to-have; it's what puts these lessons in the data.

All three quotes: Table 1 of the paper, “examples of naturally occurring demonstrations of English to French and French to English translation found throughout the WebText training set.”

Step 5 · The loss can't skip them

To push the average down, the model must learn whatever each next word demands.

You've now seen, in real training text, little translation lessons lying around. The question is why the model can't just ignore them and coast on easy English — and the answer is the averaging rule from step 2.

Recall: the loss is the average penalty over every position. Our sentence contains the position right after “Je ne suis pas un”. A model that has learned English grammar but no French can do nothing there — the next token is French, and its meaning is pinned by the English half of the sentence. Watch what one such position does to the whole sentence's grade. The slider is the probability the model manages to give the true word “imbecile”:

Drag — teach the model French, watch the sentence's loss respond

Je
p 0.80 · loss 0.22
ne
p 0.60 · loss 0.51
suis
p 0.90 · loss 0.11
pas
p 0.70 · loss 0.36
un
p 0.85 · loss 0.16
imbecile
p 0.1% · loss 6.91
sentence average loss
1.38 nats/token
this one word costs as much as
≈ 66 well-predicted tokens
0.1% — no French← drag →90% — French learned

Look at the coral bar. At 0.1% it dwarfs every other bar in the stack — one position carrying as much penalty as ~66 well-predicted tokens. There is only one way to shrink it: get better at mapping “I'm not a fool” into French. The five grey bars are fixed toy values in step 2's bookkeeping style; only the coral one moves.

If your reaction is “hold on — getting one French word right is a party trick, not translation” — good. Slow down here, because this is the exact spot where we got stuck reading the paper too. The resolution: WebText contains millions of positions like this one, in both directions, at every length (step 4's exhibits were three of them). No lookup table covers them all. The cheapest machinery that predicts them all well is machinery that actually maps meaning between English and French — so that is what gradient descent, grinding down the average loss, slowly builds.

And nothing about this is special to French. Wherever the text has a question followed by its answer, the loss quietly demands question answering; wherever an article is followed by its summary, it demands summarizing. One objective, many skills — each one paid for, position by position.

The mechanism, in one sentence

The loss averages over all positions; some positions can only be predicted by doing a task; so minimizing the loss forces the model to learn those tasks.

Toy numbers, honestly labeled: −ln(0.001) ≈ 6.91, −ln(0.9) ≈ 0.105, and 6.91 / 0.105 ≈ 66. The paper's own phrasing (§2): a model with sufficient capacity “will begin to learn to infer and perform the tasks demonstrated in natural language sequences in order to better predict them.”

Step 6 · Say it the paper's way

Every task's loss is a slice of the language-modeling loss.

You dragged the slider and watched one French word hold a whole sentence's average hostage. The paper compresses that observation into two dense sentences — worth unpacking slowly, because they're its theoretical heart.

First: a supervised task means “predict the output given the input” — p(output | input). A general system must also be told which task, so really it needs p(output | input, task). The usual approach wires the task into the architecture. The paper's move, following McCann et al.'s decaNLP: write the task in plain language, inside the text itself. A translation example can simply be the sequence (translate to french, english text, french text) — which is exactly the shape of our exhibit sentences, with “like they say in French:” playing the role of the task name.

Second — the dense one. The paper notes that the supervised objective and the unsupervised one are the same objective, evaluated on different tokens. Look at our sentence one more time:

language-modeling loss — scores every position I'm not the… like they say in French: Je ne suis pas un imbecile a “translation loss” would score just this slice same scoring rule on every token — the task loss is a subset of the LM loss
The teal bracket is what GPT-2 minimizes. The coral bracket is what a supervised translation system would minimize. The coral tokens sit inside the teal span — so a model that drives the teal loss to its floor has driven the coral slice to its floor too.

That containment is the whole argument: the global minimum of the unsupervised objective is also a global minimum of the supervised one. Perfect next-word prediction contains perfect translation as a special case. The honest caveat, which the paper raises itself: nothing ever reaches the global minimum, so the real question is whether a merely large model, optimized the ordinary way, gets usefully far. Their preliminary experiments said yes — though much more slowly than direct supervision — and that is why Part C is all about measurement.

§2 of the paper, verbatim: “Since the supervised objective is the same as the unsupervised objective but only evaluated on a subset of the sequence, the global minimum of the unsupervised objective is also the global minimum of the supervised objective.”

Step 7 · Waking a skill up

Write your input to look like the training text, and the skill switches on.

Training baked many skills into one next-word predictor. But at test time all the model can do is continue text — so how do you ask it for one specific skill, with no fine-tuning and no task flag?

You disguise your request as WebText. Hand the model a context shaped like the demonstrations it grew up on, and the most probable continuation — the thing it was trained to produce — is the answer you wanted. Every result in this paper is collected this way. The three formats below are the paper's own; notice that each one is just a step-4 exhibit with the coral part left blank:

Translation prompt (§3.7)

english sentence = french sentence … (a few example pairs) …
I'm not a fool = ▢ the model continues here

The “=” format plays the role that “like they say in French:” played in training.

Summarization prompt (§3.6)

(a full CNN article) … TL;DR: ▢ the model continues here

“TL;DR:” — too long; didn't read — is how actual posters introduce their own summaries. The prompt borrows their habit.

Reading-comprehension prompt (§3.5)

(a document) … (the dialog so far) … A: ▢ the model continues here

A lone “A:” after a question is enough — the web has taught the model what follows a “Q: … A:” pattern.

Does the cue actually matter, or would the model summarize anyway? The paper measured it: remove the “TL;DR:” hint and summarization drops by 6.4 ROUGE points — the cue is a real switch. This way of working is what the paper calls zero-shot: no gradient updates, no task-specific training. One honest footnote: the translation prompt does place a few example pairs in the context, so “zero” refers to the weights — they never move — not to the context.

Same colors on purpose

Look back at step 4: amber cue, coral answer. A prompt is that same picture with the coral part missing. Prompting isn't a clever hack bolted on afterwards — it re-creates the exact shape of the lessons the model already took.

Formats from §3.5–3.7. The word “prompt” barely appears in the paper — the practice got its name later; this is where it was first demonstrated at scale.

PART C

The evidence — flattering and not

Zero-shot scores · the size knob · and the memorization question

Step 8 · Turn the size knob

Zero-shot performance climbs steadily with model size — capacity is the fuel.

A prompt can only wake a skill that training actually built. Whether it gets built turns out to hinge on one variable above all: how big the model is. This is why the paper trained four sizes of the same design.

The cleanest test is LAMBADA — sentences whose final word needs at least 50 tokens of context to guess, so it's pure long-range next-word prediction, the model's home game. Drag across the four sizes and watch the numbers move (all real, from Table 3):

Drag across the four trained sizes — chart and readouts use the paper's numbers

previous best: 99.8 117M 345M 762M 1542M model size (log-spaced) → LAMBADA perplexity (log) ↓ better
model
1542M 48 layers
LAMBADA perplexity
8.63 prev. best 99.8
LAMBADA accuracy
63.24%
117M — “GPT-1 size”← drag →1542M — GPT-2

Two things to see. First, even the smallest model — the leftmost dot — already beats the previous state of the art: the dashed grey line sits above all four dots. Second, the dots keep falling with no sign of leveling off; the paper reports the same steady, roughly log-linear climb across most of its tasks (Figure 1).

Across the paper's eight language-modeling benchmarks, the full-size GPT-2 sets a new state of the art on seven — zero-shot, having trained on none of their training data. And capacity keeps mattering all the way up: on open-domain question answering the smallest model can't clear 1% accuracy while the largest reaches 4.1% — a 5.3× jump from scale alone.

From the abstract, verbatim

“The capacity of the language model is essential to the success of zero-shot task transfer and increasing it improves performance in a log-linear fashion across tasks.”

Table 3. The one defeat: on the One Billion Word benchmark GPT-2 falls well short of the specialized state of the art — 1BW shuffles its text at the sentence level, destroying exactly the long-range structure GPT-2 is best at. And one wrinkle: on CBT common nouns, 762M scores 93.45 but 1542M scores 93.30 — the climbs are steady, not strictly monotone.

Step 9 · Grade the tasks honestly

Real skills, unmistakably present — and mostly nowhere near useful yet.

Language-modeling records are the model's home game, though. The paper's actual claim is about tasks — so here is the zero-shot scorecard, wins and embarrassments side by side, because the paper honestly reports both.

Scorecard · GPT-2 (1.5B) with no task training at all

Where it lands punches

  • Reading comprehension · CoQA 55 F1 — matches or beats 3 of 4 supervised baselines that each trained on 127,000+ labeled examples. GPT-2 saw zero.
  • Winograd Schema 70.70% — commonsense pronoun resolution, +7 points over the previous state of the art.
  • Fr→En translation 11.5 BLEU — beats several dedicated unsupervised MT systems. The kicker: WebText contains only ~10 MB of French, ~500× less than what those systems train on.
  • QA calibration — on the 1% of questions it's most confident about, 63.1% correct. E.g. “Who wrote the book the origin of species?” → “Charles Darwin”, confidence 83.4%.

Where it gets humbled

  • Summarization — ROUGE barely above copying 3 random sentences from the article; “qualitatively performing the task”, quantitatively rudimentary.
  • En→Fr translation 5 BLEU — worse than word-by-word dictionary substitution. (The reverse direction is the impressive one.)
  • Open-domain QA 4.1% exact match, versus 30–50% for the retrieval-based systems of the day.
  • The paper's own verdict — zero-shot GPT-2 is “still far from use-able” for practical applications (§6).

One more exhibit belongs here, because it made GPT-2 famous far beyond any scorecard: prompted with a fake news lede about unicorns discovered in the Andes, the model wrote a fluent, structured news article — inventing a scientist, quotes, a back-story. Read one detail closely, though: it names the herd “Ovid's Unicorn”, then calls them “four-horned, silver-white unicorns” one sentence later. Fluency arrived before coherence. (The paper labels the sample honestly: it's a cherry-pick, the best of 10 tries.)

How to hold both columns at once

The right reading isn't “GPT-2 is good at tasks”. It's that task ability shows up at all without task training, and grows with scale. The left column proves step 5's mechanism is real; the right column measures how far it still had to go.

CoQA §3.5; Winograd §3.4; translation §3.7; Natural Questions §3.8 (Table 5); summarization §3.6 (Table 4: ROUGE avg 21.40 vs 20.98 for 3 random sentences); unicorns Table 13. A CoQA note worth smiling at: the model often answers “who” questions with any name from the document — simple heuristics still lurk behind impressive scores.

Step 10 · The skeptic's question

Mostly learning, not memorizing — and even 1.5B parameters is still underfitting.

Some of those scores look suspicious for a model nobody supervised. The paper raises the objection itself: with 40 GB of web text, maybe the test sets were simply in the training data, and “zero-shot” is quiet plagiarism.

To check, the authors built Bloom filters — a compact structure for asking “have I seen this exact phrase before?” — over every 8-word sequence in WebText, then measured how much of each benchmark's test set also appears in training. Overlap exists. But look at it next to the right baseline:

8-gram overlap with training data — average across benchmarks (§4)

Test sets vs. WebText · GPT-2's “contamination”

3.2%

Test sets vs. their own training sets

5.9%

Read the two bars together: the standard benchmarks overlap their own training data (grey, 5.9%) almost twice as much as they overlap WebText (cinnabar, 3.2%). Whatever advantage GPT-2 gets from contamination, everyone else gets more of it. And when the authors sampled from GPT-2, most generations shared under 1% of their 8-grams with the training set. It can recite famous passages — feed it the opening of the Gettysburg Address, which appears ~40 times in WebText, and it recites for a while before drifting — but recitation is the exception, not the engine.

The closing observation flips the question around: on WebText's own held-out split, training and test loss fall together as model size grows, all the way to 1.5B parameters. The biggest model is still underfitting — it hasn't finished extracting what its own diet contains. Whatever ceiling this recipe has, GPT-2 wasn't at it.

Why this step earns the paper trust

A paper claiming “no supervision needed” audits its own training set for leaks, quantifies them, and reports the awkward cases — a WikiText-103 test article sits verbatim in its training set; 1BW overlaps itself 13.2%. The claim survives its own audit.

§4, Table 6, Figures 4–5 (30%+ of GPT-2 samples share no 8-gram at all with training; Bloom-filter false-positive rate bounded by 1/10⁸).

Step 11 · Close the loop

Six questions, and where this result was headed.

Learning, mostly — and still hungry. That's the argument end to end: one game, a diet full of hidden lessons, a loss that can't skip them, prompts that wake them, scale as the fuel. Before the bigger story, check that it stuck.

Try each question in your head before opening it — the fold-out answer is a couple of sentences, and each one names the step to revisit if it doesn't come easily.

Why does predicting the next word force a model to learn translation? (steps 4–5)

Because the training text contains real translation demonstrations, and the loss averages over every position — including the ones right after “like they say in French:”. Those positions can only be predicted well by translating, so pushing the average down builds that ability.

What did the Reddit-karma filter actually buy? (step 3)

Quality and, crucially, diversity — 8M pages of varied, human-endorsed text. Diversity is what fills the corpus with demonstrations of many different tasks; a single-domain corpus would starve the mechanism.

What exactly does “zero-shot” mean here? (step 7)

No gradient updates and no task-specific training — the weights are frozen, and the task is specified by writing a context that looks like the training text. (Fine print: the translation prompt does put example pairs in the context; “zero” is about the weights.)

Why does the paper call the two objectives “the same”? (step 6)

A supervised task scores predictions on a subset of the tokens — the answer span; language modeling scores all of them. Same scoring rule, different coverage — so the LM loss contains every task loss as a slice, and its global minimum is theirs too.

Is GPT-2 just regurgitating memorized test data? (step 10)

Mostly no: test sets overlap WebText less (3.2%) than they overlap their own training sets (5.9%), and most GPT-2 samples share under 1% of their 8-grams with training. It can recite famous passages, but the scores don't ride on that.

Where did zero-shot GPT-2 clearly fall short? (step 9)

Summarization (barely above picking random sentences), En→Fr translation (5 BLEU), open-domain QA (4.1% vs 30–50% for retrieval systems) — the paper itself calls zero-shot GPT-2 “still far from use-able” in practice.

What happened next — the same lab's scaling-laws paper soon made “bigger keeps helping” quantitative, and one year later GPT-3 ran this exact recipe at ~100× the parameters — where step 7's prompting trick blossomed into few-shot, in-context learning. The path from this page to modern chat assistants is remarkably straight.

“These findings suggest a promising path towards building language processing systems which learn to perform tasks from their naturally occurring demonstrations.” — Radford, Wu, Child, Luan, Amodei & Sutskever, 2019
The profound impact

The paper that let us ask machines for things in plain text.

GPT-2's scores were surpassed within a year. What survived is the working assumption of the whole field since: train one big model on one simple objective, and address it in ordinary language.

2020 · the sequel

GPT-3 & in-context learning

The same recipe at ~100× the parameters. The prompting seed from §3 grew into few-shot, in-context learning — and the log-linear climb kept paying.

the interface

Prompting

“Shape your input like the training data” became how people use AI. Every system prompt, every “TL;DR:”, traces back to these experiments.

2019 · the precedent

Staged release

OpenAI initially withheld the full 1.5B model over misuse worries — the first time releasing a language model was treated as a safety decision. That debate never stopped.

One objective, addressed in plain language — nearly every model you talk to today is this paper's thesis, scaled.