Skip to content
Sign in

What is In-Context Learning?

In-context learning is a prompting technique where a pre-trained model performs new tasks by inferring patterns from examples included directly in the input prompt, without updating its weights.

The model receives a prompt containing task instructions plus one or more input-output examples. It uses its existing parameters to recognize the pattern and generate the correct output for a new query that follows the same format.

No gradient updates or fine-tuning occur; the 'learning' happens entirely within the forward pass by conditioning on the provided context. Performance typically improves as more relevant examples are added, up to the model's context window limit.

This approach emerged prominently with large language models and enables rapid task adaptation using only natural language, bridging zero-shot and traditional supervised learning.

Example

A prompt might list three math word problems with their step-by-step solutions, then ask the model to solve a fourth similar problem. The model mimics the demonstrated reasoning style to produce the answer.

Why it matters

It allows large models to handle novel tasks instantly without costly retraining, making powerful AI systems far more flexible and accessible for real-world applications.

Frequently asked questions

Normal training updates model weights with gradient descent; in-context learning leaves weights unchanged and only uses examples inside the prompt.