Skip to content

luminolous/NH-LoRA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

PyTorch Implementation CIL Python 3.12+ Last Commit Project Homepage

Overview

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.

Getting Started

Environments

  • Python==3.12+
  • PyTorch==2.11.0
  • TorchVision==0.26.0
  • timm==1.0.26
  • numpy
  • Pillow
  • PyYAML
  • tqdm
  • safetensors
  • huggingface_hub

Training

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>.sh

or in a Python notebook:

bash scripts/<bash_file_benchmark_you_want_to_run>.sh

Benchmark / Dataset

Cifar-100

scripts/run_cifar100.sh

ImageNet-A

scripts/run_imagenet_a.sh

ImageNet-R

scripts/run_imagenet_r.sh

Custom

scripts/run_custom.sh

Custom 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/logs
  • outputs/custom/metrics/custom
  • outputs/custom/summaries/custom_summary.json
  • outputs/custom/checkpoints/custom
  • outputs/custom/deploy/custom

Keep benchmark.num_tasks and benchmark.classes_per_task compatible with the real class count in your dataset. The custom builder validates the resolved split and raises an error if the task count implied by classes_per_task does not match benchmark.num_tasks.

After training, the deploy bundle for a seed is written under:

outputs/custom/deploy/custom/seed_<seed>/

Acknowledgments

This data loader and preparation implementation builds using the LAMDA-PILOT code.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

NH-LoRA: Future-Aware Structural Expansion of Low-Rank Adapters for Rehearsal-Free Class-Incremental Learning

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors