Papers › Efficient Token Compression for Vision Transformer with Spatial Information Preserved

Efficient Token Compression for Vision Transformer with Spatial Information Preserved

30 Mar 2025arXiv:2503.23455archive 2025-07-28

Junzhu Mao, Yang shen, Jinyang Guo, Yazhou Yao, Xiansheng Hua

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× 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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2503.23455")

Code

Syntology Ran 0 of 14 code samples harvested from 1 repository linked to this paper; 14 have no recorded run.

By repository: official repository: 14 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

nust-machine-intelligence-laboratory/prune_and_merge officialmentioned in paperpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

14 samples harvested; 0 ran; 0 honoured the contract we drafted; 14 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

14unverified

Licence: 14 of the 14 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from nust-machine-intelligence-laboratory/prune_and_merge. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

build_dataset nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/datasets.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 43f5d3f52fed74d4 · report
build_transform nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/datasets.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 298ab77e1ac660f2 · report
gauss_norm nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/tm_prune_merge_to_center.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 3c5eb850c7f680b1 · report
get_deit_base_patch16_224_config nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/config.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 49fe8666e9499cf8 · report
get_deit_small_patch16_224_config nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/config.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 4697a5e7358211b5 · report
get_deit_tiny_patch16_224_config nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/config.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 7288f110b9b4d4dd · report
load_matrix nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/visualize.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 22479ea1d7d13ebb · report
max_norm nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/tm_prune.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 9555f12025653843 · report
mean_norm nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/tm_prune.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · bc76c12550d19a97 · report
normalize nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/tm_prune_merge_to_center.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 43fe6cf78ba8bdc7 · report
normalize nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/tm_prune.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 971af9b36e21c087 · report
process_blocks nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/visualize.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 97427a40f42cf47b · report
set1_except0 nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/tm_prune_merge_to_center.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · f5f252851e922349 · report
split_image nust-machine-intelligence-laboratory/prune_and_merge/pm-vit/visualize.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 2d962204e7a5f59a · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AttentionPruningSoftmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections