In-context learning is the capacity of a language model to adapt to a new task purely from the contents of its input context, instructions, worked examples, or both, with no gradient update to its weights. The GPT-3 paper named the phenomenon in 2020 and showed that at 175 billion parameters a single prompted model could perform translation, arithmetic, question answering, and novel-word tasks competitively with fine-tuned systems, establishing prompting as a practical alternative to task-specific training.1

Zero-shot, one-shot, few-shot

The GPT-3 evaluation framed three regimes: zero-shot, where only a natural-language instruction is given; one-shot, with a single demonstration; and few-shot, with a handful of input-output demonstrations prepended to the query. Accuracy improved with demonstrations and with scale, and the paper reported that in-context learning strengthens log-linearly as models grow.1 GPT-2 had shown the zero-shot version a year earlier, reading comprehension and translation from instructions alone, but at unreliable quality.

Mechanisms and limits

Because the weights never change, in-context learning must be implemented by the forward pass itself. Interpretability work identified induction heads, attention circuits that complete patterns of the form "A B ... A" by copying the earlier B, as a key mechanism, and showed they emerge abruptly during pretraining in step with in-context learning ability.3 The behavior is sensitive to surface details: example order, format, and label distribution can swing accuracy substantially, and one analysis found models can absorb the input-output mapping even when demonstrations carry random labels, suggesting the context teaches task framing and format more than new knowledge.4 Extending the context with reasoning traces, chain-of-thought prompting, reliably improves multi-step tasks,2 and the broader practice of trading context computation for capability developed into test-time compute.

See also

References


  1. Brown, T., et al., "Language Models are Few-Shot Learners," arXiv:2005.14165, May 2020. ↩↩

  2. Wei, J., et al., "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models," arXiv:2201.11903, January 2022. ↩

  3. Olsson, C., et al., "In-context Learning and Induction Heads," arXiv:2209.11895, September 2022. ↩

  4. Min, S., et al., "Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?," arXiv:2202.12837, February 2022. ↩