Learn AI /Training and Model Adaptation /In-context learning
In-context learning
- Intermediate
- Training and Model Adaptation
- Technical readers
Also called: learning from examples in the prompt.
Back to the milestone you came from
In five seconds
What it is
A model uses examples and instructions placed in the current prompt to imitate a pattern for that one interaction, without changing its stored parameters.
In plain words
You can steer a model by showing it a few examples right in your request. It often copies the pattern for that conversation, but it has not been permanently retrained.
An everyday example
At a food distribution point, a new clerk must estimate how many family parcels to prepare for the next hour. A supervisor places three completed tally sheets on the table, each showing crowd size, average family size and the final parcel estimate. Then the supervisor gives a new sheet with today's numbers and asks for the estimate in the same format. The clerk follows the pattern from the examples for this one task, but the clerk's official handbook is not rewritten.
A human clerk may truly reason from general experience and may remember the lesson later. A model using in-context learning does not necessarily form a stable new skill, and the effect usually does not persist beyond the current prompt or session. Also, the model does not literally inspect paper examples one by one; it processes all prompt text as tokens inside its context window.
Remember thisExamples in the current prompt can steer a model's task, labels and format for that interaction, without changing its stored parameters.
This term is contested
The broad idea is widely used, but authors do not always draw the boundary in exactly the same way between in-context learning, few-shot prompting and related forms of prompt-based adaptation.
Understand it
Understand it
Why it matters
People often hear 'we trained it on our data' when what actually happened was much lighter and more temporary. That difference matters for cost, speed, privacy, governance and reliability. In-context learning can be set up quickly and changed from one task to the next, which is useful for prototypes, formatting, extraction and classification. But because the model itself is not updated, the behaviour may be less consistent than fine-tuning, will not carry into a later request unless the relevant context is supplied again, and depends heavily on prompt quality and context length. If you know this term, you can ask better questions: Are examples only in the prompt? Will the behaviour persist? What data was sent to the service? What human checks are still needed?
How in-context learning works in one prompt
Show that examples in a prompt can steer a model's response for one interaction without changing the model itself.
01
1. Add instruction
The prompt starts with a short task description, such as the format or rule to follow.
Draw a rectangular box labelled 'Instruction' containing two short lines of sample text. Use a muted blue background.
02
2. Add examples
The prompt includes one or more examples that pair an input with the desired output.
Draw a second box labelled 'Examples' with two mini input-output pairs stacked vertically. Connect from step 1 with an arrow.
03
3. Add the new case
A new input is placed after the examples. The model uses the earlier pattern to continue.
Draw a third box labelled 'New input' showing one short line of text. Connect from step 2 with an arrow.
04
4. Generate response
The model produces an output shaped by the prompt examples, while a side note states that stored parameters do not change.
Draw a fourth box labelled 'Output' with one short answer. Place a central model icon behind steps 2 to 4 with a small label 'parameters unchanged'. Connect step 3 to step 4 with an arrow.
A left-to-right sequence with four boxes. Read from the user's instruction and examples, to the new input, to the unchanged model, to the patterned output. A note under the model says the internal parameters stay the same.
Hovering over each step highlights the matching part of a sample prompt below the diagram; on tap, the same highlight appears and the explanation text updates.
Describe this without the diagram
This diagram explains in-context learning as a four-step process. First, the user provides an instruction that says what task to do. Second, the user includes examples showing the desired pattern, such as sample inputs and outputs. Third, the user adds a new input to be solved. Fourth, the model produces an output that follows the pattern from the examples. A note attached to the model says its stored parameters do not change, meaning this is not fine-tuning or training. The key point is that examples inside the current prompt temporarily steer the response.
With reduced motion: A static four-step row shows Instruction, Examples, New input and Output, with arrows between them and a fixed note near the model icon reading 'parameters unchanged'.
In-context learning means guiding a model by showing it examples inside the current prompt. You might give an instruction, then a few input-output pairs, then a new input. The model uses the pattern in that temporary text to produce a response.
What goes in? Usually three things: a task description, one or more examples, and the new case you want solved. What happens? The model uses the examples in the prompt to continue the pattern for the new case. What comes out is an answer shaped by those examples.
This is often confused with training or fine-tuning. They are different. In training or fine-tuning, learned parameters are updated and saved. In in-context learning, those stored settings stay the same. The guidance applies only while that text remains in the model's context. It can be applied again if the text is supplied again.
It is useful when you want to adapt behaviour quickly without rebuilding the model. But it has limits. If the prompt is too long, too ambiguous, or too different from the new case, performance can drop. The model can also copy a superficial pattern from the examples without reliably applying the deeper rule.
How “Showing a clerk a few completed tally sheets” maps onto the real thing
| In the story | In the AI system |
|---|---|
| completed tally sheets on the table | examples included in the prompt |
| new sheet with today's numbers | the new input the model must handle |
| estimate in the same format | the model continues the pattern shown by the examples |
| handbook is not rewritten | the model's stored parameters are not updated |
A worked example
A security analyst is preparing cleared status lines for a liaison office's quarterly donor report and wants an approved model to reproduce the agreed classification and format.
Starting from: Instruction: Classify each observation as On track, Watch or Action required. Return "Status: [label] | Follow-up: [text]". Example 1: "All scheduled liaison briefings took place." -> Status: On track | Follow-up: None Example 2: "One briefing moved; a replacement date is confirmed." -> Status: Watch | Follow-up: Confirm completion next quarter Example 3: "A required approval remains outstanding and blocks the planned activity." -> Status: Action required | Follow-up: Escalate through the agreed channel New observation: "Two briefings moved to next month; replacement dates are confirmed."
- The prompt supplies an instruction, three demonstration pairs and a new observation.
- Through attention over the current prompt, the model associates confirmed rescheduling with the demonstrated "Watch" pattern rather than with a blocked activity.
- It reproduces the requested status and follow-up structure. Its stored weights are not updated, so the pattern is not learned permanently.
Result: Status: Watch | Follow-up: Confirm completion next quarter
In a United Nations workplace
On the afternoon before clearance of a quarterly donor report, a security analyst in a liaison office gives an approved model three synthetic examples showing how cleared observations should be labelled as "on track", "watch" or "action required", then asks it to format a new, non-sensitive observation in the same way.
The model can imitate the labels and reporting format from the current prompt without retraining. The examples shape its output for that interaction through the prompt context, while its stored parameters remain unchanged.
Before you try thisReal security-sensitive details must not be used as prompt examples or pasted into a tool that is not approved for them. Use only an approved environment and cleared, sanitised or synthetic material, since prompts may be retained or exposed. The analyst must verify both the label and the donor-facing wording before clearance.
Where you may hear it
- A vendor demo in a procurement meeting
- A prompt review before clearance of the quarterly report
- An ICT governance board discussion on an approved pilot
- A front office discussion about standardising draft status lines
Avoid confusion
Avoid confusion
Often confused with
Fine-tuning
Updating a pre-trained model's parameters with additional examples to improve performance on a narrower task, style or domain.
Training
Training is the process of adjusting a model's parameters using data or feedback to improve performance on a learning objective.
Zero-shot, one-shot and few-shot
These labels describe how many task examples a model gets in the prompt before it tries a new input: none, one, or a small handful.
Common misconceptions
Common misconception: If I give the model examples in the prompt, I have trained it on my data.
Correction: Not in the usual technical sense. In-context learning uses your examples only as part of the current input. The model's saved parameters are not updated, so the effect is temporary unless the examples are sent again in a later prompt.
Common misconception: Examples in the prompt make the answer reliable in the same way as fine-tuning.
Correction: Examples can improve consistency, but they do not guarantee stable behaviour. The model may follow surface patterns, be sensitive to wording or example order, and behave differently when the prompt is longer or the new case differs from the examples.
Common misconception: The model learns and remembers the new rule forever after seeing it once.
Correction: Usually no. The model may use the rule within the current context window, but that does not mean it will retain the rule across future sessions. Persistent change usually requires training, fine-tuning or another stored system design.
Quick check
Which situation is the best example of in-context learning?
In-context learning happens during use, inside the prompt. The model sees examples and applies the pattern to the new input, but its stored parameters do not change. Updating weights and saving a new version would be fine-tuning or training, not in-context learning.
Go deeper
Go deeper
The simple version
You can steer a model by showing it a few examples right in your request. It often copies the pattern for that conversation, but it has not been permanently retrained.
The technical version
In-context learning refers to task adaptation through the prompt context rather than parameter updates. The prompt may contain instructions plus demonstration pairs, and the model conditions its next-token predictions on that sequence. In a transformer model, the current context influences output through the attention mechanism over tokens in the prompt, but the underlying weights remain fixed during inference. This is why in-context learning can mimic new formatting, extraction, classification or transformation behaviours without producing a new checkpoint. It is closely related to zero-shot, one-shot and few-shot prompting, though the exact boundary between these terms can vary by author. It differs from fine-tuning, supervised fine-tuning, LoRA and other parameter-efficient methods because those create a persistent model change rather than a temporary context-dependent one.
Reviewed external resources
EncyclopaediaPrompt engineering (opens in a new tab)Wikipedia
This link gives a broad overview of prompt engineering concepts and suits readers who want a general reference before going deeper.
Intermediatelink checked 2026-07-31
CourseLLM Course (opens in a new tab)Hugging Face
This course offers structured lessons on how large language models use prompts and examples, and suits learners who want a technical but guided path.
Deeperlink checked 2026-07-31
CourseShort Courses (opens in a new tab)DeepLearning.AI
This set of short courses is useful for practitioners who want hands-on prompt techniques, including example-based prompting, in a compact format.
Intermediatelink checked 2026-07-31
VideoVideo explanations: In-context learning (opens in a new tab)YouTube search
This is a YouTube search results page, so it helps readers compare different video explanations of in-context learning and suits people who learn well from visual teaching.
search results, not one pagelink checked 2026-07-31
DiscussionCommunity discussion: In-context learning (opens in a new tab)Reddit search
This is a Reddit search results page, so it gives a sense of common questions, confusions and practitioner discussions, and suits readers who want informal perspectives with caution about accuracy.
search results, not one pagelink checked 2026-07-31
Where this came from
Drafted with a language model through an offline pipeline, checked against this site's schema, and every external link above fetched to see whether it answers. Treat it as a starting point and check anything that matters against the primary sources. How this site is built and what that means.
The one thing to remember
Examples in the current prompt can steer a model's task, labels and format for that interaction, without changing its stored parameters.