Spectrum-Preserving Token Merging (PiToMe)
Transformers spend most of their compute on attention, which is quadratic in the number of tokens. You can merge redundant tokens to shrink that count, but merge the wrong ones and you throw away information. PiToMe adds an energy score that flags which tokens sit in a dense, redundant neighbourhood (safe to merge) versus which are isolated and informative (protect), and it comes with a spectral guarantee: the merged token graph keeps almost the same Laplacian spectrum. Step through the layers and watch PiToMe protect the informative tokens while naive ToMe merges them away and its spectral distance climbs.
Each dot is a token (a feature vector, shown here in 2D). The scene has three dense clusters of redundant tokens plus a handful of isolated informative token pairs sitting on their own. Similarity is a Gaussian kernel of feature distance, simij = exp(−‖xi−xj‖² / 2σ²) with zero diagonal (on real features the paper uses cosine similarity of L2-normalized keys). PiToMe's novelty is the energy score Ei = meanj ELU(simij − m): a token surrounded by many similar tokens scores high (redundant, safe to merge), an isolated token scores low (informative, protect). Each layer removes r = floor(N − N·ratio) tokens: sort by energy, mark the top 2r as mergeable and pass the rest through untouched, then do bipartite soft matching inside the mergeable set (sources = mergeable[::2] each merged into their most-similar destination = mergeable[1::2]) via a size-weighted average, so a merged token's circle grows with the patches it represents and attention FLOPs (∝ N²) fall. The right panel is the money shot: it builds the normalized Laplacian L = I − D−1/2 A D−1/2 and compares the leading eigenvalues of the original vs merged token graph. PiToMe merges only redundant tokens, so those eigenvalues barely move and the spectral distance stays near zero (the spectrum-preserving guarantee, Theorem 1); naive ToMe matches purely by raw similarity with no protection, so it merges the isolated informative tokens away and its spectral distance climbs. (This is a 2D didactic illustration of the exact energy-score + protect-then-merge + spectral-distance mechanism, run to about 50% token reduction, the paper's operating regime; at extreme compression even PiToMe must eventually touch the informative tokens. The published method applies PiToMe off-the-shelf to ViT, CLIP, BLIP, BERT and LLaVA, saving 40–60% FLOPs with under 1% accuracy drop. TrungTin Nguyen is a co-author.)
Run the experiments
Every animation runs live in your browser. Click a button to play that experiment on the demo (it scrolls up and starts); drag any control to take over. Nothing is downloaded.
Merge the token layers
Step through the encoder layers: redundant tokens merge while the informative ones are protected and the graph spectrum is preserved.
PiToMe vs naive ToMe
Flip the policy and compare the spectral distance: PiToMe protects the informative pairs, ToMe merges them away.
Keep ratio
Merge more or fewer tokens per layer.
Energy margin m
Sweep the ELU energy margin that separates redundant from informative tokens.
The idea in three steps
Merging tokens is cheap; merging the right tokens is the whole game. PiToMe turns "which tokens are redundant?" into a scored, protectable quantity and proves the merge keeps the graph spectrum.
Energy = redundancy
Each token's energy averages ELU(similarity − margin) over the others. A token in a dense, similar neighbourhood scores high (redundant); an isolated token scores low (informative), so redundancy becomes a number you can rank.
Keep the informative ones
Sort by energy: the lowest-energy tokens are passed through untouched, and only the high-energy redundant tokens enter the bipartite soft matching, merged by a size-weighted average. ToMe, matching by raw similarity, has no such protection.
The eigenvalues stay put
Because only redundant tokens merge, the normalized-Laplacian spectrum is provably almost unchanged (Theorem 1). The running spectral distance makes this visible: PiToMe stays near zero, ToMe drifts up as it destroys informative structure.
For the energy score, the dynamic per-layer margin, the spectrum-preserving theorem and the ViT / CLIP / BLIP / BERT / LLaVA results, see Accelerating Transformers with Spectrum-Preserving Token Merging (Tran, Duy M. H. Nguyen, Duy M. Nguyen, TrungTin Nguyen, Le, Xie, Sonntag, Zou, Binh T. Nguyen & Niepert, NeurIPS 2024) and the PiToMe code.