Predicting Token Impact Towards Efficient Vision Transformer

Hong Wang, Su Yang, Xiaoke Huang, Weishan ZhangarXiv 2023 · DOI

Abstract

Vision Transformers (ViTs) have demonstrated superior performance in computer vision tasks but suffer from high computational costs due to the quadratic complexity of self-attention. While existing methods often employ complex hierarchical pruning, this paper introduces DL-ViT (Delta Loss Vision Transformer), a "one-pass" approach that identifies and removes redundant tokens at the network's input. By utilizing a novel "Delta Loss" metric to train a lightweight Multi-Layer Perceptron (MLP) filter, DL-ViT achieves a 46% reduction in FLOPs with negligible accuracy loss, offering a highly efficient alternative for edge deployment.

Introduction

The rise of Vision Transformers has shifted the landscape of computer vision, yet their deployment remains constrained by the self-attention mechanism. As every image patch (token) attends to every other patch, the computational burden grows quadratically with the number of tokens. To mitigate this, researchers have explored restricting attention windows, token clustering, and layer-wise pruning. However, these methods often introduce architectural complexity or deployment challenges.

This work proposes a simpler paradigm: predicting token importance at the very beginning of the pipeline. By viewing token reduction as a feature selection problem, the authors demonstrate that a significant portion of image data can be discarded before entering the main Transformer blocks without compromising classification performance.

Methodology: The DL-ViT Framework

The core of DL-ViT is a two-stage process: generating ground-truth importance labels via Delta Loss and training a predictive filter.

The Delta Loss Metric

To quantify a token's contribution, the authors define Delta Loss (ΔL). Using a pre-trained ViT, they measure the change in cross-entropy loss when a specific token is masked versus when it is present. A high ΔL indicates a vital token, while a near-zero ΔL suggests the token represents redundant background information.

The DL-ViT training framework uses Delta Loss to generate pseudo-labels for training the MLP selection module.

The Token Filter

Since calculating ΔL during inference is computationally prohibitive, the authors train a lightweight MLP to predict these importance values. The MLP takes individual token features concatenated with a Global Feature (the average of all tokens) to provide necessary context. This global context is crucial; for instance, a patch of fur is only "important" if the global context suggests an animal classification task.

One-Pass Inference

Unlike hierarchical methods that prune tokens at multiple stages, DL-ViT performs selection once. After the initial patch embedding, the MLP filter identifies the "surviving" tokens, and only these are processed by the subsequent Transformer layers.

The DL-ViT inference pipeline demonstrates the "one-pass" selection module filtering tokens before they enter the Transformer Encoder.

Experimental Evaluation

The researchers evaluated DL-ViT on the ImageNet-1K dataset using the DeiT (Data-efficient Image Transformer) backbone.

Key Results

  • DL-ViT-T (Tiny): Achieved 71.1% Top-1 accuracy (a mere 0.3% drop from the full backbone) while reducing FLOPs by 46%. It reached a throughput of 4,565 images/s, outperforming state-of-the-art dynamic pruning methods.
  • DL-ViT-S (Small): Maintained 79.6% Top-1 accuracy with a 15% reduction in FLOPs.

Discussion and Insights

The success of DL-ViT highlights several key properties of image data in Transformers:

  1. Early Predictability: Token impact can be accurately estimated before any attention layers are applied, challenging the need for multi-stage pruning.
  2. Statistical Sparsity: Visualization of ΔL values confirms that most image patches have negligible impact on the final classification decision.
  3. Deployment Efficiency: The "one-pass" architecture is significantly easier to optimize for parallel computing environments (GPUs) compared to layer-wise pruning, which requires frequent synchronization.

Conclusion and Future Work

DL-ViT provides a robust and efficient "shortcut" for Vision Transformers. While the aggressive early pruning is highly effective for classification, its "irreversible" nature means discarded tokens cannot be recovered for fine-grained tasks in later layers. Future research may explore applying this predictive logic to intermediate layers or extending the framework to dense prediction tasks like object detection and segmentation.

Summary updated

BibTeX
@misc{wang2023predicting,
  author = {Hong Wang and Su Yang and Xiaoke Huang and Weishan Zhang},
  title = {{Predicting Token Impact Towards Efficient Vision Transformer}},
  year = {2023},
  eprint = {2305.14840},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.14840},
}
Figure