The PyTorch code repository for Hierarchical Semantic Tree Anchoring for CLIP-Based Class-Incremental Learning. If you use this code in your research, please cite:
@inproceedings{hu2026hierarchical,
title={Hierarchical Semantic Tree Anchoring for CLIP-Based Class-Incremental Learning},
author={Tao Hu and Lan Li and Zhen-Hao Xie and Da-Wei Zhou},
booktitle = {NeurIPS},
year = {2026}
}Class-Incremental Learning (CIL) enables models to learn new classes continually while preserving past knowledge. Recently, vision-language models like CLIP offer transferable features via multimodal pre-training, making them well-suited for CIL. However, real-world visual and linguistic concepts are inherently hierarchical: a textual concept like "dog" subsumes fine-grained categories such as "Labrador" and "Golden Retriever," and each category is associated with corresponding images. Nevertheless, existing CLIP-based CIL methods fail to explicitly capture this inherent hierarchy, leading to feature drift of fine-grained classes during incremental updates and ultimately to catastrophic forgetting. To address this challenge, we propose HASTEN (Hierarchical Semantic Tree Anchoring), a hierarchy-aware framework that uses semantic structure to stabilize CLIP-based CIL. Rather than treating classes as isolated labels, HASTEN leverages external hierarchical knowledge as structured supervision to organize visual and textual features in hyperbolic space, helping maintain parent--child relations as new tasks arrive and mitigating feature drift. Since the shared hyperbolic mapper is updated across tasks, we further stabilize it by constraining its updates to a null space induced by prior-task features, reducing interference with previous mappings while retaining adaptability to new classes. Extensive experiments on nine benchmarks show that HASTEN consistently outperforms existing methods while reducing feature drift and catastrophic forgetting.
Environment
Dataset
We provide the processed datasets as follows:
- CIFAR100: will be automatically downloaded by the code.
- CUB200: Google Drive: link or OneDrive link
- ImageNet-R: Google Drive: link or Onedrive: link
- ObjectNet: Onedrive: link You can also refer to the filelist and processing code if the file is too large to download.
- Cars: Google Drive: link or OneDrive: link
- UCF: Google Drive: link or OneDrive: link
- Aircraft: Google Drive: link or OneDrive: link
- Food: Google Drive: link or OneDrive: link
- SUN: OneDrive: link
These subsets are sampled from the original datasets. Please note that I do not have the right to distribute these datasets. If the distribution violates the license, I shall provide the filenames instead.
Set DATA_ROOT_PATH in utils/data.py to your dataset directory; its default is data/ relative to the repository root. The prepared layout is:
data/
├── cifar100/
│ └── cifar-100-python/
│ ├── train
│ ├── test
│ └── meta
├── aircraft/{train,test}/
├── cars/{train,test}/
├── cub/{train,test}/
├── food101/{train,test}/
├── imagenet-r/{train,test}/
├── objectnet/{train,test}/
├── sun/{train,test}/
└── ucf/{train,test}/
To prepare your JSON files, refer to the settings in the exps folder and run the following command. All main experiments from the paper are already provided in the exps folder, you can simply execute them to reproduce the results found in the logs folder.
python main.py --config ./exps/hasten/[configname].json
We provide task-wise semantic trees for the main experiments in knowledge/. A generation script is also available at utils/create_hier.py to construct incremental semantic trees for different seeds or task splits.
This implementation builds on CIL_Survey, PyCIL, C3Box, and OpenCLIP.