In-context Continual Learning Assisted by an External Continual Learner

Saleh Momeni, Sahisnu Mazumder, Zixuan Ke, Bing Liu

Abstract

Existing continual learning (CL) methods mainly rely on fine-tuning or adapting large language models (LLMs), which often suffer from catastrophic forgetting (CF). While in-context learning (ICL) leverages the extensive knowledge within LLMs without updating parameters, it lacks scalability in class-incremental settings. Adding training examples for every new class leads to excessively long prompts that exceed token limits and degrade performance due to overextended context. To address this, we introduce InCA, a novel approach that integrates an External Continual Learner (ECL) with ICL. The ECL pre-selects a small subset of likely classes for each test instance, restricting the ICL prompt to a manageable length while maintaining high performance. Experimental results demonstrate that InCA significantly outperforms existing CL baselines, achieving substantial performance gains across multiple datasets.

Introduction

Continual Learning (CL) aims to enable models to learn a sequence of tasks over time. In the Class-Incremental Learning (CIL) setting, a model must distinguish between all classes seen so far without knowing which task a test instance belongs to. Traditionally, this has faced two major hurdles: Catastrophic Forgetting (CF), where new knowledge erases old ones, and Inter-task Class Separation (ICS), the difficulty of establishing boundaries between new and old classes.

In-Context Learning (ICL) offers a potential solution by providing examples in the prompt, avoiding parameter updates entirely. However, as the number of classes grows, prompt length explodes. Even "infinite context" models struggle with performance degradation when prompts are cluttered with irrelevant information from dozens of classes. InCA solves this by using a "coarse-to-fine" classification pipeline.

The InCA Architecture

InCA splits the classification task into three distinct stages to ensure scalability and accuracy:

  1. Tag Generation: The LLM generates semantic "tags" (keywords/topics) that capture the core meaning of the input.
  2. The External Continual Learner (ECL): This lightweight, non-gradient-based component represents each class as a Gaussian distribution of tag embeddings (using Sentence-BERT). It maintains a running mean vector for each class and a shared covariance matrix, requiring no traditional training.
  3. Refined In-Context Learning: The ECL calculates the Mahalanobis distance between the input tags and known class distributions to select the top-$k$ most likely classes. The LLM is then prompted with only the input and concise summaries of these $k$ classes.
The InCA pipeline: from input text to tag generation, class pre-selection by the ECL, and final LLM classification.

Experimental Evaluation

The researchers evaluated InCA on four diverse text classification benchmarks: CLINC (150 classes), Banking (77 classes), HWU (64 classes), and DBpedia (70 classes).

A critical component of InCA's success is the recall performance of the ECL. If the correct class is not within the top-$k$ selected by the ECL, the LLM has no chance of making a correct final prediction. As shown in the experimental results, the ECL is highly effective; even with 150 classes, the correct class is almost always within the top 3 or 5 identified.

Recall performance of the External Continual Learner (ECL) compared to traditional retrieval (TR) across different buffer sizes and k values.

Key Insights and Results

  • The "Noise" Problem: One of the most striking findings is that providing more context is not always better. Even state-of-the-art models like Gemini 1.5 Flash perform worse when all class summaries are included in the prompt. The "noise" of irrelevant classes distracts the model, a problem InCA bypasses by pre-filtering.
  • Superior Accuracy: InCA achieved 94.4% accuracy on CLINC, significantly higher than the best fine-tuning baseline (VAG at 76.4%). In low-data regimes (e.g., 10 samples per class), InCA even outperformed JOINT training, where the model sees all data at once.
  • Replay-Free Efficiency: Unlike many CL methods, InCA does not require storing old training examples in replay buffers, making it highly privacy-friendly and memory-efficient.
  • Tags over Text: The ECL performs better by matching semantic tags rather than raw text, helping the model focus on intent rather than surface-level phrasing.

Conclusion

InCA demonstrates that integrating a lightweight external learner with the reasoning capabilities of LLMs can overcome the fundamental scalability limits of In-Context Learning for continual tasks. By filtering the search space before the LLM step, InCA maintains high accuracy and efficiency without the risk of catastrophic forgetting. Future work will explore extending this framework to generative tasks and multi-modal learning environments.

Summary updated

BibTeX
@inproceedings{momeni2025context,
  author = {Saleh Momeni and Sahisnu Mazumder and Zixuan Ke and Bing Liu},
  title = {{In-context Continual Learning Assisted by an External Continual Learner}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=PDf3QQdhhN},
}
Figure