An Image is Worth 1/2 Tokens After Layer 2: Plug-and-Play Inference Acceleration for Large Vision-Language Models

Liang Chen, Haozhe Zhao, Tianyu Liu, Shuai Bai, Junyang Lin, Chang Zhou, Baobao Chang · DOI

Introduction

Large Vision-Language Models (LVLMs) have revolutionized AI's ability to interpret visual data. However, these models are computationally intensive. When processing an image, models like LLaVA decompose it into hundreds of visual tokens, each requiring processing through every transformer layer. This leads to significant memory and FLOPs (Floating Point Operations) demands.

FastV is a plug-and-play inference acceleration method designed to address this inefficiency. It reduces computational costs by up to 45% with negligible performance impact by identifying and pruning redundant visual tokens mid-inference.

The FastV Methodology

The core of FastV lies in a key observation: while LVLMs require dense visual information in early layers to grasp a scene, they largely ignore these tokens in deeper layers.

The "Anchor Token" Phenomenon

Analysis of attention maps reveals that in shallow layers (Layers 1-2), attention is distributed across image tokens. However, from Layer 3 onwards, attention shifts dramatically toward "anchor tokens"—non-image tokens such as the system prompt or instruction text. These anchor tokens effectively "digest" the visual information early on, rendering many raw image tokens redundant for subsequent processing.

Attention allocation shifts from image tokens in shallow layers to anchor tokens (e.g., system prompt) in deep layers.

Pruning Mechanism

FastV implements a dynamic pruning strategy defined by two parameters: the filtering layer ($K$) and the filtering ratio ($R$).

  1. Processing: The model processes all tokens normally up to layer $K$.
  2. Ranking: At layer $K$, image tokens are ranked based on their average attention scores.
  3. Discarding: The bottom $R\%$ of tokens—those with the least impact—are discarded.
  4. Continuation: The remaining tokens proceed through the rest of the network.

Because FastV requires no retraining or fine-tuning, it is immediately compatible with existing open-source models like LLaVA, Qwen-VL, and Video-LLaVA.

Experimental Results

The researchers evaluated FastV across a wide range of benchmarks, including image captioning (Nocaps), VQA (OCR-VQA), and expert reasoning (MMMU).

Efficiency and Performance

FastV achieves a significant reduction in computational overhead. For LLaVA-1.5-13B, the method achieved a 45% reduction in FLOPs with almost no performance loss. In real-world latency tests on an A40 GPU, inference time for a 13B model was reduced from 10 minutes to 6.5 minutes, effectively matching the speed of a 7B model while retaining the accuracy of the larger architecture.

FastV's efficiency/performance trade-off across different models, demonstrating substantial FLOPs reduction with minimal impact on average performance.

Video Understanding

The benefits are even more pronounced in video tasks. Due to high temporal redundancy, FastV can discard massive amounts of background data across frames. In some instances, such as the TGIF benchmark, FastV actually improved performance by removing "noise" tokens that might otherwise distract the model.

Discussion and Limitations

While FastV is highly effective, model sensitivity varies. For instance, InstructBLIP, which uses a Q-Former for pre-compression, requires pruning at a later stage (Layer 5) to maintain stability. Future work may involve more sophisticated ranking functions or integrating sparsity constraints during the training phase to develop natively efficient models.

Summary updated

BibTeX
@inproceedings{chen2024image,
  author = {Liang Chen and Haozhe Zhao and Tianyu Liu and Shuai Bai and Junyang Lin and Chang Zhou and Baobao Chang},
  title = {{An Image is Worth 1/2 Tokens After Layer 2: Plug-and-Play Inference Acceleration for Large Vision-Language Models}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-73004-7\_2},
}
Figure