Task-Free Dynamic Sparse Vision Transformer for Continual Learning

Fei Ye, Adrian G. Bors

Abstract

Continual Learning (CL) requires artificial intelligence models to learn from a non-stationary stream of data while mitigating catastrophic forgetting. Most existing CL frameworks rely on explicit task boundaries, which are often unavailable in real-world scenarios. We propose the Task-Free Dynamic Sparse Vision Transformer (TFDSViT), a novel architecture designed for Task-Free Continual Learning (TFCL). TFDSViT integrates an energy-based expansion strategy for unsupervised novelty detection with a dual-attention mechanism that balances the preservation of old knowledge with the reuse of features for new concepts. Our evaluation on standard benchmarks, including Split CIFAR-100 and MiniImageNet, demonstrates that TFDSViT achieves state-of-the-art performance and exhibits superior robustness to fuzzy task boundaries while maintaining architectural efficiency.

Introduction

The "stability-plasticity" dilemma is a fundamental challenge in Continual Learning: models must remain plastic enough to integrate new information while staying stable enough to retain previously acquired knowledge. In Task-Free Continual Learning (TFCL), the absence of task labels or boundary signals makes this balance even harder to achieve. While Vision Transformers (ViTs) have become a dominant paradigm in computer vision, adapting them to TFCL typically results in either significant forgetting or an unsustainable explosion in model parameters.

TFDSViT addresses these challenges by employing a dynamic expansion strategy driven by data novelty. By utilizing sparse experts and a specialized attention mechanism, the model can grow its capacity selectively, ensuring that it remains efficient even as it learns from an ongoing data stream.

Methodology

The TFDSViT framework is built upon three core pillars: Dynamic Sparse Experts, a Dual Attention Mechanism, and Energy-Based Expansion.

The overall TFDSViT pipeline, illustrating the flow from data stream to training and the energy-based expansion decision process.

Dynamic Sparse Experts

Rather than using a single dense network, TFDSViT utilizes a set of "experts." Each expert is composed of self-attention blocks and Multi-Layer Perceptron (MLP) layers. These experts are sparse, meaning that only specific portions of their capacity are allocated to particular information categories. This sparsity allows the model to pack a higher density of knowledge into a given parameter budget compared to traditional dense models.

Dual Attention Mechanism

The dual-attention mechanism is the engine behind TFDSViT's ability to manage the stability-plasticity trade-off. It consists of two components:

  • Sparse Attention (SA): This module uses binary masks to "lock" the attention blocks associated with previously learned tasks. By freezing these weights, the model prevents the corruption of old knowledge during new training phases.
  • Knowledge Transfer Attention (KTA): To facilitate learning, the KTA module uses a Gumbel-Softmax trick to regulate information flow from all existing experts. This allows a new sub-model to "borrow" relevant features from the past, promoting positive knowledge transfer without causing interference.
Detailed view of the Expert architecture, highlighting the interaction between Sparse Attention and Knowledge Transfer Attention.

Energy-Based Expansion

To determine when the model needs to grow, TFDSViT employs an autoencoder-based energy function. When a new batch of data arrives, the model calculates its reconstruction error (energy). A high energy value indicates that the data is "novel" and cannot be adequately represented by the current experts. This triggers an expansion process, where the model either adds a new sub-model to an existing expert or initializes a completely new expert, depending on the available capacity.

Experiments and Results

The authors evaluated TFDSViT on several standard benchmarks adapted for the task-free setting, including Split MNIST, Split CIFAR-10, Split CIFAR-100, and Split MiniImageNet. The model was also tested against "Fuzzy Task Boundaries," a realistic scenario where data from different tasks are mixed during transitions.

Performance Benchmarks

TFDSViT consistently outperformed state-of-the-art TFCL methods. On the Split CIFAR-100 dataset, the model achieved an accuracy of 32.86%, a significant improvement over the previous best of 29.87%. On MiniImageNet, performance increased from 28.03% to 35.62%.

Robustness and Efficiency

In tests involving fuzzy task boundaries, TFDSViT maintained high performance (e.g., 93.62% on Split MNIST), proving its resilience to non-discrete data transitions. Furthermore, despite its dynamic nature, TFDSViT remains more compact than competing models like DyTox, which tend to grow linearly with every new task.

Conclusion

TFDSViT represents a significant advancement in Task-Free Continual Learning for Vision Transformers. By combining unsupervised novelty detection with a dual-attention mechanism for selective knowledge reuse, the framework effectively mitigates catastrophic forgetting while maintaining computational efficiency. Future research will explore pruning strategies to keep the model size bounded over indefinitely long data streams and further optimize the management of initial patch embeddings in non-stationary environments.

Summary updated

BibTeX
@inproceedings{ye2024task,
  author = {Fei Ye and Adrian G. Bors},
  title = {{Task-Free Dynamic Sparse Vision Transformer for Continual Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i15.29581},
}
Figure