Visual token compression

Also known as: visual token pruning

On this page 7

Visual token compression is the family of techniques that reduces the number of visual tokens an image or video contributes to a multimodal model before or during inference, so that the language model processes a shorter sequence at lower cost. In multimodal AI, a single high-resolution image can expand into hundreds or thousands of tokens, and a few minutes of video can exceed the context window entirely; compression keeps the information that matters for the task while discarding redundancy.

The approach is also called visual token pruning when tokens are removed rather than merged or resampled. It sits between the vision encoder and the language model, or inside the early layers of the language model, and it is now a standard design lever for latency, memory and context budget in vision-language systems.

Why visual tokens need compression

Visual tokens are expensive because attention cost grows quadratically with sequence length, and the key-value cache grows linearly with every token kept. A vision transformer with a 14-pixel patch size turns a 336 by 336 image into 576 patch tokens; dynamic image tiling at higher resolutions multiplies that count by the number of tiles. Many of these tokens describe uniform background, sky or blank page margins, which carry little information for the question being asked.

The typical token budgets below show how quickly the load grows. The figures are representative of common open architectures, and exact numbers depend on patch size, tiling strategy and frame sampling rate.

InputTypical encodingApproximate tokens
Single image, low resolution336 x 336, 14-pixel patches576
Single image, tiled high resolutionGlobal view plus 4 to 6 tiles2,500 to 4,000
Scanned document pageDense tiling for small text2,000 to 6,000
One minute of video1 frame per second, 576 tokens per frameAbout 34,000
Typical visual token counts before compression

Main families of visual token compression

Compression methods differ in where they act and whether they need training. Some reshape the encoder output with a learned module, while others score and drop tokens at inference time without changing any weights. The choice determines how much accuracy is lost and how easily the method can be added to an existing model.

FamilyMechanismTraining neededTypical reduction
Spatial poolingAverage or strided pooling of neighboring patchesLight fine-tuning4x
Learned resamplerFixed set of query tokens attends to all patchesYes576 to 32-144 tokens
Token mergingSimilar tokens are averaged into oneOften none2x to 4x
Attention-based pruningTokens with low attention scores are droppedNone2x to 10x
Text-guided selectionTokens irrelevant to the prompt are removedOptionalTask dependent
Temporal compressionRedundant tokens across video frames are mergedVaries5x to 20x for video
Families of visual token compression

A learned resampler, such as a Perceiver resampler or a Q-Former style module, produces a fixed number of output tokens regardless of image size. Training-free pruning, by contrast, reads the attention map inside the language model after a few layers and removes tokens that receive little attention from the text, which makes it attractive for retrofitting deployed models.

How compression interacts with the model pipeline

Compression can occur at three points in the pipeline: inside the vision encoder, in the multimodal projector, or in the early layers of the language model. Earlier compression saves more compute, because every later layer processes fewer tokens, but it has less information about the question and therefore risks discarding a detail the user later asks about.

  • Encoder-side compression merges patches before projection and saves the most computation overall.
  • Projector-side compression reshapes or pools tokens while mapping them into the language embedding space.
  • Language-model-side pruning uses prompt-aware attention after two or three layers to decide which tokens survive.

Visual token compression is related to, but distinct from, prompt compression, which shortens text instructions, and from KV cache quantization, which keeps every token but stores it at lower precision. The techniques combine well, because they reduce different dimensions of the same memory budget.

Choosing a compression strategy

The right strategy depends on what the task needs to see. Fine-grained tasks such as reading small text or counting objects tolerate far less compression than scene description or general visual question answering. The decision table below summarizes common situations.

SituationRecommended approachReason
Document and chart understandingMild compression, keep high resolutionSmall glyphs vanish under pooling
General image captioningResampler or 4x poolingGlobal content survives aggressive reduction
Long video question answeringTemporal merging plus frame samplingAdjacent frames are highly redundant
Deployed model, no retraining budgetTraining-free attention pruningNo weight changes required
On-device or edge inferenceStrong pooling with a small encoderMemory is the binding constraint
Decision guide for compression strength

Practitioners should measure on the target task, not on a generic benchmark, because average scores can hide sharp drops on the specific skills that matter. A useful protocol is to sweep the retention ratio from 100 percent down to 10 percent and plot accuracy against latency for each task category.

Limitations and failure modes

The central trade-off is efficiency against fine detail. Removing tokens is irreversible within a forward pass, so a question about a small object in a pruned region cannot be answered correctly, and the model may then produce multimodal hallucination instead of admitting uncertainty.

SymptomLikely causeMitigation
Misread numbers in tablesPooling merged adjacent charactersLower ratio for text-heavy inputs
Missed small objectsAttention pruning favored salient regionsKeep a uniform sample of tokens
Wrong spatial answersPositional information lost in mergingPreserve position embeddings per token
Inconsistent results across promptsText-guided selection depends on wordingPrune after a stable instruction prefix
Common failure modes and mitigations

Another subtle issue is compatibility with efficient attention kernels. Some pruning methods need the full attention matrix to score tokens, which conflicts with fused kernels that never materialize it, so the theoretical speedup may not appear in wall-clock measurements. Reported savings should always be verified on the actual serving stack.

The short version

An AI model that looks at pictures first cuts each picture into many small pieces. Each piece becomes a token, much like a word in a sentence. A sharp photo can become thousands of these pieces, and reading them all is slow and costly.

Visual token compression keeps the useful pieces and drops or combines the rest. A blue sky does not need two hundred pieces to say it is blue. The model then answers faster and uses less memory. The catch is simple: squeeze too hard and small details disappear, such as fine print or a distant sign.

Where it makes a difference

A logistics company runs a vision-language model that answers questions about warehouse camera footage. Each query covers a two-minute clip sampled at one frame per second, which produces about 69,000 visual tokens and exceeds the model’s comfortable context budget. Responses take more than 20 seconds and the graphics processor runs out of memory under concurrent load.

The engineering team adds temporal token merging that combines nearly identical tokens across consecutive frames, followed by attention-based pruning in the third layer of the language model. The sequence shrinks to roughly 7,000 tokens, a reduction of about ten times. Median response time falls to under four seconds, and accuracy on the team’s internal question set drops by less than two points. For questions about reading pallet labels, the team routes queries to an uncompressed high-resolution path, because tests showed that compression erased the small printed codes.