LXMERT: Learning Cross-Modality Encoder Representations from Transformers
- Publication
- EMNLP 2019Conference
- First submitted to arXiv
- arXiv:1908.07490
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{multimodalitylxmert2019,
title = {{LXMERT: Learning Cross-Modality Encoder Representations from Transformers}},
author = {Hao Tan and Mohit Bansal},
year = {2019},
eprint = {1908.07490},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1908.07490}
}
During this period, researchers have increasingly focused on multimodal studies.
Many models, such as ViLBERT, VL-BERT, and VisualBERT, were all published around the same time.
LXMERT incorporates more attention mechanisms and a comprehensive pre-training strategy to provide a relatively complete vision-and-language solution for its time.
Defining the Problem
The major challenge these models aim to address is similar:
- How can we design and train a model that effectively understands and represents both visual and language information while performing well across various cross-modal tasks?
ViLBERT, VisualBERT and LXMERT are concurrent explorations. This paper asks whether cross-modal pretraining transfers across tasks; it should not be framed as dismissing those contemporary models as failed predecessors.
Approach
Model Architecture
The design draws on Transformer self-attention and cross-attention so the image and sentence can first be encoded separately, then interact. Figure 1 has three encoders: a language encoder, an object-relationship encoder and a cross-modality encoder. The first two use self-attention within each modality. The last first exchanges information using bidirectional cross-attention, then applies self-attention and feed-forward layers within each stream. The language/object/cross encoders have 9/5/5 layers, with hidden size 768.
In the language component, sentences are tokenized using a WordPiece tokenizer, with each word and its position within the sentence represented as a vector.
For vision, a pretrained Faster R-CNN detector, frozen during LXMERT training, supplies 36 objects per image. Each object's 2048-dimensional RoI feature and bounding-box position are projected separately and combined, preserving spatial cues for the attention layers.
As illustrated, LXMERT provides three types of outputs: language, vision, and cross-modal. Language and vision outputs derive directly from feature sequences in the cross-modal encoder, while the cross-modal output leverages a special [CLS] token, representing the combined information from both modalities and suited for a range of downstream tasks.
Pre-training Strategy
To help the model develop a deeper understanding of vision-language connections, LXMERT is pre-trained on a large, aggregated dataset.
The pre-training tasks include:
-
Language Task – Masked Cross-Modal Language Model
The model predicts masked tokens rather than generating an open-ended sentence. As in BERT, 15% of words are selected; LXMERT can also use the image to predict them.
For example, if the word “apple” is masked in the sentence and the image displays an apple, LXMERT can use the visual hint to fill in the word.
-
Visual Task – Masked Object Prediction
Zero out RoI features with 15% probability, then regress their original features and classify their detector labels using remaining visual/text context. Labels come from Faster R-CNN and can be noisy. These are two objectives, not pixel reconstruction.
-
Cross-Modal Tasks
-
Cross-Modal Matching
This task strengthens the model’s ability to associate an image and sentence correctly. The model must determine if a sentence accurately describes an image, similar to BERT’s “Next Sentence Prediction” but focused on image-language alignment.
-
Image Question Answering (QA)
Given an image and question, classify among 9,500 answer candidates; this is not open-ended text generation. The loss applies only to unreplaced image–question pairs.
-
Pre-training data is sourced from five major vision-language datasets, using images primarily from MS COCO and Visual Genome. Altogether, the data comprises 180,000 images with 9.18 million associated image-sentence pairs.
Encoders and embeddings start from scratch, without BERT initialization; the visual detector is still pretrained. Losses have equal weights across 20 epochs, with image QA added only in the last 10. The reported run takes about ten days on four Titan Xp GPUs; each downstream task still requires fine-tuning.
Discussion
Comparison with Other Models
Despite table1 in the imported filename, this image is the paper's Table 2. VQA and GQA use test-standard; NLVR2 uses the unreleased Test-U split. These are comparisons across different tasks and earlier methods, not a single controlled ablation.
-
VQA (Visual Question Answering)
The previous SOTA result was presented by Kim et al. in 2018 with BAN+Counter, which outperformed other recent methods such as MFH, Pythia, DFAF, and Cycle-Consistency on VQA.
Overall accuracy is 72.5% versus 70.4%, a 2.1-point gain. Binary is 88.2% versus 85.8%, and Other 63.1% versus 60.7%, each 2.4 points higher. Without BAN+Counter's explicit counting module, Number is 54.2% versus 53.7%, a 0.5-point gain.
-
GQA
The comparison uses the contemporary GQA leaderboard’s BAN baseline. The 2018 citation refers to the BAN method, not the date of this GQA evaluation.
Overall accuracy is 60.3% versus 57.1%, a 3.2-point gain; Open questions score 45.0% versus 40.4%, a 4.6-point gain. The authors suggest GQA's greater emphasis on visual reasoning may explain the larger improvement.
-
NLVR2
On unreleased Test-U, accuracy is 76.2% versus 53.5%, a 22.7-point gain. Consistency is 42.1% versus 12.0%, about 3.5 times the earlier score. Consistency measures whether every image pair associated with a statement is answered correctly; it is distinct from per-example accuracy.
Importance of Pre-training
-
Comparison between BERT and LXMERT
The paper compares variants that use BERT for the language encoder, add visual features or cross-attention, or initialize LXMERT from BERT. On the NLVR2 dev set, variants without LXMERT pre-training score 50.9%–52.6%, while the full model scores 74.9%, a gap of roughly 22–24 percentage points. These are multimodal configurations; the table is not showing a 22-point drop for a plain text-only BERT image classifier.
LXMERT offers a specialized pre-training strategy that accounts for both language and vision, capturing complex relationships across modalities more effectively.
-
Importance of Visual QA Pre-training
With visual QA pre-training, the model learns not only language structure but also how to interpret and respond to questions based on image content, improving performance on tasks like NLVR2.
Table 4 reports NLVR2 dev scores of 72.4 and 74.9, a 2.5-point gain. The paper’s prose says 2.1%, which conflicts with the table; the arithmetic here follows the table. Both indicate a gain from QA pretraining.
-
Pre-training and Data Augmentation
Here DA means adding questions from other QA datasets during fine-tuning, not generic crops or flips. In Table 4, DA scores slightly below the corresponding single-task fine-tuning setting both without QA pre-training (68.0% versus 68.9% on VQA) and with it (69.1% versus 69.9%). The experiment favors pre-training with multiple QA datasets followed by single-task fine-tuning over mixing those datasets at the fine-tuning stage.
Conclusion
By combining several pre-training tasks, LXMERT achieves strong results across vision-language tasks. It sets new benchmarks among the methods listed in the paper for VQA and GQA, and its transfer to NLVR2 is especially striking: 76.2% versus 53.5% on Test-U.
We see why the authors put so much emphasis on pre-training here. The gains come from the combination of architecture, data and objectives; the ablations support parts of that story without assigning every point to one attention layer.