In-Context Learning
In-context learning is a model's use of examples or task information supplied in its input to guide a new response without updating its weights. A few labeled examples can communicate a mapping, format or convention, although the result remains sensitive to which demonstrations are chosen and how they are presented.
What it is
A prompt can show several input–output pairs and then a new input whose output is left to the model. The model conditions its next-token predictions on that sequence, applying patterns that its training enabled it to recognize. There is no separate optimizer step or persistent parameter change during ordinary inference. Few-shot prompting is a common way to invoke this behavior, while in-context learning is the broader capability being used. Instructions, labels, ordering and formatting all contribute to the task representation, including unintended correlations in the examples.
What the work involves
The practitioner chooses demonstrations that cover distinct cases and match the intended output convention. It is useful to vary example order, test an instruction-only baseline and reserve evaluation cases that are not near duplicates of the demonstrations. For large example pools, retrieval can select relevant demonstrations per request. The artifact includes the selected pairs, selection policy and measured behavior on unfamiliar inputs. Recording the full prompt matters because the same model can perform differently when examples are changed without any new training.
Illustrative example
A team wants short incident notes classified as service outage, access issue or unclear. The prompt includes examples showing ordinary cases and an ambiguous note labeled unclear. A new note about an expired login session is then classified under the demonstrated scheme. Evaluation includes notes with both an outage and an access problem, testing whether the model follows the intended tie-breaking convention. Adding more examples is accepted only if it improves those decisions on held-out notes.
Limits and common mistakes
Demonstrations can encourage copying incidental wording or position patterns instead of the desired rule. A model can also follow a well-formed example while misunderstanding a genuinely new case. In-context learning should not be described as durable training or proof that the model learned a general algorithm. Its quality depends on the model, task and prompt distribution, so examples need evaluation and isolation from the final test set.
Prerequisites
Related skills
- → is subcategory of: Prompt Engineering
Sources and further reading
- Language Models are Few-Shot Learners
Primary demonstration and definition of language-model task conditioning with in-context examples.
Last updated: 2026-10-10