Skip to content

Language Models are Few-Shot Learners

Skip →Chain-of-Thought prompting
main track #5corefundamentalpaperrubric 12/122020 · ~75 min

Tom B. Brown, Benjamin Mann, Nick Ryder, … Dario Amodei

Status

TL;DR. GPT-3 is a 175B-parameter decoder-only Transformer trained on 300B tokens. Its main finding is in-context learning: given a task description and a few solved examples in the prompt, it performs the task with no gradient updates. Few-shot GPT-3 is competitive with fine-tuned models on some benchmarks (TriviaQA, LAMBADA), but weak on others (natural language inference, some reading comprehension). The gap between zero-, one- and few-shot performance tends to grow with model size.

Why it matters now. Prompting, few-shot examples, LLM judges and synthetic data generation all rest on in-context learning. GPT-3 also set the template for later scale-up reports: a family of model sizes, a curated web mixture, contamination checks, and a frank limitations section.

Model (§2.1, Table 2.1). A GPT-2-style Transformer with alternating dense and locally banded sparse attention. Eight sizes from 125M to 175B parameters. The largest has 96 layers, dmodel=12288d_{\text{model}}=12288, 96 heads and a 2048-token context. All sizes are trained on 300B tokens.

Data (§2.2, Table 2.2). Filtered Common Crawl (45TB compressed before filtering, 570GB after), plus WebText2, two book corpora and Wikipedia. Sampling is weighted by quality, not size:

datasettokensweightepochs in 300B
Common Crawl410B60%0.44
WebText219B22%2.9
Books112B8%1.9
Books255B8%0.43
Wikipedia3B3%3.4

Evaluation settings (§2). All use the same frozen weights:

  • Zero-shot: a task description and the query.
  • One-shot: plus one solved example.
  • Few-shot: plus KK solved examples, typically 10–100, as many as fit in the context.

Multiple-choice tasks are scored by comparing per-token-normalised likelihoods of the options.

Compute. About 6ND=6×175B×300B≈3.1×10236ND = 6\times175\text{B}\times300\text{B}\approx3.1\times10^{23} FLOPs, which the appendix reports as 3.14×10233.14\times10^{23}.

GPT-3: in-context learning formats, the training mixture, and closed-book results Left: three ways to condition GPT-3 without gradient updates. Zero-shot gives a task description and the query. One-shot adds one solved example. Few-shot adds 10 to 100 solved examples, as many as fit in the 2048-token context. Top right: the training mix by sampling weight, with Common Crawl 60 percent, WebText2 22 percent, Books1 8 percent, Books2 8 percent and Wikipedia 3 percent; the smaller high-quality sets are repeated 1.9 to 3.4 times while Common Crawl is seen less than once in 300 billion tokens. Bottom right: a small table of results for the 175 billion parameter model. LAMBADA accuracy: zero-shot 76.2, one-shot 72.5, few-shot 86.4, previous state of the art 68.0. TriviaQA closed-book: 64.3, 68.0, 71.2, against 68.0 for a fine-tuned retrieval-augmented model. Natural Questions: 14.6, 23.0, 29.9, against 44.5. Conditioning only, no gradient updates zero-shot Translate English to French: book => ? one-shot Translate English to French: house => maison book => ? few-shot (K = 10–100) Translate English to French: house => maison … K examples … fill 2048 tokens book => ? One set of weights: 175B params, 96 layers, 96 heads, d_model 12288, 300B training tokens. Training mix by sampling weight Common Crawl 60% WebText2 B1 B2 W WebText2 22% · Books1 8% · Books2 8% · Wiki 3% Common Crawl and Books2 seen < 1 time; WebText2, Books1 and Wikipedia repeated 1.9–3.4 times 175B results (Tables 3.2, 3.3) taskzeroonefewref. LAMBADA acc76.272.586.468.0 SOTA TriviaQA64.368.071.268.0 RAG NatQuestions14.623.029.944.5 RAG QA is closed-book: no retrieval, answers from weights RAG = fine-tuned retrieval-augmented model
Original sketch. Left: zero-, one- and few-shot prompts use the same weights and differ only in context. Right: the sampling weights of the training mix, and closed-book results for the 175B model against the best reference systems.
  • LAMBADA (Table 3.2). Accuracy 76.2 zero-shot, 72.5 one-shot and 86.4 few-shot, against a previous best of 68.0. Few-shot perplexity is 1.92. The few-shot fill-in-the-blank format shows the model that a single word is wanted.
  • Closed-book QA (Table 3.3). Few-shot: Natural Questions 29.9, WebQuestions 41.5, TriviaQA 71.2. A fine-tuned retrieval-augmented model (RAG) gets 44.5, 45.5 and 68.0. So GPT-3 beats it on TriviaQA but not on Natural Questions.
  • Arithmetic (Table 3.9). Few-shot: 100% on 2-digit addition, 98.9% on 2-digit subtraction, 80.4% and 94.2% for 3 digits, about 25–27% for 4 digits and about 9–10% for 5 digits. Only 0.8% of 3-digit addition test problems appeared in the training data.
  • Weak spots. Performance is close to chance on WiC and weak on ANLI and some reading comprehension tasks, which the authors link to the lack of a bidirectional objective.
  • Contamination (§4). About a quarter of benchmarks have more than 50% of items flagged, but most scores barely change on clean subsets. PIQA and Winograd are marked as possibly affected. Some Wikipedia language-modelling benchmarks and the Children’s Book Test were dropped.

The paper’s §5 is unusually candid:

  • Text quality. Long generations repeat, lose coherence and sometimes contradict themselves. The model struggles with common-sense physics.
  • Objective. No bidirectional or denoising objectives, and every token is weighted equally regardless of importance.
  • Sample efficiency. Pretraining sees far more text than a human does in a lifetime.
  • Learning or recognising? It is unclear whether few-shot examples teach a new task or only identify one learned in pretraining.
  • Cost. Inference is expensive; the authors suggest distillation.
  • Bias and misuse. §6 studies gender, race and religion biases and misuse risks.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    GPT-3 175B was trained on 300B tokens. Estimate its training compute with the 6·N·D rule, convert it to petaflop/s-days (1 pf-day = 8.64 × 10^19 FLOPs), and compare with the 3.14 × 10^23 FLOPs the paper reports. Then compute how many times Common Crawl was seen, given 410B tokens and a 60% sampling weight.

    What a strong answer covers
    • 6 × 175 × 10^9 × 300 × 10^9 ≈ 3.15 × 10^23 FLOPs, matching the reported 3.14 × 10^23.
    • 3.14 × 10^23 / 8.64 × 10^19 ≈ 3,640 pf-days, consistent with "several thousand petaflop/s-days".
    • Common Crawl: 0.60 × 300B / 410B ≈ 0.44 epochs, as in Table 2.2. Smaller, higher-quality sets were repeated (Wikipedia 3.4 epochs).
    • By the later Chinchilla rule of thumb (about 20 tokens per parameter) a 175B model would want about 3.5T tokens, so GPT-3 was heavily under-trained on data.
  2. Mechanism

    On LAMBADA, GPT-3 175B scores 76.2 zero-shot, 72.5 one-shot and 86.4 few-shot. Explain what changes between the three settings, why one example can hurt while many help, and what the paper's fill-in-the-blank format has to do with it.

    What a strong answer covers
    • All three use the same frozen weights; only the context changes: a task description plus 0, 1 or K (10–100) solved examples.
    • LAMBADA asks for the last word of a passage. Without guidance the model may continue with several words; the few-shot fill-in-the-blank format shows that exactly one word is wanted.
    • The paper notes one-shot does worse than zero-shot here, plausibly because a single example is not enough for the model to recognise the pattern and may add noise.
    • This illustrates the paper's own ambiguity: in-context examples may teach a new task or only help the model recognise one it already knows and the right output format.
  3. Critique

    Section 4 studies training-data contamination. Describe the method, what it found for PIQA, Winograd, reading comprehension and LAMBADA, and why its conclusions are weaker than they first appear.

    What a strong answer covers
    • A filtering bug left some test overlap in the training data, and retraining was too costly. For each benchmark the authors built a "clean" subset with no 13-gram overlap and compared scores.
    • PIQA (29% flagged) dropped 3 points and Winograd (45% flagged) 2.6 points on clean subsets; both are marked with an asterisk. Reading-comprehension sets were over 90% flagged, but mostly because source passages, not QA pairs, appeared in training. LAMBADA had real contamination but the clean score was within 0.5%.
    • Clean subsets are not random samples: removing overlapping items can shift difficulty, so a small change does not prove contamination did not help.
    • 13-gram overlap misses paraphrases and translations, so false negatives are likely.
  4. What if…

    For few-shot arithmetic GPT-3 175B scores 100% on 2-digit addition, 80.4% on 3-digit addition and 25.5% on 4-digit addition. How did the authors check that this is not memorisation, and what does the drop with digit count suggest?

    What a strong answer covers
    • They searched the training data for 3-digit test problems in forms like "<NUM1> + <NUM2> =" and "<NUM1> plus <NUM2>" and found 17 of 2,000 addition (0.8%) and 2 of 2,000 subtraction (0.1%) problems.
    • So most correct answers were not copied, which suggests the model computes something addition-like.
    • Accuracy falls sharply with digit count and the 13B model solves only about half of 2-digit problems, so the skill is brittle and depends on scale.
    • A string search does not rule out memorised partial patterns, and the BPE tokenisation of numbers makes digit-level carrying harder; both are confounds.
  5. Design

    Design an experiment that separates "learning a new task from the examples" from "recognising a known task" in few-shot prompting, using GPT-3-style models of several sizes.

    What a strong answer covers
    • Use tasks whose input-output mapping cannot be in pretraining: random symbol substitutions, invented label words, or flipped labels on a known task.
    • Compare accuracy with correct, flipped and random labels in the examples. If labels barely matter, the model is mostly recognising format and task.
    • Vary K and model size; the paper's claim that bigger models are better meta-learners predicts steeper gains with K at larger sizes.
    • Control for format by including a condition with the right format but no input-output pairing.
  6. Connect

    Closed-book GPT-3 few-shot beats a fine-tuned retrieval-augmented model on TriviaQA (71.2 vs 68.0) but loses badly on Natural Questions (29.9 vs 44.5). Explain the difference and what it implies for retrieval-augmented systems.

    What a strong answer covers
    • Closed-book means answers must come from the weights. TriviaQA questions are about widely repeated trivia, which large models memorise well.
    • Natural Questions are real search queries that often need specific, long-tail facts that a model sees rarely in pretraining.
    • So parametric knowledge covers frequent facts but not the long tail, which is where retrieval adds the most.
    • The same trade-off drives modern RAG design, including how much to trust retrieved text versus the model's memory.

Done with this page?

Status