What is in context learning?
In context learning is a way of guiding an AI language model by including examples, instructions, or reference material directly inside the prompt. The model reads that context, infers what you want, and responds accordingly. No retraining, no fine-tuning, no code.
The phrase comes from AI research, where it describes a model's ability to pick up a task from examples shown at inference time rather than baked in during training. For a team lead, the practical meaning is simpler: you can teach the model how to behave for your specific situation just by showing it, inside the prompt itself.
This is part of a broader set of prompting techniques that shape how a model responds. What distinguishes in context learning from other approaches is that it relies on examples rather than instructions alone. You show the model a finished piece of work, a decision it should replicate, or a format it should follow, and it generalizes from that to your actual request.
The technique works across all the major consumer models, including ChatGPT, Claude, Copilot, and Gemini. You do not need a developer to implement it. If you can write a prompt, you can use it.
Published: 2025-07-15. Last updated: 2025-07-15.
How it works
Every time you send a message to an AI model, you are building a context window: the full text the model can see when it generates its response. In context learning happens entirely inside that window. You place examples, instructions, or background information in your prompt, and the model uses those to shape what comes back.
The model itself does not change. No weights are updated, no fine-tuning occurs. What changes is the model's immediate frame of reference. Think of it like briefing a contractor before a meeting: the contractor's skills are fixed, but what they focus on and how they present themselves shifts based on what you told them five minutes ago.
Concretely, the mechanism works like this. The model processes all the text in the context window together, treating your examples as implicit rules. If you show it three customer emails formatted a certain way, it picks up on the pattern: tone, structure, what gets included, what gets cut. The fourth email it writes follows that pattern without you needing to spell out every requirement.
Context window size sets a hard ceiling on how much you can include. Most current models handle tens of thousands of tokens, which is plenty for a few examples and a set of instructions. Where it gets tight is when you need many long examples, a large document, and a detailed instruction set all at once. Something usually has to give.
Worked examples
Each example below shows the same basic move: context supplied in the prompt, followed by the model applying it. The output slots are marked for a human to fill before this page goes live.
Example 1: Classifying customer feedback
Prompt
Classify each message as Positive, Neutral, or Negative.
Examples:
"Delivery was faster than expected." → Positive
"The packaging was fine." → Neutral
"My order arrived damaged and support ignored me." → Negative
Now classify these:
1. "Easy to set up, works perfectly."
2. "It does the job."
3. "Broke after two days and no refund offered."
Model output: [NEEDS REAL OUTPUT]
Commentary: Two or three labeled examples are enough for the model to anchor its classification logic. Without them, tone-neutral phrases like "It does the job" often get misclassified.
Example 2: Matching a brand's writing style
Prompt
Here are two subject lines we have used before:
"Your June report is ready"
"One thing you can fix before Monday"
Write three more subject lines for a newsletter about Q3 planning. Match the same tone.
Model output: [NEEDS REAL OUTPUT]
Commentary: The examples give the model a reference register: short, direct, no exclamation marks. Without them, it defaults to generic marketing phrasing.
Example 3: Rewriting in a constrained format
Prompt
Below is a long product description. Rewrite it as a three-bullet summary, using this existing bullet as a style guide:
"Syncs automatically, no manual export needed."
Product description: [PASTE TEXT]
Model output: [NEEDS REAL OUTPUT]
Commentary: A single well-formed example is often enough when the format constraint is tight. The model mirrors the verb-first, benefit-last structure.
When to use it and when not to
In context learning earns its place when the format or tone you need is specific enough that a plain instruction won't get you there. If you can describe the output clearly in words, a direct instruction is usually faster. If the output has a shape that's easier to show than explain, examples are the right tool.
Good situations to reach for it:
- You have an existing artifact (a past email, a sample report, a worked ticket) that already captures what "good" looks like
- The task recurs often enough that a reusable prompt with baked-in examples will save time across a team
- The model keeps drifting toward a generic format you don't want, even after explicit instructions
- You need consistent tone across documents written by different people
Where it underperforms or causes problems:
- Your examples contain confidential data that shouldn't travel in a prompt
- The task genuinely varies every time and no single example set covers the range
- You're hitting token limits on a long document and examples are crowding out the actual content
- You need the model to do something it hasn't been trained on at all. More examples won't fix a capability gap.
One honest limitation: if your examples are subtly off, the model will faithfully reproduce what's wrong about them. Garbage in, garbage out applies here more literally than with vague instructions, because the model has something concrete to copy.
When the task is genuinely novel and you have no examples to draw on, zero-shot prompting is the more practical starting point.
In context learning compared with related techniques
In context learning sits alongside several techniques that can look similar from the outside. The differences matter when you're choosing what to reach for.
| Technique | What you provide | Model learns from it? | Persists across sessions? |
|---|---|---|---|
| In context learning | Examples or instructions in the prompt | No, applies only to that call | No |
| Zero-shot prompting | Task description only, no examples | No | No |
| Fine-tuning | A large labeled dataset, used to retrain the model | Yes, weights change | Yes |
| System prompts | Standing instructions set before the conversation | No | Only within a session |
| Retrieval-augmented generation | External documents pulled in at runtime | No | No |
Zero-shot prompting is the simpler cousin: you describe the task and the model attempts it with no examples to reference. In context learning adds those examples, which tends to narrow the output toward the style or format you actually want.
System prompts are often used alongside in context learning. A system prompt might establish the model's role and constraints, while the examples in the main prompt show it exactly what "good" looks like in practice. The two work well together.
Fine-tuning is the one technique that actually changes the model. If your use case involves hundreds of thousands of similar tasks, or requires a style so specific that examples alone can't carry it, fine-tuning may be worth the investment. For most teams, though, it's significant overhead relative to simply writing better prompts.
Common mistakes
The most frequent error is treating examples as decoration. A single example with obvious inputs and obvious outputs adds almost nothing. The model already knows how to handle easy cases. Examples earn their place by showing the model how to handle the edge cases, the exceptions, the tone shifts you actually need.
Inconsistent formatting between examples is a close second. If example one presents the input as a labeled field and example two presents it as a raw paragraph, you have introduced noise. The model is pattern-matching across everything you provide, so contradictions in structure translate directly into inconsistency in output.
Choosing unrepresentative examples is another common problem. Teams often pick the clearest, most textbook instances of a task because they are easy to write. But if your real workload is messier, the model will be calibrated to the clean version, not the version that actually shows up on a Monday morning.
Adding too much in a single context window can also work against you. Packing in six examples, a long system prompt, and a dense task description risks burying the signal. If the model's attention is spread thin, the examples lose their effect.
Finally, many teams write examples once and never revisit them. Tasks drift over time. An example set that worked in January may be quietly misleading by June.
Using this across a team
In context learning works well for individuals, but its value compounds when a team adopts it consistently. The problem most teams run into is that each person builds their own examples in isolation. One person writes a strong few-shot prompt for customer responses; nobody else sees it; the next person starts from scratch.
The fix is treating your examples as shared assets. A small library of vetted, reusable prompts, each with good examples baked in, means a new team member can get consistent output on day one rather than spending two weeks figuring out what works.
A few practical steps that actually stick:
- Agree on a canonical example set for each recurring task type (support replies, report summaries, briefing notes) and keep them somewhere everyone can find them.
- When someone discovers a better example, update the shared version rather than keeping it local.
- Review examples periodically. A good example from six months ago may no longer reflect how your team writes, or how your customers communicate.
Convergence's prompt templates are built around exactly this workflow: prompts that include worked examples, shared across a team, with a single place to update them when the examples need refreshing. It is a practical way to stop useful prompts from living only in one person's chat history.
Frequently asked questions
What is in context learning in simple terms?
In context learning is a way of guiding an AI model by including examples or instructions directly inside your prompt, rather than changing the model itself. You write the prompt, the model reads it, and the examples you included shape how it responds. No training, no code, no special access required.
How many examples do I need to include?
One to five examples is usually enough. Diminishing returns set in quickly, and a prompt stuffed with ten or more examples can confuse the model or push important instructions out of its working window. Start with two or three, check the output, and add more only if the pattern still isn't landing.
Does in context learning work the same way across ChatGPT, Claude, Copilot, and Gemini?
The core mechanics are consistent: every major model reads your examples and adapts its output accordingly. Differences show up in context window size and how each model weighs recent versus early parts of a long prompt. If you're sharing prompts across a team using multiple tools, test your examples on each model before rolling them out.
When should I use zero-shot prompting instead?
Use zero-shot prompting when the task is straightforward and a clear instruction is enough. If the model already handles the format or tone you need without examples, adding them just adds length.
Will my examples become part of the model's training?
No. Examples in your prompt are processed at inference time only. They influence that session's output and nothing beyond it.
Further reading
The resources below go deeper on in context learning and the techniques that sit closest to it. They range from foundational research to practical guidance you can apply immediately.
Prompt Engineering Guide (DAIR.AI) A thorough, regularly updated reference covering in context learning, few-shot prompting, and chain-of-thought reasoning. Written for practitioners, not just researchers. The few-shot section is particularly useful alongside the worked examples on this page.
Language Models are Few-Shot Learners (Brown et al., 2020) The original GPT-3 paper that put few-shot in context learning on the map. The first few sections are readable without a machine learning background and explain clearly why examples in a prompt change model behavior so reliably.
Prompting techniques: a practical overview Convergence's guide to the full range of prompting methods, with in context learning placed alongside zero-shot, chain-of-thought, and role prompting. Good orientation if you want to understand which technique fits which task.
Zero-shot prompting explained The direct counterpart to in context learning. If you are deciding whether examples are worth the effort, this page covers what zero-shot handles well and where it falls short.
System prompts: what they are and how to write them In context learning works best when the surrounding prompt is well structured. This guide covers how to set instructions, tone, and constraints before your examples even appear.
Published: 2025-01-15. Last updated: 2025-06-01.