Skip to content

AI Glossary · Concepts

What is In-Context Learning?

In-Context Learning

In-context learning is a language model's ability to pick up a task from instructions or examples placed in its prompt, at inference time, without any change to its weights. What it 'learns' lasts only as long as that text stays in the context.

Also known as: ICL

· Chain of Thought

AI Engineering

  • 2 explainers
  • 4 sources

Nothing about the model changes. A support lead can paste three labeled tickets into a prompt, such as “charged twice: billing” and “can’t sign in: account access”, and the model will usually label a fourth ticket the same way. Start a new conversation without those examples and the behavior is gone, because it lived in the input, not in the weights. That is the practical difference from fine-tuning, which trains the pattern into the model.

The term became common with GPT-3. Brown and colleagues showed that a large model could do many tasks from a handful of demonstrations in its input with no gradient updates (Brown et al.). Usage varies: Google’s glossary treats in-context learning as another name for few-shot prompting, while research surveys use it for learning from any task description or examples in the context, including the zero-shot case (Dong et al.).

Examples do not teach the way training data does. In one study, swapping the demonstration labels for random ones barely hurt results on the tasks tested; the examples mainly showed the model which labels were possible, what inputs looked like and what format to use (Min et al.). That is a research finding for those tasks and models, not a rule, but it is a useful warning: good examples set format and scope, and they will not reliably add knowledge the model lacks.

It matters because it is the cheapest way to adapt a model: no training run, and you can change the examples per request. The costs are tokens and space. Every example is resent on each call and uses part of the context window, which prompt caching can make cheaper. When the same examples go out on every request, or the task needs knowledge the model doesn’t have, compare against fine-tuning or retrieval-augmented generation on the same held-out test set.

Sources

Go deeper