Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Flamingo: a Visual Language Model for Few-Shot Learning

  • Problem Adapting a vision model to a new task usually needs thousands of annotated examples and per-task tuning, while contrastive vision-language models cannot generate open-ended text.
  • Method Flamingo keeps a vision encoder and a language model frozen, trains a Perceiver Resampler and tanh-gated cross-attention layers between the language-model blocks, and prompts the model with interleaved image, video and text examples.
  • Results Outperforms the fine-tuned state of the art on 6 of the 16 tasks with 32 task-specific examples, and sets new few-shot state of the art on the 9 tasks with published few-shot results.

What existing approaches cannot do

The usual way to adapt a vision model is to pretrain it on large supervised data and then fine-tune it on the target task. Successful fine-tuning often needs many thousands of annotated examples, and each task usually brings its own hyperparameter tuning and compute cost. Contrastive vision-language models transfer without fine-tuning, but they only output a similarity score between a text and an image.

That restricts them to tasks with a fixed, predefined set of outcomes such as classification, and they are weak for open-ended generation such as captioning or visual question answering.

Flamingo is aimed at both gaps: it generates text, and it adapts to a new task from a short prompt of input-output examples instead of from weight updates. The starting point is large language models, which can perform new tasks when a few examples are placed in the prompt alongside a query. The open question is how to give such a model images and videos and mix them freely with text inside one prompt.

Frozen backbones joined by trained bridges

Flamingo keeps two pretrained components frozen: a vision model that perceives the scene and a large language model that handles generation and a basic form of reasoning. New components are placed between these two models so that the knowledge each one has built up during pretraining is preserved. The result is a visually conditioned autoregressive text generator, and Figure 3 gives the overall flow from interleaved visual and text input to text output.

The vision encoder is an NFNet-F6, a Normalizer-Free ResNet, pretrained with a two-term contrastive loss on image-text pairs and then frozen. Its final stage gives a two-dimensional grid of features, which is flattened into a one-dimensional sequence. For video, frames are sampled at 1 FPS and each frame is encoded separately, then learned temporal embeddings are added to form a three-dimensional spatio-temporal grid before flattening.

The Perceiver Resampler turns a variable number of visual features into a fixed set of 64 visual tokens per image or video, which bounds the cost of the cross-attention that follows. It learns a predefined set of latent queries that a Transformer processes while cross-attending to the visual features.

The language model stays frozen, and new GATED XATTN-DENSE blocks are inserted between its original layers and trained from scratch. Inside each block, cross-attention takes its keys and values from the visual features and its queries from the language stream, and a dense feed-forward layer follows. The output of each new sub-layer is multiplied by tanh of a learnable scalar that starts at zero, so at initialisation the block adds nothing and the model matches the pretrained language model.

The authors credit this initialisation with more stable training and better final performance.

Flamingo models the likelihood of a text \(y\) given interleaved images and videos \(x\) as \(p(y|x)=\prod_{\ell=1}^{L} p(y_\ell \mid y_{<\ell}, x_{\leq \ell})\). Each token \(y_\ell\) is conditioned on the preceding tokens and on the images or videos that appear before it in the sequence, so the same expression covers interleaved prompts.

Per-image attention masking for interleaved prompts

Attention masking limits each text token's cross-attention to the visual tokens of the image that appears just before it in the sequence. Earlier images are not removed: their information still reaches later tokens through the self-attention of the language model.

Training sequences contain at most 5 images, yet evaluation uses sequences of up to 32 image-text shots. The authors report that the largest model also makes better use of larger numbers of shots.

In the ablation, attending only to the most recent image gives a 7.2% better overall score than attending to all previous images. The authors tried explicit image indices in the image tags and learned index embeddings, but these were less robust when the number of images changed between training and test time.

Training data mixture

Flamingo is trained on three kinds of web-scraped data: an interleaved image-and-text corpus called M3W, and paired image-text and video-text datasets. M3W starts from web documents with non-English pages removed, uses images at the same HTML level as the text, and applies filters on image size, aspect ratio and quality. Paired data comes from ALIGN, a noisy set of 1.8 billion images with alt-text, and is supplemented by LTIP with 312 million images and VTP with 27 million short videos.

Captions average 12.4 tokens per image for ALIGN and 20.5 for LTIP.

The correspondence between text and images in a webpage is unknown, so for each sampled webpage the text is aligned either to the previous image or to the next image. Each webpage picks the next-image alignment with probability 1/2, which sometimes pairs text with a semantically unnatural image. The authors report a small advantage over always using the previous image or always using the next one, which they read as a data augmentation effect.

Few-shot results across 16 benchmarks

Evaluation covers 16 benchmarks: 5 DEV benchmarks used during development (COCO, OKVQA, VQAv2, MSVDQA and VATEX) and 11 held-out benchmarks. Design choices were tuned on the DEV benchmarks, so their scores may be biased, and the held-out set is used only to estimate few-shot performance without that bias. Each evaluation draws support samples for the prompt and separate query samples, and DEV benchmarks also keep validation subsets.

Four few-shot prompt templates are chosen according to the task, and the evaluation hyperparameters are held fixed across benchmarks.

On 6 of the 16 tasks, Flamingo outperforms the fine-tuned state of the art with 32 task-specific examples, using a single set of model weights. The introduction puts the task-specific training data used by the fine-tuned state of the art at around 1000 times the 32 examples. Flamingo sets a new few-shot state of the art on the 9 tasks with published few-shot results.

Performance rises with model size across Flamingo-3B, Flamingo-9B and Flamingo-80B, built on Chinchilla models of 1.4B, 7B and 70B parameters, and it also rises with the number of shots.

Fine-tuning results

Fine-tuning is treated as a secondary use: with no limit on the annotation budget, the largest model is adapted to each task. The procedure uses a short schedule and a small learning rate, and it unfreezes the vision backbone so that the model accepts higher input resolution.

This sets new state of the art on five benchmarks: VQAv2, VATEX, VizWiz, MSRVTTQA and HatefulMemes. The comparison table includes state-of-the-art entries that use tricks such as model ensembling or metric optimisation, and these are marked separately.

How the ablations are run

All ablations use Flamingo-3B, evaluated with 4 shots on the validation subsets of five DEV benchmarks. Each benchmark score is divided by its state-of-the-art value from Table 1, and the results are averaged into an Overall score. The baseline Flamingo-3B row has an Overall score of 70.7 and a COCO CIDEr of 86.5, and step time is the time spent on gradient updates.

Data and conditioning ablations

Removing M3W from the mixture lowers performance by more than 17%, and removing the paired image-text data lowers it by 9.8%. Dropping the video-text pairs hurts all video tasks, and replacing the image-text pairs with LAION-400M gives a slight degradation.

The round-robin update variant reaches 62.9 overall against 70.7 for the gradient accumulation used by the authors.

Removing the tanh gating drops the overall score by 4.2%, and the authors observed training instabilities without it. Vanilla cross-attention reaches 66.9 overall and GRAFTING reaches 63.1, against 70.7 for GATED XATTN-DENSE.

Layer frequency and vision encoder

Adding GATED XATTN-DENSE blocks at every layer is best overall, but it increases the trainable parameters and training time. Under hardware limits, the authors add a block every fourth layer for Flamingo-9B and every seventh layer for Flamingo-80B.

The authors take this as evidence that a strong vision backbone matters.

Freezing the language model and its pretraining data

The authors prefer freezing the language model over including the MassiveText pretraining data in the training mixture.

The authors attribute the drop to C4 being smaller and less filtered than MassiveText.

In the extended ablation, the vision encoder trained from random initialisation reaches 61.4 overall, and the contrastively pretrained one reaches 68.1, against a baseline of 70.7.

Prompt construction at inference

When the support set is too large for one prompt, RICES retrieves the support images whose frozen visual features are closest to the query. The retrieved top-N examples are ordered by increasing similarity, so the most similar example sits right before the query, since language models are sensitive to ordering through recency bias. RICES is used for classification with many hundreds of classes, where one or more examples per class do not fit in the prompt.

For close-ended tasks, prompt ensembling averages the log-likelihoods of a candidate answer over 6 random permutations of the few-shot examples. It can be combined with RICES by permuting the ranked nearest neighbours. For close-ended tasks the authors found that a single text example in the zero-shot prompt is not needed.

Limitations

Flamingo builds on pretrained language models and inherits their weaknesses, including occasional hallucinations and ungrounded guesses. The language model generalises poorly to sequences longer than those seen in training, and it has poor sample efficiency during training.

Classification lags behind contrastive models, which optimise directly for text-image retrieval, and the authors see a unified approach as an open direction.

The ablations are run only on Flamingo-3B with 4 shots and shorter schedules. Design decisions were made on the DEV benchmarks, which can bias their scores, and 11 held-out benchmarks estimate performance. Flamingo carries the risks of large language models, such as offensive output and social bias, and its visual inputs add gender and racial bias concerns.

Paper info

Authors
Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob Menick, Sebastian Borgeaud, Andrew Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, Karen Simonyan
Venue
arXiv · Preprint
First published
2022-4-29
Added
2026-10-20
Updated
2022-11-15
Version
v2
arXiv
2204.14198
Category
cs.CV · cs.AI · cs.LG
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob Menick, Sebastian Borgeaud, Andrew Brock et al. (2022). Flamingo: a Visual Language Model for Few-Shot Learning. arXiv:2204.14198v2. https://arxiv.org/abs/2204.14198v2

BibTeX
@misc{alayrac2022flamingo,
  title = {{Flamingo: a Visual Language Model for Few-Shot Learning}},
  author = {Jean-Baptiste Alayrac and Jeff Donahue and Pauline Luc and Antoine Miech and Iain Barr and Yana Hasson and Karel Lenc and Arthur Mensch and Katie Millican and Malcolm Reynolds and Roman Ring and Eliza Rutherford and Serkan Cabi and Tengda Han and Zhitao Gong and Sina Samangooei and Marianne Monteiro and Jacob Menick and Sebastian Borgeaud and Andrew Brock and Aida Nematzadeh and Sahand Sharifzadeh and Mikolaj Binkowski and Ricardo Barreira and Oriol Vinyals and Andrew Zisserman and Karen Simonyan},
  year = {2022},
  eprint = {2204.14198},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.14198v2}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up