A Perceiver resampler is a neural module that converts a variable number of visual features into a small, fixed number of output tokens by letting a set of learned latent queries attend to those features through cross-attention. In multimodal AI, it sits between a vision encoder and a language model, so that an image or a video clip of any length reaches the language model as, for example, 64 compact visual tokens instead of hundreds or thousands of patch embeddings.
The module was popularized by the Flamingo family of vision-language models, which adapted ideas from the earlier Perceiver architecture. It belongs to the broader group of multimodal projectors and is one of the main techniques for visual token compression in artificial intelligence systems that combine images, video and text.
How the Perceiver resampler compresses visual features
The Perceiver resampler works by giving a fixed set of trainable vectors, called latents or queries, the job of summarizing whatever the vision encoder produced. A frozen encoder first turns each image or video frame into a grid of patch embeddings. These embeddings are flattened into one long sequence, and temporal position embeddings are added for video so that the module knows which frame each feature came from.
Each resampler layer then performs cross-attention from latents to features: the latents form the queries, while the keys and values come from the visual features concatenated with the latents themselves. A feed-forward block with residual connections follows. After several such layers, typically six in the original Flamingo design, the latents hold a condensed description of the visual input and are passed on as visual tokens.
The decisive property is that output length no longer depends on input length. Whether the encoder delivers 256 features for one image or 8,000 features for a short clip, the language model always receives the same number of tokens, which keeps its context budget and memory use predictable.
The following table summarizes the main components and the role each one plays in the module.
| Component | What it does | Typical setting |
|---|---|---|
| Learned latent queries | Hold the compressed summary | 32 to 256 vectors |
| Cross-attention layer | Reads from visual features | Several heads per layer |
| Feed-forward block | Transforms latent content | Width about 4x model dimension |
| Temporal embeddings | Mark frame order in video | One vector per frame index |
| Layer stack | Refines the summary iteratively | 1 to 6 layers |
Key parameters and design choices
The most important design choice is the number of latent queries, because it sets the trade-off between visual detail and language model cost. Fewer latents mean shorter sequences and faster inference, but they also limit how much fine-grained information, such as small text in a document, can survive the compression.
The table below shows how the main parameters influence quality and cost.
| Parameter | Effect when increased | Main cost |
|---|---|---|
| Number of latents | More retained visual detail | Longer language model sequence |
| Number of layers | Richer, more selective summary | More training compute |
| Input resolution | Finer source features | Quadratic growth in encoder cost |
| Frames per clip | Better temporal coverage | Larger cross-attention input |
Because attention runs from M latents to N input features, the cost of each layer grows roughly with M times N rather than N squared. This linear scaling in input length is what makes the design attractive for video and for high-resolution images that produce very long feature sequences.
Perceiver resampler compared with other multimodal projectors
The Perceiver resampler is one of several ways to connect a vision encoder to a language model, and each approach balances token count against fidelity differently. The closest relative is the Q-Former of BLIP-2, which also uses learned queries but adds text interaction and a separate pretraining stage. Simple linear or MLP projectors, used in many instruction-tuned models, keep every patch token and therefore preserve more detail at higher cost.
This comparison highlights how the main connector types differ in practice.
| Connector | Output token count | Main strength | Main weakness |
|---|---|---|---|
| Perceiver resampler | Fixed, small | Predictable cost for video | Can lose fine detail |
| Q-Former | Fixed, small | Text-aware query learning | Extra pretraining stage |
| MLP projector | Equal to patch count | High fidelity, simple | Long visual sequences |
| Pooling or pixel shuffle | Reduced by fixed ratio | Cheap and spatially faithful | Rigid compression rate |
In Flamingo, the resampler output feeds gated cross-attention layers inserted into a frozen language model, rather than being placed directly into the input sequence. Later open models often use resampler-style modules with a single cross-attention layer and place the resulting tokens straight into the prompt, which simplifies training.
Where the Perceiver resampler is used
A Perceiver resampler is most useful when the system must handle many images or long video inside a limited context window. Interleaved image-text documents, multi-frame video question answering and multimodal in-context learning with several example images all benefit, because each visual input costs the same small number of tokens.
- Video-language models that sample dozens of frames per clip and need a stable token budget.
- Few-shot multimodal prompting, where several image-text demonstrations must fit in one prompt.
- On-device vision assistants, where shorter sequences reduce latency and memory.
- Frozen-backbone training, where only the resampler and adapters are updated to save compute.
Limitations and common mistakes
The main limitation is information loss from fixed compression. Tasks that depend on small details, such as chart understanding, optical character recognition in dense documents or precise visual grounding, often degrade when only a few dozen latents represent a high-resolution page. Many recent models therefore prefer higher token counts or combine resampling with dynamic image tiling.
The table lists frequent problems, their usual cause and a practical remedy.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Small text is misread | Too few latents for page | Add latents or use image tiles |
| Object positions are wrong | Weak spatial information | Add 2D position embeddings |
| Frame order is confused | Missing temporal embeddings | Encode frame index explicitly |
| Training is unstable | Resampler learns too fast | Lower learning rate, warm up |
A common misconception is that the latents correspond to fixed image regions. They do not: each latent learns to collect whatever information proves useful, so a single latent may draw from many regions, and interpretability is limited without dedicated probing.
A plain-language summary
Picture a reporter who must describe any event in exactly sixty-four short notes. A small event and a huge one both get the same number of notes. The reporter learns what matters and leaves the rest out.
A Perceiver resampler does this for pictures and videos. It reads everything the image system saw and writes a fixed, short summary for the language model. This keeps the model fast. The cost is that tiny details can be lost.
An example from practice
A team building a video question answering assistant for warehouse safety footage samples 32 frames from each two-minute clip. A vision transformer produces 256 patch features per frame, which would mean 8,192 visual tokens if passed through directly, far too many for the language model they want to run on a local GPU.
They insert a Perceiver resampler with 64 latent queries and temporal embeddings for frame order. Each clip now costs only 64 tokens, so the assistant can compare several clips in one prompt. Answers about whether a forklift entered a pedestrian zone stay accurate, while reading small labels on boxes becomes unreliable, so the team adds a separate high-resolution crop step for those questions.