TL;DR
ViLBERT is a model that learns from pairs of pictures and sentences. It has two parallel transformer streams, one that reads the image as a set of object regions and one that reads the words, and the two streams exchange information through a special attention layer called co-attention. It is pretrained on about 3.3 million image-caption pairs with two tasks: guessing masked words and regions, and deciding whether a caption matches its image. The same pretrained model is then fine-tuned on four tasks with only a small new output layer each, and it set state-of-the-art results on all four.
Builds on: BERT: Pre-training of Deep Bidirectional Transformers, Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks, Transformer, Multi-Head Attention, Masked Language Modeling · Leads to: later vision-and-language models that pretrain one joint model on paired image and text data
Why it mattered
Before ViLBERT, a system that answered questions about pictures usually had a vision model and a language model, trained separately and joined by a task-specific design. The paper showed that one pretrained model could be reused across tasks that look quite different: answering questions about images, reasoning about movie scenes, pointing to the object a phrase refers to, and retrieving an image from a caption.
The paper's reported gains are large. On visual commonsense reasoning, the holistic Q to AR score rises from 43.1 for the earlier state-of-the-art R2C model to 54.04 for ViLBERT. On the Flickr30k image-retrieval task, recall at 1 rises from 48.60 for SCAN to 58.20. The paper reports that it sets state-of-the-art on VCR, RefCOCO+ and image retrieval by 7 to 10 percentage points.
By late 2026 the paper had about 5,100 citations on OpenAlex. Its idea of a joint pretrained model with a separate stream per modality is a standard reference point for vision-language pretraining.
The problem
A transformer that reads a sentence uses attention over word positions. An image has no natural order of pieces, and its useful units are regions with features, not pixels. The paper frames two difficulties with the simplest way to join the two.
The simplest way is to cluster image features into a vocabulary of visual tokens and feed them to BERT as if they were words. The paper names three drawbacks. Clustering throws away detail. The two kinds of input are treated identically, although an image region usually carries less context than a word and visual features are already the output of a deep network. And forcing one set of pretrained weights to handle both kinds of input can hurt the language side.
The paper's answer is to keep two streams with different depths and let them talk only at chosen layers.
How it works
Take a tiny example with one attention head and vectors of length 1 or 2. An image has two region features and the sentence has two words, "dog" and "runs". The question is what the visual region "sees" in the words.
- Start with separate streams. The image regions form a visual stream. Each region has a feature vector, plus a spatial code made from its normalized box corners and the fraction of the image it covers. The words form a linguistic stream, with word embeddings, position codes and a special classification token.
- Build the queries, keys and values as usual. Each stream computes its own queries, keys and values from its own representations, just as in a standard Transformer block. Visual queries come from the regions; text keys and values come from the words.
- Swap keys and values for co-attention. This is the new step. The visual stream uses its own queries but the text keys and values. Say the query for region 1 is , and the text keys are and . The scores are and .
- Turn scores into weights. A softmax gives weights for "dog" and for "runs". Check: the two weights sum to 1.
- Mix the text values. Let the text values be and . The attended vector for region 1 is . Region 1 now carries a mix of word information, weighted by how relevant each word is to it.
- Do the same in the other direction. The text stream uses its own queries with the visual keys and values, so each word picks up information from the regions. Both streams then add their results back to their own input, the residual connection, and continue.
- Repeat at chosen depths. The two streams can be different depths, and co-attention sits at a few chosen depths, not at every layer. Each stream therefore does its own processing and only meets the other at designated points.
flowchart TB
subgraph V[Visual stream]
direction TB
v1[region features plus spatial code] --> v2[transformer blocks]
v2 --> vc[co-attention layer: queries from regions, keys and values from words]
vc --> v3[more transformer blocks]
end
subgraph W[Linguistic stream]
direction TB
w1[word embeddings plus positions] --> w2[12 transformer blocks]
w2 --> wc[co-attention layer: queries from words, keys and values from regions]
wc --> w3[more transformer blocks]
end
vc -. keys and values .-> wc
wc -. keys and values .-> vc
The image representation is the output at a special IMG token, which stands for the whole image. The text representation is the output at the CLS token. Both are used in the pretraining and fine-tuning steps below.
The math
The paper writes the co-attention step in the usual transformer notation. For the visual stream at layer , with visual input and text input :
where , and are learned projection matrices, is the key dimension, and the softmax is taken over the words. The text stream does the same with the roles swapped.
Step 3 in symbols: the scores
The score matrix has one row per region and one column per word. Dividing by keeps the scores from growing with the dimension. In the tiny example, and the score for region 1 with "dog" is .
Step 4 in symbols: the weights
The softmax of a row is , so each row of weights sums to 1. In the example the row is , and the weights are and .
Step 5 in symbols: the mixed value
The attended output for region is , where is the weight of word for region and is that word's value vector. In the example this is , rounded to .
The pretraining objectives
The first task, masked multi-modal modelling, masks about 15 percent of the words and of the image regions. A masked word is handled as in BERT and predicted from its context with Cross-Entropy Loss. A masked region has its features zeroed 90 percent of the time and is left alone 10 percent of the time. The model predicts a distribution over object classes for that region, and the target is the class distribution from the detector that produced the features. The loss is the Kullback–Leibler Divergence between the detector's distribution and the model's.
The second task, multi-modal alignment prediction, takes an image and a caption and predicts whether they match. The paper multiplies the two holistic vectors element-wise and applies a linear layer with a binary loss. Conceptual Captions contains only matching pairs, so the paper makes negatives by swapping the image or the caption with a random one. The two losses have equal weight.
Results
The paper fine-tunes ViLBERT on four tasks, each with a small new output head and end-to-end training. The main numbers from its Table 1 are below.
- VQA 2.0 (test-dev): ViLBERT 70.55, against 70.22 for DFAF, the previous best. The single-stream baseline with pretraining reaches 68.85.
- VCR (Q to A, QA to R, Q to AR): ViLBERT 72.42, 74.47 and 54.04, against R2C's 63.8, 67.2 and 43.1 on validation.
- RefCOCO+ (val / testA / testB): ViLBERT 72.34, 78.52 and 62.61, against MAttNet's 65.33, 71.62 and 56.02.
- Caption-based image retrieval on Flickr30k (R1 / R5 / R10): ViLBERT 58.20, 84.90 and 91.52, against SCAN's 48.60, 77.70 and 85.20.
- Zero-shot retrieval, no fine-tuning (R1 / R5 / R10): 31.86, 61.12 and 72.80. This shows that the alignment head alone carries some grounding.
The ablations are as informative as the headline numbers. Removing pretraining (the model labeled ViLBERT with a dagger in the paper) costs between 2 and 13 percent across tasks. A single-stream model that shares one transformer for both modalities is consistently behind the two-stream version. The depth study shows that different tasks prefer different numbers of co-attention blocks: VQA improves from 69.92 with 2 layers to 70.55 with 6, while RefCOCO+ testA is best with 2 layers, at 78.61.
The limits are important. The visual features come from a detector trained on Visual Genome, so the model inherits that detector's vocabulary and its blind spots. The pretraining data is noisy: Conceptual Captions is scraped automatically from alt-text, and its captions are sometimes not human-like or short on detail. The fine-tuning tasks are benchmarks with their own annotation biases. The retrieval numbers come from one split of Flickr30k, so they measure one setting. And a gap such as 70.22 against 70.55 is small enough that training noise could account for it.
Reading guide
- Section 1, Introduction. Needs Masked Language Modeling and the idea of Self-Supervised Learning. Read the figures for the two-stream picture first.
- Section 2.1, BERT. Needs BERT: Pre-training of Deep Bidirectional Transformers, Transformer and Positional Encoding. The masking rules are the 15, 80, 10 and 10 percent scheme of BERT.
- Section 2.2, the model. Needs Multi-Head Attention, Attention Mechanism and Residual Connection. The co-attention step is the "How it works" walkthrough above. The spatial code for regions is a 5-vector, which the paper describes in one paragraph.
- Section 2.2, pretraining tasks. Needs Kullback–Leibler Divergence, Cross-Entropy Loss and Softmax.
- Section 3, transfer tasks. Needs VQA: Visual Question Answering, Object Detection, Region Proposal Network and Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks for the region features. The retrieval setup uses Image Captioning-style pairing.
- Section 4, results. Needs Transfer Learning and Vision-Language Model for context on the field.
Check yourself
QuestionIn co-attention, which modality supplies the queries and which supplies the keys and values for the visual stream?Show answer
QuestionIn the tiny example, the region query is 1 and the two word keys are 1 and 0. What are the attention weights, to three decimals?Show answer
QuestionWhy does ViLBERT use a KL divergence for masked image regions instead of regressing the masked feature values directly?Show answer
QuestionA model with 12 text layers and co-attention at only a few depths is compared with one that shares a single stream for both modalities. Which design lets the two modalities keep different amounts of processing, and why does that matter here?Show answer
QuestionViLBERT reaches 58.20 R1 on Flickr30k retrieval against SCAN's 48.60. Name one reason this comparison alone does not prove that ViLBERT grounds text better than all alternatives.Show answer
Sources
- Lu, Batra, Parikh, Lee, "ViLBERT: Pretraining Task-Agnostic Visiolinguistic Representations for Vision-and-Language Tasks," arXiv:1908.02265 (2019). https://arxiv.org/abs/1908.02265
- Devlin et al., "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding," arXiv:1810.04805 (2018). https://arxiv.org/abs/1810.04805