DX Heroes logo
#ai
#prompting

What is in-context learning?

Length: 

3 min

Published: 

June 9, 2026

What is in-context learning?

What in-context learning means

In-context learning is the ability of a large language model to learn a task from the examples and instructions inside your prompt, at the moment you ask. The model's underlying weights do not change. It simply uses what you put in the prompt as a guide for that one response.

This is what makes few-shot prompting work. When you show a model three examples of input and the output you want, it spots the pattern and applies it to your real input, all within a single conversation. The "learning" lasts only as long as that context. Start a fresh chat and the model has forgotten it.

In plain words

Think of asking a sharp colleague to sort your emails. You do not send them on a training course. You show them three emails you have already sorted and say "like this." They get the rule from your examples and carry on. In-context learning is the model doing exactly that, every prompt, from scratch.

Why it matters

  • No retraining needed. You adapt the model to a new task by writing a prompt, not by running an expensive fine-tuning job.
  • Fast to try. Change the examples, change the behaviour, in seconds. It is the cheapest way to test whether a model can do what you need.
  • Flexible. The same model handles classification, rewriting, or extraction depending purely on what you show it.
  • The foundation of prompting. Zero-shot, few-shot, and chain-of-thought prompting are all forms of in-context learning.

Common pitfalls

  • It does not stick. Nothing learned in context survives the conversation. For knowledge the model should keep, you need fine-tuning or a connected data source.
  • The context window is finite. Examples take up space. Pack in too many and you crowd out the actual task, or hit the model's limit.
  • Examples can mislead. The model copies whatever you show it, quirks included. Unrepresentative examples produce unrepresentative answers.
  • Confusing it with real learning. The model is not getting smarter. It is reading your prompt well. Judge it on the output, not on the impression that it "understood."

Related articles:

  • What is few-shot prompting? - The most common way to put in-context learning to work.
  • What is fine-tuning? - The alternative when you need the model to keep what it learns.
  • What is a context window? - The space your examples and instructions have to fit into.

Want to stay one step ahead?

Don't miss our best insights. No spam, just practical analyses, invitations to exclusive events, and podcast summaries delivered straight to your inbox.