Inferensys

Glossary

Flamingo

Flamingo is a family of few-shot learning capable vision-language models from DeepMind that processes interleaved sequences of visual and textual data using a novel perceiver-resampler architecture.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
MULTI-MODAL RAG

What is Flamingo?

Flamingo is a pioneering family of vision-language models from DeepMind, notable for its few-shot learning capabilities and its novel architecture for processing mixed visual and textual data.

Flamingo is a family of few-shot learning capable vision-language models (VLMs) developed by DeepMind that processes interleaved sequences of images, videos, and text. Its core innovation is a perceiver-resampler architecture, which converts a variable number of visual features from a frozen image encoder into a fixed set of visual tokens. These tokens are then interleaved with text tokens and fed into a large, frozen language model, enabling in-context, multi-modal reasoning without extensive task-specific fine-tuning.

The model's design decouples visual feature extraction from language modeling, allowing it to leverage powerful pre-trained components efficiently. By demonstrating strong few-shot and zero-shot performance on tasks like visual question answering and captioning, Flamingo established a key architectural pattern for combining large language models with visual understanding. It is a direct precursor to modern multi-modal systems used in retrieval-augmented generation (RAG) that ground responses in both textual and visual data.

FLAMINGO

Key Architectural Features

Flamingo is a family of few-shot learning capable vision-language models from DeepMind that processes interleaved sequences of visual and textual data using a novel perceiver-resampler architecture.

01

Perceiver-Resampler Architecture

The core innovation enabling Flamingo's few-shot learning. A fixed, pre-trained Perceiver Resampler module ingests a variable number of image or video frames and outputs a fixed, small number of visual tokens. This acts as a learned bottleneck, converting high-dimensional pixel data into a manageable sequence that a frozen, pre-trained Large Language Model (LLM) can process alongside text tokens. This design allows the LLM's powerful text-based reasoning to be applied to visual inputs without expensive end-to-end retraining.

02

Frozen Language Model Backbone

Flamingo leverages a massive, pre-trained language model (e.g., Chinchilla) that remains frozen during vision-language training. Only the newly added components—the Perceiver Resampler and cross-attention layers—are trained. This is a form of parameter-efficient tuning, preserving the LLM's world knowledge, reasoning, and few-shot abilities while economically adding visual understanding. The model generates text autoregressively based on the fused visual-textual context.

03

Cross-Attention Dense Fusion

To deeply integrate visual and textual information, Flamingo inserts gated cross-attention dense (GCD) layers between the layers of the frozen LLM. At each decoder layer, these modules allow text representations to attend to all visual tokens from the resampler output. This creates a tight, iterative fusion where language generation is continuously grounded in the visual context, enabling detailed visual question answering and captioning.

04

Interleaved Visual-Textual Inputs

Flamingo is trained on and natively supports arbitrarily interleaved sequences of images/videos and text. This mirrors how humans process multimodal information (e.g., a textbook with diagrams and paragraphs). The model architecture treats this interleaved sequence as a unified input stream, allowing it to handle complex tasks like:

  • Visual dialogue (multiple turns about an image)
  • Contextual few-shot learning (interleaved examples)
  • Story understanding from image sequences
05

Few-Shot In-Context Learning

A defining capability inherited from its large language model backbone. Flamingo can perform new tasks with zero or few examples provided in the prompt, without gradient updates. For example, given an interleaved prompt containing an image, a question, and an answer (as a demonstration), it can answer a new question about a different image. This makes it highly flexible and reduces the need for extensive task-specific fine-tuning.

06

Training on Massive Web Data

Flamingo was trained on a colossal, diverse dataset of interleaved image-text sequences scraped from the web, including pages from social media and encyclopedias. This large-scale, noisy pre-training is crucial for developing robust cross-modal representations. The training objective combines standard language modeling loss on text tokens with the novel integration of visual data through the perceiver-resampler and cross-attention mechanisms.

ARCHITECTURE OVERVIEW

How the Flamingo Architecture Works

Flamingo is a family of vision-language models from DeepMind designed for few-shot learning on tasks involving both images and text.

The Flamingo architecture processes interleaved sequences of visual and textual data using a novel perceiver-resampler module. This component converts a variable number of image features from a frozen vision encoder into a fixed number of visual tokens. These tokens are then seamlessly integrated into a large, frozen language model, enabling the system to handle arbitrary sequences of images and text for in-context learning.

Key to its design is the gated cross-attention mechanism, which allows the frozen language model to condition its text generation on the processed visual tokens. By keeping the core vision and language backbones frozen and training only the connecting components, Flamingo achieves strong few-shot and zero-shot performance on multimodal benchmarks without full model fine-tuning, establishing a template for efficient large-scale multimodal model development.

ARCHITECTURAL INNOVATIONS

Capabilities and Use Cases

Flamingo's novel perceiver-resampler architecture enables it to process arbitrary sequences of images and text for few-shot learning, setting a foundation for modern multimodal reasoning.

01

Few-Shot In-Context Learning

Flamingo's core capability is few-shot learning from interleaved image-text examples. Unlike models requiring extensive fine-tuning, Flamingo can perform new tasks by conditioning on just a few examples provided in its input context. This is enabled by its cross-attention layers that bridge the frozen vision and language models, allowing the language model to learn from visual demonstrations without updating its weights.

  • Example: Provide 2-3 examples of 'image → caption' or 'image, question → answer' to solve novel visual question answering tasks.
  • Mechanism: The perceiver-resampler converts variable-sized images into a fixed set of visual tokens, which are seamlessly integrated into the language model's sequence.
02

The Perceiver-Resampler Architecture

This is Flamingo's key innovation for handling variable visual inputs. The perceiver-resampler is a transformer-based module that sits between the frozen vision encoder and the frozen language model.

  • Function: It takes the high-dimensional visual features from the vision encoder (e.g., a NFNet) and resamples them into a fixed, manageable number of visual tokens.
  • Purpose: This allows the model to process any number of input images or video frames and present a consistent number of tokens to the language model's cross-attention layers.
  • Benefit: Enables efficient processing of long, interleaved sequences of images and text, which is critical for conversational and reasoning tasks.
03

Open-Domain Visual Dialogue

Flamingo excels at open-ended dialogue about images and videos. By processing an interleaved history of user messages and images, it can conduct coherent, multi-turn conversations grounded in visual content.

  • Use Case: A user can upload an image and ask follow-up questions (e.g., "What is this device?" → "How does its mechanism work based on the visible components?").
  • Technical Basis: The model's training on massive web-scale alt-text data allows it to handle a vast array of subjects and infer context not explicitly stated in the prompt.
  • Distinction: This goes beyond simple captioning to include explanation, comparison, and hypothetical reasoning about visual scenes.
04

Video Understanding and Reasoning

The architecture naturally extends to video processing by treating a video as a sequence of frames. Flamingo can reason across temporal events, making it suitable for complex video understanding tasks.

  • Capability: Answer questions about actions, causality, and sequences of events within a video clip.
  • Implementation: Multiple frames are encoded and passed through the perceiver-resampler, creating a temporal sequence of visual tokens for the language model to attend to.
  • Benchmark Performance: Achieved state-of-the-art results on benchmarks like VQAv2, OK-VQA, and TVQA at the time of its release, demonstrating strong few-shot performance.
05

Interleaved Text-Image Generation

While primarily a discriminative model (for understanding), Flamingo's decoder-only language model backbone allows it to perform generative tasks. It can create coherent text that references previously shown images in a sequence.

  • Example Task: Given an image and a text prompt ("Write a story about this scene:"), Flamingo can generate a narrative.
  • Connection to Modern VLMs: This generative capability directly influenced later autoregressive vision-language models like GPT-4V, which use similar principles for interleaved generation.
  • Limitation: As a model from its era, it does not generate images; it generates text conditioned on input images.
06

Foundation for Modern Multimodal RAG

Flamingo's design principles are foundational for Multi-Modal Retrieval-Augmented Generation (RAG). Its ability to ground language generation in visual context is the conceptual precursor to retrieving and fusing multimodal documents.

  • Architectural Blueprint: The use of a frozen pretrained language model augmented with visual inputs is a standard pattern for efficiency.
  • Retrieval Analogy: The perceiver-resampler acts like a dynamic, learned retriever, condensing vast visual information into key tokens relevant for the language model's query (the text prompt).
  • Legacy: Techniques like cross-attention for modality fusion and few-shot in-context learning are now standard in systems that answer questions using retrieved images, charts, and diagrams.
ARCHITECTURAL COMPARISON

Flamingo Model Variants and Scale

A comparison of the primary Flamingo model variants, detailing their architectural scale, training data, and few-shot learning capabilities.

Architectural FeatureFlamingo-3BFlamingo-9BFlamingo-80B

Total Parameters

3 Billion

9 Billion

80 Billion

Vision Encoder Backbone

NFNet-F6

NFNet-F6

NFNet-F6

Language Model Backbone

Chinchilla-70M

Chinchilla-400M

Chinchilla-70B

Perceiver Resampler Layers

4
4
4

Cross-Attention Densities

Sparse

Sparse

Sparse

Pre-training Data (Image-Text Pairs)

~3B

~3B

~3B

Interleaved Vision-Language Data

Few-Shot Learning Capability

Reported VQA Accuracy (Zero-Shot)

~45%

~52%

~65%

Reported VQA Accuracy (4-Shot)

~52%

~58%

~70%

FLAMINGO

Frequently Asked Questions

Flamingo is a pioneering family of vision-language models from DeepMind. These technical FAQs address its core architecture, capabilities, and its foundational role in modern multi-modal AI systems.

Flamingo is a family of few-shot learning capable vision-language models (VLMs) from DeepMind that processes interleaved sequences of visual and textual data using a novel perceiver-resampler architecture. It works by first encoding images and videos with a frozen, pre-trained vision encoder (like a CNN or Vision Transformer). These visual features are then processed by a key innovation: the Perceiver Resampler. This module acts as a learned, fixed-length bottleneck, converting a variable number of image patches into a fixed, smaller set of visual tokens. These visual tokens are then interleaved with text tokens and fed into a frozen, large language model (LM). The LM, conditioned on these visual tokens, generates the final textual output. Crucially, only the parameters of the Perceiver Resampler and some cross-attention layers are trained, making the model highly parameter-efficient.

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.