In-context learning is the ability of a large language model to perform a task it was never explicitly trained for, using only examples or instructions supplied in its input. Nothing inside the model changes. Its internal parameters, or weights, stay fixed, and the "learning" disappears when the request ends. The capability exists because it removes a costly step. Before 2020, adapting a model to a new job usually meant collecting labelled data and retraining it. In-context learning lets a person show a model three examples of a product description written in a house style and get a fourth back, in seconds, for the price of a few hundred extra tokens.
The term is often used interchangeably with few-shot prompting, but the two are not the same thing. In-context learning is the capability; few-shot prompting is the most common technique that exploits it.
How a model learns without learning
A request that relies on in-context learning typically has three parts. An optional task description states what is wanted ("Classify each review as positive or negative"). A set of demonstrations follows: input-output pairs that show the task being done. The final part is the query, the new input the model must handle. The model reads all of it as one continuous sequence of tokens and predicts the most probable continuation, which, if the demonstrations worked, is an answer in the same format and spirit.
Practitioners count demonstrations in "shots". Zero-shot means instructions only. One-shot means a single example. Few-shot usually means between two and a few dozen. Many-shot describes hundreds or thousands, a regime that only became practical once context windows grew. The original GPT-3 accepted 2,048 tokens in total. Google's Gemini 1.5 Pro, announced on February 15, 2024, opened a 1,000,000-token window to testers, and as of October 2026 Anthropic lists the same 1,000,000-token window for each of its current models.
Everything happens in a forward pass, the same computation used for any reply. There is no training job and no new model version. But the examples must be resent and reprocessed with every request, so a prompt carrying 50 examples pays for those tokens each time it runs. Caching features that store a repeated prompt prefix, which Anthropic added in August 2024 according to PPC Land's explainer on the prompt, exist largely to soften that bill.
A retailer rewriting product titles for search ads shows the pattern. Given five original titles with approved rewrites, a model is likely to infer conventions nobody stated, such as brand first and sizes abbreviated. That inference from demonstrations, rather than from explicit rules, is the defining feature.
From GPT-3 to million-token prompts
The idea surfaced with scale. The decisive moment came on May 28, 2020, when Tom Brown and 30 co-authors at OpenAI posted "Language Models are Few-Shot Learners" to arXiv. The paper described GPT-3, a 175 billion parameter model that achieved strong results on many language benchmarks "without any gradient updates or fine-tuning", with tasks and demonstrations "specified purely via text interaction with the model". It reported that larger models made more efficient use of demonstrations.
Fragility was documented quickly. Tony Zhao and colleagues posted "Calibrate Before Use" on February 19, 2021, showing that few-shot accuracy swung widely depending on prompt format, the choice of examples and their order; a correction they called contextual calibration raised average accuracy by up to 30 percentage points. On April 18, 2021, Yao Lu and colleagues reported that the order of the same demonstrations alone could move a model from near state of the art to roughly random guessing.
Long context then changed the scale of the exercise. Google's Gemini 1.5 technical report, posted on March 8, 2024, described the model learning to translate English into Kalamang, a language with fewer than 200 speakers, from a grammar manual supplied in the prompt, at a level similar to a person who learned from the same material. On April 17, 2024, Rishabh Agarwal and colleagues at Google DeepMind published "Many-Shot In-Context Learning", reporting significant gains across tasks when moving from few to many examples, while noting that inference cost rises linearly with prompt length.
The unresolved question of mechanism
Why in-context learning works is unsettled. Four explanations compete, and they are not mutually exclusive.
The Bayesian inference view, set out by Sang Michael Xie and colleagues at Stanford on November 3, 2021, argues that pretraining text has long-range coherence, so a model learns to infer the latent "concept" behind a document. Demonstrations act as evidence that narrows down which concept applies.
The implicit learning algorithm view treats the transformer as running a small optimisation internally. On August 1, 2022, Shivam Garg and colleagues showed that transformers trained from scratch could learn linear functions in context with accuracy comparable to the optimal least-squares estimator. Johannes von Oswald and colleagues, in a paper posted on December 15, 2022, showed that a single layer of linear self-attention can be equivalent to a step of gradient descent, and described trained transformers as "mesa-optimizers".
The circuit view comes from interpretability research. On September 24, 2022, Catherine Olsson and colleagues at Anthropic published "In-context Learning and Induction Heads", identifying attention heads that find an earlier occurrence of the current token and copy what followed it. These heads formed at the same point in training as a sharp jump in in-context learning ability. The authors described the evidence as preliminary and indirect for large models.
The fourth view is deflationary: demonstrations mostly remind a model of what it already knows. Sewon Min and colleagues reported on February 25, 2022 that randomly replacing the labels in demonstrations "barely hurts performance" across 12 models, implying that format, label space and input distribution matter more than correct answers. Jerry Wei and colleagues at Google pushed back on March 7, 2023, finding that sufficiently large models do follow flipped labels and override prior knowledge, an ability they described as emerging with scale. Both can hold at different model sizes.
Why marketers keep meeting it
Brand guidelines, approved examples and policy rules entered into generative advertising tools are typically placed in a model's context rather than trained into its weights.
Google Ads offers a visible case. Google introduced text guidelines for AI-powered campaigns on September 10, 2025, allowing up to 25 term exclusions and 40 natural-language messaging restrictions per campaign, and took the beta global for AI Max and Performance Max on February 26, 2026. Google's help documentation advises advertisers to "add an example within your guidelines to achieve the best results", citing "Avoid mention of any prices, e.g. $45/night or $4,567". Google does not document how the model consumes those examples. The documentation also says the model "can only take hard requirements" and rejects conditional wording.
The broader shift has been framed as context engineering, a term that spread in June 2025 to describe managing everything an AI agent sees, not only the wording of a single prompt. Anthropic's free prompt engineering course, released in May 2025, teaches example-giving directly.
Where it breaks
Sensitivity is the first weakness: the 2021 studies on example order and format have not been made obsolete by larger models, and results still vary with seemingly trivial changes. Position is the second. Nelson Liu and colleagues reported on July 6, 2023 that models use information at the start and end of a long context better than material in the middle, which matters when hundreds of examples are stacked together.
Security is the third. On April 2, 2024, Anthropic disclosed "many-shot jailbreaking", in which up to 256 fabricated dialogues placed in a long prompt overrode safety training. Its effectiveness followed the same power-law pattern as benign in-context learning: the property that makes the technique useful also makes it exploitable. One classification-based mitigation cut attack success from 61% to 2%, according to Anthropic.
Comparison with fine-tuning remains contested. Early results suggested fine-tuned models generalised worse outside their training data. Marius Mosbach and colleagues argued on May 26, 2023 that, once model size is held constant between 125 million and 30 billion parameters, both approaches "generalize similarly". Emergence is disputed too. Rylan Schaeffer and colleagues argued on April 28, 2023 that sudden capability jumps, including some attributed to in-context learning, can be artefacts of the metrics chosen. Newer reasoning models complicate matters further: the DeepSeek-R1 paper published in Nature on September 17, 2025 reported that few-shot prompting degraded the model's performance, leaving zero-shot instructions as the recommended setting.
Not to be confused with
Few-shot prompting is a prompting technique: placing a handful of examples in the input. In-context learning is the model capability that makes it work, and also covers zero-shot instructions and many-shot setups.
Fine-tuning continues training a model on new data and permanently changes its weights. In-context learning changes nothing permanent; remove the examples and the behaviour goes with them.
Retrieval-augmented generation inserts retrieved documents into the context to supply facts. It relies on the same context window but aims to inform an answer rather than demonstrate a task format.
Recent developments
PPC Land published its explainer on text guidelines on October 25, 2026, reporting that the feature remains an experimental beta, that Google plans to fold it into AI Brief, and that since October 9, 2026 previews show up to 10 sample headlines and descriptions filtered by an advertiser's guidelines. Researchers have also begun combining in-context learning with test-time training, in which a model briefly updates some weights on the prompt itself, blurring the line with fine-tuning. As of November 2026, no consensus mechanism has displaced the four competing accounts, and context windows of 1,000,000 tokens have made the many-shot regime routine on frontier models.
Timeline
- May 28, 2020 - Brown and colleagues post "Language Models are Few-Shot Learners", describing GPT-3 (175 billion parameters, 2,048-token context)
- February 19, 2021 - Zhao and colleagues post "Calibrate Before Use", documenting few-shot instability and gains of up to 30 points from calibration
- April 18, 2021 - Lu and colleagues show demonstration order alone can swing accuracy from near state of the art to near random
- November 3, 2021 - Xie and colleagues propose in-context learning as implicit Bayesian inference
- February 25, 2022 - Min and colleagues report random demonstration labels barely hurt performance across 12 models
- August 1, 2022 - Garg and colleagues show transformers learn linear functions in context near the least-squares optimum
- September 24, 2022 - Anthropic researchers link in-context learning to induction heads
- December 15, 2022 - von Oswald and colleagues relate in-context learning to gradient descent
- March 7, 2023 - Wei and colleagues find larger models can override priors with flipped labels
- April 28, 2023 - Schaeffer and colleagues question whether emergent abilities are real or metric artefacts
- May 26, 2023 - Mosbach and colleagues report fine-tuning and in-context learning generalise similarly at matched model size
- July 6, 2023 - Liu and colleagues publish "Lost in the Middle" on long-context use
- February 15, 2024 - Google announces Gemini 1.5 Pro with a 1,000,000-token context window
- March 8, 2024 - Gemini 1.5 report describes Kalamang translation learned from a grammar manual in the prompt
- April 2, 2024 - Anthropic discloses many-shot jailbreaking
- April 17, 2024 - Google DeepMind researchers publish "Many-Shot In-Context Learning"
- August 2024 - Anthropic adds prompt caching
- September 10, 2025 - Google introduces text guidelines for AI-generated ad text
- September 17, 2025 - DeepSeek-R1 paper in Nature reports few-shot prompting degrades the model
- February 26, 2026 - Google's text guidelines beta goes global for AI Max and Performance Max
- October 2026 - Anthropic lists 1,000,000-token context windows across its current models
Related PPC Land coverage
- Explaining few-shot prompting - The prompting technique built on in-context learning, from the 2006 one-shot vision work to many-shot prompts and the DeepSeek-R1 finding.
- Explaining prompt - What goes into the input that steers a model, including GPT-3's examples-in-the-input approach and prompt caching.
- Explaining tokens - The units models read and bill by, which set the cost of every demonstration placed in a prompt.
- Explaining text guidelines - Google's term exclusions and messaging restrictions for AI-generated ad text, with the October 2026 status of the beta.
- Google introduces text guidelines for AI-powered advertising campaigns - The September 2025 launch, with 25 term exclusions and 40 messaging restrictions per campaign.
- Google's text guidelines beta goes global for AI Max and Performance Max - The February 2026 global expansion and Google's warning about counterintuitive guidelines.
- Context engineering emerges as crucial discipline for AI agent success - How the focus moved from single prompts to everything an agent sees.
- Anthropic launches free prompt engineering course - A nine-chapter course covering role prompting and few-shot examples.
Summary
Who. Model developers such as OpenAI, Google, Anthropic and DeepSeek build models with the capability; academic and industry researchers, including teams at Stanford, Anthropic and Google DeepMind, argue over how it works; advertisers, agencies and ad platforms use it whenever they feed examples or brand rules into generative tools.
What. In-context learning is a language model's ability to perform a task from instructions and examples placed in its input, without any change to its weights. It underpins zero-shot, few-shot and many-shot prompting.
When. It came to prominence with OpenAI's GPT-3 paper on May 28, 2020. Mechanism research peaked between 2021 and 2023, and million-token context windows from February 2024 onwards made prompts carrying hundreds or thousands of examples practical.
Where. It happens inside the model's context window at inference time, in chat products, APIs and the generative features of ad platforms such as Google's AI Max and Performance Max text guidelines.
Why. It lets a general model adapt to a specific task in seconds without training data pipelines or new model versions. The trade-offs are sensitivity to example choice and order, repeated token costs, weaker use of material in the middle of long prompts, and exposure to attacks such as many-shot jailbreaking.
Discussion