Home

Awesome

🌲 GrootVL: Tree Topology is All You Need in State Space Model

Yicheng Xiao<sup><span>1,*</span></sup>, Lin Song<sup><span>2,3,📧,*</span></sup>, Shaoli Huang<sup>3</sup>, Jiangshan Wang<sup><span>1</span></sup>, Siyu Song<sup><span>4</span></sup>, Yixiao Ge<sup><span>2,3</span></sup>, Xiu Li<sup><span>1,📧</span></sup> and Ying Shan<sup><span>2,3</span></sup>

<sup><span>*</span></sup> Equal contribution <sup><span>📧</span></sup> Corresponding author

<sup>1</sup> Tsinghua University <sup>2</sup> ARC Lab, Tencent PCG <sup>3</sup> Tencent AI Lab <sup>4</sup> South China Normal University

<a href='https://arxiv.org/pdf/2406.02395'><img src='https://img.shields.io/badge/ArXiv-2406.02395-red'></a>

📖 Abstract

The state space models, employing recursively propagated features, demonstrate strong representation capabilities comparable to Transformer models and superior efficiency. However, constrained by the inherent geometric constraints of sequences, it still falls short in modeling long-range dependencies. To address this issue, we propose the GrootVL network, which first dynamically generates a tree topology based on spatial relationships and input features. Then, feature propagation is performed based on this graph, thereby breaking the original sequence constraints to achieve stronger representation capabilities. Additionally, we introduce a linear complexity dynamic programming algorithm to enhance long-range interactions without increasing computational cost. GrootVL is a versatile multimodal framework that can be applied to both visual and textual tasks. Extensive experiments demonstrate that our method significantly outperforms existing structured state space models on image classification, object detection and segmentation. Besides, by fine-tuning large language models, our approach achieves consistent improvements in multiple textual tasks at minor training cost.

⚓ Tree State Space Model with Tree Scanning Algorithm

We first revisit the selective state space model and design an input-aware topology scanning algorithm for state space modeling. With this superior algorithm, we develop a tree SSM and propose a novel framework called GrootVL, which consists of two sub-networks: GrootV for visual tasks and GrootL for fine-tuning a pre-trained language model.

<p align="center"> <img src="assets/tree_ssm.png" width="100%"> </p>

⛲ Efficient Implementation for Multi-Modality

We utilize a dynamic programming procedure to accelerate the inference and training processes which results in linear complexity $O(L)$ instead of $O(L^2)$.

<p align="center"> <img src="assets/vis_tree_scanning.png" width="80%"> </p> <p align="center"> <img src="assets/lan_tree_scanning.png" width="80%"> </p>

🛠️ Environment Setup

Vision Tasks

conda create -n grootv python=3.9
conda activate grootv

# Install pytorch 
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117

# Install other packages
pip install -r GrootV/grootv_requirements.txt 

# Install Vision_Tree_Scanning
cd GrootV/third-party/TreeScan
pip install -v -e .

Language Tasks

conda create -n grootl python=3.9
conda activate grootl

# Install pytorch 
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2

# Install other packages
pip install -r GrootL/grootl_requirements.txt 

# Install Language_Tree_Scanning
cd GrootL/third-party/TreeScanLan
pip install -v -e .

# Install language model evluation tools
cd GrootL/3rdparty/lm-evaluation-harness
pip install -v -e .

🍺 Model Zoo

Vision Tasks

<details> <summary> ImageNet-1k Image Classification </summary> <br> <div>
namepretrainresolutionacc@1#paramFLOPsdownload
GrootV-TImageNet-1K224x22483.430M4.8Gckpt | cfg
GrootV-SImageNet-1K224x22484.251M8.5Gckpt | cfg
GrootV-BImageNet-1K224x22484.891M15.1Gckpt | cfg
GrootV-LImageNet-22K384x384RUNNING--ckpt | cfg
</div> </details> <details> <summary> COCO Object Detection and Instance Segmentation </summary> <br> <div>
backbonemethodschedulebox mAPmask mAP#paramFLOPsdownload
GrootV-TMask R-CNN1x47.042.749M265G- | cfg
GrootV-TMask R-CNN3x49.043.849M265G- | cfg
GrootV-SMask R-CNN1x48.643.670M341G- | cfg
GrootV-SMask R-CNN3x50.144.670M341G- | cfg
</div> </details> <details> <summary> ADE20K Semantic Segmentation </summary> <br> <div>
backbonemethodresolutionmIoU (ss/ms)#paramFLOPsdownload
GrootV-TUperNet512x51248.5 / 49.460M941G- | cfg
GrootV-SUperNet512x51250.7 / 51.782M1019G- | cfg
</div> </details>

Language Tasks

<details> <summary> Language Understanding </summary> <br> <div>
MethodPIQA ↑Arc-E ↑sst ↑WinoGrande ↑LAMBADA-ppl ↓race ↑Openbookqa ↑Average Acc ↑download
Mamba64.548.065.651.816.127.416.845/7model
+LoRA64.748.365.152.217.728.617.846.1-
+GrootL65.049.869.551.115.928.919.247.2model
</div> </details>

🚀 Train & Evaluate

<details> <summary> ImageNet-1k Image Classification </summary> <br>

bash GrootV/scripts/bash_cls_train.sh

You need to modify the relevant path to your own.

</details> <details> <summary> Language Understanding </summary> <br>
cd GrootL
bash eval.sh

You need to modify the relevant path to your own.

</details>

⭐️ BibTeX

If you find this work useful for your research, please cite:

@article{xiao2024grootvl,
  title={GrootVL: Tree Topology is All You Need in State Space Model},
  author={Xiao, Yicheng and Song, Lin and Huang, Shaoli and Wang, Jiangshan and Song, Siyu and Ge, Yixiao and Li, Xiu and Shan, Ying},
  journal={arXiv preprint arXiv:2406.02395},
  year={2024}
}

❤️ Acknowledgement

Code in this repository is built upon several public repositories. Thanks for the wonderful work InternImage and VMamba ! !

☑️ LICENSE

Our codes are under MIT license.