Abstract
Continual learning (CL) in language models often suffers from knowledge interference and suboptimal task routing. We propose L2R (Learning to Route), a framework that trains task-specific adapters in isolation to prevent interference and subsequently trains a specialized router using a small memory buffer. This router dynamically composes adapters at inference time using a Gumbel-sigmoid distribution. L2R achieves state-of-the-art performance on diverse class-incremental benchmarks, including multilingual sentiment analysis and document classification, while maintaining computational efficiency.
Introduction
In Continual Learning (CL), a model must learn a sequence of tasks without "forgetting" previously acquired knowledge. A popular approach is Parameter-Efficient Fine-Tuning (PEFT), such as adapters or LoRA, where a small set of parameters is added for each new task while the backbone remains frozen. However, current PEFT-based CL methods face two major hurdles:
- Interference: Training a new adapter in the presence of previously learned adapters can interfere with the model's ability to specialize on the new task.
- Suboptimal Routing: At inference time, selecting the correct adapter is challenging. Most methods rely on simple similarity-based selection, which often fails to effectively combine specialized knowledge across modules.
Methodology
The L2R (Learning to Route) framework operates in two distinct phases to address these challenges:
- Isolated Training: When a new task arrives, L2R adds a new LoRA adapter and trains it while keeping the backbone and all previous adapters frozen and deactivated. This ensures each adapter becomes a pure specialist for its specific task.
- Router Learning: Before inference, L2R uses a small non-parametric memory (storing approximately 10% of training examples) to train a router network. This router processes the input representation (the
[CLS]token) to determine an allocation vector for adapter contribution.
The framework explores two composition methods: L2R-wavg, which computes a weighted average of hidden states, and L2R-merge, which merges adapter weights into a single set of parameters. A key technical innovation is the use of a Gumbel-sigmoid distribution for the router, allowing for differentiable, "binary-like" activations that turn adapters on or off decisively.
Experimental Setup
L2R was evaluated on three diverse benchmarks:
- MTL5: Five distinct text classification tasks (e.g., AGNews, Yelp), representing "far-domain" learning.
- Web-of-Science (WOS): Seven document classification tasks from various scientific fields, representing "near-domain" learning.
- AfriSenti: A multilingual sentiment analysis dataset featuring 12 low-resource African languages.
Testing was conducted in both Task-Incremental Learning (TIL) and the more challenging Class-Incremental Learning (CIL) setups.
Discussion
Several key insights emerged from the study:
- Isolation Breeds Specialization: Deactivating old adapters during new task training prevents feature drift, allowing adapters to learn new tasks without compensating for existing parameters.
- Routing as Local Adaptation: Treating routing as a lightweight learning problem using a small memory buffer is significantly more effective than using fixed mathematical similarity scores.
- Binary-ish Gates: The Gumbel-sigmoid approach outperformed standard Softmax, suggesting that modular systems benefit from a router that can decisively pick specific experts rather than spreading signals across all modules.
- Efficiency:
L2R-wavgadds negligible computational overhead to the base BERT model, unlike competitors that increase FLOPs through complex similarity searches.
Results
L2R-wavg demonstrated superior generalization, particularly in the difficult CIL setup. On the AfriSenti benchmark, L2R-wavg achieved 60.04% accuracy, significantly outperforming the previous state-of-the-art (MoCL) at 45.61%. In TIL setups, the model often matched the "Upper-Bound" performance of models trained individually with perfect task knowledge.
Performance was found to scale positively with memory size. As the memory buffer increased from 1% to 30%, the router's performance continued to improve, especially on complex datasets like WOS.
Conclusion
L2R provides a robust framework for continual learning by combining isolated specialization with learned dynamic routing. While the current study focused on BERT-base and AfroXLMR, future work will explore scaling L2R to Large Language Models (LLMs) and developing online router training methods for dynamic data streams.
Summary updated