Large-Scale Adversarial Training for Vision-and-Language Representation Learning
- Publication
- NeurIPS 2020Conference
- First submitted to arXiv
- arXiv:2006.06195
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{multimodalityvilla2020,
title = {{Large-Scale Adversarial Training for Vision-and-Language Representation Learning}},
author = {Zhe Gan and Yen-Chun Chen and Linjie Li and Chen Zhu and Yu Cheng and Jingjing Liu},
year = {2020},
eprint = {2006.06195},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2006.06195}
}
Let’s dive into an intriguing paper.
The authors introduce the concept of adversarial training in this work, which can often be confused with denoising. So, let’s first clarify the distinction between these two concepts:
-
Denoising
The goal of denoising is to remove noise from images or data to recover the original, unperturbed information.
For example, if you have a noisy image, the denoising process seeks to eliminate the noise and restore the image to its clean, original state.
-
Adversarial Training
The goal of adversarial training is to enable the model to make correct predictions even when facing adversarial attacks.
For instance, if a model is presented with inputs deliberately designed to mislead it into making incorrect predictions, adversarial training helps the model learn to handle such scenarios, improving its generalization capability.
In summary, denoising seeks to recover clean data from noisy inputs, while adversarial training challenges the model with deliberately chosen perturbations. Denoising need not assume that the noise pattern is known.
When training a model, we don’t only show it standard, familiar images and text but also introduce imaginary “adversaries” — inputs deliberately altered to confuse the model. These surprise challenges ask it to cope with different situations. In VILLA, the changes are applied to image-region features or word embeddings, and the paper mainly measures downstream performance on clean data.
Defining the Problem
The authors present VILLA as the first known large-scale attempt to add adversarial training to vision–language pretraining. That is the gap they saw!
The authors aim to explore how to effectively apply adversarial training to multimodal tasks while ensuring good performance.
Besides seeking robustness to bounded feature-space perturbations, they want to maintain or improve generalization on clean data. This is challenging because adversarial training adds considerable computation and training time. The study tests the clean-data gains; practical image or text attacks require a separate robustness evaluation.
Solution
This section is a bit technical, but let's read through it together.
The authors structure the entire model into three parts.
VILLA Model Design
The primary goal of this stage is to learn generalized image and text representations applicable to various downstream tasks.
-
Dataset
The dataset for pre-training (denoted as Dp in the paper) consists of image-text pairs (X_img, X_txt).
-
Feature Representation
- Images (X_img) are transformed into region feature vectors through a fixed bottom-up feature extractor (g_bu(·)).
- Text (X_txt) is converted into feature vectors through a learnable word embedding function (g_emb(·)).
-
Multimodal Fusion
To fuse image and text features, a multi-layer Transformer structure is used, popular in natural language processing and other multimodal tasks. Here, the [CLS] token holds special significance, with its encoding serving as the joint representation for multimodal tasks.
Pre-Training Tasks
MLM and ITM have been discussed in previous papers, so we'll briefly cover them and spend more time on MRM. These are common pretraining tasks; VILLA's UNITER adversarial-pretraining experiment applies to MLM and ITM.
-
Masked Language Model (MLM)
In masked language modeling, about 15% of the input tokens are randomly selected and masked. The model's task is to predict these masked tokens based on other visible language tokens and provided visual tokens.
-
Image-Text Matching (ITM)
ITM asks the model to decide whether an image and a text are paired. It is a binary classification task.
-
Masked Region Modeling (MRM)
MRM asks the model to predict masked image-region targets using the remaining image regions and text. It resembles MLM but applies to region features rather than text tokens. Here we are explaining a common pretraining task; the VILLA-on-UNITER experiment above uses MLM and ITM.
In image data X_img, selected region features are set to zero. The model then has to infer targets for those regions.
Given other unmasked multimodal information (such as other parts of the image and related text descriptions), the model's task is to predict the correct content of the masked regions. This prediction can be quantified through cross-entropy loss, KL divergence loss, or contrastive learning.
Two-Stage Adversarial Training
This refers to both pre-training and fine-tuning stages.
This discussion explores how to conduct adversarial training during pre-training and fine-tuning stages and their relationship.
-
Connection Between Pre-Training and Fine-Tuning
Pre-training and fine-tuning are two main stages in most deep learning workflows. Pre-training aims to gain a fundamental understanding and basic feature extraction capabilities, while fine-tuning specializes the model for specific tasks. These two stages are closely related, with pre-training providing the necessary foundation for fine-tuning.
-
Importance of Cross-Modal Understanding
The model needs to understand both image and text content in tasks like MLM or VQA. For example, if a picture contains a dog, the model needs to link this visual information with the word "dog."
-
Assumptions in Adversarial Training
- The first assumption is that adversarial pre-training can enhance the model's generalization ability, benefiting the fine-tuning stage. Generalization refers to the model's performance on unseen data.
- The second assumption is that during the fine-tuning stage, with specific task training data, adversarial training methods can be reused to further improve model performance.
-
Shared Mathematical Formulas
Since pre-training and fine-tuning stages are mathematically similar, both can employ the same adversarial training methods.
The emphasis is that both stages can use adversarial training. The paper evaluates generalization on clean downstream data, not robustness by measuring attack success rates.
Adversarial training in the pre-training stage helps enhance the model's basic generalization ability, while in the fine-tuning stage, it can further improve performance for specific tasks.
Perturbations
This section explores how to add adversarial perturbations in the embedding space of image and text.
-
Perturbations in Image Modality
In the V+L models studied here, the input includes region features from a pretrained object detector. Instead of changing a dog photo's pixels, VILLA adds bounded perturbations directly to the region features supplied to the multimodal model. It does not produce a visibly attacked photo.
-
Perturbations in Text Modality
Unlike the continuous values in image pixels, text tokens are discrete, making them harder to manipulate. Traditionally, creating adversarial examples that preserve the original semantics is challenging in text modality. However, this method chooses to add perturbations in the word embedding space instead of directly altering the words. This avoids changing the original text content while still affecting the model's prediction.
For instance, consider "The dog barks." Instead of replacing or modifying the word, VILLA adds a bounded perturbation to the embedding of "dog." The resulting vector need not correspond to another readable word.
-
Position Encoding
In pre-trained V+L models, position encoding is used to encode the positions of image regions and subword tokens. In this adversarial training method, only image and word encodings are modified, keeping other features unchanged.
-
Consideration for Simultaneous Perturbations
The authors perturb image or text features separately and combine the training losses, rather than always changing both inputs in one forward pass. The objective retains the original supervision labels and encourages the perturbed and clean prediction distributions to stay close. Table 3 also notes that simultaneous and alternating perturbation gave similar results in their test.
Multimodal "Free" Adversarial Training
This section elaborates on the multimodal "free" adversarial training method used in the VILLA model, involving multiple mathematical formulas and technical details. Don't worry, let's break it down:
-
Training Objective
In VILLA, adversarial training adds bounded perturbations to image-region features or word embeddings during training. Its purpose is to improve generalization on downstream clean data.
The training process considers three main loss components:
-
Standard Cross-Entropy Loss (L-std)
This is cross-entropy on clean inputs, using the supervision labels of the pretraining or downstream task.
-
Label-Preserving Adversarial Training Loss (R-at)
This separately searches for image- and text-embedding perturbations that increase loss, then trains against them using the original supervision labels. It is an optimization objective.
-
Fine-Grained Adversarial Regularization Term (R-kl)
This uses symmetric KL divergence to encourage the perturbed and clean predictive distributions to be close.
-
-
Multimodal Adversarial Perturbations
VILLA trains on the original image-region features and word embeddings, and on bounded perturbations of each representation, to improve downstream generalization.
The perturbations have norm constraints, so their magnitude is controlled.
The training has an outer minimization over model parameters and an inner maximization over bounded perturbations. The model update lowers the objective; projected gradient ascent seeks perturbations that raise it. This is the direction required by the inner maximization, even though the method is conventionally called PGD (Projected Gradient Descent).
Specifically, for image modality, during each iteration of updating perturbations, PGD first calculates the current perturbation's impact on the loss, i.e., the gradient of the loss with respect to the perturbation. Then, it takes a small step in this gradient direction to find a new perturbation that maximizes the loss. This process is repeated until the preset number of iterations or perturbation size limit is reached.
Imagine training a model to distinguish dogs from cats in photos. The image-region encoding represents features extracted from the photo.
-
Adding Adversarial Perturbations
Suppose someone nudges the extracted region features to make a cat harder for the model to distinguish from a dog. VILLA perturbs these features, not the photo pixels.
-
Norm Constraints
These changes are bounded in feature space. The bound limits their magnitude; it does not literally prevent a cat's visible face from deforming, since the photo is never edited.
-
Optimization
In each training iteration, the model tries to identify these adjustments and learn to ignore them, focusing on distinguishing features between dogs and cats. Using SGD, the model adjusts its parameters based on these adjustments' impact, reducing the error rate on these perturbed images. Using PGD, the model tries to find the most likely disturbances in each iteration, learning and adjusting for the worst-case scenarios.
-
-
Further Enhancement of Adversarial Regularization
Adversarial regularization is a technique in machine learning aimed at improving the model's generalization, ensuring it can make correct predictions even with adversarial perturbations. In some situations, adversarial perturbations can significantly alter the model's prediction, and this regularization method seeks to limit such changes.
This regularizer adds a distribution-similarity target beyond the original-label loss. It encourages predictions before and after perturbation to stay close; it is a training constraint, not a promise that every prediction stays unchanged.
Free Adversarial Training Strategy
Adversarial training uses perturbed representations while optimizing model parameters. Here, the authors call one gradient-reuse strategy “Free.” (Does that mean “no cost” or “freedom”? Neither is quite right.)
-
Computational Cost of K-step PGD
PGD (Projected Gradient Descent) is commonly used in adversarial training. Using K-step PGD requires K forward and backward passes through the model, which is time-consuming. Moreover, only the final perturbation after K steps is used for model training, meaning all previous steps are just for generating this final perturbation.
-
Solution: FreeLB
To make large-scale training more practical, the authors adopt FreeLB. Each perturbation step still runs forward and backward computation, but parameter gradients are accumulated while the perturbation gradients are calculated. The model parameters are updated once after the K steps.
This uses the intermediate perturbations as a K-fold “virtual” mini-batch. It does not create K independent new training examples or remove the roughly K-fold adversarial computation.
To make it more relatable, let's consider an example:
Imagine assembling a bicycle, where each step involves specific parts.
-
Traditional K-step PGD Method
This is like testing the bicycle's functionality at each assembly step. For instance, after installing the pedals, you take a short ride, then add the chain and ride again, testing at each step. While this ensures each part is correctly installed, it's time-consuming.
However, you find that only the final ride test after assembling all parts is crucial, indicating whether the entire bicycle is correctly assembled.
-
FreeLB Strategy
Now, imagine a different assembly strategy.
Instead of testing at each step, you note potential issues or considerations during assembly (equivalent to accumulating gradients). After assembling all parts, you conduct a comprehensive test and adjustment based on accumulated issues and considerations.
This analogy illustrates accumulating information before one model-parameter update. It has a limit: FreeLB still runs a forward and backward pass at every perturbation step, so it does not eliminate those tests or their compute cost.
Of course, all analogies have limitations and may not perfectly map to the target concept, but they help provide a feel.
Discussion
The focus of this paper is mainly on the design of adversarial training.
But we still need to see if this design is effective. And how effective?
Experimental Setup
To validate VILLA, the authors evaluated pretrained V+L models on Visual Question Answering (VQA), Visual Commonsense Reasoning (VCR), Referring Expression Comprehension (RE), Visual Entailment, Image–Text Retrieval, and NLVR2.
The validation proceeds with UNITER for downstream tasks and ablations, then LXMERT for a smaller transfer test of whether the fine-tuning recipe also works on another V+L model.
If you haven't read about these two models, refer to the following:
-
Main Model Configurations: UNITER and LXMERT
-
UNITER
- UNITER-base: A single-stream model with 12 layers, 768 hidden units per layer, and 12 attention heads.
- UNITER-large: A larger version with 24 layers, 1024 hidden units per layer, and 16 attention heads.
- Same structure as BERT, but with inputs combining both modalities (vision and language).
-
LXMERT
- LXMERT is a dual-stream model with independent self-attention layers for each modality (9 layers for text, 5 layers for vision), followed by 5 layers for cross-attention and self-attention processing.
-
-
Setup Details
- For UNITER experiments, the authors used four main large datasets for pre-training: COCO, Visual Genome (VG), Conceptual Captions, and SBU Captions.
- VILLA's adversarial pretraining applies to UNITER's MLM and ITM tasks. UNITER-base runs 100k standard steps and 100k adversarial steps; UNITER-large runs 425k and 75k respectively. The total step counts match their respective baselines, but adversarial steps require more computation, so the comparison is not equal compute.
VILLA on UNITER and Analysis
-
VILLA Compared to Other Pre-Trained V+L Models
- VILLA performs strongly on most listed columns, but does not win every one. For example, VILLA-base Flickr30k image retrieval R@10 is 95.82, below UNITER-base's 96.08.
- Compare VILLA-base with UNITER-base using the same split and metric:
-
In VQA: test-std rises by 0.76 percentage points over UNITER-base
- In VCR Q→AR: the parenthesized ensemble scores 60.6 versus 58.2, a 2.4-point gain; the single models score 59.75 versus 57.76, a 1.99-point gain.
- In NLVR2 test-P: 79.30 versus 77.85, a 1.45-point gain.
- In SNLI-VE test: 79.03 versus 78.28, a 0.75-point gain.
- In Flickr30k image/text retrieval: +2.22/+0.70 points at R@1.
- The average gain across three RE datasets is 0.99 points; individual splits vary.
-
VILLA-large model improvements
- Similar performance improvement trends overall.
- In VCR Q→AR: the parenthesized ensemble scores 65.7 versus 62.8, a 2.9-point gain; the single-model scores are 65.18 versus 62.59, a 2.59-point gain. The authors suggest that the task's social dynamics and common-sense reasoning might be involved, but this experiment does not isolate that cause.
- In VQA test-std: from 74.02 to 74.87 for the single models.
- An ensemble reaches 75.85 on VQA test-std, a different condition from the 74.87 single-model result.
In-Depth Analysis of VILLA
-
Pre-Training vs. Fine-Tuning
Using UNITER-base to study the effects of adversarial training in pre-training and fine-tuning stages.
- UNITER (reimp.): UNITER-base model re-implemented with standard training.
- VILLA-pre vs. VILLA-fine: Models applying adversarial training only in pre-training or fine-tuning stages, respectively.
- Results: VILLA-pre and VILLA-fine provided +0.51 and +0.82 average performance gains across six evaluation tasks. Combining both stages resulted in +1.15 gain.
On these three validation curves, full VILLA is ahead of original UNITER in the later training period. UNITER is still ahead for part of early VQA training, and the gap does not grow at every step.
-
Image vs. Text Modality (Table 3a)
These adversarial examples are perturbations of image-region features or word embeddings; the paper does not produce a photo or sentence for a human visual similarity comparison. Table 3(a) contrasts text-only, image-only, and both-modality training.
- Experiments and Results
- Independent image perturbation: Adding perturbation only to image features significantly improves model performance. This contrasts with traditional belief where adversarial training often negatively impacts model accuracy on clean images.
- Intuition vs. Actual Results: A single perturbed modality already helps. Yet the both row has the highest VILLA-base VQA and VCR Q→AR values, and all four VILLA-large columns. The paper also reports similar results for simultaneous versus alternating perturbation.
VCR requires social and common-sense reasoning about images. Its gains here are larger than VQA's; the authors suggest task complexity as a possible reason, but the ablation does not test that explanation separately.
- Experiments and Results
-
FreeLB vs. VILLA (Table 3b)
Table 3(b) compares FreeLB with VILLA-fine on VQA and VCR. Every listed VILLA-fine column is higher in this fine-tuning comparison. In the base model, VQA rises from 72.82 to 73.29 and VCR Q→AR from 58.73 to 59.30.
But wait, didn't we mention earlier that VILLA adopts the FreeLB strategy? Why compare it again?
VILLA uses FreeLB's gradient accumulation strategy but adds fine-grained adversarial regularization. That is why the paper compares VILLA-fine with FreeLB rather than treating them as the same method.
The table supports an improvement from that added regularization in these tested models and tasks.
-
Results on LXMERT
To check whether the method is limited to UNITER, the authors applied VILLA-fine only to LXMERT. Relative to the reimplemented LXMERT baseline, VQA test-dev rises 72.50→73.02, GQA test-dev 59.92→60.98, and NLVR2 test-P 74.75→75.73. Its VQA test-std 73.18 exceeds UNITER-base's 72.91, while NLVR2 test-P 75.73 remains below UNITER-base's 77.85.
The three-task Meta-Ave. increases from 69.12 to 70.00, or 0.88 points. This is evidence that adversarial fine-tuning transfers to LXMERT; LXMERT did not receive VILLA's adversarial pretraining.
Conclusion
In exploring deep-learning robustness, adversarial attacks are an important area. This study considers adversarial training for vision-and-language (V+L) representations. Attack strategies for these models were relatively underexplored: backpropagating through multimodal Transformers to a CNN backbone for pixel-level image attacks, and crafting text attacks that fit the visual context, are challenging. VILLA instead perturbs the input feature and embedding spaces and mainly evaluates clean-data tasks.
VILLA is an adversarial training framework for vision-and-language representation learning. It applies adversarial training during both pretraining and fine-tuning. By perturbing the embedding spaces, it improves many reported benchmark results, with exceptions in individual columns.
The authors view VILLA as a “plug-in” training concept: an existing V+L architecture can incorporate its adversarial training recipe without being replaced. You still need to train the model; it is not a last-minute inference switch. Gains of roughly 1–3 percentage points apply to particular models, tasks, splits, and metrics rather than every score.
Finally, the authors acknowledge that despite VILLA's significant benefits, the time-consuming nature of adversarial training remains a challenge. Future work aims to find more efficient adversarial training methods to make large-scale pre-training more feasible in everyday practice.