aria-trl: Continual Learning for LLM Fine-tuning
aria-trl brings ARIA's continual learning mechanisms to Hugging Face's TRL library, enabling fine-tuning of large language models on sequential tasks without catastrophic forgetting.
Overview
Fine-tuning LLMs sequentially on multiple tasks typically leads to catastrophic forgetting — the model forgets earlier tasks while learning new ones. aria-trl prevents this through three ARIA mechanisms:
-
PlasticityGatedMLP: Dual fast/slow pathways in FFN layers
- Fast pathway: volatile, learns task-specific patterns
- Slow pathway: stable, retains task-generic knowledge
- Learned gate routes computation per token
-
Slow-Pathway Consolidation (SPC): Fisher-weighted regularization
- Estimates diagonal Fisher Information after each task
- Protects consolidated knowledge from being overwritten
- 50% fewer parameters than standard EWC
-
Task-Specific Adapters: Lightweight LoRA-like modules
- One residual adapter per task
- Frozen after training to prevent overwriting
- Minimal parameter overhead
Version History
aria-trl has been validated twice, each with a methodology improvement over the last:
- ARIA-TRL v1 — first validation: standard fine-tuning vs. aria-trl, 3-task sequential benchmark, 3 seeds. aria-trl won on both accuracy (+0.0028) and forgetting (46% less). Superseded by v2's more rigorous comparison.
- ARIA-TRL v2 — current validation: adds a real EWC baseline, 8 seeds (3 dev + 5 held-out fresh). aria-trl ties EWC on accuracy and clearly beats it on forgetting. This is the result detailed below, and what the current
aria_trlpackage reflects.
Each linked repo is a frozen snapshot of the code and README exactly as they stood at that milestone — this repo keeps moving forward.
Current Results
Summary
distilgpt2 was fine-tuned three ways on the same 3-task continual learning benchmark,
with identical data across all three: standard sequential fine-tuning (no protection),
EWC (textbook Fisher-weighted consolidation, no fast/slow split), and aria-trl
(the three mechanisms described below). Validated in two stages — 3 seeds used during
development, then 5 fresh seeds chosen after the fact and never used while tuning —
reported separately below, not just combined.
Across all 8 seeds, aria-trl matches EWC on accuracy (within noise) and cuts forgetting to near zero — while beating unmitigated fine-tuning outright on both metrics.
Reproducing this: these numbers come from
examples/kaggle_benchmark.py, which originally inlined a corrected version of the mechanism after three implementation defects (Fisher penalty leaking into the fast pathway, gate warmup never activating, cold-started heads) were found and fixed while building a fair EWC comparison; seepaper/ARIA_TRL_paper.pdfSection 2 for details. These fixes have since been ported into the installablearia_trl/package. Porting surfaced a fourth, more severe defect specific to the package (not present in the benchmark script):PlasticityGatedMLPwas never copying the pretrained FFN weights into the new fast/slow pathways, so everyContinualSFTTrainerrun silently fine-tuned from randomly-initialized FFN layers instead of the pretrained checkpoint — fixed as part of this port. The ported package was verified end-to-end on a full seed-42 run: task-0 accuracy went from 0.463 (below chance, pre-fix) to 0.762, with ACC and BWT close to the benchmark script's numbers and within the seed-to-seed variance already documented above — not byte-identical, which isn't a realistic bar across two independently-structured codebases, but the same architecture producing statistically consistent results.
Setup
- Model:
distilgpt2, 5 epochs per task (all three methods) - Tasks (in order): SST-2 (Movies) → Yelp Review Full (Restaurants) → dair-ai/emotion (Social)
- Dev seeds: 42, 123, 7 · Fresh seeds (held out): 2024, 777, 555, 99, 1234
https://github.com/user-attachments/assets/d720c09b-cad2-484d-a5b4-0e8943961408
Results
| Metric | Standard FT | EWC | aria-trl |
|---|---|---|---|
| ACC (dev, n=3) | 0.7639 | 0.7903 | 0.7861 |
| ACC (fresh, n=5) | 0.7992 | 0.7942 | 0.7975 |
| ACC (combined, n=8) | 0.7859 | 0.7927 | 0.7932 |
| BWT (dev, n=3) | −0.0563 | −0.0334 | −0.0104 |
| BWT (fresh, n=5) | −0.0362 | −0.0313 | −0.0038 |
| BWT (combined, n=8) | −0.0438 | −0.0320 | −0.0063 |
aria-trl's combined-8 ACC is +0.0005 ahead of EWC — smaller than either method's own seed-to-seed std (0.008–0.018), i.e. a statistical tie, not a win. BWT is +0.0257 ahead of EWC and +0.0375 ahead of Standard FT — the least forgetting of the three at every validation stage. This is not a clean sweep: 3 of the 8 seeds are simultaneous losses on both metrics for aria-trl, reported honestly rather than averaged away — see the paper for the per-seed breakdown.
The same pattern — aria-trl tied with EWC on ACC, ahead on BWT — holds independently in the development seeds and the fresh, previously-unseen seeds.
Task-0 accuracy after each step, all 8 seeds shown individually. Seeds 777 and 1234 are where aria-trl's retention advantage does not hold.
Full accuracy matrix, seed 42 — aria-trl's off-diagonal (older-task) values sit closer to their diagonal values than either baseline's.
Full per-seed numbers: results/kaggle_benchmark_results.json. Full write-up with method, defects found, and limitations: paper/ARIA_TRL_paper.pdf. Benchmark script: examples/kaggle_benchmark.py.
Features
- ✅ Drop-in SFTTrainer subclass — minimal code changes
- ✅ Asymmetric learning rates — slow pathway learns slower
- ✅ Gradient dampening — slow grads scaled by (1−π̄)
- ✅ Works with any HF model — LLaMA, Mistral, DistilGPT2, etc.
- ✅ Full checkpoint support — save/load with consolidation state
- ✅ Production-ready — comprehensive error handling
Installation
pip install aria-trl
Or install from source:
git clone https://github.com/rsd-darshan/aria-trl.git
cd aria-trl
pip install -e .
Quick Start
from aria_trl import ContinualSFTTrainer, ARIAConfig
from transformers import AutoModelForSequenceClassification, AutoTokenizer, TrainingArguments
# Load model
model = AutoModelForSequenceClassification.from_pretrained("distilgpt2", num_labels=2)
tokenizer = AutoTokenizer.from_pretrained("distilgpt2")
# Configure ARIA
aria_config = ARIAConfig(
plasticity_lambda=0.01, # bimodal gate specialization
spc_lambda=100.0, # Fisher consolidation strength
adapter_dim=64, # task adapter bottleneck
# slow_lr_ratio defaults to 1.0 (gate-driven gradient dampening is the
# only slow-pathway throttle by default; lower this only on top of that,
# not instead of it) and warmup_steps defaults to None (auto-computed
# from your actual dataset size and batch size).
)
# Training arguments
args = TrainingArguments(
output_dir="./checkpoints",
learning_rate=2e-4,
num_train_epochs=3,
per_device_train_batch_size=8,
)
# Create trainer
trainer = ContinualSFTTrainer(
model=model,
tokenizer=tokenizer,
args=args,
train_dataset=task1_train,
eval_dataset=task1_eval,
aria_config=aria_config,
)
# Train on task 1
trainer.train()
# Consolidate before next task (Fisher estimation)
trainer.consolidate_task(task_id=0)
# Train on task 2
trainer.add_task(task_id=1)
trainer.train_dataset = task2_train
trainer.eval_dataset = task2_eval
trainer.train()
# Consolidate again
trainer.consolidate_task(task_id=1)
# Evaluate on all tasks to measure forgetting
metrics = trainer.evaluate_all_tasks(all_tasks)
Core Components
ARIAConfig
Configuration for ARIA continual learning:
from aria_trl import ARIAConfig
config = ARIAConfig(
plasticity_lambda=0.01, # Bimodal specialization loss weight
spc_lambda=100.0, # Fisher regularization strength
adapter_dim=64, # Task adapter bottleneck dimension
slow_lr_ratio=1.0, # Slow pathway LR multiplier (on top of
# gate-driven gradient dampening, which
# is the default throttle — see below)
warmup_steps=None, # None = auto-compute one epoch's worth
# of steps from your dataset/batch size
consolidation_steps_per_task=None # Fisher estimation steps (None=all)
)
PlasticityGatedMLP
Replaces transformer FFN layers automatically. Routes per-token computation:
output = π * fast_pathway(x) + (1−π) * slow_pathway(x)
where π ∈ (0,1) is learned and regularized to specialize (0 or 1).
TaskFastAdapter
Per-task residual adapter (LoRA-like):
h_new = h + adapter(h)
Bottleneck design: h → compress → ReLU → expand, zero-initialized expansion.
FisherConsolidator
Estimates diagonal Fisher Information on validation data after each task:
consolidator = FisherConsolidator(model, device)
consolidator.consolidate(task_id, eval_loader)
loss = consolidator.compute_spc_loss(global_step)
Metrics
Compute continual learning metrics with:
from aria_trl.utils import compute_continual_metrics
metrics = compute_continual_metrics(task_accuracies)
# Returns: avg_accuracy, forgetting, forward_transfer
- Average Accuracy: Mean accuracy on all tasks at end
- Forgetting: How much old tasks degrade (lower is better)
- Forward Transfer: How much new tasks benefit from old tasks
Example: DistilGPT2 on Sequential Tasks
See examples/distilgpt2_example.py for a complete working example:
python examples/distilgpt2_example.py
Trains on 3 sequential tasks (sentiment, toxicity, spam) and prints metrics.
How ARIA Prevents Forgetting
The Problem
Standard fine-tuning on sequential tasks overwrites weights learned on earlier tasks:
Task 1: [update all weights]
Task 2: [update all weights again] ← Task 1 weights overwritten
Task 3: [update all weights again] ← Task 1 & 2 weights overwritten
Eval: [accuracy on Task 1 ↓↓↓] ← Catastrophic forgetting!
The Solution
ARIA separates fast (volatile) and slow (stable) pathways:
Fast pathway: [updates freely, learns task-specific patterns]
Slow pathway: [updates slowly, consolidated by Fisher regularization]
Gate π: [routes each token: fast for new patterns, slow for stability]
Result: Old tasks remain in slow pathway, new tasks learn in fast pathway
Design Philosophy
aria-trl's design prioritizes:
- Compatibility: Subclasses SFTTrainer, works with any HF model
- Simplicity: Three mechanisms, no complex multi-model ensembles
- Efficiency: Task adapters add <1% parameters, Fisher diagonal reduces memory
- Interpretability: Gate π shows per-token plasticity, easy to debug
Papers & Motivation
- ARIA (PyTorch): paper (PDF) · repo — core continual learning research, CNNs and task-incremental learning
- aria-trl (TRL): paper (PDF) — this package; brings ARIA mechanisms to LLM fine-tuning via Hugging Face
- NCG: "Novelty-triggered Capacity Growth" — reactive capacity expansion (predecessor)
- EWC: "Elastic Weight Consolidation" — standard baseline for catastrophic forgetting
Limitations & Future Work
- Slow pathway at 0.5× LR: Conservative; tuning improves CIFAR-10 accuracy
- Fisher diagonal only: Full Fisher or Kronecker-factored approximations are future work
- DistilGPT2 tested: Larger models (7B+) need memory optimization
- Binary classification: Multi-class and language modeling tasks need validation
Contributing
Contributions welcome! Please:
- Fork the repo
- Create a feature branch (
git checkout -b feature/my-feature) - Commit changes (no AI attribution required)
- Push to remote and open a PR
License
MIT License — see LICENSE for details.
Citation
If you use aria-trl in your research, please cite:
@software{poudel2026aria_trl,
title = {aria-trl: Continual Learning for LLM Fine-tuning},
author = {Poudel, Darshan},
year = {2026},
url = {https://github.com/rsd-darshan/aria-trl}
}
Contact
- GitHub: @rsd-darshan
- Email: poudeldarshan44@gmail.com
aria-trl — continual learning, without the catastrophe.
Metadata
Release files for aria-trl 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aria_trl-1.1.0.tar.gz | 3.5 MB | Without provenance | Details for aria_trl-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aria_trl-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for aria_trl-1.1.0-py3-none-any.whl |
Total release size: 3.5 MB
Release files / aria_trl-1.1.0.tar.gz
| Download URL | aria_trl-1.1.0.tar.gz |
|---|---|
| Size | 3.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19e0ca9fb609aab2a2ec1371176c7c0e61ea0ff7b0004447b2cdf01357c3914a
|
|
BLAKE2b-256 checksum How to use checksums |
5286dfb283d0efac8e8cdf3f53a6c911eae9fb14ae8948342642eb770b19736a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / aria_trl-1.1.0-py3-none-any.whl
| Download URL | aria_trl-1.1.0-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2fab580828598585a2e0afafc5907cacfa4a5ed00cac1cc452c7de73f4cbcdbe
|
|
BLAKE2b-256 checksum How to use checksums |
4dcd29a5d0192324ed82133e81c9f359ad9a3491a2a7b54be0c5cca5b9b1ed96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for aria-trl 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.