{'fraction_non_alphanumeric': 0.04805472051583671, 'fraction_numerical': 0.017252646712847992, 'mean_word_length': 4.771561478501383, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 2, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
LAVENDER: Unifying Video-Language Understanding as Masked Language Modeling

Unified vision-language frameworks have greatly advanced in recent years, most of which adopt an encoder-decoder architecture to unify image-text tasks as sequence-to-sequence generation. However, existing video-language (VidL) models still require task-specific designs in model architecture and training objectives for each task. In this work, we explore a unified VidL framework LAVENDER, where Masked Language Modeling (MLM) is used as the common interface for all pre-training and downstream tasks. Such unification leads to a simplified model architecture, where only a lightweight MLM head, instead of a decoder with much more parameters, is needed on top of the multimodal encoder. Surprisingly, experimental results show that this unified framework achieves competitive performance on 14 VidL benchmarks, covering video question answering, text-to-video retrieval and video captioning. Extensive analyses further demonstrate the advantage of LAVENDER over existing VidL methods in: (i) supporting all downstream tasks with just a single set of parameter values when multi-task finetuned; (ii) few-shot generalization on various downstream tasks; and (iii) enabling zero-shot evaluation on video question answering tasks. Code is available at https://github.com/microsoft/LAVENDER.


Introduction
Large-scale transformer-based pre-training is now the de facto practice for NLP and vision-language research [14,36,51,50,24]. Together with the great success of image-text pre-training [62,40,11,34], video-language (VidL) pre-training [61,87,32,28,84] has also received an increasing amount of attention. By pre-training an end-to-end multimodal transformer on a large number of video-text pairs, state-of-the-art performance has been achieved across a wide range of VidL tasks, including video question answering (QA) [23,73], text-to-video retrieval [21,54], and video captioning [76,69]. These advances are encouraging; however, on the other hand, all existing VidL works require designing task-specific heads on top of the transformer encoder for each pre-training  [14] (MLM) and Video Text Matching (VTM) heads are used, while a new, separately parameterized head needs to be added for each downstream adaptation. Furthermore, due to the particular nature of different tasks, they are typically modeled using different training objectives. For example, multiplechoice video QA is formulated as a classification problem, while video captioning is inherently a generation task. A natural but challenging question arises: can we have a unified architecture that supports all the popular VidL tasks simultaneously without introducing task-specific heads?
To answer this, we present LAVENDER, a unified VidL framework where all pre-training and downstream tasks are formulated as simple MLM. As shown in Figure 1, we use two pre-training tasks: MLM and VTM. However, for VTM, instead of adding a head on top of the output of the commonly used [CLS] token, as used in all existing works, we propose to append the same [MASK] token that is used for MLM at the end of the video-text input, and use the same MLM head to predict whether the input video-text pair matches or not. Note that VTM is typically formulated as a binary classification problem; here, we simply treat the output of true or false from VTM as natural language tokens directly predicted from the whole vocabulary, so that the same set of parameters can be used for both MLM and VTM.
During downstream adaptation, instead of discarding the MLM head used in pre-training and adding new heads, which is the standard practice for all previous VidL works, we use the same MLM head used in pre-training for all downstream tasks. Specifically, • For text-to-video retrieval, we train the model in the same way as in the VTM pre-training task. During inference, for each text query, we concatenate it with each candidate video, and calculate the corresponding probability of the [MASK] token being predicted as true, and then rank all candidate videos based on that score. • For multiple-choice video QA, we concatenate the question and each answer candidate sequentially, and add a [MASK] token at the end of the sequence, and use the same MLM head to predict the answer as "n" (assuming the ground-truth choice is the n-th answer). • For open-ended video QA, since most of the ground-truth answers in our tested datasets only contain one word, we simply append a [MASK] token to the end of the video-question input, and let the model predict the answer from the whole vocabulary. • For video captioning, during training, we mask a certain percentage of the tokens, and then predict the masked tokens using a seq2seq attention mask [34,85]. During inference, the full caption is auto-regressively predicted, by inserting [MASK] tokens one at a time.
LAVENDER is inspired by VL-T5 [13], UNICORN [80] and OFA [68] that aim to provide a unified pre-training framework for image-text tasks. However, ours is very different from theirs, as we use an encoder-only model and an additional lightweight MLM head on top of it, while a heavy transformer decoder is needed in [13,80,68]. By unifying all the VidL tasks as MLM, LAVENDER can seamlessly adapt to different VidL tasks, and enables new capabilities over existing task-specific methods, such as (i) supporting different VidL tasks with a single set of parameter values when multi-task finetuned; (ii) better generalizability to test data under few-shot finetuning; and (iii) zero-shot inference on video question answering. Surprisingly, by using this simple generative approach, we outperform previously published state-of-the-arts on 12 out of 14 downstream tasks (Table 1), even when pre-trained with much fewer data (see Section 4.5 for detailed comparisons).

Related Work
Video-Language Pre-training. Branching out from large-scale image-text pre-training [11,62], researchers have been leveraging large-scale multimodal data [10,27,58,46,84,3,83] to build pre-(a) Existing VidL Methods (b) Existing Unified Image-text Models (c) LAVENDER Figure 2: Illustration of the differences between LAVENDER and existing methods with image/video question answering (QA) as an example. Unlike task-specific designs in existing VidL methods, LAVENDER unifies all tasks as MLM ( Figure 1). We adopt an encoder-only architecture, with a lightweight MLM head, instead of the heavy decoder in unified image-text models (e.g., VL-T5 [13] with task-specific prefix in text input).
Although achieving strong performance, existing methods all require task-specific architectures or objectives for different downstream tasks. For example, text-to-video retrieval [21,54] is modeled as binary classification [28] or via contrastive learning [45,17]; video question answering [23,73] is often formulated as multi-class classification with a set of pre-defined answer candidates [84,81]; and video captioning can be tackled via MLM with a multi-layer perceptron [35] or prefix language modeling with a text decoder [57].
Unified Frameworks for Multimodal Understanding. There have been attempts in building an omnipotent model that can simultaneously handle different tasks with a unified architecture, which can be broadly categorized into two directions. The first is to insert expert-designed task-specific heads for each downstream task [20,59,22,33]. These task-specific output layers not only require expert knowledge, but are also unlikely to generalize to new tasks. For example, when a new question answering task comes in, a new fully-connected layer with output dimension of answer vocabulary size is required. The second direction is to unify the input-output format of different downstream tasks [70,13,80,68]. With a unified vocabulary, different downstream tasks (e.g., image question answering [19], image captioning [10] and visual grounding [26]) can be formulated as the sequence-to-sequence generation with the shared encoder-decoder architecture [80,68].
Our work aims to provide a unified framework for VidL understanding, in contrast to task-specific architectures and objectives used in existing VidL models (Figure 2c vs. Figure 2a). LAVENDER differs from the previous unified image-text models in that all pre-training and downstream tasks are unified as MLM, and a simple encoder-only architecture with a lightweight MLM head is used, instead of sequence-to-sequence modeling as in [13,70,68,80] that also requires a heavy transformer decoder (Figure 2c vs. Figure 2b).

Model Architecture
Given a pair of text sentence {w n }| N n=1 and a video {v t }| T t=1 , we first encode them separately via unimodal encoders (i.e., vision encoder and text encoder) to generate unimodal features. Here, N is the number of tokens in a sentence and T is the number of frames sampled from the input video. We follow previous works [28,84] to only sparsely sample a few frames to ease the computational burden. A multimodal fusion encoder (dubbed as fusion encoder) projects textual features and visual features into a shared embedding space to learn cross-modal representations. As LAVENDER unifies both pre-training and downstream tasks as Masked Language Modeling (MLM), the same MLM head is used to generate the final outputs from the cross-modal representations, across different tasks. Next, we explain each component in detail.
Vision Encoder. Inspired by the success of vision transformers in modeling spatial details in images [15,37], different transformer architectures [5,38,77] have been proposed to model the long-range temporal modeling in videos, achieving promising results on action recognition [25]. Recent video-language works [16,35] have started to embrace the success of video transformers, demonstrating stronger performance than encoding each video frame independently [28]. In our work, we adopt Video Swin Transformer [38] (VidSwin) as the vision encoder to encode the raw video frame inputs as a sequence of visual features. Given T input video frames {v t }| T t=1 of size H ×W ×3, we first split each frame into non-overlapping patches of size h×w. VidSwin additionally enforces temporal downsampling of size 2 as a preprocessing step. To allow LAVENDER to have the flexibility of utilizing both video-text and image-text data for pre-training, we remove this temporal downsampling. As a result, we can extract a sequence of visual features of size T × H h × W w from the last encoder block of VidSwin. Each feature is of size 8C (C is the channel dimension), which is projected to the same dimensional space as text features via a fully-connected layer. We follow [16] to add learnable positional embedding layers along both spatial and temporal dimensions. The resulting visual features are used as input to the fusion encoder to learn cross-modal representations.
Text Encoder. The input text sentence is first tokenized into the sequence of word tokens {w n }| N n=1 , following [72]. Two special tokens [CLS] and [SEP] are inserted at the beginning and the end of the token sequence. We follow previous works [28,84,16] to adopt a lightweight word embedding layer [14] as the text encoder. The high-dimensional text embeddings are concatenated with visual features and then fed into the fusion encoder.
Multimodal Fusion Encoder. The fusion encoder is a 12-layer, 768-dimensional Transformer [65], mirroring the BERT-base architecture [14]. To compute the cross-modal representations, the unimodal features from vision and text encoders are fused together via self-attention operations.

Our Unified Framework
Now, we introduce how LAVENDER can be trained in a unified way.
Video-language Pre-training.
We adopt two objectives to pre-train LAVENDER. The first is Masked Language Modeling (MLM), which is directly adopted from language model pretraining [14,36]. In MLM, we randomly replace 15% of word tokens with a [MASK] token, a random word, or the same word. The goal is to reconstruct the correct tokens based on the corresponding hidden representations from the output of the fusion encoder at the masked position. A multi-layer perceptron (MLP) with output dimension as vocab_size projects these hidden representations into the discrete word token space. Cross-entropy loss is used to supervise the model training. The second is Video Text Matching, but reformatted as MLM (VTM as MLM). Specifically, we append a [MASK] token to the textual sentence to mimic the masked textual inputs in MLM. At each training step, we randomly replace the corresponding text for a given video with a text description from a different video in the same batch. At the masked position, LAVENDER reuses the exact same MLP used in MLM to make a prediction. Although the ground-truth label is restricted to two tokens (i.e., true (false) for a positive (negative) video-text pair), but the model predictions are made across all vocabularies.
Downstream Adaptation. As shown in Figure 1, we can readily apply the pre-trained LAVENDER to 4 types of downstream tasks, including text-to-video retrieval, multiple-choice video question answering, open-ended video question answering and video captioning. For each task, we transform the text input by inserting or replacing existing tokens with [MASK] tokens, so that all tasks can be supervised with cross-entropy loss, and the final predictions are made based on the word token predicted at the masked position. Here, we explain in detail how to construct the masked textual inputs and generate model predictions for each downstream task.
For text-to-video retrieval, similar to VTM during pre-training, we insert a [MASK] token at the end of the text input. During training, we treat corresponding video-text pairs as positives (with groundtruth label true) and all other pairwise combinations constructed by replacing the ground-truth text with a randomly sampled one as negatives (with ground-truth label false). During inference, given a textual query, we rank the videos according to the model confidence of predicting true at the masked position. For multiple-choice video QA, we concatenate each answer choice (A n ) sequentially to the question (Q) with a [SEP] token in between. A [MASK] token is then added at the end, to allow the model to make a prediction of the correct index for the ground-truth answer choice. For example, for a question and 5 answer choices, we take Q+[SEP]+A 0 +[SEP]+...+A 4 +[MASK] as the text input. If A n is the correct answer, the ground-truth label for the masked token is n. Through the MLM head, the model makes a prediction at the masked position over the whole vocabulary. During inference, to ensure a valid answer, we take the most probable predictions over all answer indices (e.g., {0,1,2,3,4}). For open-ended video QA, we similarly inject [MASK] tokens after the question. For simplicity, we only add one [MASK] token. 1 We then tokenize the ground-truth answers as the ground-truth label for masked prediction. If the tokenized answer is longer than 1 word, we simply ignore it during training, and regard it as a wrong prediction during inference. For video captioning, we use a causal self-attention mask where the caption token can only attend to the existing output tokens, which simulates a uni-directional seq2seq generation process, following [35]. During training, we randomly "mask" some words with [MASK] token and apply the MLM objective. During inference, the caption is generated in an auto-regressive manner. At each generation step, the model sees the entire video input and previously generated tokens, plus a [MASK] token, at which the model makes a prediction for the current token.

Experiments
In this section, we first describe our experimental settings (4.1), and show the superiority of LAVEN-DER over comparable task-specific baselines under both single-task (4.2) and multi-task (4.3) finetuning settings. We then show that our model can better generalize to testing data under few-shot finetuning and has strong zero-shot capability on video question answering benchmarks (4.4). Lastly, we compare LAVENDER with prior arts and show we outperform published methods on 12 out of 14 benchmarks, even when pre-trained with much fewer data (4.5).

Experimental Settings
Pre-training Data. In our default setting, we follow [3] to aggregate video-text pairs in Web-Vid2.5M [3] and image-text pairs in CC3M [58] to pre-train LAVENDER. As a scale-up recipe, we additionally crawl 11.9M video-text pairs from the web, following the same procedure in [3]. We similarly scale up image-text pairs by assembling COCO [10], Visual Genome [27], SBU Captions [47], CC12M [8] and CC3M. Combining these video-text and image-text datasets together results in 14M videos + 16M images. Unless otherwise specified, all results reported in this section as LAVENDER are pre-trained under the default setting with 2.5M videos + 3M images. In Section 4.5, we show that scaling up our pre-training data further improves model performance.
Downstream Tasks. We evaluate LAVENDER on 14 video-language benchmarks over popular VidL tasks, including text-to-video retrieval, video question answering (QA) in both multiple-choice (MC) and open-ended (OE) settings and video captioning. We briefly list the evaluation datasets for each task type below; detailed descriptions are included in Appendix E.
• Text-to-video Retrieval: MSRVTT [76], DiDeMo [21], MSVD [9] and LSMDC [54]; • MC Video QA: TGIF-Action, TGIF-Transition [23], MSRVTT-MC [82] and LSMDC-MC [64]; • OE Video QA: TGIF-Frame [23], MSRVTT-QA, MSVD-QA [73] and LSMDC-FiB [44]; • Video Captioning: MSRVTT [76] and MSVD [9]. Implementation Details. We initialize our Vision Encoder with VideoSwin-Base [38], pre-trained on Kinetics-600 [25]. Text Encoder and Multimodal Fusion Encoder are initialized from pre-trained BERT-Base [14]. We train LAVENDER in an end-to-end manner for both pre-training and downstream finetuning. Our implementation of LAVENDER is based on PyTorch [48]. We adopt AdamW [39] as the optimizer with an initial learning rate of 2e-5, betas of (0.9, 0.98), and weight decay of 1e-3 for all pre-training and finetuning experiments. During pre-training, we sparsely sample T =4 video frames and resize them into H=W =224 to split into patches with size h=w=32. For default setting with 2.5M videos + 3M images, we pre-train LAVENDER for 10 epochs on 32 NVIDIA V100 GPUs with a batch size of 28 per GPU, which takes about 2 days. The scale-up pre-training takes about 10 days on 64 NVIDIA V100 GPUs. For all downstream tasks, we adopt the same video frame size and patch size, but T =5 video frames. More details can be found in Appendix C. Table 2: Comparison to task-specific baseline under single-task (ST) and multi-task (MT) finetuning (FT), with or without video-langauge pre-training (PT). We report accuracy for TGIF-Action and MSVD-QA, average (R1, R5, R10) for DiDeMo Retrieval (Ret.) and CIDEr score for MSRVTT Captioning (Cap.). Meta-Ave. is the average score across all evaluation datasets. P and H denote the total parameter count in the backbone of LAVENDER (vision encoder + text encoder + fusion encoder) and top output layer. Note that the baseline with task-specific heads (L3-6) is LAVENDER-TS, introduced in Section 4.2. Task

Comparison to Task-specific Baseline
To make a fair comparison to task-specific methods, we train a task-specific version of LAVENDER (denoted as LAVENDER-TS). We replace the shared Masked Language Modeling (MLM) head in LAVENDER with task-specific heads and adopt task-specific objectives. For text-to-video retrieval (and similarly for video text matching during pre-training), a multi-layer perceptron (MLP) with output dimension 1 is applied over the global video-language representation of the [CLS] token and binary cross-entropy loss is adopted to supervise the model training. For multiple-choice video question answering (QA), we concatenate questions with all answer candidates to form the input text, similar to what was described in Section 3.2, but without the added [MASK] token. A task-specific MLP with output dimension as the number of answer choices is applied over the representation of [CLS] token and cross-entropy loss is used to train a classifier over all answer indices (e.g., {0, 1, 2, 3, 4} with 5 answer choices). For open-ended video QA, we follow the common practice [84,16] to build a finite set of answer vocabularies covering the most common answers in the training split of each dataset. Similarly, a MLP with output dimension as the number of answers is added and cross-entropy loss is used to train a classifier over all answers. For video captioning, we simply adopt the same training strategy with MLM head as in our unified model. Table 2 compares LAVENDER to the task-specific baseline LAVENDER-TS under different settings, on four representative benchmarks. For easier comparisons, we use Meta-Ave, the average across scores over all evaluation tasks, to measure the average model performance. Here, we focus our discussion on results under single-task finetuning, and delay the analysis on multi-task finetuning to Section 4.3. Without video-language (VidL) pre-training, task-specific baseline with different task heads (L3) outperforms our unified model (L1) on MSVD-QA and DiDeMo Retrieval. Captioning performance are similar as we adopt the same MLM head and finetuning strategy for both models. The only outlier is TGIF-Action, on which we empirically find the training of LAVENDER-TS struggles to converge, leading to a low Meta-Ave score.
We also compare the two models under VidL pre-training. We follow [28] to pre-train task-specific LAVENDER-TS with MLM and the standard Video Text Matching (VTM) task, which is modeled as binary classification with an additional MLP layer. In comparison, the unified model LAVENDER is pre-trained with MLM and VTM as MLM, with the shared MLM head (Section 3.2). The unified VidL pre-training (L7) significantly enhances the performance of LAVENDER, with a gain of +23.4 on Meta-Ave over without pre-training (L1). Comparing both models under VidL pre-training, we also observe that LAVENDER (L7) outperforms LAVENDER-TS (L5) by a notable margin across all 4 tasks (+4.9 on Meta-Ave).

Multi-task Finetuning
In this section, we aim to answer the important question raised in Section 1: can we have a unified architecture that supports all downstream tasks simultaneously without introducing task-specific heads? We first compare LAVENDER with several multi-task learning baselines with different taskspecific designs in Table 2 and report results under the extreme multi-task setting -a single model that can support all 14 datasets (all-in-one) in Table 3.
Comparison to task-specific baseline. We begin our comparison with the most common multi-task baseline in literature [33,41] -adopting a task-specific head and objective for each task, while sharing the backbone. This is equivalent to finetuning the task-specific model LAVENDER-TS under multi-task setting. We compare the two models in Table 2 and summarize our findings below: • Single-task vs. Multi-task: Without video-language (VidL) pre-training (L1-4), we find that multi-task training greatly improves model performance in both cases, as it can take advantages of additional and diverse supervision. Combining multi-task finetuning with VidL pre-training renders slight performance drop (L5-8). • Single shared head vs. Task-specific heads: Results show that LAVENDER (single shared head) outperforms LAVENDER-TS (task-specific heads), with (L8 vs. L6, +5.9) or without (L2 vs. L4, +2.9) VidL pre-training. LAVENDER also saves more parameters (approximately 3H) from the additional 3 task-specific heads in LAVENDER-TS under multi-task finetuning. In addition, the performance drop of multi-task finetuning from single-task finetuning is less severe with the shared MLM head (-0.6 for LAVENDER vs. -1.6 for LAVENDER-TS) under VidL pre-training.
Multi-task Variants with LAVENDER. We also explore different multi-task variants with our unified framework LAVENDER in Table 2: (i) L8: the vanilla version without any task-specific design; (ii) L9: with human-readable task-specific prompts (e.g., "is the video-text paired, true or false?" for video text matching), which has shown promising results for language understanding [56]; and (iii) L10: with learnable task-specific tokens (e.g., a special token [VTM] for video text matching), which is in analogy to the task prefixes in [13]. Different from observations in [56,13], both task-specific prompts and tokens do not show a clear advantage over the vanilla version. We conjecture the differences may be due to the weaker text encoder and the less diverse text prompts, which we leave as interesting directions for future study. Based on the above analyses, we simply extend the vanilla multi-task finetuning method from 4 to all 14 VidL benchmarks considered.
All-in-One. In Table 3, we finally attempt to answer the question with one model that can conquer all 14 downstream tasks simultaneously. We first establish the baseline performance by training single-task (ST) models with LAVENDER. We then report multi-task results with (i) a single set of parameters for all tasks (MT (all-in-one)); (ii) the best-performing checkpoint for each task (MT (best)); and (iii) with multi-task finetuning as 2nd stage pre-training and then finetune on each single task (MT→ST), from the learned weights with MT (all-in-one). As the results show, MT→ST achieves slightly better Meta-Ave across all settings. Surprisingly, the all-in-one model is very competitive, with only -0.5 performance drop on Meta-Ave, when compared with ST models.

Few-shot and Zero-shot Evaluation
Next, we showcase two new capabilities enabled by LAVENDER over task-specific baseline.
Few-Shot Generalizability. We first study how LAVENDER can generalize to testing data with limited training examples. Figure Table 4: Zero-shot Evaluation on Video QA. Top-1 accuracy is reported. We gray out BLIP [31], which is additionally supervised with VQA v2 [19], and MERLOT RESERVE [83], pre-trained with additional audio modality and uses GPT-3 [7]  Zero-Shot Evaluation on Video QA. Even without a heavy text decoder as in [13,80,68], a pre-trained LAVENDER can be directly evaluated on video question answering (QA) tasks without finetuning. Table 4 compares zero-shot (ZS) performance of LAVENDER with task-specific baseline LAVENDER-TS on 8 video QA benchmarks.
Since the model has neither learned to perform the multiple-choice QA task nor seen similar data during pre-training, we transform multiple-choice QA as Video Text Matching (VTM) for better ZS performance. Specifically, we let LAVENDER to predict true or false via MLM head, given a video-question-answer input, and we rank the probability of model prediction as true across all answer choices. Similarly, for LAVENDER-TS with binary classification head for VTM, we simply rank the probability of model prediction as "matched". With the same pre-training data, LAVENDER evidently outperforms LAVENDER-TS on all multiple-choice QA benchmarks. On open-ended QA tasks, LAVENDER can be applied seamlessly, thanks to the shared MLM head. However, for LAVENDER-TS, the randomly initialized task-specific heads give meaningless ZS predictions.
We also compare LAVENDER against previous methods. Without the help of additional audio modality in [83] or supervision signals in [31], LAVENDER achieves competitive ZS performance, even when pre-trained with much less data (5.5M vs. >69M). When scaling up the pre-training data by roughly 5 times, we observe notable performance improvements on most QA benchmarks. The performance drop on a few datasets may be due to the inclusion of more noisy data when scaling up.

Comparison to Prior Arts
In this section, we compare LAVENDER with prior arts, which are mostly designed to tackle a single type of video-language (VidL) task. Table 5 summarizes results of LAVENDER on video question answering (QA) and video captioning. For video QA, LAVENDER achieves significant gains over existing VidL pre-trained models on 7 out 8 video QA benchmarks considered. On MSRVTT-QA, LAVENDER is only 1.8 points behind All-in-one [67] pre-trained with 283M videos, which is 9 times more than ours (30M). It is worth mentioning that VIOLET [16] adopts the same model architecture and finetuning objectives as  our task-specific baseline LAVENDER-TS. Even when scaling up the VidL pre-training to 186M videos+images, the task-specific model VIOLET still underperforms LAVENDER, which further demonstrates the advantages of our unified framework. For video captioning, LAVENDER achieves the new state-of-the-arts on both datasets. Note that MV-GPT [57] is pre-trained for multi-modal video captioning, where the auto-transcribed text from audio is used as additional input. With video-only inputs, LAVENDER is able to achieve comparable performance. Table 6 presents the comparison on text-to-video retrieval. The most competitive methods [12,6,18] on text-to-video retrieval are based on CLIP [50] pre-trained on 400M images. However, with much fewer pre-training data, LAVENDER can still perform competitively on all 4 benchmarks, especially when compared to non-CLIP pre-trained methods [67,16,3]. Notably, on DiDeMo and LSMDC, LAVENDER surpasses all baseline methods in Table 6. We hypothesize that the fusion encoder in LAVENDER is more effective in modeling interactions between video and long paragraph query (i.e., DiDeMo) or the contextualized queries collected from movie scripts (i.e., LSMDC), than the late dot-product fusion in [12,6].

Conclusion and Discussion of Broader Impact
We introduce LAVENDER, the first unified video-language (VidL) framework, that can tackle various VidL tasks with a unified Masked Language Modeling objective. Without any task-specific architectures, LAVENDER outperforms the prior state-of-the-art on 12 out of 14 benchmarks considered. Experiments show that LAVENDER is better suited for multi-task learning, few-shot generalization and zero-shot evaluation on video question answering tasks. There are several potential limitations of LAVENDER that would make for promising directions for future work, including: (i) extension to fine-grained VidL tasks (e.g., video corpus moment retrieval [30]); and (ii) more effective in-context few-shot learning or prompt tuning. Like other data-driven systems, LAVENDER shares similar risks that may have negative societal impact, such as biases in training data and energy consumption with large-scale training. However, we believe that our unified framework combined with multi-task learning can most likely reduce both memory and energy costs, and potentially lead to more economical deployment in real-world applications.

A Additional Results
Multi-task Finetuning. For completeness, we include additional results under multi-task finetuning. Table 7 presents the results of single-task finetuning and multi-task variants from the scale-up pre-training on 14M videos + 16M images. For easier reference in future work, we report detailed retrieval results on R1/5/10 in Table 8.  Investigation on Other Pre-training Tasks. As mentioned in the main text, we only adopt Masked Language Modeling (MLM) and Video Text Matching (VTM) as pre-training tasks for both the proposed LAVENDER and the task-specific baseline LAVENDER-TS. Here we briefly discuss other popular pre-training objectives with LAVENDER-TS. The first is Frame Order Modeling [32,84], where the input video frames are randomly shuffled and the goal is to revert back its original order. Different from the video-ASR pairs utilized in these works, the paired text in our pre-training data is not temporally grounded. In most cases, the shuffled frame sequence will probably still be globally aligned with the textual description. Hence, such fine-grained temporal reasoning objective is not applicable in our case. The second is Masked Visual Modeling (MVM), where the model learns to reconstruct high-level semantics or low-level details for a certain percentage of "masked" visual inputs (i.e., features or patches). Different variants have been proposed and shown little-to-none effect in vision-language pre-training, such as predicting the object category of masked image regions [11] and distilling region/frame features from well-supervised vision encoders [11,32]. More recently, by taking advantage of pre-trained DALL-E [52], researchers [4,16,63] have shown potentials in masked visual token modeling, which asks the model to recover the discrete latent codes of the masked image patches. [71] explores image feature descriptors such as Histograms of Oriented Gradients (HOG) as the prediction target for self-supervised visual pre-training. In Table 9, we investigate three different MVM objectives on top of VTM + MLM pre-training for LAVENDER-TS: (i) VQ Token: to recover the discrete codes extracted from pre-trained DALL-E following [16]; (ii) Pixel: to regress the RGB colors as in [71]; and (iii) HOG: to regress the HOG values, following [71].
Results show that only MVM with HOG achieves a marginal performance improvement of +0.3 on average. Therefore, we adopt a simple recipe for all other pre-training experiments in the paper, that is with only MLM and VTM.
Qualitative Comparisons to Task-specific Baseline. Figure 4 provides qualitative comparisons between LAVENDER and task-specific baseline LAVENDER-TS on video question answering (QA). The model predictions are sampled from MSVD-QA.
In Figure 4a, the ground-truth answer "fold" is not in the top-k (k = 1000 for MSVD-QA, following [16]) most common answers in training split, hence excluded from the pre-defined answer vocabulary for training LAVENDER-TS. In Figure 4b, the ground-truth answer "bowl" appears roughly 9 times more than "bag" in the training split. These visualization results on video QA suggest that (i) our LAVENDER can better fit the  open-ended setting for QA tasks, as it does not restrict the predictions to be from a pre-defined answer vocabulary as in LAVENDER-TS ( Figure 4a); and (ii) the task-specific baseline is easier to fail on questions with out-ofdistribution answers than LAVENDER (Figure 4b). Additionally, we show in Figure 4c when both models can provide reasonable answers to the question, which do not exactly match the ground-truth answer. This result reveals potential problems with the current evaluation metrics or existing datasets on video QA. Future work may consider collecting additional annotations to enrich the dataset and improve the evaluation metric to handle multiple ground-truth answers (e.g., similar to VQA scores [19]). Figure 2 in the main text shows the detailed comparison between LAVENDER and existing methods with the image/video question answering task as an example. In Figure 5, we illustrate the differences among these methods in pre-training. Unlike existing video-language models, which design task-specific heads and objectives for different pre-training tasks. LAVENDER unifies masked language modeling (MLM) and video text matching (VTM) as MLM. Compared with unified image-text models (e.g., VL-T5 [13]), which are typically pre-trained with a combination of complex pre-training tasks, such as visual question answering and grounded captioning. Although these pre-training tasks may enable the model with new abilities (e.g., generating region proposals (a) Existing VidL Methods (b) Existing Unified Image-text Models (c) LAVENDER Figure 5: Illustration of the differences between LAVENDER and existing methods during pre-training. LAVENDER unifies both masked language modeling (MLM) and video text matching (VTM) as MLM, without task-specific heads in existing video-language (VidL) models. Take VL-T5 [13] as an example; most unified image-text models are pre-trained with a combination of complex pre-training tasks (e.g., visual question answering (VQA), visual grounding (VG), grounded captioning (GC)).

B Additional Comparison with Existing Work
as in [80,68]), the supervision often comes from human-annotated data. It remains unclear how to design and effectively pre-train a unified model with such capability but without dependency on human-labeling.

C Implementation Details
Task-specific Prompts and Tokens. As mentioned in Section 4.3 of the main text, we explore the vanilla multi-task finetuning without any task-specific designs and two additional variants with task-specific prompts and tokens for LAVENDER. Here, we describe the prompts and tokens used in these baselines.
For task-specific prompts, we insert a human-readable text prompt at the beginning of the text input.
• For text-to-video retrieval and video-text matching during pre-training, the text prompt is "is the video-text paired, true or false"; • For multiple-choice video question answering (QA), the text prompt is "which answer choice is correct, choose from 0, 1, 2, 3, 4."; • For open-ended video QA, the text prompt is "answer the question about the video."; • For video captioning, the text prompt is "write a description about the video.".
As discussed in the Experiments section of the main text, we only briefly investigate prompt tuning with LAVENDER. How to design more diverse prompts for more effective prompt tuning is an interesting direction for future work.
For task-specific tokens, we add several new tokens to the whole vocabulary, and learn these token embeddings from scratch during multi-task finetuning. For both training and inference, the task-specific token is inserted right after Additional Training Details. We summarize the training configurations for downstream finetuning in Table 10. Due to various data scales and domains, we use task-specific batch size and training epochs based on the performance of the validation set for each downstream task (Table 10b). All other settings are shared across all datasets (Table 10a). All experiments are conducted on Microsoft Azure [1], adopting mixed-precision training with DeepSpeed [53]. All video data are pre-processed by evenly extracting 32 frames to avoid expensive decoding on-the-fly. During training, we randomly sample T frames from 32 frames, resize the shorter side of all frames to 224 and random crop (224x224) at the same location for all the frames in a given video. During inference, we evenly sample T frames from 32 frames and center crop (224x224) for all the frames.
For multi-task finetuning, since the same set of videos are shared among several downstream tasks, there might be overlaps between one's training split and others' validation or testing split (e.g., some video-text pairs in MSRVTT-Retrieval 9K-train is in the testing split of MSRVTT-Captioning). To avoid data contamination, we filter out validation and testing videos in all downstream datasets from the training splits, and use this cleaned version for multi-task finetuning. At each training step, we randomly sample one dataset from all 14 of them, and construct a batch of examples from that dataset. The training is conducted on 16×80GB A100 for 20 epochs, and we adopt the same batch size for retrieval tasks as shown in Table 10b, and batch size 60 for all other tasks. • SBU-Captions [47] is another widely used dataset for image-text pre-training, web-crawled from Flickr. It contains 1M image-text pairs.
• COCO [10] and Visual Genome (VG) are two human-annotated image-text datasets. COCO contains 5 captions per image over 120K images. Unlike COCO captions that can describe the whole scene, VG collects 5M regional descriptions over more than 100K images.

Video-Text Data Collection
For the scale-up pre-training, we additionally crawl 11.9M video-text pairs from the web, following the same procedure in [3]. Here, we briefly describe how we collected the data.
WebVid2.5M has led to promising results in text-to-video retrieval tasks as shown in [3]. This motivates us to further crawl more video-text pairs from the same source. We first use a search engine to identify the potential data sources based on sampled textual descriptions in WebVid2.5M, and then we scrape the video-text pairs from these data sources. Similarly, we follow [3,58] to filter out offensive content and hide person and location names. In total, we have collected 11.9M videos, each accompanied with an alt-text description. The collected dataset shares similar characteristics as WebVid2.5M, with the average video duration as ∼ 20 seconds, and the average number of words in the textual description as ∼20. Note that at the time when we started this project, WebVid10M in [3] has not been released yet. We later found our 11.9M data largely overlaps with WebVid10M. Hence, we refer future work to WebVid10M for scale-up pre-training.

E Downstream Datasets
In this section, we introduce all downstream datasets used for evaluating LAVENDER and discuss some datasetspecific training details below. Table 11 summarizes the number of examples in training/validation/testing split for each dataset.
Text-to-video Retrieval We evaluate LAVENDER on 4 popular text-to-video retrieval datasets, namely MSRVTT [76], DiDeMo [21], MSVD [9] and LSMDC [54]. MSRVTT contains 10K YouTube videos with 200K descriptions. We follow [3] to train on 9K videos and evaluate on 1K-A testing split. DiDeMo consists of 10K Flickr videos, each annotated with 4 sentences. We concatenate all sentences from the same video into a paragraph and perform paragraph-to-video retrieval, following [28,3]. Although this dataset comes with localisation annotations (ground-truth temporal proposals) for each sentence, we perform all experiments without leveraging this fine-grained information for both training and evaluation. Instead, we use the same procedure as described in Appendix C to sample frames from videos. MSVD is based on 2K YouTube videos and crowdsourced 40 textual descriptions per video. LSMDC is built upon 118K video clips from 202 movies. Each clip has a caption from movie scripts or descriptive video services. We use the standard splits for DiDeMo, MSVD and LSMDC, following [43]. For paragraph-to-video retrieval on DiDeMo, we adopt the text augmentation technique proposed in Frozen [3], which is to randomly sample and concatenate a variable number of sentences as paragraph for each video.
Multiple-choice Video QA We evaluate LAVENDER on four multiple-choice QA datasets: TGIF-Action, TGIF-Transition [23], MSRVTT-MC [73] and LSMDC-MC [44]. Among them, TGIF-Action and TGIF-Transition aim to test the model's ability to recognize repeating actions and state transitions in short GIFs. Each videoquestion pair is accompanied with 5 answer choices. We concatenate the 5 answer choices sequentially with the question, and the model is asked to predict the ground-truth answer index. MSRVTT-MC and LSMDC-MC are based on retrieval tasks, but reformulated as multiple-choice QA. A model needs to find the caption that describes the video out of 5 candidate captions. Due to its similarity to video-to-text retrieval, we formulate it as video-text matching, which is the same as zero-shot evaluation described in the Experiments section of the main text. Specifically, we let LAVENDER to predict true or false via MLM head, given a video-question-answer input, and we rank the probability of model prediction as true across all answer choices. As there is no training and validation data constructed in the same way for MSRVTT-MC, we follow [28] to evaluate the retrieval model trained on MSRVTT to rank the 5 candidate answers.
Open-ended Video QA Four datasets are considered for open-ended video QA: TGIF-Frame [23], MSRVTT-QA, MSVD-QA [73] and LSMDC-FiB [44]. Among them, the question-answer pairs in all but TGIF-Frame are based on the linguistic transformation of captions for each video. Questions in TGIF-Frame is collected via crowd-sourcing, which are answerable with just a single frame in the video. MSRVTT-QA contains 243K open-ended questions over 10K videos and MSVD-QA consists of 47K questions over 2K videos. The Fil-inthe-blank (FiB) task of LSMDC-FiB is, given a video and a sentence with a blank in it, to predict a correct word for the blank. We replace the blank with a [MASK] token, and naturally it becomes a Masked Language Modeling (MLM) task.
As mentioned in the main text, LAVENDER answers the open-ended questions in these datasets with only one word, as there is only one [MASK] token appended to the text input. Table 12 summarizes the max answer length and the percentage of examples with answers longer than one word in all four datasets. As the statistics show, more than 92% of examples in these datasets are answerable with a single word.
Video Captioning MSRVTT [76] and MSVD [9] are used for captioning evaluation. As introduced before, MSRVTT consists of 10K videos with 20 captions per video, and MSVD contains 2K videos, with 40 captions  Train Val Test Train Val Test Train Val Test Train Val Test  Max answer_len  4  5 5  4  7 6  3  3 3  4 4 4 % of data w/ answer_len > 1 2.8 2.8 2.5 2.9 4.9 4.6 2.4 2.7 2.6 6.6 7.9 7.0 per video. We follow the standard captioning splits in [76] and [66] for MSRVTT and MSVD, respectively. During training, we set the probability of random masking caption tokens to be 0.15, the same as what is used in MLM during pre-training. During inference, we perform generation until the model outputs a [SEP], which is defined as the sentence ending token or when it reaches the maximum generation step 50.

F Data Usage
We strictly comply with the data usage agreement for each public dataset used in this paper, which is to only use for non-commercial research purposes. To the best of our knowledge, there is no personal identification information or offensive content in any of the public datasets.