summaries: This paper introduces a method  to perform text-image matching and demonstrate that  it can be used to solve several language-vision downstream tasks  ranging from image-text retrieval, VQA and national language for visual reasoning among others.   * Given an  image and a textual input visual and  textual embedding are obtained  that are then fed  to a multimodal encoder with  cross-attention layers.  * The first key idea of this paper lies in the image-text contrastive loss employed between the image/text embeddings before feeding them to the multimodal  decoder with the intuition behind that being that forcing these embeddings to align before fusing them through the multi-modal encoder results into better representations for downstream tasks * The second key idea is in the usage of  a momentum model that generates pseudo-target labels by keeping a moving average that are then used for supervision at training time.   An in-depth discussion is provided: 1) for each of the losses used, 2) on the fact that the proposed approach maximizes a lower bound on the mutual information between different “views” of an image-text pair  Extensive Results for several tasks and datasets are provided and strong results are reported. The qualitative results demonstrating where the learned attention is focusing for each downstream task are also quite insightful This paper proposes a new vision-language representation learning framework, ALBEF, which uses image-text contrastive (ITC), masked language modeling (MLM), and image-text matching (ITM) losses with momentum distillation to learn SOTA representations. The ITC and MLM losses are adapted to be convex combinations of the original loss and the KL divergence between the predicted probability distribution (of the image or text or masked tokens) and the soft pseudo targets obtained from the momentum model.   The pipeline is evaluated on image-text retrieval, visual entailment, NLVR, VQA, and grounding and shows improved performance on all tasks compared to prior work, and with fewer training samples in comparison to several prior methods. Qualitative visualizations also verify the quality of the learned representations, with convincing heat maps suggesting well grounded, semantically aligned embeddings.  This paper presents an vision-and-language pretraining framework that utilizes momentum distillation to address the issue of training on noisy web data. More specifically, it presents a self-training approach to learn from pseudo-targets that are generated by a momentum model. In contrast to existing approaches which simply use cross-modal attention to reason about concatenated sequences of image regions and words, this work also leverages contrastive learning to learn more effective representations before using cross-modal attention. The paper proposes to learn joint vision and language representations by addressing several limitations in the existing methods. Firstly, they learn separate image and text representations using unimodal encoders without the need for bounding box annotations. Second, they fuse these two representations using a multimodal encoder based on cross modal attention and, third, they address the noise in large scale web based image-text datasets using a Momentum Distillation approach that generates pseudo-targets as additional supervision. They demonstrate the effectiveness of their approach on various downstream V+L tasks and gain substantial improvement over SOTA methods. Their main contributions are: removing the need for pre-trained object detector and high resolution images and combining it with the contrastive loss function for learning effective multi-modal representations, image-text contrastive learning loss (ITC). They also generate pseudo-targets for the ITC loss and the masked language modeling (MLM) loss using the momentum encoder model to address the weak correlations in the noisy image-text web data. This achieves high performance on both reasoning and retrieval tasks unlike other methods. The paper  is very well written and easy to follow and understand.   In this paper, the authors study the vision-transformer-like vision-language-pretraining (VLP) methods. The raw image and text are first encoded by a vision transformer and a text transformer respectively, and are then sent into a multimodal transformer for fusion. There are two major technical contributions, i.e., 1) the proposed ITC loss and 2) the moving average “teacher” to generate the pseudo targets.     The proposed method (ALBEF) outperforms previous E2E VLP methods, and achieves comparable performance to the VLP methods that take object region features. 
abstractText: Large-scale vision and language representation learning has shown promising improvements on various vision-language tasks. Most existing methods employ a transformer-based multimodal encoder to jointly model visual tokens (region-based image features) and word tokens. Because the visual tokens and word tokens are unaligned, it is challenging for the multimodal encoder to learn image-text interactions. In this paper, we introduce a contrastive loss to ALign the image and text representations BEfore Fusing (ALBEF) them through cross-modal attention, which enables more grounded vision and language representation learning. Unlike most existing methods, our method does not require bounding box annotations nor high-resolution images. To improve learning from noisy web data, we propose momentum distillation, a self-training method which learns from pseudo-targets produced by a momentum model. We provide a theoretical analysis of ALBEF from a mutual information maximization perspective, showing that different training tasks can be interpreted as different ways to generate views for an image-text pair. ALBEF achieves state-of-the-art performance on multiple downstream visionlanguage tasks. On image-text retrieval, ALBEF outperforms methods that are pre-trained on orders of magnitude larger datasets. On VQA and NLVR2, ALBEF achieves absolute improvements of 2.37% and 3.84% compared to the state-ofthe-art, while enjoying faster inference speed. Code and models are available at https://github.com/salesforce/ALBEF.
authors.name: Junnan Li
authors.name: Ramprasaath R. Selvaraju
authors.name: Akhilesh D. Gotmare
authors.name: Shafiq Joty
authors.name: Caiming Xiong
authors.name: Steven C.H. Hoi
references.authors: H. Tan M. Bansal
references.title: LXMERT: learning cross-modality encoder representations from transformers
references.authors: Y. Chen L. Li L. Yu
references.title: UNITER: universal image-text representation learning
references.venue: In ECCV,
references.authors: X. Li X. Yin C. Li
references.title: Oscar: Object-semantics aligned pre-training for vision-language tasks
references.venue: In ECCV,
references.authors: P. Sharma N. Ding S. Goodman
references.title: Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning
references.authors: V. Ordonez G. Kulkarni T.L. Berg
references.title: Im2text: Describing images using 1 million captioned photographs
references.authors: A. Radford J.W. Kim C. Hallacy
references.title: Learning transferable visual models from natural language supervision
references.venue: arXiv preprint arXiv:2103.00020,
references.authors: C. Jia Y. Yang Y. Xia
references.title: Scaling up visual and vision-language representation learning with noisy text supervision
references.venue: arXiv preprint arXiv:2102.05918,
references.authors: Z. Gan Y. Chen L. Li
references.title: Large-scale adversarial training for vision-and-language representation learning
references.authors: R.R. Selvaraju M. Cogswell A. Das
references.title: Grad-cam: Visual explanations from deep networks via gradient-based localization
references.venue: In ICCV,
references.authors: W. Su X. Zhu Y. Cao
references.title: Vl-bert: Pre-training of generic visual-linguistic representations
references.venue: In ICLR
references.authors: J. Lu D. Batra D. Parikh
references.title: Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks
references.authors: J. Lu V. Goswami M. Rohrbach
references.title: 12-in-1: Multi-task vision and language representation learning
references.venue: In CVPR,
references.authors: L.H. Li M. Yatskar D. Yin
references.title: Visualbert: A simple and performant baseline for vision and language
references.venue: arXiv preprint arXiv:1908.03557,
references.authors: D. Qi L. Su J. Song
references.title: Imagebert: Cross-modal pre-training with large-scale weaksupervised image-text data
references.venue: arXiv preprint arXiv:2001.07966,
references.authors: G. Li N. Duan Y. Fang
references.title: Unicoder-vl: A universal encoder for vision and language by cross-modal pre-training
references.venue: In AAAI,
references.authors: F. Yu J. Tang W. Yin
references.title: Ernie-vil: Knowledge enhanced vision-language representations through scene graph
references.venue: arXiv preprint arXiv:2006.16934,
references.authors: P. Zhang X. Li X. Hu
references.title: Vinvl: Making visual representations matter in vision-language models
references.venue: arXiv preprint arXiv:2101.00529,
references.authors: Z. Huang Z. Zeng Y. Huang
references.title: Seeing out of the box: End-to-end pre-training for vision-language representation learning
references.venue: arXiv preprint arXiv:2104.03135,
references.authors: A. Suhr S. Zhou A. Zhang
references.title: A corpus for reasoning about natural language grounded in photographs
references.authors: S. Antol A. Agrawal J. Lu
references.title: VQA: visual question answering
references.venue: In ICCV,
references.authors: W. Kim B. Son I. Kim
references.title: Vilt: Vision-and-language transformer without convolution or region supervision
references.venue: arXiv preprint arXiv:2102.03334,
references.authors: F. Faghri D.J. Fleet J.R. Kiros
references.title: VSE++: improving visual-semantic embeddings with hard negatives
references.venue: In BMVC,
references.authors: K. Li Y. Zhang
references.title: Visual semantic reasoning for image-text matching
references.venue: In ICCV,
references.authors: K. He H. Fan Y. Wu
references.title: Momentum contrast for unsupervised visual representation learning
references.venue: In CVPR
references.authors: T. Chen S. Kornblith M. Norouzi
references.title: A simple framework for contrastive learning of visual representations
references.venue: In ICML
references.authors: J. Li P. Zhou C. Xiong
references.title: Prototypical contrastive learning of unsupervised representations
references.venue: In ICLR
references.authors: J. Li C. Xiong S.C. Hoi
references.title: Mopro: Webly supervised learning with momentum prototypes
references.venue: In ICLR
references.authors: G. Hinton O. Vinyals J. Dean
references.title: Distilling the knowledge in a neural network
references.venue: arXiv preprint arXiv:1503.02531,
references.authors: S. Zagoruyko N. Komodakis
references.title: Paying more attention to attention: Improving the performance of convolutional neural networks via attention transfer
references.venue: In ICLR
references.authors: T. Furlanello Z.C. Lipton M. Tschannen
references.title: Born-again neural networks
references.authors: H. Touvron M. Cord M. Douze
references.title: Training data-efficient image transformers & distillation through attention
references.venue: arXiv preprint arXiv:2012.12877,
references.authors: V. Sanh L. Debut J. Chaumond
references.title: Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter
references.authors: Y. Zhang T. Xiang T.M. Hospedales
references.title: Deep mutual learning
references.venue: In CVPR,
references.authors: R. Anil G. Pereyra A. Passos
references.title: Large scale distributed neural network training through online distillation
references.venue: In ICLR
references.authors: A. Tarvainen H. Valpola
references.title: Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results
references.venue: In NIPS,
references.authors: J. Li R. Socher S.C. Hoi
references.title: Dividemix: Learning with noisy labels as semi-supervised learning
references.venue: In ICLR
references.authors: R. Cheng B. Wu P. Zhang
references.title: Data-efficient language-supervised zero-shot learning with self-distillation
references.venue: arXiv preprint arXiv:2104.08945,
references.authors: A. Dosovitskiy L. Beyer A. Kolesnikov
references.title: An image is worth 16x16 words: Transformers for image recognition at scale
references.venue: In ICLR
references.authors: A. Vaswani N. Shazeer N. Parmar
references.title: Attention is all you need
references.authors: J. Devlin M. Chang K. Lee
references.title: BERT: pre-training of deep bidirectional transformers for language understanding
references.authors: T. Lin M. Maire S.J. Belongie
references.title: Microsoft COCO: common objects in context
references.venue: eds., ECCV,
references.authors: R. Krishna Y. Zhu O. Groth
references.title: Visual genome: Connecting language and vision using crowdsourced dense image
references.venue: annotations. IJCV,
references.authors: S. Changpinyo P. Sharma N. Ding
references.title: Conceptual 12M: Pushing web-scale image-text pre-training to recognize long-tail visual concepts
references.venue: In CVPR
references.authors: I. Loshchilov F. Hutter
references.title: Decoupled weight decay regularization
references.venue: arXiv preprint arXiv:1711.05101,
references.authors: E.D. Cubuk B. Zoph J. Shlens
references.title: Randaugment: Practical automated data augmentation with a reduced search space
references.venue: In CVPR Workshops,
references.authors: Y. Tian C. Sun B. Poole
references.title: What makes for good views for contrastive learning
references.authors: Oord A. v. d Y. Li O. Vinyals
references.title: Representation learning with contrastive predictive coding
references.venue: arXiv preprint arXiv:1807.03748,
references.authors: L. Kong C. de Masson d’Autume L. Yu
references.title: A mutual information maximization perspective of language representation learning
references.venue: In ICLR. OpenReview.net,
references.authors: B.A. Plummer L. Wang C.M. Cervantes
references.title: Flickr30k entities: Collecting region-to-phrase correspondences for richer image-to-sentence models
references.venue: In ICCV,
references.authors: V. Do O.-M. Camburu Z. Akata
references.title: e-snli-ve: Corrected visual-textual entailment with natural language explanations
references.venue: arXiv preprint arXiv:2004.03744,
references.authors: N. Xie F. Lai D. Doran
references.title: Visual entailment: A novel task for fine-grained image understanding
references.venue: arXiv preprint arXiv:1901.06706,
references.authors: Y. Goyal T. Khot D. Summers-Stay
references.title: Making the V in VQA matter: Elevating the role of image understanding in visual question answering
references.venue: In CVPR,
references.authors: L. Yu Z. Lin X. Shen
references.title: Mattnet: Modular attention network for referring expression comprehension
references.venue: In CVPR,
references.authors: J. Cho J. Lei H. Tan
references.title: Unifying vision-and-language tasks via text generation
references.venue: arXiv preprint arXiv:2102.02779,
references.authors: J. Kim J. Jun B. Zhang
references.title: Bilinear attention networks
references.authors: L. Yu P. Poirson S. Yang
references.title: Modeling context in referring expressions
references.authors: X. Liu L. Li S. Wang
references.title: Adaptive reconstruction network for weakly supervised referring expression grounding
references.venue: In ICCV,
references.authors: Z. Zhang Z. Zhao Z. Lin
references.title: Counterfactual contrastive learning fo weakly-supervised vision-language grounding
references.authors: A. Karpathy F. Li
references.title: Deep visual-semantic alignments for generating image descriptions
references.venue: In CVPR,
references.authors: S.R. Bowman G. Angeli C. Potts
references.title: A large annotated corpus for learning natural language inference
references.authors: Z. Yu J. Yu Y. Cui
references.title: Deep modular co-attention networks for visual question answering
references.venue: In CVPR,
references.authors: S. Kazemzadeh V. Ordonez M. Matten
references.title: Referitgame: Referring to objects in photographs of natural scenes
references.authors: A. Das H. Agrawal C.L. Zitnick
references.title: Human Attention in Visual Question Answering: Do Humans and Deep Networks Look at the Same Regions? 2016
sections.heading: 1 Introduction
sections.text: Vision-and-Language Pre-training (VLP) aims to learn multimodal representations from large-scale image-text pairs that can improve downstream Vision-and-Language (V+L) tasks. Most existing VLP methods (e.g. LXMERT [1], UNITER [2], OSCAR [3]) rely on pre-trained object detectors to extract region-based image features, and employ a multimodal encoder to fuse the image features with word tokens. The multimodal encoder is trained to solve tasks that require joint understanding of image and text, such as masked language modeling (MLM) and image-text matching (ITM).
  While effective, this VLP framework suffers from several key limitations: (1) The image features and the word token embeddings reside in their own spaces, which makes it challenging for the multimodal encoder to learn to model their interactions; (2) The object detector is both annotation-expensive and compute-expensive, because it requires bounding box annotations during pre-training, and highresolution (e.g. 600⇥1000) images during inference; (3) The widely used image-text datasets [4, 5] are collected from the web and are inherently noisy, and existing pre-training objectives such as MLM may overfit to the noisy text and degrade the model’s generalization performance.
  We propose ALign BEfore Fuse (ALBEF), a new VLP framework to address these limitations. We first encode the image and text independently with a detector-free image encoder and a text encoder. Then we use a multimodal encoder to fuse the image features with the text features through crossmodal attention. We introduce an intermediate image-text contrastive (ITC) loss on representations from the unimodal encoders, which serves three purposes: (1) it aligns the image features and the text features, making it easier for the multimodal encoder to perform cross-modal learning; (2) it
  35th Conference on Neural Information Processing Systems (NeurIPS 2021).
  improves the unimodal encoders to better understand the semantic meaning of images and texts; (3) it learns a common low-dimensional space to embed images and texts, which enables the image-text matching objective to find more informative samples through our contrastive hard negative mining.
  To improve learning under noisy supervision, we propose Momentum Distillation (MoD), a simple method which enables the model to leverage a larger uncurated web dataset. During training, we keep a momentum version of the model by taking the moving-average of its parameters, and use the momentum model to generate pseudo-targets as additional supervision. With MoD, the model is not penalized for producing other reasonable outputs that are different from the web annotation. We show that MoD not only improves pre-training, but also downstream tasks with clean annotations.
  We provide theoretical justifications on ALBEF from the perspective of mutual information maximization. Specifically, we show that ITC and MLM maximize a lower bound on the mutual information between different views of an image-text pair, where the views are generated by taking partial information from each pair. From this perspective, our momentum distillation can be interpreted as generating new views with semantically similar samples. Therefore, ALBEF learns vision-language representations that are invariant to semantic-preserving transformations.
  We demonstrate the effectiveness of ALBEF on various downstream V+L tasks including image-text retrieval, visual question answering, visual reasoning, visual entailment, and weakly-supervised visual grounding. ALBEF achieves substantial improvements over existing state-of-the-art methods. On image-text retrieval, it outperforms methods that are pre-trained on orders of magnitude larger datasets (CLIP [6] and ALIGN [7]). On VQA and NLVR2, it achieves absolute improvements of 2.37% and 3.84% compared to the state-of-the-art method VILLA [8], while enjoying much faster inference speed. We also provide quantitative and qualitative analysis on ALBEF using Grad-CAM [9], which reveals its ability to perform accurate object, attribute and relationship grounding implicitly.
sections.heading: 2 Related Work
sections.heading: 2.1 Vision-Language Representation Learning
sections.text: Most existing work on vision-language representation learning fall into two categories. The first category focuses on modelling the interactions between image and text features with transformerbased multimodal encoders [10, 11, 12, 13, 1, 14, 15, 2, 3, 16, 8, 17, 18]. Methods in this category achieve superior performance on downstream V+L tasks that require complex reasoning over image and text (e.g. NLVR2 [19], VQA [20]), but most of them require high-resolution input images and pre-trained object detectors. A recent method [21] improves inference speed by removing the object detector, but results in lower performance. The second category focuses on learning separate unimodal encoders for image and text [22, 23, 6, 7]. The recent CLIP [6] and ALIGN [7] perform pre-training on massive noisy web data using a contrastive loss, one of the most effective loss for representation learning [24, 25, 26, 27]. They achieve remarkable performance on image-text retrieval tasks, but lack the ability to model more complex interactions between image and text for other V+L tasks [21].
  ALBEF unifies the two categories, leading to strong unimodal and multimodal representations with superior performance on both retrieval and reasoning tasks. Furthermore, ALBEF does not require object detectors, a major computation bottleneck for many existing methods [1, 2, 3, 8, 17].
sections.heading: 2.2 Knowledge Distillation
sections.text: Knowledge distillation [28] aims to improve a student model’s performance by distilling knowledge from a teacher model, usually through matching the student’s prediction with the teacher’s. While most methods focus on distilling knowledge from a pre-trained teacher model [28, 29, 30, 31, 32], online distillation [33, 34] simultaneously trains multiple models and use their ensemble as the teacher. Our momentum distillation can be interpreted as a form of online self-distillation, where a temporal ensemble of the student model is used as the teacher. Similar ideas have been explored in semi-supervised learning [35], label noise learning [36], and very recently in contrastive learning [37]. Different from existing studies, we theoretically and experimentally show that momentum distillation is a generic learning algorithm that can improve the model’s performance on many V+L tasks.
sections.heading: 3 ALBEF Pre-training
sections.text: In this section, we first introduce the model architecture (Section 3.1). Then we delineate the pretraining objectives (Section 3.2), followed by the proposed momentum distillation (Section 3.3). Lastly we describe the pre-training datasets (Section 3.4) and implementation details (Section 3.5).
sections.heading: 3.1 Model Architecture
sections.text: As illustrated in Figure 1, ALBEF contains an image encoder, a text encoder, and a multimodal encoder. We use a 12-layer visual transformer ViT-B/16 [38] as the image encoder, and initialize it with weights pre-trained on ImageNet-1k from [31]. An input image I is encoded into a sequence of embeddings: {vcls,v1, ...,vN}, where vcls is the embedding of the [CLS] token. We use a 6-layer transformer [39] for both the text encoder and the multimodal encoder. The text encoder is initialized using the first 6 layers of the BERTbase [40] model, and the multimodal encoder is initialized using the last 6 layers of the BERTbase. The text encoder transforms an input text T into a sequence of embeddings {wcls,w1, ...,wN}, which is fed to the multimodal encoder. The image features are fused with the text features through cross attention at each layer of the multimodal encoder.
sections.heading: 3.2 Pre-training Objectives
sections.text: We pre-train ALBEF with three objectives: image-text contrastive learning (ITC) on the unimodal encoders, masked language modeling (MLM) and image-text matching (ITM) on the multimodal encoder. We improve ITM with online contrastive hard negative mining.
  Image-Text Contrastive Learning aims to learn better unimodal representations before fusion. It learns a similarity function s = gv(vcls)>gw(wcls), such that parallel image-text pairs have higher similarity scores. gv and gw are linear transformations that map the [CLS] embeddings to normalized lower-dimensional (256-d) representations. Inspired by MoCo [24], we maintain two queues to store the most recent M image-text representations from the momentum unimodal encoders. The normalized features from the momentum encoders are denoted as g0v(v0cls) and g 0 w(w 0 cls). We define s(I, T ) = gv(vcls)>g0w(w 0 cls) and s(T, I) = gw(wcls) >g0v(v 0 cls).
  For each image and text, we calculate the softmax-normalized image-to-text and text-to-image similarity as:
  pi2tm (I) = exp(s(I, Tm)/⌧)PM
  m=1 exp(s(I, Tm)/⌧) , pt2im (T ) = exp(s(T, Im)/⌧)PM m=1 exp(s(T, Im)/⌧)
  (1)
  where ⌧ is a learnable temperature parameter. Let yi2t(I) and yt2i(T ) denote the ground-truth one-hot similarity, where negative pairs have a probability of 0 and the positive pair has a probability of 1. The image-text contrastive loss is defined as the cross-entropy H between p and y:
  Litc = 1
  2 E(I,T )⇠D
  ⇥ H(yi2t(I),pi2t(I)) + H(yt2i(T ),pt2i(T )) ⇤ (2)
  Masked Language Modeling utilizes both the image and the contextual text to predict the masked words. We randomly mask out the input tokens with a probability of 15% and replace them with the special token [MASK]1. Let T̂ denote a masked text, and pmsk(I, T̂ ) denote the model’s predicted probability for a masked token. MLM minimizes a cross-entropy loss:
  Lmlm = E(I,T̂ )⇠DH(y msk,pmsk(I, T̂ )) (3)
  where ymsk is a one-hot vocabulary distribution where the ground-truth token has a probability of 1.
  Image-Text Matching predicts whether a pair of image and text is positive (matched) or negative (not matched). We use the multimodal encoder’s output embedding of the [CLS] token as the joint representation of the image-text pair, and append a fully-connected (FC) layer followed by softmax to predict a two-class probability pitm. The ITM loss is:
  Litm = E(I,T )⇠DH(yitm,pitm(I, T )) (4) where yitm is a 2-dimensional one-hot vector representing the ground-truth label.
  We propose a strategy to sample hard negatives for the ITM task with zero computational overhead. A negative image-text pair is hard if they share similar semantics but differ in fine-grained details. We use the contrastive similarity from Equation 1 to find in-batch hard negatives. For each image in a mini-batch, we sample one negative text from the same batch following the contrastive similarity distribution, where texts that are more similar to the image have a higher chance to be sampled. Likewise, we also sample one hard negative image for each text.
  The full pre-training objective of ALBEF is: L = Litc + Lmlm + Litm (5)
sections.heading: 3.3 Momentum Distillation
sections.text: The image-text pairs used for pre-training are mostly collected from the web and they tend to be noisy. Positive pairs are usually weakly-correlated: the text may contain words that are unrelated to the image, or the image may contain entities that are not described in the text. For ITC learning, negative texts for an image may also match the image’s content. For MLM, there may exist other words different from the annotation that describes the image equally well (or better). However, the one-hot labels for ITC and MLM penalize all negative predictions regardless of their correctness.
  To address this, we propose to learn from pseudo-targets generated by the momentum model. The momentum model is a continuously-evolving teacher which consists of exponential-moving-average versions of the unimodal and multimodal encoders. During training, we train the base model such that its predictions match the ones from the momentum model. Specifically, for ITC, we first compute the image-text similarity using features from the momentum unimodal encoders as s0(I, T ) = g0v(v 0 cls) >g0w(w 0 cls) and s 0 (T, I) = g0w(wcls) >g0v(v 0 cls). Then we compute soft pseudotargets qi2t and qt2i by replacing s with s0 in Equation 1. The ITCMoD loss is defined as:
  Lmoditc = (1 ↵)Litc + ↵
  2 E(I,T )⇠D
  ⇥ KL(qi2t(I) k pi2t(I)) + KL(qt2i(T ) k pt2i(T )) ⇤ (6)
  1following BERT, the replacements are 10% random tokens, 10% unchanged, and 80% [MASK]
  Similarly, for MLM, let qmsk(I, T̂ ) denote the momentum model’s prediction probability for the masked token, the MLMMoD loss is:
  Lmodmlm = (1 ↵)Lmlm + ↵E(I,T̂ )⇠DKL(q msk (I, T̂ ) k pmsk(I, T̂ )) (7) In Figure 2, we show examples of the top-5 candidates from the pseudo-targets, which effectively capture relevant words/texts for an image. More examples can be found in Appendix.
  We also apply MoD to the downstream tasks. The final loss for each task is a weighted combination of the original task’s loss and the KL-divergence between the model’s prediction and the pseudo-targets. For simplicity, we set the weight ↵ = 0.4 for all pre-training and downstream tasks 2.
sections.heading: 3.4 Pre-training Datasets
sections.text: Following UNITER [2], we construct our pre-training data using two web datasets (Conceptual Captions [4], SBU Captions [5]) and two in-domain datasets (COCO [41] and Visual Genome [42]). The total number of unique images is 4.0M, and the number of image-text pairs is 5.1M. To show that our method is scalable with larger-scale web data, we also include the much noisier Conceptual 12M dataset [43], increasing the total number of images to 14.1M 3. Details are in Appendix.
sections.heading: 3.5 Implementation Details
sections.text: Our model consists of a BERTbase with 123.7M parameters and a ViT-B/16 with 85.8M parameters. We pre-train the model for 30 epochs using a batch size of 512 on 8 NVIDIA A100 GPUs. We use the AdamW [44] optimizer with a weight decay of 0.02. The learning rate is warmed-up to 1e 4 in the first 1000 iterations, and decayed to 1e 5 following a cosine schedule. During pre-training, we take random image crops of resolution 256⇥ 256 as input, and also apply RandAugment4 [45]. During fine-tuning, we increase the image resolution to 384⇥ 384 and interpolate the positional encoding of image patches following [38]. The momentum parameter for updating the momentum model is set as 0.995, and the size of the queue used for image-text contrastive learning is set as 65,536. We linearly ramp-up the distillation weight ↵ from 0 to 0.4 within the 1st epoch.
sections.heading: 4 A Mutual Information Maximization Perspective
sections.text: In this section, we provide an alternative perspective of ALBEF and show that it maximizes a lower bound on the mutual information (MI) between different “views” of an image-text pair. ITC, MLM, and MoD can be interpreted as different ways to generate the views.
  Formally, we define two random variables a and b as two different views of a data point. In selfsupervised learning [24, 25, 46], a and b are two augmentations of the same image. In vision-language representation learning, we consider a and b as different variations of an image-text pair that capture its semantic meaning. We aim to learn representations invariant to the change of view. This can be achieved by maximizing the MI between a and b. In practice, we maximize a lower bound on MI(a, b) by minimizing the InfoNCE loss [47] defined as:
  LNCE = Ep(a,b)
  " log exp(s(a, b)) P
  b̂2B̂ exp(s(a, b̂))
  # (8)
  where s(a, b) is a scoring function (e.g., a dot product between two representations), and B̂ contains the positive sample b and |B̂| 1 negative samples drawn from a proposal distribution. Our ITC loss with one-hot labels (Equation 2) can be re-written as:
  Litc = 1
  2 Ep(I,T )
  ⇥ log exp(s(I, T )/⌧) PM
  m=1 exp(s(I, Tm)/⌧) + log
  exp(s(T, I)/⌧) PM
  m=1 exp(s(T, Im)/⌧)
  ⇤ (9)
  Minimizing Litc can be seen as maximizing a symmetric version of InfoNCE. Hence, ITC considers the two individual modalities (i.e., I and T ) as the two views of an image-text pair, and trains the unimodal encoders to maximize the MI between the image and text views for the positive pairs.
  2our experiments show that ↵ = 0.3, 0.4, 0.5 yield similar performance, with ↵ = 0.4 slightly better 3some urls provided by the web datasets have become invalid 4we remove color changes from RandAugment because the text often contains color information
  As shown in [48], we can also interpret MLM as maximizing the MI between a masked word token and its masked context (i.e. image + masked text). Specifically, we can re-write the MLM loss with one-hot labels (Equation 3) as
  Lmlm = Ep(I,T̂ ) ⇥ log exp( (ymsk)>f(I, T̂ )) P
  y2V exp( (y) >f(I, T̂ ))
  ⇤ (10)
  where (y) : V ! Rd is a lookup function in the multimodal encoder’s output layer that maps a word token y into a vector and V is the full vocabulary set, and f(I, T̂ ) is a function that returns the final hidden state of the multimodal encoder corresponding to the masked context. Hence, MLM considers the two views of an image-text pair to be: (1) a randomly selected word token, and (2) the image + the contextual text with that word masked.
  Both ITC and MLM generate views by taking partial information from an image-text pair, through either modality separation or word masking. Our momentum distillation can be considered as generating alternative views from the entire proposal distribution. Take ITCMoD in Equation 6 as an example, minimizing KL(pi2t(I), qi2t(I)) is equivalent to minimizing the following objective:
  X
  m
  qi2tm (I) log p i2t m (I) =
  X
  m exp(s0(I, Tm)/⌧)PM m=1 exp(s 0(I, Tm)/⌧) log exp(s(I, Tm)/⌧)PM m=1 exp(s(I, Tm)/⌧) (11)
  It maximizes MI(I, Tm) for texts that share similar semantic meaning with the image I because those texts would have larger qi2tm (I). Similarly, ITCMoD also maximizes MI(Im, T ) for images that are similar to T . We can follow the same method to show that MLMMoD generates alternative views y0 2 V for the masked word ymsk, and maximizes the MI between y0 and (I, T̂ ). Therefore, our momentum distillation can be considered as performing data augmentation to the original views. The momentum model generates a diverse set of views that are absent in the original image-text pairs, and encourages the base model to learn representations that capture view-invariant semantic information.
sections.heading: 5 Downstream V+L Tasks
sections.text: We adapt the pre-trained model to five downstream V+L tasks. We introduce each task and our fine-tuning strategy below. Details of the datasets and fine-tuning hyperparameters are in Appendix.
  Image-Text Retrieval contains two subtasks: image-to-text retrieval (TR) and text-to-image retrieval (IR). We evaluate ALBEF on the Flickr30K [49] and COCO benchmarks, and fine-tune the pretrained model using the training samples from each dataset. For zero-shot retrieval on Flickr30K, we evaluate with the model fine-tuned on COCO. During fine-tuning, we jointly optimize the ITC loss (Equation 2) and the ITM loss (Equation 4). ITC learns an image-text scoring function based on similarity of unimodal features, whereas ITM models the fine-grained interaction between image and text to predict a matching score. Since the downstream datasets contain multiple texts for each image, we change the ground-truth label of ITC to consider multiple positives in the queue, where each positive has a ground-truth probability of 1/#positives. During inference, we first compute the feature similarity score sitc for all image-text pairs. Then we take the top-k candidates and calculate their ITM score sitm for ranking. Because k can be set to be very small, our inference speed is much faster than methods that require computing the ITM score for all image-text pairs [2, 3, 8].
  Visual Entailment (SNLI-VE5 [51]) is a fine-grained visual reasoning task to predict whether the relationship between an image and a text is entailment, neutral, or contradictory. We follow UNITER [2] and consider VE as a three-way classification problem, and predict the class probabilities using a multi-layer perceptron (MLP) on the multimodal encoder’s representation of the [CLS] token.
  Visual Question Answering (VQA [52]) requires the model to predict an answer given an image and a question. Different from existing methods that formulate VQA as a multi-answer classification problem [53, 2], we consider VQA as an answer generation problem, similar to [54]. Specifically, we use a 6-layer transformer decoder to generate the answer. As shown in Figure 3a, the auto-regressive answer decoder receives the multimodal embeddings through cross attention, and a start-of-sequence token ([CLS]) is used as the decoder’s initial input token. Likewise, an end-of-sequence token ([SEP]) is appended to the end of decoder outputs which indicates the completion of generation.
  5results on SNLI-VE should be interpreted with caution because its test data has been reported to be noisy [50]
  The answer decoder is initialized using the pre-trained weights from the multimodal encoder, and finetuned with a conditional language-modeling loss. For a fair comparison with existing methods, we constrain the decoder to only generate from the 3,128 candidate answers [55] during inference.
  Natural Language for Visual Reasoning (NLVR2 [19]) requires the model to predict whether a text describes a pair of images. We extend our multimodal encoder to enable reasoning over two images. As shown in Figure 3b, each layer of the multimodal encoder is replicated to have two consecutive transformer blocks, where each block contains a self-attention layer, a cross-attention layer, and a feed-forward layer (see Figure 1). The two blocks within each layer are initialized using the same pre-trained weights, and the two cross-attention layers share the same linear projection weights for the keys and values. During training, the two blocks receive two sets of image embeddings for the image pair. We append a MLP classifier on the multimodal encoder’s [CLS] representation for prediction.
  For NLVR2, we perform an additional pre-training step to prepare the new multimodal encoder for encoding an image-pair. We design a text-assignment (TA) task as follows: given a pair of images and a text, the model needs to assign the text to either the first image, the second image, or none of them. We consider it as a three-way classification problem, and use a FC layer on the [CLS] representation to predict the assignment. We pre-train with TA for only 1 epoch using the 4M images (Section 3.4).
  Visual Grounding aims to localize the region in an image that corresponds to a specific textual description. We study the weakly-supervised setting, where no bounding box annotations are available. We perform experiments on the RefCOCO+ [56] dataset, and fine-tune the model using only imagetext supervision following the same strategy as image-text retrieval. During inference, we extend Grad-CAM [9] to acquire heatmaps, and use them to rank the detected proposals provided by [53].
sections.heading: 6 Experiments
sections.heading: 6.1 Evaluation on the Proposed Methods
sections.text: First, we evaluate the effectiveness of the proposed methods (i.e. image-text contrastive learning, contrastive hard negative mining, and momentum distillation). Table 1 shows the performance of the downstream tasks with different variants of our method. Compared to the baseline pre-training tasks (MLM+ITM), adding ITC substantially improves the pre-trained model’s performance across
  all tasks. The proposed hard negative mining improves ITM by finding more informative training samples. Furthermore, adding momentum distillation improves learning for both ITC (row 4), MLM (row 5), and on all downstream tasks (row 6). In the last row, we show that ALBEF can effectively leverage more noisy web data to improve the pre-training performance.
sections.heading: 6.2 Evaluation on Image-Text Retrieval
sections.text: Table 2 and Table 3 report results on fine-tuned and zero-shot image-text retrieval, respectively. Our ALBEF achieves state-of-the-art performance, outperforming CLIP [6] and ALIGN [7] which are trained on orders of magnitude larger datasets. Given the considerable amount of improvement of ALBEF when the number of training images increases from 4M to 14M, we hypothesize that it has potential to further grow by training on larger-scale web image-text pairs.
sections.heading: 6.3 Evaluation on VQA, NLVR, and VE
sections.text: Table 4 reports the comparison with existing methods on other V+L understanding tasks. With 4M pre-training images, ALBEF already achieves state-of-the-art performance. With 14M pre-training images, ALBEF substantially outperforms existing methods, including methods that additionally use object tags [3] or adversarial data augmentation [8]. Compared to VILLA [8], ALBEF achieves absolute improvements of 2.37% on VQA test-std, 3.84% on NLVR2 test-P, and 1.88% on SNLI-VE test. Because ALBEF is detector-free and requires lower resolution images, it also enjoys much faster inference speed compared to most existing methods (>10 times faster than VILLA on NLVR2).
sections.heading: 6.4 Weakly-supervised Visual Grounding
sections.text: Table 5 shows the results on RefCOCO+, where ALBEF substantially outperforms existing methods [57, 58] (which use weaker text embeddings). The ALBEFitc variant computes Grad-CAM
  visualizations on the self-attention maps in the last layer of the image encoder, where the gradients are acquired by maximizing the image-text similarity sitc. The ALBEFitm variant computes Grad-CAM on the cross-attention maps in the 3rd layer of the multimodal encoder (which is a layer specialized in grounding), where the gradients are acquired by maximizing the image-text matching score sitm. Figure 4 provides a few visualizations. More analysis is in Appendix.
  We provide the Grad-CAM visualizations for VQA in Figure 5. As can be seen in Appendix, the Grad-CAM visualizations from ALBEF are highly correlated with where humans would look when making decisions. In Figure 6, we show per-word visualizations for COCO. Notice how our model not only grounds objects, but also their attributes and relationships.
  6.5 Ablation Study Flickr30K w/ hard negs w/o hard negs
  sitc k = 16 k = 128 k = 256 k = 128
  TR 97.30 98.60 98.57 98.57 98.22 ( 0.35) IR 90.95 93.64 93.99 93.95 93.68 ( 0.31)
  Table 6: Ablation study on fine-tuned image-text retrieval. The average recall on the test set is reported. We use sitc to filter top-k candidates and calculate their sitm score for ranking.
  Table 6 studies the effect of various design choices on image-text retrieval. Since we use sitc to filter top-k candidates during inference, we vary k and report its effect. In general, the ranking result acquired by sitm is not sensitive to changes
  in k. We also validate the effect of hard negative mining in the last column.
  Table 7 studies the effect of textassignment (TA) pre-training and parameter sharing on NLVR2. We examine three strategies: (1) the two mutimodal blocks share all parameters, (2) only the cross-
  attention (CA) layers are shared, (3) no sharing. Without TA, sharing the entire block has better performance. With TA to pre-train the model for image-pair, sharing CA leads to the best performance.
sections.heading: 7 Conclusion and Social Impacts
sections.text: This paper proposes ALBEF, a new framework for vision-language representation learning. ALBEF first aligns the unimodal image representation and text representation before fusing them with a multimodal encoder. We theoretically and experimentally verify the effectiveness of the proposed
  image-text contrastive learning and momentum distillation. Compared to existing methods, ALBEF offers better performance and faster inference speed on multiple downstream V+L tasks.
  While our paper shows promising results on vision-language representation learning, additional analysis on the data and the model is necessary before deploying it in practice, because web data may contain unintended private information, unsuitable images, or harmful texts, and only optimizing accuracy may have unwanted social implications.
title: Align before Fuse: Vision and Language Representation Learning with Momentum Distillation