# 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.

Canonical: https://promptlyfound.com/glossary/in-context-learning
Updated: 2026-12-01

## Short answer

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.

## Key findings

- The GPT-3 paper defines few-shot as giving the model a few demonstrations of a task at inference time, with no weight updates. The authors typically used 10 to 100 examples, as many as fit in a 2,048-token context window. [1]
- Across 42 benchmarks in the GPT-3 paper, few-shot performance rose faster with model size than zero-shot performance. The authors read this as larger models being more proficient at in-context learning. [1]
- Randomly replacing the answers in the examples barely hurt performance on classification and multiple-choice tasks, across 12 models including GPT-3. [2]
- With hundreds or thousands of examples, in-context learning gave significant gains, could override biases from pre-training and performed comparably to fine-tuning. Inference cost grew linearly with the number of examples. [3]

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](https://arxiv.org/abs/2005.14165), 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](https://developers.google.com/machine-learning/glossary) lists in-context learning as a synonym for few-shot prompting.[1][4] [What is few-shot prompting?](https://promptlyfound.com/glossary/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](https://arxiv.org/abs/2202.12837), 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](https://arxiv.org/abs/2404.11018), 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](https://platform.claude.com/docs/en/about-claude/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)?](https://promptlyfound.com/ai-search/rag) covers the retrieval side.

## Sources

1. Language Models are Few-Shot Learners. arXiv, 2020-05-28. https://arxiv.org/abs/2005.14165
2. Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?. arXiv, 2022-02-25. https://arxiv.org/abs/2202.12837
3. Many-Shot In-Context Learning. arXiv, 2024-04-17. https://arxiv.org/abs/2404.11018
4. Machine Learning Glossary. Google for Developers. https://developers.google.com/machine-learning/glossary
5. Glossary. Claude API documentation. https://platform.claude.com/docs/en/about-claude/glossary

---

This is a plain-text copy of https://promptlyfound.com/glossary/in-context-learning from Promptly Found. The web page is the canonical version and includes the charts.
