SlowGuess/NAACL_2021_OCR huggingface dataset:
DECEMBERT: Learning from Noisy Instructional Videos via Dense Captions and Entropy Minimization
Zineng Tang Jie Lei Mohit Bansal
{terran, jielei, mbansal}@cs.unc.edu
Leveraging large-scale unlabeled web videos such as instructional videos for pre-training followed by task-specific finetuning has become the de facto approach for many video-and-language tasks. However, these instructional videos are very noisy, the accompanying ASR narrations are often incomplete, and can be irrelevant to or temporally misaligned with the visual content, limiting the performance of the models trained on such data. To address these issues, we propose an improved video-and-language pre-training method that first adds automatically-extracted dense region captions from the video frames as auxiliary text input, to provide informative visual cues for learning better video and language associations. Second, to alleviate the temporal misalignment issue, our method incorporates an entropy minimization-based constrained attention loss, to encourage the model to automatically focus on the correct caption from a pool of candidate ASR captions. Our overall approach is named DECEMBERT (Dense Captions and Entropy Minimization). Comprehensive experiments on three video-and-language tasks (text-to-video retrieval, video captioning, and video question answering) across five datasets demonstrate that our approach outperforms previous state-of-the-art methods. Ablation studies on pre-training and downstream tasks show that adding dense captions and constrained attention loss help improve the model performance. Lastly, we also provide attention visualization to show the effect of applying the proposed constrained attention loss.<sup>1</sup>
Video and language are ubiquitous in the world we live. The ability to understand the interplay of video and language is thus essential for intelligent agents to operate in real-world scenario. Past success in video-and-language has mostly been driven
by supervised learning, where models are learned on manually labeled data for a particular task (e.g., text-to-video retrieval). However, manually annotating video and language data is very expensive, hence limiting the scale of such datasets, and consequently also limiting the performance of models trained on the datasets. The self-supervised pretraining then finetuning paradigm offers an easy and generic solution to this dilemma, where models are first pre-trained on large-scale unlabeled data by performing various "proxy tasks", followed by finetuning the pre-trained model on downstream tasks where data is often limited.
Recent advances on language pre-training (Devlin et al., 2019; Liu et al., 2019) demonstrate the effectiveness of this approach, where transformer-based (Vaswani et al., 2017) models pre-trained on large-scale unlabeled text corpus has shown to perform remarkably well across a wide range of natural language tasks (Rajpurkar et al., 2016; Williams et al., 2017; Zellers et al., 2018; Wang et al., 2018). Following this momentum, multimodal pre-training (Tan and Bansal, 2019; Lu et al., 2019; Chen et al., 2020; Su et al., 2019; Cho et al., 2021; Sun et al., 2019; Li et al., 2020c; Zhu and Yang, 2020; Miech et al., 2020; Li et al., 2020b; Lei et al., 2021) on large-scale image-text corpus (Sharma et al., 2018; Chen et al., 2015; Krishna et al., 2017) and video-text corpus (Lei et al., 2018; Miech et al., 2019; Sun et al., 2019) have also shown to outperform existing approaches (Anderson et al., 2018; Yu et al., 2018a; Lei et al., 2020a,b) on vision and language tasks (Antol et al., 2015; Xu et al., 2016; Yu et al., 2018a; Suhr et al., 2019; Zhou et al., 2017; Lei et al., 2020b). The most commonly used "proxy tasks" for multimodal pre-training are masked language modeling (Devlin et al., 2019) (MLM) and cross-modal matching (Tan and Bansal, 2019; Lu et al., 2019; Zhu and Yang, 2020) (e.g., video-text matching), where MLM aims to learn a better language model in the presence of the extra
$^{1}$ Code and models: https://github.com/zinengtang/DeCEMBERT
Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2415-2426 June 6-11, 2021. ©2021 Association for Computational Linguistics
Figure 1: An instructional video example from HowTo100M (Miech et al., 2019). We show three clips and their corresponding ASR captions and dense captions. We use green box to indicate correct matched ASR caption for the middle clip. We highlight semantically misaligned ASR caption in pink. As can be seen from this example, the ASR captions are often incomplete and unpunctuated, and are semantically or temporally misaligned with their corresponding clips. In contrast, dense captions typically capture key objects, attributes and actions in the clips.
vision modality, and the matching objective encourages better association and alignment between relevant image-text or video-text pairs.
Existing video-text pre-training models (Sun et al., 2019; Miech et al., 2020; Zhu and Yang, 2020) are typically trained on large-scale instructional video datasets such as HowTo100M (Miech et al., 2019). The dataset contains 1.2 million videos with 136 million clips that are automatically harvested from YouTube. Each clip is paired with text transcribed from the video narrations via an automatic speech recognition (ASR) system. While the models trained on HowTo100M have shown promising results, they suffer from a few inherent drawbacks from the dataset: (i) Semantic misalignment: the narration words are sometimes irrelevant to the visual content (e.g., credits or other non-visual words, see Figure 1 text highlighted in pink), and vice versa, i.e., some important visual objects and actions are not described by words. (ii) Temporal misalignment: the videos and the captions are far from perfectly aligned, i.e., people might talk about something before or after they actually demonstrate it. For example, Figure 1 shows the caption "cross" is spoken after the action happened. Miech et al. (2019) reported that around  $50\%$  of the clip-caption pairs in HowTo100M suffers from these two misalignments, both of which cause difficulties in optimizing the video-text matching objective. (iii) Furthermore, the ASR captions are generally noisy, incomplete, and unpunctuated (Tilk and Alumae, 2015) (e.g., in Figure 1, "taking pieces paper go"), which limits the language modeling ability of the systems that trained on such text.
To address the aforementioned issues, we propose to add Dense Captions (Johnson et al., 2016; Yang et al., 2017) as a complementary text input to the ASR captions. Beyond serving as an extra
language input for better language modeling, dense captions also describes important object, attribute, and action details regarding several salient regions in the video frames, providing useful signals for video-text matching. In addition to its use in the pre-training stage, these dense captions also provide helpful clues for downstream tasks such as video question answering.
In parallel, to alleviate the temporal misalignment issue, we propose a constrained attention loss that encourages the model to automatically focus on the relevant ASR caption from a pool of continuous caption candidates. Instead of using only a single paired ASR caption for each clip, we also use the captions from its neighboring clips. We expect one of neighboring captions semantically aligns with the clip. To encourage the alignment between the clip and its relevant caption, we employ a "constrained attention loss" that encourages the attention mass from video features to the captions to be distributed mostly in one of the caption, by minimizing the entropy of attention scores.
We evaluate our DECEMBERT (Dense Captions and Entropy Minimization) model on a wide range of video-and-language tasks, including video question answering (Xu et al., 2017), text-to-video retrieval (Xu et al., 2016; Zhou et al., 2017), and video captioning (Xu et al., 2016; Zhou et al., 2017), where our approach outperforms previous state-of-the-art methods. To better understand the underlying factors that contribute to this success, we present comprehensive analyses concerning each of the added components.
To summarize, our contribution is three-fold: (i) We propose incorporating automatically extracted dense captions as an extra text input for video-text pre-training. (ii) We propose an entropy minimization-based constrained attention loss to
encourage the model to dynamically select the best matched captions from a pool of neighboring captions, to alleviate the inherent misalignment between the ASR captions and the videos. (iii) Extensive experiments on three video-and-language tasks (text-to-video retrieval, video captioning, and video question answering) across five datasets demonstrate the effectiveness of our approach. Furthermore, we also provide comprehensive ablation study and visualization to quantitatively and qualitatively examine the effect of using dense captions and the proposed constrained attention loss.
Since the birth of BERT (Devlin et al., 2019), transformer (Vaswani et al., 2017) language pre-training models (Liu et al., 2019; Yang et al., 2019; Lan et al., 2020; Dong et al., 2019; Song et al., 2019; Raffel et al., 2020; Clark et al., 2020) which perform unsupervised pre-training followed by downstream task specific finetuning has became the de facto approach for various natural language understanding tasks (Rajpurkar et al., 2016; Williams et al., 2017; Zellers et al., 2018; Wang et al., 2018). Followed by this success, image-and-language pretraining models (Tan and Bansal, 2019; Lu et al., 2019; Chen et al., 2020; Zhou et al., 2020; Li et al., 2020a) and video-and-language pre-training models (Sun et al., 2019; Miech et al., 2019; Zhu and Yang, 2020; Miech et al., 2020; Li et al., 2020b; Luo et al., 2020; Huang et al., 2020; Stroud et al., 2020) have also shown promising results on many vision and language tasks (Antol et al., 2015; Xu et al., 2016; Zhou et al., 2017).
For video-and-language pre-training in particular, most existing work (Sun et al., 2019; Miech et al., 2019; Zhu and Yang, 2020; Miech et al., 2020; Li et al., 2020b; Luo et al., 2020) are trained on large-scale unlabeled instructional videos, such as HowTo100M (Miech et al., 2019) videos. However, as the ASR captions associated with these videos are noisy, i.e., they are often temporally or semantically misaligned with the video content. Miech et al. (2020) propose Multiple Instance Learning Noise Contrastive Learning (MIL-NCE) to address the temporal misalignment issue, but semantic misalignment still remains. Moreover, MIL-NCE requires computing a separate similarity score from the target clip to each of the ASR caption candidates, it does not suitable for the prevailing single-stream transformer pre-training ar
chitecture due to linearly increased computation cost.
Inspired by recent work (Kim and Bansal, 2019; Kim et al., 2020) that uses dense captions (Johnson et al., 2016; Yang et al., 2017) to improve image and video QA models, we propose to add dense captions as auxiliary text input that provide aligned visual cues to ease the difficulties of learning a video-text matching objective from often temporally and semantically misaligned ASR captions. In addition, we also propose a constrained attention loss, which employs an entropy minimization-based regularization (Tanaka et al., 2018; Yi and Wu, 2019) to the model to encourage higher attention scores from the video to the correct matched caption among a pool of ASR caption candidates.
In this section, we describe the details of DECEMBERT, including its architecture, pre-training objectives, dense caption inputs, and the constrained attention loss. Figure 2 shows an overview of DECEMBERT.
Input Representations. Input text (e.g., ASR captions) are tokenized and represented as a sequence of WordPiece (Wu et al., 2016) tokens. We use a trainable word embedding layer to encode the tokens into feature representations. We use appearance and motion features to represent videos. For appearance, we use a resnet152 (He et al., 2016) model pre-trained on ImageNet (Deng et al., 2009) to extract 2D video features at 1FPS. Similarly, for motion, we use a 3D ResNeXt (Xie et al., 2017; Hara et al., 2018; Kataoka et al., 2020) to extract 3D video features at 1FPS. The temporally aligned appearance and motion features are L2-normalized and concatenated together at feature dimension. We then apply a two-layer MLP to map the it to the same dimension as the word embeddings. Next, we add learned positional embedding and token type embedding (Devlin et al., 2019) to the video and text representations to encode the position and token type information. The video and text representations are then concatenated as a single sequence as inputs to a 12-layer transformer encoder for pre-training and downstream task finetuning.
Dense Captions. The original captions from ASR systems might not well describe a video with rich content or can even be irrelevant to the video as discussed in Section 1. Moreover, as ASR cap
Figure 2: Overview of DECEMBERT architecture. It takes video representations, dense captions and ASR captions as input to its transformer layers, and learn model parameters via video-text matching, masked language modeling. It is also regularized by a constrained attention loss for learning better alignment between the video clips and the ASR captions.
tions are often incomplete and unpunctuated, they might also be sub-optimal for language modeling. Therefore, we use dense captions (Johnson et al., 2016) automatically extracted from an off-the-shelf image dense captioning model (Yang et al., 2017) as additional language input for the model. This dense captioning model is pre-trained on Visual Genome (Krishna et al., 2017) regional captions. To obtain video-level captions, we extract dense captions from frames sampled at every two seconds. There are on average 4.4 dense captions per frame, we sample two of them from each frame at each training step to avoid redundant information and reduce memory and computation cost. Note that the other dense captions might still be sampled in another training step. The sampled dense captions are then concatenated together as video-level captions for training.
These extracted dense captions provide rich and comprehensive information regarding the salient objects, attributes, and actions (see examples in Figure 1 and Figure 2), which helps to optimize a video-text matching objective during pre-training and provide essential visual clues for many downstream tasks such as video question answering. Meanwhile, because the dense captions are text input with diverse semantics, it complements the typically short and incomplete ASR captions as additional resources for better language modeling. We observe in our ablation study that adding dense captions improves both MLM accuracy and videotext matching accuracy, demonstrating the effectiveness of using them as extra inputs.
Pre-Training Objectives. During pre-training, we use masked language modeling (Devlin et al., 2019) (MLM) and cross-modality matching (Tan and Bansal, 2019; Lu et al., 2019; Miech et al., 2019; Zhu and Yang, 2020) (also referred as videotext matching in our context) as our objectives to learn model parameters. For masked language modeling, the goal is to learn better language models conditioned on bidirectional text context and the video. We set a probability of  $0.20^{2}$  to replace an input language token with [MASK]. When dense captions are used as extra text input, we also perform masked language modeling on them with the same masking probability as the ASR captions.
For video-text matching, with a probability of 0.50, we replace the original ASR captions with randomly sampled captions from other videos or clips as a negative. Of the sampled negative ASR captions,  $50\%$  of them are from different videos, while another  $50\%$  are from the same video but different clips. Text from the same video clip is likely to have the same theme or similar context, and thus can serve as hard samples to improve the model's ability to do fine-grained matching. We do not designate a [CLS] token before the start of input caption, instead we take the mean pooling of the output sequence hidden states to perform binary classification for video-text matching. Empirically, we found this approach works better than using a
<sup>2</sup>Because ASR captions are typically very short and grammatically less rigorous, we use a higher masking probability of 0.20 instead of the commonly used 0.15 as in BERT (Devlin et al., 2019).
Figure 3: Illustration of applying the proposed entropy minimization-based constrained attention loss. This loss is added to every attention head in the transformer layers. It forces the model to give high attention scores only to one of the candidate ASR captions, i.e., to peak at only one caption rather than being flat because the one-hot distribution has the smallest entropy.
designated [CLS] token.
Constrained Attention Loss. The ASR captions are often temporally misaligned with their corresponding clips, simply pre-train a model over these misaligned clip-text pairs may lead to sub-optimal performance. To alleviate this issue, we propose a constrained attention loss that encourages the model to automatically select the best matched ASR caption from a pool of continuous caption candidates. This is achieved by minimizing the entropy of the attentions from the video to the ASR captions. Formally, we denote an input video  $V$  as  $[c_1, c_2, \dots, c_N]$ , its corresponding ASR captions are denoted as  $[s_1, s_2, \dots, s_N]$ , where  $c_i$  is the  $i$ -th clip of  $V$  and  $s_i$  is the ASR caption of  $c_i$ .  $N$  is the total number of clips in the video. For a clip  $c_i$  instead of only inputting its associated caption  $s_i$ , we also include captions from its two neighboring clips, i.e.,  $s_{i-1}$  and  $s_{i+1}$ . In most cases, the correct matched caption for the clip is from these three captions. We denote  $X = [X_{c_i}; X_{s_{i-1}}; X_{s_i}; X_{s_{i+1}}] \in \mathbb{R}^{l \times d}$  as the generalized input sequence to each transformer layer (dense captions are ignored for simplicity), where  $X_{c_i}, X_{s_{i-1}}, X_{s_i}, X_{s_{i+1}}$  are the embedding matrices correspond to the input clip and three captions. We further simplify the notations as  $X = [X_0; X_1; X_2; X_3]$ . A single head
3While our approach works for arbitrary number of neighbors, we use two neighbors to illustrate the idea for simplicity. In fact, we found that, of 100 randomly sampled videos, using two neighbors already covers  $95\%$  of the videos with at least one positive matched ASR caption.
self-attention operation in the transformer encoder layers can then be expressed as:
$$
\boldsymbol {A} = \operatorname {s o f t m a x} \left(\frac {\boldsymbol {X} \boldsymbol {X} ^ {T}}{\sqrt {d}}, \dim = 1\right) \boldsymbol {X}, \tag {1}
$$
where  $\mathrm{softmax}(\cdot ,\mathrm{dim} = 1)$  denotes applying softmax at the second dimension of the input matrix.  $A$  is the attention output matrix. When multiple attention heads are used, the formulation is similar. We use  $S$  to denote the similarity matrix computed by  $\mathbf{X}\mathbf{X}^T$ , it can be expressed using block matrices:
$$
\boldsymbol {S} _ {q, r} = \boldsymbol {X} _ {q} \boldsymbol {X} _ {r} ^ {T}, \quad q, r \in \{0, 1, 2, 3 \}. \tag {2}
$$
Our goal is to encourage the model to focus on the correct matched caption for an input clip, i.e., the attention mass from the video clip to the correct matched caption should be higher than the others. To achieve this, we first define the maximum response between the video hidden states  $X_0$  to the ASR captions hidden states  $X_j$  as:
$$
\boldsymbol {z} _ {j} = \max  (\boldsymbol {S} _ {0, j}, \dim = 1), j \in \{1, 2, 3 \}. \tag {3}
$$
For a single example, we define its constrained attention loss as:
$$
u _ {j} = \frac {\exp \left(\bar {z} _ {j}\right)}{\sum_ {k = 1} ^ {3} \exp \left(\bar {z} _ {k}\right)}, \tag {4}
$$
$$
\mathcal {L} _ {e} = - \sum_ {j = 1} ^ {3} u _ {j} \log (u _ {j}). \tag {5}
$$
This loss formulation is based on entropy minimization (Tanaka et al., 2018; Yi and Wu, 2019), it forces the model to assign high attention scores only to one of the ASR captions, i.e., to peak at only one caption rather than being flat because the one-hot distribution has the smallest entropy. Figrue 3 shows an overview of applying the constrained attention loss. During pre-training, we add this loss to each of the attention heads across all layers, we add these losses along with the MLM loss and video-text matching loss for joint optimization. Meanwhile, as the similarity matrix  $S$  is a symmetric matrix, the entropy minimization objective also encourages the correct matched ASR caption to have higher similarity to the video, while forcing the mismatched captions to put more attention on the other ASR captions rather than the video.
In this section, we compare our model with state-of-the-art methods on three video-and-language downstream tasks (e.g., video captioning, text-to-video
retrieval, and video question answering) across five datasets. We then present a comprehensive ablation study, where we show that each of our proposed components help improve the pre-training task performance and downstream task performance. Lastly, we also provide an attention visualization example to demonstrate the effect of applying our proposed constrained attention loss.
4.1 Datasets and Tasks
Pre-training. We use HowTo100M (Miech et al., 2019) for pre-training. It contains 1.22 million YouTube instructional videos that cover 23.6K instruction tasks (e.g., making peanut butter, pruning a tree). Each video is associated with an English narration automatically transcribed by an Automatic Speech Recognition (ASR) system. On average, each video has 110 clip-caption pairs, with an average duration of 4 seconds per clip and 4 words per caption. We reserve 10K videos for validation, and use the rest of the videos for pre-training.
Video Captioning. We evaluate video captioning on MSRVTT (Xu et al., 2016) and YouCook2 (Zhou et al., 2017) datasets. The task is to generate a text description (a single sentence or a paragraph of multiple sentences) for a given video. (i) MSRVTT contains 10K YouTube videos with 20 descriptions per video. The videos in MSRVTT are typically 10-30 seconds long, with an average length of 14.8 seconds. Its contains 6.5K videos in the train set, 497 videos in the val set, and 3K videos in the test set. (ii) YouCook2 is a cooking video dataset harvested from YouTube. It contains 2K videos from 89 recipes with a total length of 176 hours. Each video is annotated with temporal timestamps that indicate event segments (clips), a textual description is provided for each segment. In total, there are 14K video segments.
Text-to-Video Retrieval. We evaluate text-to-video retrieval on MSRVTT and YouCook2 datasets, where the goal is to retrieve a relevant video from a gallery of videos given a text query. (i) MSRVTT is the same dataset as the captioning task. We follow previous work (Yu et al., 2018b; Miech et al., 2019) to use the 7k train+val videos for training and report results on the 1K test set sampled by Yu et al. (2018b). (ii) YouCook2 is the same dataset as the captioning task. We evaluate our model on the clip retrieval task as in previous work (Miech et al., 2019; Zhu and Yang, 2020).
Method	B@4	M	R	C
SibNet (Liu et al., 2020b)	40.9	27.5	60.2	47.5
OA-BTG (Zhang and Peng, 2019)	41.4	28.2	-	46.9
GRU-EVE (Aafaq et al., 2019)	38.3	28.4	60.7	48.1
MGSA (Chen and Jiang, 2019)	42.4	27.6	-	47.5
POS+CG (Wang et al., 2019)	42.0	28.2	61.6	48.7
POS+VCT (Hou et al., 2019)	42.3	29.7	62.8	49.1
ORG-TRL (Zhang et al., 2020)	43.6	28.8	62.1	50.9
DECEMBERT	45.2	29.7	64.7	52.3
Table 1: Video captioning results on MSRVTT test set. We report BLEU@4 (B@4), METEOR (M), Rouge-L (R), CIDEr-D (C).
Video Question Answering. We evaluate video question answering (QA) performance on the MSRVTT-QA (Xu et al., 2017) dataset. It contains 243K open-ended questions constructed based on the videos and captions in MSRVTT.