Larger language models do in-context learning differently

Jerry W. Wei, Jason Wei, Yi Tay, Dustin Tran, Albert Webson, Yifeng Lu, Xinyun Chen, Hanxiao Liu, Da Huang, Denny Zhou, Tengyu Ma

Abstract

We study how in-context learning (ICL) in language models is affected by semantic priors versus input-label mappings. We investigate two setups—ICL with flipped labels and ICL with semantically-unrelated labels—across various model families (GPT-3, InstructGPT, Codex, PaLM, and Flan-PaLM). Our experiments show that overriding semantic priors is an emergent ability of model scale. While small language models ignore flipped labels and rely primarily on semantic priors from pretraining, large models can override these priors when presented with in-context exemplars that contradict them. Furthermore, the ability to perform semantically-unrelated label ICL (SUL-ICL) also emerges with scale. Finally, we find that instruction tuning strengthens both the use of semantic priors and the capacity to learn input-label mappings, though it reinforces the former more strongly.

Introduction

In-context learning (ICL) allows Large Language Models (LLMs) to perform tasks by observing a few examples in a prompt without any parameter updates. A central question in AI research is whether models actually learn the relationship between inputs and labels provided in the prompt, or if the examples merely act as a "trigger" for knowledge already acquired during pre-training. Previous research suggested that labels might not matter much, implying models rely almost exclusively on internal semantic priors. This paper investigates whether this holds true as models scale from millions to hundreds of billions of parameters.

Experimental Framework

To decouple pre-trained knowledge from in-prompt learning, we designed two distinct experimental setups:

  1. Flipped-Label ICL: Exemplars are provided where labels are intentionally reversed (e.g., a positive movie review labeled as "Negative"). This tests if a model can prioritize the prompt's logic over its internal "common sense."
  2. Semantically-Unrelated Label ICL (SUL-ICL): Natural labels (e.g., Positive/Negative) are replaced with meaningless ones (e.g., Foo/Bar). This forces the model to learn the mapping from scratch, as the labels provide no semantic clues.
Overview of the three ICL experimental setups: Regular ICL (natural labels), Flipped-Label ICL (reversed natural labels), and SUL-ICL (semantically-unrelated labels like Foo/Bar).

These setups were tested across seven NLP benchmarks, including sentiment analysis (SST-2), classification (TREC, ETHOS), and reasoning (RTE).

The Emergence of Mapping Abilities

Our findings indicate that the ability to override semantic priors is an emergent property that typically appears only at massive scales (generally >100B parameters).

Small models appear "stubborn"; they are essentially hard-wired to their pre-training. Even when shown 16 examples of flipped labels, they continue to predict based on the original semantic meaning of the words. In contrast, massive models like PaLM-540B or code-davinci-002 are "attentive" to the prompt. They treat the context as a temporary source of truth that can supersede their extensive pre-training.

Key Results

In the Flipped-Label setup, the performance of large models like text-davinci-002 on the SST-2 dataset dropped from ~90% accuracy (with regular labels) to ~22% (with 100% flipped labels). This drop is a sign of success: it proves the model was following the flipped instructions in the prompt rather than its own priors. Small models, conversely, showed almost no change in prediction regardless of the labels provided.

Model performance on flipped-label tasks. Larger models (darker lines) show a significant drop in accuracy relative to original labels as the percentage of flipped labels increases, indicating they are successfully following the in-context mapping rather than their semantic priors.

In the SUL-ICL (Foo/Bar) setup, large models achieved high accuracy even with meaningless labels. PaLM-540B performed nearly as well with "Foo/Bar" as it did with "Positive/Negative," whereas smaller models dropped to near-random performance. Notably, the largest Codex model successfully performed 16-dimensional linear classification—a task with zero natural language context—purely by learning the numerical patterns provided in the prompt.

The Impact of Instruction Tuning

Instruction tuning (e.g., the "Flan" series) presents a unique trade-off. While it makes models better at learning new mappings (SUL-ICL), it also makes them more resistant to flipped labels. Instruction tuning appears to reinforce the "correct" semantic meaning of words, making the model more reluctant to treat "Positive" as "Negative," even when explicitly shown to do so in the context.

Conclusion

As language models grow, they transition from static knowledge bases to dynamic symbolic reasoners. While small models are bound by their pre-training, large models can be "re-programmed" on the fly via their prompts. This suggests that future, even larger models may behave more like general-purpose reasoning engines that can adapt to entirely novel rules and mappings provided in-context.

Summary updated

BibTeX
@misc{wei2023larger,
  author = {Jerry W. Wei and Jason Wei and Yi Tay and Dustin Tran and Albert Webson and Yifeng Lu and Xinyun Chen and Hanxiao Liu and Da Huang and Denny Zhou and Tengyu Ma},
  title = {{Larger language models do in-context learning differently}},
  year = {2023},
  eprint = {2303.03846},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.03846},
}
Figure