Efficient Visual Transformer by Learnable Token Merging

Yancheng Wang, Yingzhen Yang
7/21/2024
cs.CVcs.LG

Official code: Statistical-Deep-Learning/LTM (5 stars, last commit 2025-07-08).

Abstract

Self-attention and transformers have been widely used in deep learning. Recent efforts have been devoted to incorporating transformer blocks into different neural architectures, including those with convolutions, leading to various visual transformers for computer vision tasks. In this paper, we propose a novel and compact transformer block, Transformer with Learnable Token Merging (LTM), or LTM-Transformer. LTM-Transformer performs token merging in a learnable scheme. LTM-Transformer is compatible with many popular and compact transformer networks, and it reduces the FLOPs and the inference time of the visual transformers while maintaining or even improving the prediction accuracy. In the experiments, we replace all the transformer blocks in popular visual transformers, including MobileViT, EfficientViT, ViT, and Swin, with LTM-Transformer blocks, leading to LTM-Transformer networks with different backbones. The LTM-Transformer is motivated by reduction of Information Bottleneck, and a novel and separable variational upper bound for the IB loss is derived. The architecture of the mask module in our LTM blocks, which generates the token merging mask, is designed to reduce the derived upper bound for the IB loss. Extensive results on computer vision tasks evidence that LTM-Transformer renders compact and efficient visual transformers with comparable or much better prediction accuracy than the original visual transformers. The code of the LTM-Transformer is available at https://github.com/Statistical-Deep-Learning/LTM}

View on arXivView PDF

Code Implementations(1)

Code for LTM.

50MDX, ShellMay 31, 20241 years ago

Similar Papers

Cite this paper

@article{wang2024efficient,
  title  = {Efficient Visual Transformer by Learnable Token Merging},
  author = {Yancheng Wang and Yingzhen Yang},
  year   = {2024},
  eprint = {2407.15219},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2407.15219v2}
}

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/2407.15219.svg)](https://codeofpaper.com/paper/2407.15219)

Discussion