arXiv:2503.23455cs.CVcs.MM2025-03中稿 · IEEE Transactions …被引 2

提出可硬件部署的视觉变换器令牌压缩方法,高效保留空间信息。

Efficient Token Compression for Vision Transformer with Spatial Information Preserved

  • 通过可训练的合并与重建矩阵实现逐层令牌压缩
  • 在ImageNet-1k上实现1.64倍加速,仅损失0.2%准确率
  • 自动识别最优压缩结构,适合资源受限场景部署

令牌压缩对于降低Transformer模型的计算与内存开销至关重要,有助于其在资源受限环境中的部署。本文提出一种高效且硬件兼容的令牌压缩方法——Prune and Merge。该方法将令牌剪枝与合并操作集成于Transformer模型中,实现逐层压缩。通过引入可训练的合并与重建矩阵,并结合捷径连接,可在高效合并令牌的同时保留关键信息,并支持被剪枝令牌的恢复。此外,我们提出一种新型梯度加权注意力评分机制,在训练阶段计算令牌重要性得分,避免推理时额外计算,提升压缩效率。同时利用梯度信息捕捉令牌的全局影响,自动识别最优压缩结构。在ImageNet-1k和ADE20K数据集上的大量实验验证了方法的有效性,相较于现有最优方法取得显著加速,且精度损失极小。例如,在DeiT-Small上,于ImageNet-1k上实现1.64×加速,准确率仅下降0.2%。通过压缩分割模型并与现有方法对比,进一步证明本方法在效率与效果上的优越性。代码与模型已开源:https://github.com/NUST-Machine-Intelligence-Laboratory/prune_and_merge。

原文摘要 · Abstract (English)

Token compression is essential for reducing the computational and memory requirements of transformer models, enabling their deployment in resource-constrained environments. In this work, we propose an efficient and hardware-compatible token compression method called Prune and Merge. Our approach integrates token pruning and merging operations within transformer models to achieve layer-wise token compression. By introducing trainable merge and reconstruct matrices and utilizing shortcut connections, we efficiently merge tokens while preserving important information and enabling the restoration of pruned tokens. Additionally, we introduce a novel gradient-weighted attention scoring mechanism that computes token importance scores during the training phase, eliminating the need for separate computations during inference and enhancing compression efficiency. We also leverage gradient information to capture the global impact of tokens and automatically identify optimal compression structures. Extensive experiments on the ImageNet-1k and ADE20K datasets validate the effectiveness of our approach, achieving significant speed-ups with minimal accuracy degradation compared to state-of-the-art methods. For instance, on DeiT-Small, we achieve a 1.64$\times$ speed-up with only a 0.2\% drop in accuracy on ImageNet-1k. Moreover, by compressing segmenter models and comparing with existing methods, we demonstrate the superior performance of our approach in terms of efficiency and effectiveness. Code and models have been made available at https://github.com/NUST-Machine-Intelligence-Laboratory/prune_and_merge.

视觉变换器令牌压缩硬件兼容高效推理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。