NH-LoRA: Future-Aware Structural Expansion of Low-Rank Adapters for Rehearsal-Free Class-Incremental Learning
This repository contains the official PyTorch implementation of NH-LoRA: Future-Aware Structural Expansion of Low-Rank Adapters for Rehearsal-Free Class-Incremental Learning.
NH-LoRA is a rehearsal-free class-incremental learning method built on a frozen Vision Transformer and parameter-efficient low-rank adaptation. It separates reusable cross-task knowledge from task-specific expandable memory, then uses a task-aware planner to control structural decisions such as reuse, rank expansion, or new-slot creation. During learning, sparse routing and post-task consolidation help balance plasticity and stability while keeping parameter growth under control.
Python==3.12+PyTorch==2.11.0TorchVision==0.26.0timm==1.0.26numpyPillowPyYAMLtqdmsafetensorshuggingface_hub
To train the model, set up the configuration in the configs folder first, navigate to the main directory, and then run:
scripts/<bash_file_benchmark_you_want_to_run>.shor in a Python notebook:
bash scripts/<bash_file_benchmark_you_want_to_run>.shscripts/run_cifar100.shscripts/run_imagenet_a.shscripts/run_imagenet_r.shscripts/run_custom.shCustom ImageFolder datasets must follow this structure:
data/custom-dataset/
|- train/
| |- class_000/
| | |- img_0001.jpg
| | |- img_0002.jpg
| | `- ...
| |- class_001/
| |- class_002/
| `- ...
`- test/
|- class_000/
| |- img_0001.jpg
| `- ...
|- class_001/
|- class_002/
`- ...
The custom benchmark reads train/ and test/ class folders, requires the class-folder sets to match, and uses alphabetical folder order as the class order.
configs/run_custom.yaml is the single source of truth for the custom output layout:
outputs/custom/logsoutputs/custom/metrics/customoutputs/custom/summaries/custom_summary.jsonoutputs/custom/checkpoints/customoutputs/custom/deploy/custom
Keep
benchmark.num_tasksandbenchmark.classes_per_taskcompatible with the real class count in your dataset. The custom builder validates the resolved split and raises an error if the task count implied byclasses_per_taskdoes not matchbenchmark.num_tasks.
After training, the deploy bundle for a seed is written under:
outputs/custom/deploy/custom/seed_<seed>/
This data loader and preparation implementation builds using the LAMDA-PILOT code.
This project is licensed under the MIT License - see the LICENSE file for details.