Adaptive Sparse ViT: Towards Learnable Adaptive Token Pruning by Fully Exploiting Self-Attention

Xiangcheng Liu, Tianyi Wu, Guodong Guo
9/28/2022
cs.CV
transformer-attentionquantization-pruning

Official code: Cydia2018/AS-ViT (16 stars, Python, last commit 2023-08-01).

Abstract

Vision transformer has emerged as a new paradigm in computer vision, showing excellent performance while accompanied by expensive computational cost. Image token pruning is one of the main approaches for ViT compression, due to the facts that the complexity is quadratic with respect to the token number, and many tokens containing only background regions do not truly contribute to the final prediction.

Show full abstract

Existing works either rely on additional modules to score the importance of individual tokens, or implement a fixed ratio pruning strategy for different input instances. In this work, we propose an adaptive sparse token pruning framework with a minimal cost. Specifically, we firstly propose an inexpensive attention head importance weighted class attention scoring mechanism. Then, learnable parameters are inserted as thresholds to distinguish informative tokens from unimportant ones. By comparing token attention scores and thresholds, we can discard useless tokens hierarchically and thus accelerate inference. The learnable thresholds are optimized in budget-aware training to balance accuracy and complexity, performing the corresponding pruning configurations for different input instances. Extensive experiments demonstrate the effectiveness of our approach. Our method improves the throughput of DeiT-S by 50% and brings only 0.2% drop in top-1 accuracy, which achieves a better trade-off between accuracy and latency than the previous methods.

View on arXivView PDF

Code Implementations(1)

Cydia2018/AS-ViTOfficial100%

Adaptive Sparse ViT

161Python, ShellMay 26, 20233 years ago
dynamic-vitpruningsparsetransformervit

Similar Papers

Cite this paper

@article{liu2022adaptive,
  title  = {Adaptive Sparse ViT: Towards Learnable Adaptive Token Pruning by Fully Exploiting Self-Attention},
  author = {Xiangcheng Liu and Tianyi Wu and Guodong Guo},
  year   = {2022},
  eprint = {2209.13802},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2209.13802}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2209.13802.svg)](https://codeofpaper.com/paper/2209.13802)

Discussion