MSSR: Memory-Aware Adaptive Replay for Continual LLM Fine-Tuning
Organizations: The Chinese University of Hong Kong, Shenzhen · Nanjing University
Abstract
Continual fine-tuning of large language models (LLMs) is becoming increasingly crucial as these models are deployed in dynamic environments where tasks and data distributions evolve over time. While strong adaptability enables rapid acquisition of new knowledge, it also exposes LLMs to catastrophic forgetting, where previously learned skills degrade during sequential training. Existing replay-based strategies, such as fixed interleaved replay, accuracy-supervised, and loss-driven scheduling, remain limited: some depend on heuristic rules and provide only partial mitigation of forgetting, while others improve performance but incur substantial computational overhead. Motivated by retention dynamics under sequential fine-tuning, we propose Memory-Inspired Sampler and Scheduler Replay (MSSR), an experience replay framework that estimates sample-level memory strength and schedules rehearsal at adaptive intervals to mitigate catastrophic forgetting while maintaining fast adaptation. Extensive experiments across three backbone models and 11 sequential tasks show that MSSR consistently outperforms state-of-the-art replay baselines, with particularly strong gains on reasoning-intensive and multiple-choice benchmarks.
Figures & tables
| Model | Mistral-7B-v0.3 | Llama-3.1-8B | Qwen2.5-7B | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Dataset | MMLU | GSM8K | MATH | AVG | MMLU | GSM8K | MATH | AVG | MMLU | GSM8K | MATH | AVG |
| Vanilla | 60.2 | 57.7 | 27.5 | 48.5 | 64.5 | 63.8 | 29.3 | 52.5 | 57.6 | 70.1 | 28.6 | 52.1 |
| R | 60.5 | 58.8 | 28.3 | 49.2 | 65.1 | 64.4 | 29.5 | 53 | 58.5 | 70.5 | 29.3 | 52.8 |
| R | 60.7 | 58.4 | 28.8 | 49.3 | 65.3 | 64.7 | 29.6 | 53.2 | 58.4 | 72.3 | 30.4 | 53.7 |
| R | 61.0 | 59.3 | 29.4 | 49.9 | 64.9 | 64.5 | 29.9 | 53.1 | 59.5 | 71.7 | 29.9 | 53.7 |
| MSSR | 60.8 | 59.5 | 28.6 | 49.6 | 64.8 | 65.3 | 29.5 | 53.2 | 59.1 | 71.9 | 31.1 | 54.3 |
| Model | Method | AGNews | SQuAD | SciQ | BoolQ | ARC | GSM8K | MATH 1 | MATH 2 | MATH 3 | MATH 4 | MATH 5 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Gemma2-9B | None | 0.714 | 73.98 | 0.952 | 0.889 | 0.336 | 0.520 | 0.778 | 0.688 | 0.649 | 0.425 | 0.242 |
| Fixed | 0.761 | 74.23 | 0.944 | 0.876 | 0.388 | 0.638 | 0.873 | 0.743 | 0.626 | 0.387 | 0.228 | |
| Loss | 0.758 | 73.42 | 0.961 | 0.890 | 0.425 | 0.643 | 0.847 | 0.726 | 0.632 | 0.394 | 0.257 | |
| Accu | 0.754 | 74.67 | 0.959 | 0.901 | 0.441 | 0.636 | 0.864 | 0.731 | 0.650 | 0.392 | 0.276 | |
| MSSR | 0.772 | 75.83 | 0.952 | 0.906 | 0.456 | 0.654 | 0.834 | 0.725 | 0.649 | 0.409 | 0.302 | |
| MSSR | 0.769 | 76.10 | 0.957 | 0.903 | 0.462 | 0.646 | 0.852 | 0.741 | 0.635 | 0.399 | 0.263 |
| Buffer Size | Average Retention (%) |
|---|---|
| 512 | 62.1 |
| 1024 | 71.4 |
| 2048 | 78.9 |
| 4096 | 80.3 |
| Interval Sequence | Acc. (%) | Forget ↓ |
|---|---|---|
| Fixed ( ) | 84.6 | 0.0 |
| Geometric | 87.2 | 2.6 |
| Ebbinghaus | 89.1 | 4.5 |
| Strategy / | fixed | loss | eval | 0.05 | 0.10 | 0.20 | 0.30 |
|---|---|---|---|---|---|---|---|
| GSM8K Avg Acc | 0.706 | 0.698 | 0.727 | 0.716 | 0.725 | 0.748 | 0.731 |
| BoolQ Avg Acc | 0.876 | 0.854 | 0.865 | 0.874 | 0.892 | 0.889 | 0.883 |
| Buffer Size (samples) | 512 | 1024 | 2048 | 4096 |
|---|---|---|---|---|
| Average Retention (%) | 68.7 | 73.5 | 75.9 | 76.8 |
| Method | Wall-clock Time | Peak Memory | Throughput (samples/s) | Per-step Latency |
|---|---|---|---|---|
| Fixed Replay | 1.00 | 1.00 | 1.00 | 1.00 |
| MSSR | 1.03 | 1.04 | 0.99 | 1.02 |
| MSSR | 1.04 | 1.05 | 0.98 | 1.02 |
| MSSR | 1.05 | 1.06 | 0.98 | 1.05 |
| Interval Pattern | Interval Sequence | Avg Acc (%) | Forget Drop (%) |
|---|---|---|---|
| Fixed | 3,3,3,… | 76.1 | 4.8 |
| Geometric | 1,3,7,15,… | 77.8 | 3.1 |
| MSSR | 1,2,4,7,15,… | 78.5 | 2.4 |
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
| Parameter | Default | Candidate Values | Role | Where used |
| (shared) | baseline decay | Eq. ( 4 ), Eq. ( 7 ) | ||
| loss sensitivity | Eq. ( 4 ), Eq. ( 7 ) | |||
| sigmoid | — | monotone mapping | Eq. ( 4 ), Eq. ( 7 ) (via ) | |
| (sigmoid) | slope / hardness band width | Eq. ( 20 ) | ||
| (sigmoid) | center of difficulty band | Eq. ( 20 ) | ||
| EMA | loss denoising | Eq. ( 13 ) |
| Parameter | Default | Candidate Values | Role | Where used |
|---|---|---|---|---|
| initial replay interval | Eq. ( 26 ) | |||
| replay trigger threshold | Eq. ( 22 ) | |||
| early expansion gain | Eq. ( 25 ), Eq. ( 26 ) | |||
| decay rate of expansion gain | Eq. ( 25 ), Eq. ( 26 ) | |||
| initial replay ratio | Eq. ( 29 ) | |||
| minimal replay ratio | Eq. ( 29 ) |
| Item | Setting |
|---|---|
| Backbone model | Gemma2-9B / Qwen2.5-7B / LLaMA-3.1-8B |
| Fine-tuning framework | LLaMAFactory ( Zheng et al., 2024 ) |
| LoRA rank | 8 |
| LoRA scaling | 16 |
| LoRA target modules | q_proj , v_proj (all Transformer layers) |
| Optimizer | AdamW |
| Item | Setting |
|---|---|
| Replay buffer size | 1024 samples (maintained within each stage) |
| Buffer refresh interval | every 50 training steps |
| Replay batch composition | mix current-task samples with replayed samples at ratio |
| Replay sampling distribution | (Eq. ( 31 )) |
| Lazy state update | compute on demand using the latest epoch-/cycle-level hazard estimate (App. A.4 ) |
| Staleness safety cap | force refresh if exceeds a fixed cap (default: 10 epochs) |
Continual Learning for LLMs
Continual learning for large language models studies how models absorb new knowledge and skills while retaining previously learned capabilities.
See all 231 papers