Glossary termConcept

In-Context Learning

Also known as: ICL

Ability of a language model to perform a task from instructions or examples given in its prompt, without any change to its trained weights.

In-context learning describes how a large language model can pick up a task from its input alone. Shown a few examples of English words paired with French translations, or of customer reviews labeled positive and negative, the model continues the pattern for a fresh item. No parameters are updated; the learning happens within the processing of the prompt and disappears when the conversation ends. Zero-shot use relies on instructions only, one-shot use on a single example and few-shot use on several.

The phenomenon was highlighted by OpenAI's 2020 GPT-3 paper, titled "Language Models are Few-Shot Learners", which showed that a sufficiently large model could perform many tasks this way, sometimes approaching models fine-tuned specifically for them. Researchers have since studied how it works. Proposed explanations include the model implicitly identifying which task the prompt describes, and mechanisms such as induction heads, attention circuits that copy patterns from earlier in the context, identified through interpretability research.

In-context learning is what makes prompt engineering effective and lets non-specialists adapt general models to specialized tasks quickly. It is limited by the context window and can be sensitive to the choice and order of examples. Compared with Fine-Tuning, it is flexible and cheap to change but must be repeated in every request. The ability also has security implications, since instructions placed in context can redirect a model's behavior, which is the root of prompt injection.

Key points

  • In-context learning lets a model perform a task from prompt examples without updating its weights.
  • OpenAI's 2020 GPT-3 paper demonstrated strong few-shot performance across many tasks.
  • Induction heads are one proposed mechanism behind in-context learning in transformers.
  • Results can vary with the selection and order of examples and are limited by context length.

Related entries

Glossary term

The practice of designing and refining instructions, examples and context given to a generative AI model to obtain more useful and reliable outputs.

Glossary term

The maximum amount of input, measured in tokens, that a language model can take into account at once, including the text it is generating.

Glossary term

Further training of a pretrained model on a smaller, task-specific dataset so that it adapts its behavior to a particular domain, style or task.

Glossary term

Prompting technique that has a language model write out intermediate reasoning steps before its final answer, often improving accuracy on complex problems.

Glossary term

Neural network trained on very large amounts of text to predict the next token, able to generate language and perform many tasks from prompts.

Glossary term

Capabilities that appear in larger AI models but are absent or near random in smaller ones, rather than improving gradually with scale.

Glossary term

Research field that seeks to understand how AI models reach their outputs, by explaining their decisions or reverse-engineering their internal mechanisms.