Language Models are Few-Shot Learners

Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, Dario Amodei

Abstract

Recent work has demonstrated substantial gains on many NLP tasks and benchmarks by pre-training on a large corpus of text followed by fine-tuning on a specific task. While typically task-agnostic in architecture, this method still requires task-specific fine-tuning datasets of thousands or tens of thousands of examples. By contrast, humans can generally perform a new language task from only a few examples or from simple instructions - something which current NLP systems still largely struggle to do. Here we show that scaling up language models greatly improves task-agnostic, few-shot performance, sometimes even reaching competitiveness with prior state-of-the-art fine-tuning approaches. Specifically, we train GPT-3, an autoregressive language model with 175 billion parameters, 10x more than any previous non-sparse language model, and test its performance in the few-shot setting. For all tasks, GPT-3 is applied without any gradient updates or fine-tuning, with tasks and few-shot demonstrations specified purely via text interaction with the model. GPT-3 achieves strong performance on many NLP datasets, including translation, question-answering, and cloze tasks, as well as several tasks that require on-the-fly reasoning or domain adaptation, such as unscrambling words, using a novel word in a sentence, or performing 3-digit arithmetic. At the same time, we also identify some datasets where GPT-3's few-shot learning still struggles, as well as some datasets where GPT-3 faces methodological issues related to training on large web corpora. Finally, we find that GPT-3 can generate samples of news articles which human evaluators have difficulty distinguishing from articles written by humans. We discuss broader societal impacts of this finding and of GPT-3 in general.

Introduction

The prevailing paradigm in Natural Language Processing (NLP) has long been "pre-train then fine-tune." This involves training a large model on a massive corpus of unlabeled text and subsequently updating its weights using thousands of labeled examples for a specific task, such as translation or sentiment analysis. However, this approach faces significant hurdles: the high cost of collecting task-specific data, the risk of models learning spurious correlations from narrow datasets, and the lack of human-like versatility. Humans do not require tens of thousands of examples to learn a new task; often, a simple instruction or a few demonstrations suffice.

This research explores whether scaling language models can bridge this gap, enabling "few-shot learning" where a model adapts to new tasks on the fly without any weight updates.

Methods: Evaluating In-Context Learning

The researchers introduced GPT-3, an autoregressive Transformer model scaled to an unprecedented 175 billion parameters. Rather than fine-tuning, GPT-3 is evaluated using In-Context Learning. In this paradigm, the model is provided with a task description and examples directly in its text input (the "context"), and it must predict the next tokens based on this pattern.

The three settings for in-context learning compared to traditional fine-tuning.

The study explores three primary evaluation settings:

  • Zero-shot: The model receives only a natural language description of the task.
  • One-shot: The model receives a description and exactly one example.
  • Few-shot: The model receives a description and as many examples as can fit in its context window (typically 10 to 100).

Crucially, unlike traditional fine-tuning, these settings involve no gradient updates or parameter changes during inference.

Key Insights and Results

The most significant finding is that few-shot performance is an emergent property of scale. As models grow in parameter count, their ability to recognize and follow patterns within a prompt improves dramatically. Performance across almost all tasks follows a predictable power-law trend relative to model capacity.

Performance scaling as a function of model size and number of in-context examples.

Performance Benchmarks

GPT-3 achieves state-of-the-art (SOTA) or competitive results across a wide range of tasks:

  • Language Modeling: On the LAMBADA dataset, zero-shot GPT-3 achieved 76% accuracy, surpassing previous fine-tuned SOTA models.
  • Closed-Book QA: On TriviaQA, the few-shot model reached 71.2% accuracy, outperforming systems that use external knowledge retrieval.
  • Reasoning and Arithmetic: The 175B model demonstrates surprising capabilities, such as performing 3-digit addition with nearly 100% accuracy without explicit training.
  • Translation: It achieved a BLEU score of 39.2 on French-to-English translation, rivaling dedicated supervised systems.

Discussion and Limitations

While GPT-3 represents a major leap in few-shot capabilities, it has notable limitations. As a unidirectional (left-to-right) model, it struggles with tasks requiring bidirectional context, such as Natural Language Inference (NLI). Furthermore, while it is efficient at inference time, its pre-training is "heavy-shot," requiring vast amounts of data.

Methodological challenges also remain, including the potential for training data contamination from the web and the persistence of societal biases reflected in the training corpora. Future research will likely focus on bidirectional architectures at scale and improving the sample efficiency of the pre-training process itself.

Summary updated

BibTeX
@inproceedings{brown2020language,
  author = {Tom B. Brown and Benjamin Mann and Nick Ryder and Melanie Subbiah and Jared Kaplan and Prafulla Dhariwal and Arvind Neelakantan and Pranav Shyam and Girish Sastry and Amanda Askell and Sandhini Agarwal and Ariel Herbert-Voss and Gretchen Krueger and Tom Henighan and Rewon Child and Aditya Ramesh and Daniel M. Ziegler and Jeffrey Wu and Clemens Winter and Christopher Hesse and Mark Chen and Eric Sigler and Mateusz Litwin and Scott Gray and Benjamin Chess and Jack Clark and Christopher Berner and Sam McCandlish and Alec Radford and Ilya Sutskever and Dario Amodei},
  title = {{Language Models are Few-Shot Learners}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
  url = {https://openreview.net/forum?id=oyIFAEQfgml},
}
Figure