Sparse-Tuning: Adapting Vision Transformers with Efficient Fine-tuning and Inference

Ting Liu, Xuyang Liu, Liangtao Shi, Zunnan Xu, Siteng Huang, Yi Xin, Quanjun Yin · DOI

TL;DR

This paper introduces Sparse-Tuning, a novel method for efficiently adapting large Vision Transformer (ViT) models. It combines token sparsification (keeping only important image patches) with "Dense Adapters" to maintain performance while drastically reducing computational costs during both training and inference.

What Problem Does This Paper Address?

Adapting powerful pre-trained Vision Transformers (ViTs) to new tasks is crucial, but full fine-tuning is computationally expensive. Parameter-Efficient Fine-Tuning (PEFT) methods offer a solution by updating only a small fraction of parameters. However, existing PEFT methods often neglect the computational and memory demands during inference, which is critical for real-world deployment. Furthermore, techniques that reduce computation by making tokens "sparse" (i.e., removing redundant image patches) can lead to significant performance degradation due to information loss. This paper aims to bridge this gap by developing a method that is efficient in both fine-tuning and inference, while also preserving high accuracy despite token sparsification.

Methods

Sparse-Tuning is built upon two core ideas:

  • Token Sparsification (TS): This technique reduces the number of image tokens processed by the ViT. The paper integrates existing TS methods like DynamicViT (pruning based on importance scores), EViT (selecting top-k tokens based on attention), and ToMe (merging similar tokens). The core idea is to identify and retain only the most semantically relevant parts of an image, thereby cutting down computation.
  • Dense Adapters (DAs): To counteract the information loss from TS, Sparse-Tuning introduces Dense Adapters. Unlike traditional adapters that operate within a single layer, DAs establish "dense connections" across multiple encoder layers. They aggregate features from shallower layers and inject them into deeper layers, effectively enriching the remaining sparse tokens with crucial local details that would otherwise be lost. This is inspired by DenseNet's architecture.

The overall framework freezes the pre-trained ViT backbone and trains only the Dense Adapters.

Datasets

The paper evaluates Sparse-Tuning on a variety of datasets:

  • VTAB-1K: A benchmark specifically designed to assess the data efficiency of fine-tuning methods, featuring many downstream classification tasks with limited training data (1,000 samples per task).
  • Image Datasets: CIFAR-100, SVHN, and Food-101. These are used to evaluate performance on complete datasets with abundant training data.
  • Video Datasets: Kinetics-400 (K400) and Something-Something V2 (SSv2). These are used to assess performance on video action recognition tasks.

Key Insights and Ideas

  • Inference Efficiency is Crucial: The paper highlights that while PEFT methods improve training efficiency, they often fail to address the computational burden during inference, which is a major bottleneck for practical applications.
  • Token Sparsification Alone Isn't Enough: Simply removing tokens to reduce computation leads to information loss and performance degradation. The key is to find a way to preserve or reconstruct that lost information.
  • Dense Connections Bridge the Gap: Dense Adapters, by connecting information across multiple layers, are shown to be effective in compensating for the information lost during token sparsification. They act as a mechanism to propagate and enrich the remaining sparse tokens.
  • Optimal Placement Matters: The paper demonstrates that the specific layers where token sparsification is applied significantly impacts performance. Applying it too early or too late in the ViT architecture can be detrimental.

Key Results

  • Significant Efficiency Gains: Sparse-Tuning reduces GFLOPs (a measure of computational complexity) by 30-38% compared to the original ViT-B on complete datasets and by up to 66% on the VTAB-1K benchmark. It also drastically reduces training and inference time and memory usage.
  • State-of-the-Art Performance: Despite the efficiency gains, Sparse-Tuning achieves state-of-the-art accuracy on VTAB-1K and outperforms other PEFT methods on complete image and video datasets. For example, on CIFAR-100, it achieves 92.31% accuracy with significantly reduced computation.
  • Scalability: The method scales well to larger ViT models (ViT-L), offering substantial parameter reduction and efficiency improvements while maintaining superior performance.
  • Versatility: Sparse-Tuning shows promise in other tasks like segmentation, outperforming existing methods.
  • Qualitative Attention Maps: Visualizations show that Sparse-Tuning with Dense Adapters restores attention patterns closer to the original ViT, indicating better information preservation compared to other PEFT+TS combinations.

Limitations and Future Work

  • Limitations: The paper acknowledges that token sparsification can still incur a minor performance drop (around 0.48% in one ablation study) even with Dense Adapters, though this is a trade-off for significant efficiency gains.
  • Future Work:
    • Dynamic Token Retention: Developing strategies to adapt the token retention ratio in real-time based on image complexity (e.g., more tokens for detailed textures, fewer for simple backgrounds).
  • Extended Tasks: Applying Sparse-Tuning to more complex tasks like video generation and object tracking, potentially by optimizing cross-frame and cross-view feature fusion.
  • Edge Deployment: Adapting the framework for resource-constrained environments like edge devices, enabling efficient deployment of large models.

Summary updated

BibTeX
@misc{liu2024sparse,
  author = {Ting Liu and Xuyang Liu and Liangtao Shi and Zunnan Xu and Siteng Huang and Yi Xin and Quanjun Yin},
  title = {{Sparse-Tuning: Adapting Vision Transformers with Efficient Fine-tuning and Inference}},
  year = {2024},
  eprint = {2405.14700},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.14700},
}
Figure