Learning Mamba as a Continual Learner

Chongyang Zhao, Dong Gong · DOI

Introduction

Continual Learning (CL) represents a primary objective in artificial intelligence: the capacity for a model to learn from a non-stationary stream of data without suffering from catastrophic forgetting or requiring exhaustive retraining. A prominent modern paradigm is Meta-Continual Learning (MCL), where a model is meta-trained to optimize its own learning process across sequences of tasks.

However, standard Transformer-based architectures face a significant scalability bottleneck in CL. Their Key-Value (KV) cache grows linearly with the number of samples processed, leading to "linear state growth." This memory overhead directly conflicts with the efficiency requirements of long-term continual learning. While attention-free alternatives like Linear Transformers exist, they often lack the expressive power required for complex MCL tasks. This paper introduces MambaCL, a framework that leverages selective State Space Models (SSMs) to bridge the gap between efficiency and performance.

The MambaCL Framework

MambaCL reformulates the Mamba architecture as an online continual learner. Unlike Transformers, which rely on global attention over a growing history, Mamba processes sequences by maintaining a fixed-size hidden state, regardless of the stream's length. This architectural choice ensures a constant memory footprint during inference, fulfilling a core requirement of efficient CL.

Overview of the MambaCL architecture showing the inner and outer loops of the meta-continual learning process.

A primary challenge in adapting Mamba for MCL is the lack of explicit attention operations, which are typically used to guide meta-training. To address this, the authors introduce Selectivity Regularization. By leveraging the mathematical duality between SSMs and Linear Transformers, they derive "associative indicators." During the training phase, a Kullback-Leibler (KL) divergence loss is employed to align Mamba’s internal selection behavior with ground-truth associations in the data stream—such as matching a query image to its previous occurrences. Crucially, this regularization is only active during training; at inference, the model operates as a pure, efficient SSM.

Key Insights and Robustness

Experimental evaluations revealed several critical advantages of the MambaCL approach over traditional attention-based models:

  • Superior Generalization: Transformers often overfit to the specific sequence lengths encountered during training. In contrast, MambaCL generalizes significantly better to longer sequences and varying shot counts. Its recurrent nature allows it to capture global sequence information without the local positional biases that can plague Transformers.
  • Resilience to Noise: In scenarios involving "noisy" or irrelevant data injections, MambaCL demonstrated remarkable robustness. While the attention mechanisms in Transformers are easily distracted by outliers, Mamba’s selective gating effectively filters out irrelevant information, maintaining high classification accuracy.
Comparison of MambaCL against Transformer and Linear Transformer baselines across task scaling, shot scaling, and noise intensity.

Experimental Results

The authors evaluated MambaCL across a diverse battery of benchmarks, including general image classification (ImageNet-1K, Cifar-100), fine-grained recognition (CUB-200), and domain adaptation (DomainNet).

  • Performance Benchmarks: MambaCL consistently matched or exceeded Vanilla Transformers. Notably, on the CUB-200 dataset, MambaCL achieved 83.0% accuracy, surpassing the Transformer baseline of 81.4%.
  • Efficiency and Speed: MambaCL is approximately 2.6x faster during inference (858 episodes/sec vs. 325 for Transformers) and utilizes nearly 40% fewer parameters (5.4M vs. 9.2M).
  • Domain Robustness: On the DomainNet benchmark, MambaCL showed superior stability when transitioning between disparate domains, such as moving from real-world images to sketches or paintings.

Conclusion and Future Work

MambaCL demonstrates that selective State Space Models can provide a more efficient and robust foundation for Meta-Continual Learning than traditional Transformers. By maintaining a fixed-size state and utilizing selectivity regularization, the model achieves high performance with significantly lower computational overhead.

Future research directions include scaling MambaCL to Large Foundation Model dimensions and exploring hybrid architectures, such as combining SSMs with Mixture of Experts (MoE) layers to further enhance modular memory management in offline and online settings.

Summary updated

BibTeX
@misc{zhao2024learning,
  author = {Chongyang Zhao and Dong Gong},
  title = {{Learning Mamba as a Continual Learner}},
  year = {2024},
  eprint = {2412.00776},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.00776},
}
Figure