What is in-context learning?
In-context learning is a model's ability to do a task from instructions and examples in its prompt, with no further training. The GPT-3 paper named it.
In short. In-context learning is a model's ability to do a task from instructions and examples in its prompt, without further training. The 2020 GPT-3 paper used the term, and the model's weights do not change. Larger models do it better. A 2022 study found that the format of the examples mattered more than whether their answers were correct.
On this page 7 sections
The evidence
- Confirmed:
- Observed:
- Observed:
- Observed:
Confirmed by the platformObserved in data
In-context learning is why a language model can follow a new format or task from a prompt alone. AI search depends on the same ability: the model reads retrieved pages in its context and answers from them, with no retraining.
#How does in-context learning work?
The model reads the task in its prompt and continues the pattern. Language Models are Few-Shot Learners, the 2020 paper that introduced GPT-3, describes in-context learning as using the text input of a pretrained language model as a form of task specification. The model is given a natural language instruction, a few demonstrations, or both, and is expected to complete further instances of the task by predicting what comes next.1
A prompt for sentiment labels shows the idea:
Review: The battery died in a day. Sentiment: negative
Review: Setup took two minutes. Sentiment: positive
Review: The screen scratches easily. Sentiment:The model completes the last line from the pattern. The paper stresses that no gradient updates or fine-tuning take place. Google's machine learning glossary lists in-context learning as a synonym for few-shot prompting.14 What is few-shot prompting? covers how many examples providers recommend.
#What makes in-context learning work?
Model size and the shape of the examples both matter. In the GPT-3 paper, few-shot performance rose faster with model size than zero-shot performance, so larger models were more proficient at in-context learning.1
Rethinking the Role of Demonstrations, a 2022 study, tested which parts of the examples count. Randomly replacing the answers in the examples barely hurt performance across 12 models, including GPT-3. The examples helped by showing the range of possible answers, the kind of input text and the overall format.2
#How many examples can in-context learning use?
The limit is the context window. GPT-3 fit 10 to 100 examples in its 2,048-token window.1 Many-Shot In-Context Learning, a 2024 paper, used the longer windows of newer models to test hundreds or thousands of examples. It found significant gains across a wide variety of tasks, and performance comparable to fine-tuning. Inference cost grew linearly with the number of examples.3
#How does in-context learning relate to AI search?
AI search puts information into the same context. Anthropic's glossary describes retrieval-augmented generation as passing retrieved documents into the context window, where the model uses them to guide its output. This lets the model use information beyond its training data.5 Like the examples in a prompt, a retrieved page shapes one answer and leaves the model's weights unchanged. What is retrieval-augmented generation (RAG)? covers the retrieval side.
Read next
LLMs
How do large language models work?
LLMs predict text one token at a time from what fits in their context window. Tokens, context window sizes and the lost-in-the-middle effect.
LLMs
What is a context window?
A context window is the number of tokens a model can read and write in one request. Sizes from Anthropic, OpenAI and Google, and what happens at the limit.
AI search
What is retrieval-augmented generation (RAG)?
RAG retrieves documents at query time and gives them to a language model to write a cited answer. How ChatGPT, Claude, Google, Bing and Perplexity use it.
LLMs
What are tokens in AI?
A token is the unit of text a language model reads and writes. OpenAI estimates that 100 tokens are about 75 English words. Counts and limits by provider.
Related terms
Questions
Is in-context learning the same as few-shot prompting?
Google's machine learning glossary treats them as synonyms. The GPT-3 paper uses in-context learning more broadly, for a model given an instruction, a few examples, or both. Few-shot prompting is the case with several examples.
Does a model learn permanently from its prompt?
No. In-context learning involves no gradient updates or fine-tuning, so the model's weights do not change. The model can use the examples only while they are in its context window.
Does the model learn a new task in context, or recognize one it already knows?
The question is open. The GPT-3 authors kept their terms neutral on whether the model learns a new task at inference time or recognizes patterns it saw in training, and called this an important issue.
About this page
Researched and reviewed by Promptly Found. Reviewed Dec 1, 2026. Next review due Mar 2027.
Notes
- 1
- 2
- 3
- 4
- 5
Cite this page
Promptly Found. (2026, December 1). What is in-context learning? https://promptlyfound.com/glossary/in-context-learning
Revisions 1
- First published.