Inferensys

Glossary

Token Merging (ToMe)

A training-free acceleration technique that reduces the number of tokens in a Vision Transformer by gradually merging similar redundant tokens together, significantly decreasing computational cost with minimal accuracy loss.
Executive discussing AI vision with advisor, charts and projections visible, corner office afternoon meeting.
TRAINING-FREE ACCELERATION

What is Token Merging (ToMe)?

A computational optimization technique that reduces the token count in Vision Transformer models by progressively merging similar, redundant tokens, thereby decreasing FLOPs and latency with negligible impact on accuracy.

Token Merging (ToMe) is a training-free acceleration method for Vision Transformers that reduces the number of image patch tokens processed by the model. It works by identifying and combining the most similar redundant tokens in each transformer block using a lightweight bipartite soft matching algorithm, effectively pruning the input sequence without requiring any retraining or fine-tuning of the original model weights.

By gradually merging tokens throughout the network's layers, ToMe achieves a significant reduction in computational complexity—often cutting FLOPs by 40-50%—while preserving the high-resolution details necessary for dense prediction tasks. This makes it particularly valuable for deploying large vision models in resource-constrained environments or accelerating throughput in high-volume medical imaging pipelines.

TRAINING-FREE ACCELERATION

Key Features of Token Merging

Token Merging (ToMe) is a training-free acceleration technique that reduces the number of tokens in a Vision Transformer by gradually merging similar redundant tokens together, significantly decreasing computational cost with minimal accuracy loss.

01

Training-Free Integration

ToMe requires no fine-tuning, no re-training, and no additional data. It is applied directly to a pre-trained Vision Transformer as a plug-and-play module. This makes it immediately deployable on any existing ViT-based medical imaging pipeline without modifying the model's learned weights or requiring access to the original training dataset.

0
Additional Training Steps Required
02

Bipartite Soft Matching

The core algorithm partitions all tokens into two disjoint sets and, for each token in set A, finds the most similar token in set B using cosine similarity of their keys. Similar tokens are merged by averaging their features. This greedy, step-wise approach avoids the computational cost of global clustering while effectively identifying and eliminating redundancy.

03

Proportional Token Reduction

ToMe uses a scheduling function r(t) to define the number of tokens removed at each layer. A common strategy removes more tokens in deeper layers where redundancy is higher. For example, a ViT-L/16 model can drop from 197 tokens to as few as 8 tokens by the final block, achieving a 2-3x speedup on ImageNet with less than 0.5% accuracy drop.

2-3x
Typical Throughput Speedup
<0.5%
Accuracy Loss on ImageNet
04

Unmodified Attention Mechanism

Unlike sparse attention methods that alter the self-attention computation itself, ToMe physically reduces the number of tokens passed between Transformer blocks. The remaining attention operations are standard dense self-attention on a smaller set. This means ToMe is compatible with optimized attention kernels like FlashAttention without modification.

05

Medical Imaging Applicability

Medical images contain significant spatial redundancy—large regions of homogeneous tissue or background. ToMe is particularly effective here, as it can aggressively merge tokens in non-diagnostic background regions while preserving fine-grained tokens around lesions or anatomical boundaries. This makes it ideal for accelerating 3D volumetric analysis of CT and MRI scans.

06

Token Propagation with Trace

ToMe tracks which input tokens contribute to each merged token through a merge trace matrix. This enables the final output tokens to be un-merged back to the original spatial grid for dense prediction tasks like segmentation. The trace ensures that even after aggressive merging, pixel-level outputs remain spatially aligned with the input image.

TOKEN MERGING EXPLAINED

Frequently Asked Questions

Clear, technical answers to the most common questions about Token Merging (ToMe), a training-free acceleration technique for Vision Transformers.

Token Merging (ToMe) is a training-free acceleration technique that reduces the number of tokens in a Vision Transformer (ViT) by gradually merging similar, redundant tokens together. It works by partitioning the tokens in each transformer block into two equal sets using a bipartite matching algorithm based on cosine similarity. For each token in set A, the most similar token in set B is identified, and the two are merged by averaging their features. This process is repeated across the network, progressively pruning the token count without requiring any retraining or fine-tuning, significantly decreasing FLOPs with minimal accuracy loss.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.