Unlocking Continual Learning Abilities in Language Models

Wenyu Du, Shuang Cheng, Tongxu Luo, Zihan Qiu, Zeyu Huang, Ka Chun Cheung, Reynold Cheng, Jie Fu

Abstract

Continual learning (CL) remains a significant challenge for large language models (LLMs), which typically suffer from "catastrophic forgetting" when trained on sequential tasks. We present MIGU (MagnItude-based Gradient Updating), a novel, task-label-free approach that leverages internal model activations to isolate task-specific knowledge. By updating only the parameters associated with the largest output magnitudes, MIGU creates a dynamic mask that preserves previous learning without requiring task labels or data buffers. Our experiments demonstrate performance improvements of up to 15.2% on long-sequence benchmarks and superior efficiency in continual pre-training.

Introduction: The Challenge of Catastrophic Forgetting

The primary obstacle in neural network training for sequential tasks is catastrophic forgetting. When a model adapts to new data, it often overwrites weights critical for previous tasks. Existing solutions generally fall into three categories: rehearsal-based methods (storing old data), architecture-based methods (adding parameters), and parameter-based methods (protecting weights via task labels). However, these approaches often face issues with privacy, parameter bloat, or the requirement for explicit task boundaries. MIGU addresses these gaps by unlocking the model's innate ability to separate tasks using internal behaviors.

Methodology: Magnitude-based Gradient Updating (MIGU)

MIGU introduces a simple yet effective mechanism to protect existing knowledge during fine-tuning. The core hypothesis is that for any given input, the weights producing the largest output magnitudes are the most relevant for that specific task.

The MIGU training process: 1) Forward pass, 2) Caching output magnitudes, 3) Backpropagation, and 4) Generating/applying the gradient mask.

The training process follows a two-step cycle:

  1. Forward Pass: For each linear layer, the model computes the output and caches the L1-normalized magnitude of that output.
  2. Backward Pass: Instead of a global update, the model applies a gradient mask. Only the parameters corresponding to the top $T$ percent (typically $T=0.7$) of the cached magnitudes are updated.

This dynamic masking prevents the model from interfering with weights that are crucial for other tasks where the magnitudes are lower, effectively isolating knowledge within the existing parameter space.

Key Insights: The Magnitude Fingerprint

A central discovery of this work is that language models naturally segregate information. When processing different tasks, the distribution of output magnitudes in linear layers forms a unique "magnitude fingerprint."

The 'Magnitude Fingerprint' concept: different tasks produce distinct output magnitude distributions, allowing for task-label-free parameter isolation.

This observation allows for task-label-free learning. The model effectively "identifies" which weights to utilize based on the input itself, rather than relying on external metadata. Visualizations indicate that MIGU significantly reduces the overlap of updated parameters between sequential tasks compared to standard fine-tuning, leading to higher parameter isolation and reduced interference.

Experimental Results

MIGU was evaluated across diverse architectures (RoBERTa, T5, Llama2) and benchmarks:

  • Massive Gains in Long Sequences: On a 15-task sequence using T5, MIGU improved the average accuracy of a LoRA baseline by 15.2%.
  • State-of-the-Art Efficiency: In the DAS benchmark for continual pre-training, MIGU matched specialized SOTA methods while adding only 10% wall-time overhead to standard training.
  • Instruction Tuning: When fine-tuning Llama2-7B for coding tasks, MIGU achieved a superior trade-off between "learning plasticity" (acquiring new coding skills) and "memory stability" (retaining general reasoning abilities like HellaSwag).

Conclusion and Future Work

MIGU demonstrates that internal activation magnitudes are a powerful proxy for task relevance in LLMs. While highly effective, future research could explore other innate features, such as activation sparsity, to further refine the masking process. Additionally, automating the selection of the threshold $T$ could enhance the method's robustness across highly specialized domains.

Summary updated

BibTeX
@inproceedings{du2024unlocking,
  author = {Wenyu Du and Shuang Cheng and Tongxu Luo and Zihan Qiu and Zeyu Huang and Ka Chun Cheung and Reynold Cheng and Jie Fu},
  title = {{Unlocking Continual Learning Abilities in Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.379},
}
Figure