What Is In-Context Learning?
What in-context learning is, how a few examples in a prompt teach a model a new task, its limits, and how it differs from fine-tuning, for your AI interview.
In short
In-context learning is when a model learns a new task from examples inside the prompt, with no change to its weights. The examples work only in that request, and what they show (the label options, the spread of inputs and the format) shapes the result.
11 min readIntermediateCommon · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
In-context learning is when a model learns a new task from examples I put in the prompt, with no training. Say I give it three invoice lines already coded, then a new one. It spots the pattern and codes the new line the same way. The examples only steer that one request. Nothing is saved into the model. The result depends on the examples, so I pick them with care and test them.
In-context learning means a model picks up a task from examples inside the prompt. Nothing is retrained. The model reads your rules, a few solved examples and the new case in one request, then answers the new case in the same pattern. The examples are called demonstrations, and the 2020 GPT-3 paper showed that scaling up a model greatly improves how well it does with only a few examples, with no weight updates at all.
Here is the case I would use. A mid-size bank's accounts team codes supplier invoice lines to ledger codes before month-end close. I send three past lines with the codes they got, then a new line. The model proposes a code, and my code checks it against the approved list before anything is posted. The model's weights never change.
The catch is that examples matter in a specific way. A 2022 study found that wrong labels in the examples barely hurt results on classification and multiple-choice tasks, across 12 models including GPT-3. A 2023 paper found that large models can follow flipped labels, so the labels still count. The 2022 study named the label space, the spread of inputs and the format as key drivers. So if all my examples show card fees, the model is likely to code everything as a card fee. I fix that with realistic, varied examples, and I test them on lines I held back.
Fine-tuning is different. It runs training that is saved into the model. I start with examples in the prompt because they are quick to try. I move to fine-tuning only when the same behaviour is needed on every call and the data is ready.
What is in-context learning, in plain words?
You can teach an AI model a new task without training it. Put a few solved examples in your message, then the new case. The model spots the pattern and applies it to the new case. That is in-context learning: learning from what sits in the prompt, inside one request.
The model's weights do not change. The numbers inside it stay the same, and nothing is saved into the model. If you want the same behaviour next time, the examples have to be sent again.
Think of a new hire on a bank's accounts team. A manager shows them three invoices already coded and says, do it like this. The hire codes the fourth one by copying the pattern they were shown. A model does the same with the text in front of it. The bank case below shows how.
Key words
- Prompt
- All the text sent to the model in one request: your rules, examples and the new input.
- Demonstration
- A solved example placed in the prompt before the new input. Research papers use this word.
- Weights
- The numbers inside a model that training sets. A prompt does not change them.
- Fine-tuning
- Extra training on your examples that changes the weights and is saved into the model.
How does a model learn from examples in one request?
Take an accounts team at a mid-size bank. Supplier invoices arrive as lines of text, and each line needs a ledger code (the account number an accountant files that cost under) before month-end close (the monthly deadline for closing the books). Each line gets one code, such as 6410 for card operations. The team sends the model its rules, three past lines with their codes, and the new line. The model returns a code. Nobody retrained anything.
The GPT-3 paper, "Language Models are Few-Shot Learners", showed in 2020 that scaling up a language model greatly improves how well it does with only a few examples. Its authors said the model was applied "without any gradient updates or fine-tuning". Gradient updates are the small weight changes that training makes. Here, none happen.
One request, no retraining
What you send
Your rules
Code each line to one ledger code
Three solved lines
Past lines with the codes they got
New invoice line
The one the model has not seen
Model
Reads all of it, weights unchanged
Proposed code
Copies the pattern it saw
Code on the list?
Unknown codes are rejected
Posted to ledger
Only approved codes get here
- 1Your rules say how to code each line.
- 2Three solved lines show the pattern to copy.
- 3The new line goes last, as the one to code.
- 4The model copies the pattern and proposes a code.
- 5Your code compares that code with the approved list.
- 6Only a code on the list is posted.
The mechanism is not fully understood. A 2022 study put it plainly: "there has been little understanding of how the model learns". So treat in-context learning as a tool you test, and check its results on every change.
Which examples work, and which ones fail?
Examples can be imperfect and still help. The 2022 study by Min et al. found that "ground truth demonstrations are in fact not required" on classification and multiple-choice tasks, across 12 models including GPT-3.
“ground truth demonstrations are in fact not required -- randomly replacing labels in the demonstrations barely hurts performance”
Min et al., 2022
“they provide a few examples of (1) the label space, (2) the distribution of the input text, and (3) the overall format of the sequence”
Min et al., 2022
Do not read that as permission to use wrong labels. The paper names the label space, the spread of inputs and the format as key drivers. The label space is the set of possible answers, here the ledger codes. The spread of inputs is how varied the example lines are. A real team should check all three. Later work found that the effect of correct labels depends on the setup. A 2023 paper found that large models can follow flipped labels, so the labels in your examples still count.
Anthropic says that "a few well-crafted examples" improve accuracy and consistency. Its guide suggests 3 to 5 examples for best results, and asks for examples that cover edge cases, so the model does not learn an accident from a narrow set.
- Good set
Covers the real mix
The examples cover the codes that really occur, in the same layout as live lines. Every common code appears at least once.
- Thin set
All card fees
Three examples, all card fees, all coded 6410. The model can then code a freight charge as a card fee too. The examples were the only pattern it had.
The fix is simple to say and takes care to do well. Take real coded lines from last quarter, one for each common code, plus one awkward case. Then test on lines you held back, so the score measures the model.
How is it different from fine-tuning?
Fine-tuning is the other way to teach a model a task. You train it on your examples, and the change is saved into the model. OpenAI's guide presents few-shot learning as a way to steer the model without fine-tuning it.
“Few-shot learning lets you steer a large language model toward a new task by including a handful of input/output examples in the prompt, rather than fine-tuning the model.”
OpenAI
- In-context
Examples in each request
Quick to try. Change the examples and the behaviour changes at once. The examples are sent again with each call, so they add to the cost of every request.
- Fine-tuning
Training, saved in the model
More work up front: a dataset, a training run and a new model to test. The examples do not need to ride along in every prompt.
So start with examples in the prompt when the task is new or changes often. Move to fine-tuning when the same behaviour is needed on every call, and you have the data and the budget to keep it current.
How would you get a model to use a new internal code?
Start with the cheapest step, then move on only if it fails. Write the rule in plain words, add a few real coded lines that cover the common cases, and run them on lines you held back.
- 1
Pick real examples
Take coded lines from last quarter, one for each common code, plus one awkward case.
- 2
Hold some back
Keep about 50 lines out of the prompt, so the test measures the model itself.
- 3
Count the misses
Add the missed cases as examples and test again. Only when that stops helping, ask whether fine-tuning is worth it.
What does the interviewer want to hear?
A strong answer covers
- A plain definition: the model learns a task from examples in the prompt, with no weight change.
- The name and origin: few-shot prompting, shown at scale in the 2020 GPT-3 paper.
- Zero-shot vs few-shot: whether the prompt has no examples or a few.
- Its limits: the format and coverage of examples matter, and the mechanism is not fully understood.
- How it differs from fine-tuning, and when you would pick each.
- A real case: how you chose the examples and tested them on lines held back.
Common traps
Trap"The model learns, so its weights get updated."
BetterNo. The weights stay put. The examples only steer this one request.
Trap"More examples always help."
BetterNot always. Five examples of one case teach one case. Anthropic suggests 3 to 5 examples for best results, and they should cover edge cases.
Trap"Few-shot always beats fine-tuning."
BetterNeither always wins. Fine-tuning suits a behaviour you need on every call. In-context suits a task that changes often.
Can you spot the weak examples?
Spot the weak examples
Your bank's coding prompt has three examples. Which set is most likely to make the model code every new line the same way?
Quick check
Your team has a new product line with a new ledger code and only two examples. What should they try first?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Learn it in depth
Last updated on 26 November 2026
Building a tool that codes or sorts lines from examples?
I design and build AI products and agents, including the prompts, tests and the system behind them. Book a short call and tell me what you need, and we will see whether examples in the prompt are enough.