---
title: In-Context Continual Learning
url: https://www.emergentmind.com/topics/in-context-continual-learning
type: topic
---

# In-Context Continual Learning

Searching arXiv for recent papers on in-context continual learning and adjacent formulations to ground the article.
In-context continual learning (ICCL) studies how a model processes a sequence of different tasks within a shared context and adapts through conditioning on prompts, demonstrations, recent interaction history, or retrieved memories rather than only through weight updates. In the narrow formulation analyzed for Transformers, a sequence of heterogeneous tasks is presented in a single prompt and processed in a single forward pass, with no parameter updates [2605.28705]. In a broader continual-learning formulation, the same idea can be expressed through a context variable \(C\) that determines the current data distribution \(P(x,y\mid c)\); drift in \(C\) induces non-stationarity and makes adaptation depend on what contextual information about the current regime is available [2104.01678]. Across recent work, ICCL appears in prompt-based classification, online supervised learning, meta-learned vision transformers, self-referential fast-weight models, multi-episode meta-reinforcement learning, world models conditioned on long trajectories, and external or latent memory systems [2403.01554, 2507.05019, 2602.04089, 2606.17803].

## 1. Context, drift, and canonical continual-learning scenarios

A common formal starting point is the hidden context variable \(C\), which represents the state of the data-generating process. For a fixed context \(c\in\mathbb{C}\), the data are i.i.d.:
\[
(X,Y)\mid C=c \sim P(X=x, Y=y \mid C=c),
\]
so the joint distribution at context \(c\) is \(P(x,y\mid c)\). Non-stationarity over time is then expressed through a stochastic process \(\{C_t\}_{t=1}^T\), and a drift in \(C_t\) is equivalent to a distribution drift [2104.01678].

This framework separates several drift types. Real concept drift changes \(P(y\mid x,c)\) while leaving \(P(x\mid c)\) fixed; virtual drift changes \(P(x\mid c)\) while leaving \(P(y\mid x,c)\) fixed; domain drift changes \(P(x)\) without affecting \(P(y\mid x)\) nor \(P(y)\); virtual concept drift changes \(P(y)\) without affecting \(P(y\mid x)\); and criterion drift changes the learning criterion while \(P(x,y)\) stays fixed [2104.01678]. The same paper formalizes three recurrent continual-learning scenarios in terms of relations between distributions at different contexts: incremental learning with disjoint concept sets, lifelong learning with changing observation distributions but fixed concepts, and learning under real concept drift where the same observation can map to different labels or rewards across contexts [2104.01678].

Within this perspective, task labels are not the same object as context. The context variable \(c\) is a latent variable that represents the data distribution state, whereas a task label is only a piece of information about \(c\) or about \(c\)’s evolution [2104.01678]. For ICCL, prompts, task descriptions, demonstrations, conversation history, or user identity can therefore be interpreted as partial observations of the current context rather than as the context itself. This is why the same formalism can cover class-incremental prompts, domain-shifted few-shot evaluation, and interaction histories in online agents.

## 2. Theoretical mechanisms of adaptation and forgetting

A recurring theoretical distinction is between recognizing which latent task is active and learning the task in context. A PAC-style framework for in-context learning models pretraining as fitting a distribution \(D\) that is a mixture of latent tasks, and the in-context phase as fixing the pretrained model while concatenating downstream examples into the input. Under explicit assumptions on approximate independence across delimiters, lower bounds on token probabilities, lower bounds on mixture-component priors, and sufficient KL separation between components, downstream tasks are efficiently in-context learnable after pretraining on \(D\) [2303.07895]. In that analysis, in-context learning is “more about identifying the task than about learning it,” and the relevant prompt effect survives even when the labels in the prompt are randomly flipped [2303.07895].

A complementary perspective comes from meta-in-context learning. In a one-dimensional regression setting and a two-armed bandit setting, a sequence of tasks in one long context causes the model’s effective prior and its in-context learning strategy to change across tasks. In regression, the mean predicted function shifts from an increasing bias toward the negative-slope task family used in the sequence; in bandits, prior reward expectations move from extremely miscalibrated values toward the scale of the encountered environment, and the exploration strategy changes as the task index grows [2305.12907]. This establishes that context can reshape both priors over tasks and the procedure used for within-task adaptation.

The first explicit theoretical framework for ICCL in Transformers analyzes linear and masked linear self-attention on a sequence of regression tasks processed in one prompt. Under masked linear self-attention, the prediction for task \(t\) is
\[
\hat{y}_{t,q} = x_{t,q}^\top\Gamma^{-1} \Big(\beta_{t}\sum_{s=1}^t S_s\Big),\quad \beta_t = \frac{1}{t(M+1)},
\]
and forgetting after all \(T\) tasks is measured by
\[
F_t = \mathbb{E}[(\hat{Y}_{t,q}-\hat y_{t,q})^2].
\]
The resulting error decomposes into irreducible error, variance, and bias/interference. Variance decreases with larger in-context sample size \(M\), but the bias term induced by cross-task mixing remains and yields positive transfer when tasks are similar and provable negative transfer when they are misaligned [2605.28705]. The same analysis gives a mechanistic account of order sensitivity and long-prompt degradation: future tasks add new contributions, earlier tasks are effectively reweighted, and mean-based interference does not vanish even when \(M\to\infty\) [2605.28705].

An analogous split appears in world models. “Context and Diversity Matter: The Emergence of In-Context Learning in World Models” distinguishes environment recognition, where the model uses context only to infer which environment-specific world model to invoke, from environment learning, where the model estimates the environment itself from context [2509.22353]. This parallels task recognition versus task learning in language-model ICL and shows that ICCL is not confined to supervised prompting: it also governs how long-context models infer dynamics in partially observed environments.

## 3. Model families and training regimes

One major family of ICCL methods meta-learns an in-context learner and keeps adaptation at test time inside the forward pass. In vision, GEOM treats a non-causal transformer encoder as a meta-learned in-context learner over few-shot classification tasks drawn from many small datasets. In its sequential setting, each Meta-Album dataset is available only during its phase, there is no rehearsal, and no explicit continual-learning regularization is used; adaptation at test time still occurs from the support set presented in context [2507.05019]. CAMeLU pushes the same idea into unsupervised meta-learning: tasks are synthesized from unlabeled images by augmentation and mixup, there is no explicit gradient-based inner loop, and the transformer learns to infer the query label from support images in a single forward pass [2405.16124].

A second family combines contextual conditioning with online parametric learning. “Transformers for Supervised Online Continual Learning” defines supervised online continual learning as minimizing cumulative next-step predictive log-loss on a non-stationary sequence \((x_t,y_t)_{t=1}^T\), while explicitly conditioning a transformer on the last \(C\) examples through a Transformer-XL style KV cache [2403.01554]. Replay streams are then used to preserve the benefits of multi-epoch training while adhering to the sequential protocol. The intended division of labor is explicit: in-context learning gives fast adaptation through recent observations, and in-weights learning gives long-term improvement via stochastic gradient descent [2403.01554].

A third family makes the inner learner itself self-modifying. Automated Continual Learning uses self-referential weight matrices, so the network’s own fast weights are part of the recurrent state and are updated during the forward pass. Its meta-objective includes performance on the current task and on prior tasks after subsequent tasks have been processed. The paper introduces “in-context catastrophic forgetting” for the case where the learned in-context update rule rapidly adapts to a new task but overwrites the internal state needed to solve the previous one, and shows that adding backward-transfer terms to the meta-loss resolves this failure mode on the reported image-classification benchmarks [2312.00276].

Interactive RL extends ICCL beyond supervised prediction. ORBIT formulates repeated episodes in a fixed MDP as an in-context online learning problem in which the agent acts from the serialized transcript of previous episodes and current observations, with no weight updates at test time [2602.04089]. Meta-RL training across Minesweeper, Wordle, Hangman, Rock–Paper–Scissors, and Blackjack then yields cross-episode adaptation on unseen Maze and Mastermind tasks, so the model learns from interaction history in context rather than from deployment-time fine-tuning [2602.04089].

## 4. Memory, retrieval, and context compression

Several ICCL systems respond to prompt-length growth by externalizing or parameterizing context. InCA combines in-context learning with an external continual learner for class-incremental text classification. The external learner models each class as a Gaussian over SBERT embeddings of LLM-generated tags, ranks classes for a test instance by Mahalanobis distance, and restricts the final ICL prompt to only the top-\(k\) classes [2412.15563]. This changes the scaling regime: prompt length depends on \(k\), not on the total number of classes already encountered.

Continual table semantic parsing uses a different compression route. “Parameterizing Context: Unleashing the Power of Parameter-Efficient Fine-Tuning and In-Context Tuning for Continual Table Semantic Parsing” introduces a teacher-student design in which an ICT teacher solves the current few-shot task using retrieved demonstrations, while a prompt-tuned student distills the teacher’s output distribution into a task-specific soft prompt [2310.04801]. The contextual information provided by demonstrations is thus compressed into prompts that can be stored without keeping any training examples, and the frozen backbone avoids catastrophic forgetting because later tasks only update their own prompts [2310.04801].

Reasoning-oriented work shows why raw context alone can be insufficient. “Continual Self-Improvement with Lightweight Experiential Latent Memories” studies a streaming, label-free setting in which the base LLM is frozen and experience comes from the model’s own reasoning traces. The paper finds that ICL over raw reasoning traces fails to generalize, then replaces token-level reuse with lightweight per-instance soft prompt memories \(m_x\in\mathbb{R}^{k\times d}\), trained with majority-vote rewards and retrieved for future queries [2606.17803]. This converts transient computation into persistent, reusable latent memories rather than relying on direct replay of textual traces.

A related retrieval-centric design appears in “Large Language Models Know What Makes Exemplary Contexts.” There, the frozen LLM is augmented with a parameter-efficient retrieval head and a reward head so that it can self-select candidate demonstrations, self-rank candidate compositions, and then self-optimize both selection and ordering through PPO [2408.07505]. The core point is that context construction itself becomes a learned policy over a memory of examples.

At the stream level, “Bridging Streaming Continual Learning via In-Context Large Tabular Models” abstracts these mechanisms into two principles: distribution matching and distribution compression [2512.11668]. Unbounded streams are summarized on-the-fly into compact sketches to be consumed by large in-context tabular models, linking stream-learning synopses with continual-learning replay memories. In that view, diversification governs what is stored, retrieval governs what is re-prioritized for a query, and both are forms of data selection for in-context adaptation [2512.11668].

## 5. Evaluation protocols and empirical record

Evaluation protocols are not uniform. Drift-analysis work distinguishes current/final performance from online cumulative performance over a context process [2104.01678]. Theoretical ICCL defines per-task generalization \(G_t\) and forgetting \(F_t\) in a sequential prompt [2605.28705]. Continual table semantic parsing reports task accuracy, example accuracy, initial accuracy, and memory decay [2310.04801]. Interactive meta-RL uses in-context regret over repeated episodes of the same environment [2602.04089].

Representative empirical findings show both the range of ICCL settings and the strength of the reported gains. InCA reaches 94.40 final accuracy on CLINC, 84.90 on Banking77, 84.20 on DBpedia, and 86.61 on HWU, while the JOINT upper bound is 97.60, 92.50, 95.70, and 90.43 respectively [2412.15563]. ACL meta-finetuned with a 5-task objective reaches \(84.3 \pm 1.2\) on Split-MNIST class-incremental 5-task and \(96.0 \pm 1.0\) on Split-MNIST class-incremental 2-task, outperforming the reported replay-free baselines [2312.00276]. On CLOC, the pi-transformer obtains 59% average accuracy with frozen ResNet-50 features, 70% with frozen MAE ViT-L features, and 67% when trained from scratch, whereas the no-attention ablation reaches 19% [2403.01554]. In GEOM-S, performance is only slightly worse than the offline oracle, and backward transfer becomes positive up to +4.78 after later domains are seen [2507.05019]. In long-maze world modeling, 1-step PSNR rises from 16.37 at \(T=1\) to 24.65 at \(T=10^4\) for Maze-32K-L [2509.22353]. For reasoning on Llama-3.1-8B-Instruct, raw data ICL moves from 45/20/3.3 to 46.3/21.7/3.3 on MATH500/AMC23/AIME24, whereas ELM\(_{\text{input}}\) reaches 51.4/26/6.7 and ELM\(_{kv}\) reaches 50.7/23.3/7.8 [2606.17803].

These results also clarify what is being measured. In some settings the target is current or final performance on all contexts; in others it is next-step predictive log-loss, backward transfer, episode-wise success rate, in-context regret, or prompt-induced forgetting. ICCL is therefore not a single benchmark regime but a family of evaluation problems sharing one core constraint: adaptation must come from context, fast weights, or lightweight auxiliary modules rather than from unrestricted retraining on all past and current data.

## 6. Limitations, misconceptions, and open problems

A persistent misconception is that ICCL is simply standard ICL applied to longer prompts. Attention-based analysis shows that longer prompts also induce order sensitivity, inter-task interference, and persistent mean-based forgetting terms [2605.28705]. In class-incremental text classification, feeding all class summaries to long-context LLMs reduces accuracy relative to top-\(k\) class selection by an external continual learner, even for models such as Gemini 1.5 Flash with a 2M-token context window [2412.15563]. Frozen-parameter prompting removes catastrophic forgetting in the classical parameter-overwriting sense, but it does not remove in-context catastrophic forgetting or interference inside the forward computation [2312.00276].

Another limitation is task-family closure. The PAC guarantees for in-context learnability assume that downstream tasks align with latent components already present in the pretraining mixture [2303.07895]. World-model analysis similarly shows that over-training on a narrow environment set can push the model toward environment recognition rather than true environment learning, which reduces generalization to unseen environments [2509.22353]. ORBIT, while demonstrating cross-episode in-context improvement, still constrains evaluation to \(T=3\) episodes because the full cross-episode transcript must fit within a 32k-token context window [2602.04089]. Streaming settings make the same point from another angle: bounded memory and computation force explicit compression, diversification, and retrieval policies rather than unlimited accumulation of history [2512.11668].

Reasoning systems expose a further boundary. Pure ICL over raw reasoning traces, even when strengthened with self-reflection or additional test-time search, fails to generalize robustly on the reported mathematical reasoning benchmarks [2606.17803]. This suggests that some continual uses of context require learned latent representations, structured retrieval, or modular soft memories rather than direct reuse of token-level histories. A plausible implication is that the next phase of ICCL research will center less on ever-longer raw prompts and more on hybrid architectures that decide what to recognize, what to learn, what to store, and what to retrieve under explicit memory and interference constraints.

Source: https://www.emergentmind.com/topics/in-context-continual-learning