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.
Glossary
Token Merging (ToMe)

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.
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.
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.
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.
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.
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
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.
Related Terms
Token Merging (ToMe) is part of a broader ecosystem of techniques designed to make Vision Transformers computationally tractable for high-resolution medical imaging. Explore the related concepts that complement or contrast with this training-free acceleration method.
Gradient Checkpointing
A memory optimization technique that trades compute for memory. During the forward pass, intermediate activations are discarded rather than stored. During the backward pass, these activations are recomputed on demand from the nearest saved tensors. This allows training larger Vision Transformer models on high-resolution medical images with limited GPU memory. While ToMe reduces the computational graph size directly, gradient checkpointing addresses memory constraints without altering the model's forward computation.
Deformable Attention
A sparse attention mechanism where each query attends only to a small, learned set of sampling locations around a reference point, rather than all tokens. This enables efficient multi-scale feature aggregation with linear complexity relative to image resolution. Unlike ToMe, which merges redundant tokens globally, deformable attention avoids computing attention over irrelevant regions entirely, making it particularly effective for object detection in high-resolution radiology scans.
Mixed Precision Training
A training paradigm that uses lower-precision 16-bit floating-point (FP16 or BF16) for most arithmetic operations while maintaining a master copy of weights in 32-bit precision. This reduces memory consumption by nearly half and accelerates computation on modern tensor-core GPUs. When combined with ToMe during inference, mixed precision further compresses the model's runtime footprint, enabling deployment of diagnostic Vision Transformers on edge hardware with limited resources.
Stochastic Depth
A regularization technique that randomly drops entire residual blocks during training, forcing the network to learn robust representations that do not depend on any single computational path. This reduces training time and acts as an implicit model ensemble. While ToMe permanently merges tokens to reduce inference cost, stochastic depth provides a complementary benefit during the training phase by preventing co-adaptation of layers, which can improve the model's tolerance to token reduction at inference.
Vision Mamba (Vim)
A vision backbone that applies a bidirectional state space model (SSM) to sequences of image patches, offering linear-time complexity as an alternative to the quadratic self-attention of Vision Transformers. Unlike ToMe, which retrofits efficiency onto a standard ViT, Vim is architected from the ground up for linear scaling. For medical imaging tasks requiring processing of gigapixel whole slide images, Vim represents a competing paradigm to token reduction strategies.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us