Continual Learning with Transformers for Image Classification

Beyza Ermis, Giovanni Zappella, Martin Wistuba, Aditya Rawal, Cédric ArchambeauWorkshops @ CVPR 2022

Abstract

In many real-world scenarios, data to train machine learning models become available over time. However, neural network models struggle to continually learn new concepts without forgetting what has been learnt in the past. This phenomenon is known as catastrophic forgetting and it is often difficult to prevent due to practical constraints, such as the amount of data that can be stored or the limited computation sources that can be used. Moreover, training large neural networks, such as Transformers, from scratch is very costly and requires a vast amount of training data, which might not be available in the application domain of interest. A recent trend indicates that dynamic architectures based on an expansion of the parameters can reduce catastrophic forgetting efficiently in continual learning, but this needs complex tuning to balance the growing number of parameters and barely share any information across tasks. As a result, they struggle to scale to a large number of tasks without significant overhead. In this paper, we validate in the computer vision domain a recent solution called Adaptive Distillation of Adapters (ADA), which is developed to perform continual learning using pre-trained Transformers and Adapters on text classification tasks. We empirically demonstrate on different classification tasks that this method maintains a good predictive performance without retraining the model or increasing the number of model parameters over the time. Besides it is significantly faster at inference time compared to the state-of-the-art methods.

Introduction

Deep learning models are notoriously susceptible to "catastrophic forgetting," where training on a new task causes the model to lose performance on previously learned tasks. In the field of Continual Learning (CL), researchers have traditionally relied on three strategies: replay (storing old data), regularization (penalizing weight changes), or parameter isolation (adding new modules per task). While parameter isolation via "Adapters" is effective, it suffers from linear scaling issues; a model learning 1,000 tasks would grow 1,000 times larger. This research addresses these challenges by adapting the Adaptive Distillation of Adapters (ADA) framework—originally successful in Natural Language Processing—to the Computer Vision domain using Vision Transformers (ViT).

Methodology: Adaptive Distillation of Adapters (ADA)

The core of the ADA approach lies in maintaining a fixed-size pool of adapters rather than creating one for every new task. The architecture utilizes tiny, trainable "bottleneck" layers inserted into a frozen pre-trained Transformer backbone.

Architecture of Transformer layers with integrated Adapters

When a new task arrives, the system follows a three-step process:

  1. Task Training: The new task is trained into a temporary adapter.
  2. Transferability Estimation: Metrics such as LEEP or TransRate are used to identify the most similar existing adapter in the fixed-size pool (e.g., a pool of 4 or 5).
  3. Knowledge Distillation: The knowledge from the temporary adapter is distilled into the selected pool adapter using a distillation loss. This allows the model to consolidate knowledge and maintain a constant parameter count regardless of the number of tasks added.

Experimental Setup and Results

The approach was evaluated on CIFAR100 and MiniImageNet benchmarks across two scenarios: Binary Classification (20 tasks of 1-vs-1 comparisons) and Multi-class Classification (20 tasks of 5 classes each).

Accuracy performance across sequential tasks on MiniImageNet and CIFAR100 using ViT

Key Findings

  • Performance Stability: ADA (using LEEP or TransRate) maintained high accuracy across all 20 tasks, significantly outperforming traditional CL methods like Elastic Weight Consolidation (EWC) and standard fine-tuning, which showed sharp performance declines as tasks accumulated.
  • Parameter Efficiency: Once the adapter pool is full, ADA's parameter count remains constant. For a sequence of 20 tasks, ADA utilized approximately 75% fewer parameters than baseline methods that grow linearly with task count.
  • Inference Speed: By consolidating knowledge into a single model rather than requiring a separate pass for every task-specific adapter (as in AdapterFusion), ADA offers superior inference speed, making it suitable for real-world deployment.

Conclusion

This study demonstrates that the adapter-based distillation philosophy is a robust, cross-domain solution for managing knowledge in Transformers. While the method currently requires a small amount of unlabeled data for distillation, it effectively solves the scaling problem of modular CL. Future work may explore dynamic pool sizes that expand only when a task is sufficiently unique, further optimizing the balance between capacity and efficiency.

Summary updated

BibTeX
@inproceedings{ermis2022continual,
  author = {Beyza Ermis and Giovanni Zappella and Martin Wistuba and Aditya Rawal and Cédric Archambeau},
  title = {{Continual Learning with Transformers for Image Classification}},
  booktitle = {Workshops @ CVPR},
  year = {2022},
  url = {https://openreview.net/forum?id=4gWbN812AX},
}
Figure