What Is In-Context Learning?

In-Context Learning Explainer

In-context learning occurs when a trained language model adapts its behavior using instructions or examples placed in the current prompt. The model’s stored parameters stay unchanged; the temporary context guides the next-token predictions for that request.

A prompt may show input-output demonstrations, define a label scheme, or illustrate a desired format. The model infers a pattern from those tokens, but it does not necessarily learn the task in the durable sense of retaining it later.

This ability supports few-shot classification, extraction, translation, formatting, and rapid prototyping. It can reduce the need for task-specific training when examples fit inside the context window and the base model already has relevant capabilities.

Results can change with example order, wording, label choices, and irrelevant details. Demonstrations may transmit bias or incorrect rules, and apparent success can reflect memorized patterns. Careful test sets and repeated prompt variations are needed.

In-context learning is a language model’s ability to follow patterns or examples supplied in its prompt without updating its weights.

Key terms include context, demonstration, few-shot prompt, next-token prediction, example order, context window, fine-tuning and evaluation.

Examples in the prompt condition the current response while the model parameters remain fixed.

The behavior normally disappears when the examples are removed from the context.

Order, phrasing, labels, and example selection can all influence the inferred pattern.

Robust evaluation should vary prompts and test on data not used to design the examples.

Explore more "Explainers"

Discover additional explainers across politics, science, business, technology, and other fields. Each explainer breaks down a complex idea into clear, everyday language—helping you better understand how major concepts, systems, and debates shape the world around us.