Introduction
Small language models (SLMs) like BERT remain vital for production environments due to their efficiency and strong performance on specific supervised tasks. However, when trained on a sequence of tasks, they suffer from catastrophic forgetting, where new learning overwrites previously acquired knowledge. This paper introduces the Discrete Key-Value Bottleneck (DKVB), an architecture that enables localized updates to preserve old knowledge while learning new tasks, offering a more efficient alternative to traditional replay-based methods.
The Challenge of Catastrophic Forgetting
In continual learning (CL), models are fine-tuned on a stream of tasks. Standard SLMs often fail because weight updates for a new task interfere with the patterns learned for earlier ones. Existing solutions typically rely on large memory buffers (replay-based) or expanding parameters (architecture-based), both of which face scaling issues. The DKVB approach aims for an efficient, task-agnostic solution that performs well even in challenging "single-head" scenarios where task IDs are unknown.
The DKVB Architecture
The core innovation is the adaptation of the Discrete Key-Value Bottleneck for NLP. The process involves three main stages:
- Encoding: A frozen backbone (e.g., BERT) generates a latent representation of the input.
- Bottleneck Processing: The representation is partitioned into multiple "heads." Each head performs a lookup for the closest "key" in a discrete codebook using L2 distance and retrieves a corresponding "value" vector.
- Decoding: Retrieved values are aggregated and passed to a decoder for final prediction.
Crucially, during training, only the retrieved value vectors are updated. This discretization creates "compartments" for knowledge; learning a new task only modifies values associated with relevant keys, leaving the rest of the model's memory intact.
NLP-Specific Adaptations
The authors identified several critical design choices for applying DKVB to text:
- Pooling Strategy: Applying mean pooling after the bottleneck is essential to maintain the high dimensionality required for text representations.
- Generic Initialization: Keys can be optimized once on a general-purpose corpus (like Wikipedia) before task-specific training, providing a robust "Generic" initialization that rivals "Oracle" methods.
Experimental Results
The DKVB was evaluated across various scenarios, including Class Incremental Learning (CIL) on datasets like R8 and R52.
Key findings include:
- Superior Performance: In 20ng CIL, the non-parametric DKVB achieved 97.06% accuracy, significantly outperforming replay-based methods like DER++ (59.68%).
- Computational Efficiency: DKVB is remarkably fast. On the 4GLUE benchmark, it trained in ~109 seconds per epoch, compared to over 3000 seconds for architecture-based competitors.
- Stability: In single-head experiments (R8 and R52), DKVB maintained stable performance across numerous increments, whereas standard models showed sharp declines.
Conclusion
The Discrete Key-Value Bottleneck provides a powerful mechanism for continual learning in SLMs. By leveraging discrete, localized updates, it effectively mitigates catastrophic forgetting with minimal computational overhead. Future work may explore its application in decoder-only models and more complex generative NLP tasks.
Summary updated