Evaluating & Mitigating Catastrophic Forgetting during Continual Instruction Tuning of BLOOMZ (560M β 3B)
π€ 31 Model Checkpoints β’ π₯οΈ Live Demo β’ π Key Findings β’ π Quick Start
This research project investigates Catastrophic Forgetting (CF) β the phenomenon where neural networks lose previously learned knowledge when trained on new tasks. We conducted systematic experiments on the BLOOMZ model family across 5 sequential instruction-tuning tasks, combining mechanistic interpretability with practical mitigation strategies.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BLOOMZ (560M / 1.1B / 3B) β
β ββββββββ ββββββββ βββββββββ βββββββ ββββββββ β
β β SIMP β β β EMDG β β β InqQG β β β EXP β β β HGen β Sequential β
β βTask 1β βTask 2β βTask 3 β βTask4β βTask 5β Fine-Tuning β
β ββββ¬ββββ ββββ¬ββββ ββββ¬βββββ ββββ¬βββ ββββ¬ββββ β
β β β β β β β
β [Eval] [Eval] [Eval] [Eval] [Eval] β MMLU/BoolQ/ β
β RACE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Mechanistic Analysis: Gradient Conflict β CKA Drift β Loss Sharpness β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Mitigation Strategies: π Mixing β π§ Freezing β π Curvature Reg. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Model | Method | Naive (No Fix) | π Mixing | π§ Freezing | π Curvature |
|---|---|---|---|---|---|
| BLOOMZ-560M | Full FT | 22.03% | 6.05% β | 13.61% | 13.81% |
| BLOOMZ-1.1B | Full FT | 12.94% | 5.79% β | 11.81% | 7.92% |
| BLOOMZ-3B | Full FT | 5.84% | 2.51% β | 4.88% | 5.01% |
| BLOOMZ-560M | QLoRA 4-bit | 13.30% | 8.54% | 5.54% β | 8.97% |
| BLOOMZ-3B | QLoRA 4-bit | 5.91% | 4.33% | 2.22% β | 3.92% |
π‘ Key Insight: Mixing works best for Full Fine-Tuning (large parameter space), while Freezing is optimal for QLoRA (constrained adapter space).
BLOOMZ-560M Full Fine-Tuning: Accuracy drops significantly on MMLU, BoolQ, and RACE as the model learns new tasks sequentially.
BLOOMZ-3B: Larger models show more resilience to forgetting, but CF is still present.
Left: Full FT 560M β Right: QLoRA 560M. CKA scores near 1.0 = stable representations, near 0.0 = severe drift. Middle layers (L10-L14) drift most after domain-shifting tasks like EMDG.
Left: Gradient interference between consecutive tasks β high conflict ratio indicates opposing optimization directions. Right: Fisher Trace measures loss landscape sharpness β sharper landscapes correlate with higher forgetting.
Left: Forgetting Metric comparison across strategies β Mixing achieves the lowest FG for Full FT. Right: Pareto chart showing the Stability-Plasticity trade-off β ideal position is top-right corner.
A full-stack web application for real-time visualization and model inference:
- π 6 chart types: Forgetting curves, CKA heatmaps, gradient conflict, Pareto, strategy comparison
- π€ Live inference: Generate text with any of the 31 model checkpoints
- βοΈ A/B comparison: Side-by-side output comparison (Original vs Catastrophically Forgotten)
- π Chain comparison: Track output degradation across all 5 task checkpoints
- π Strategy comparison: Compare mitigation strategies in real-time
- π 6 interactive chart types rendered server-side with Matplotlib
- π€ Real-time text generation with any of the 31 BLOOMZ checkpoints
- βοΈ Side-by-side A/B comparison of Original vs Forgotten model outputs
- π Chain comparison to visualize output degradation across all 5 task checkpoints
git clone https://github.com/dovanminh100104-coder/Catastrophic-Forgetting-Analysis-BLOOMZ.git
cd Catastrophic-Forgetting-Analysis-BLOOMZ
pip install -r requirements.txtpython demo_server.pyOpens automatically at http://localhost:8000
π‘ First run downloads models from HuggingFace (~1.1GB/model). Use
--no-preloadto skip.
python generate_charts.py
# Output: charts/ directory with all PNG figures.
βββ π demo_server.py # FastAPI backend + inference engine + chart API
βββ π demo_frontend.html # Interactive web UI (vanilla JS)
βββ π demo_data.json # Experiment results (accuracy, FG, CKA, gradients)
βββ π generate_charts.py # Publication-quality chart generator
βββ πΌοΈ hinh1_framework.html # Research framework diagram
βββ π requirements.txt # Python dependencies
βββ π README_models.md # Full list of 31 HuggingFace models
βββ π assets/ # Charts and figures for README
βββ π Workflow_ThucNghiem.md # 5-step experiment workflow
βββ π Baibaonhom04_detai28.* # Research paper (DOCX + PDF)
βββ π BaoCaoMonHocNhom04_* # Course report (DOCX + PDF)
βββ π§ͺ thucnghiem/ # Kaggle experiment notebooks (GPU T4)
βββ thucnghiem-cf-llms-560m-final.ipynb # Full FT 560M
βββ thucnghiem-cf-llms-1b1-final.ipynb # Full FT 1.1B (coming soon)
βββ thucnghiem-cf-llms-3b.ipynb # Full FT 3B
βββ cf-bloomz-560m-lora-final.ipynb # QLoRA 560M
βββ cf-bloomz-3b-lora-final.ipynb # QLoRA 3B
31 model checkpoints hosted at huggingface.co/dovanminh100104
π¦ Full Model List (click to expand)
| Checkpoint | HuggingFace ID |
|---|---|
| After Task 1 (SIMP) | dovanminh100104/cf-experiment-v4-baseline-simp |
| After Task 2 (EMDG) | dovanminh100104/cf-experiment-v4-baseline-emdg |
| After Task 3 (InqQG) | dovanminh100104/cf-experiment-v4-baseline-inqqg |
| After Task 4 (EXP) | dovanminh100104/cf-experiment-v4-baseline-exp |
| After Task 5 (HGen) | dovanminh100104/cf-experiment-v4-baseline-hgen |
| Mixing Strategy | dovanminh100104/cf-experiment-v4-mixing-final |
| Curvature Strategy | dovanminh100104/cf-experiment-v4-curvature-final |
| Freezing Strategy | dovanminh100104/cf-experiment-v4-freezing-final |
| Checkpoint | HuggingFace ID |
|---|---|
| Baseline (5 tasks) | dovanminh100104/cf-lora-560m-final |
| Mixing Strategy | dovanminh100104/cf-lora-560m-mixing-final |
| Curvature Strategy | dovanminh100104/cf-lora-560m-curvature-final |
| Freezing Strategy | dovanminh100104/cf-lora-560m-freezing-final |
See README_models.md for the complete list of all 31 models.
# Full Fine-Tuned model
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("dovanminh100104/cf-experiment-v4-baseline-hgen")
tokenizer = AutoTokenizer.from_pretrained("bigscience/bloomz-560m")
# QLoRA adapter
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained("bigscience/bloomz-560m")
model = PeftModel.from_pretrained(base, "dovanminh100104/cf-lora-560m-final")| Category | Technologies |
|---|---|
| Training | PyTorch, HuggingFace Transformers, PEFT, BitsAndBytes |
| Quantization | QLoRA (NF4 4-bit) |
| Compute | Kaggle GPU T4 (15.6GB VRAM) |
| Demo Backend | FastAPI, Uvicorn |
| Demo Frontend | Vanilla JS, CSS3 (Glassmorphism UI) |
| Visualization | Matplotlib, Seaborn |
| Model Hosting | HuggingFace Hub (31 checkpoints) |
- Kirkpatrick et al., "Overcoming catastrophic forgetting in neural networks", PNAS 2017
- Kornblith et al., "Similarity of Neural Network Representations Revisited", ICML 2019
- Hu et al., "LoRA: Low-Rank Adaptation of Large Language Models", ICLR 2022
- Dettmers et al., "QLoRA: Efficient Finetuning of Quantized LLMs", NeurIPS 2023
| Name | Role |
|---|---|
| Δα» VΔn Minh | Researcher & Developer |
| Nguyα» n Thα» TuyαΊΏt Lan | Researcher & Developer |
β If you find this project helpful, please consider giving it a star!







