SlowGuess/ACL_2020_OCR huggingface dataset:
Hyounghun Kim Zineng Tang Mohit Bansal
{hyounghk, terran, mbansal}@cs.unc.edu
Videos convey rich information. Dynamic spatio-temporal relationships between people/objects, and diverse multimodal events are present in a video clip. Hence, it is important to develop automated models that can accurately extract such information from videos. Answering questions on videos is one of the tasks which can evaluate such AI abilities. In this paper, we propose a video question answering model which effectively integrates multi-modal input sources and finds the temporally relevant information to answer questions. Specifically, we first employ dense image captions to help identify objects and their detailed salient regions and actions, and hence give the model useful extra information (in explicit textual format to allow easier matching) for answering questions. Moreover, our model is also comprised of dual-level attention (word/object and frame level), multi-head self/cross-integration for different sources (video and dense captions), and gates which pass more relevant information to the classifier. Finally, we also cast the frame selection problem as a multi-label classification task and introduce two loss functions, In-and-Out Frame Score Margin (IOFSM) and Balanced Binary Cross-Entropy (BBCE), to better supervise the model with human importance annotations. We evaluate our model on the challenging TVQA dataset, where each of our model components provides significant gains, and our overall model outperforms the state-of-the-art by a large margin (74.09% versus 70.52%). We also present several word, object, and frame level visualization studies.
Recent years have witnessed a paradigm shift in the way we get our information, and a lot of it
is related to watching and listening to videos that are shared in huge amounts via the internet and new high-speed networks. Videos convey a diverse breadth of rich information, such as dynamic spatiotemporal relationships between people/objects, as well as events. Hence, it has become important to develop automated models that can accurately extract such precise multimodal information from videos (Tapaswi et al., 2016; Maharaj et al., 2017; Kim et al., 2017; Jang et al., 2017; Gao et al., 2017; Anne Hendricks et al., 2017; Lei et al., 2018, 2020). Video question answering is a representative AI task through which we can evaluate such abilities of an AI agent to understand, retrieve, and return desired information from given video clips.
In this paper, we propose a model that effectively integrates multimodal information and locates the relevant frames from diverse, complex video clips such as those from the video+dialogue TVQA dataset (Lei et al., 2018), which contains questions that need both the video and the subtitles to answer. When given a video clip and a natural language question based on the video, naturally, the first step is to compare the question with the content (objects and keywords) of the video frames and subtitles, then combine information from different video frames and subtitles to answer the question. Analogous to this process, we apply dual-level attention in which a question and video/subtitle are aligned in word/object level, and then the aligned features from video and subtitle respectively are aligned the second time at the frame-level to integrate information for answering the question. Among the aligned frames (which contain aggregated video and subtitle information now), only those which contain relevant information for answering the question are needed. Hence, we also apply gating mechanisms to each frame feature to select the most informative frames before feeding them to the classifier.
1Our code is publicly available at: https://github.com/hyounghk/ VideoQADenseCapFrameGate-ACL2020
4812
Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 4812-4822 July 5 - 10, 2020. ©2020 Association for Computational Linguistics
Next, in order to make the frame selection more effective, we cast the frame selection sub-task as a multi-label classification task. To convert the time span annotation to the label for each frame, we assign a positive label ('1') to frames between the start and end points, and negative ('0') label to the others, then train them with the binary cross-entropy loss. Moreover, for enhanced supervision from the human importance annotation, we also introduce a new loss function, In-and-Out Frame Score Margin (IOFSM), which is the difference in average scores between in-frames (which are inside the time span) and out-frames (which are outside the time span). We empirically show that these two losses are complementary when they are used together. Also, we introduce a way of applying binary cross-entropy to the unbalanced dataset. As we see each frame as a training example (positive or negative), we have a more significant number of negative examples than positive ones. To balance the bias, we calculate normalized scores by averaging the loss separately for each label. This modification, which we call balanced binary cross-entropy (BBCE), helps adjust the imbalance and further improve the performance of our model.
Finally, we also employ dense captions to help further improve the temporal localization of our video-QA model. Captions have proven to be helpful for vision-language tasks (Wu et al., 2019; Li et al., 2019; Kim and Bansal, 2019) by providing additional, complementary information to the primary task in descriptive textual format. We employ dense captions as an extra input to our model since dense captions describe the diverse salient regions of an image in object-level detail, and hence they would give more useful clues for question answering than single, non-dense image captions.
Empirically, our first basic model (with dual-level attention and frame-selection gates) outperforms the state-of-the-art models on TVQA validation dataset (72.53% as compared to 71.13% previous state-of-the-art) and with the additional supervision via the two new loss functions and the employment of dense captions, our model gives further improved results (73.34% and 74.20% respectively). These improvements from each of our model components (i.e., new loss functions, dense captions) are statistically significant. Overall, our full model's test-public score substantially outperforms the state-of-the-art score by a large margin
of  $3.57\%$  (74.09% as compared to 70.52%).<sup>2</sup> Also, our model's scores across all the 6 TV shows are more balanced than other models in the TVQA leaderboard<sup>3</sup>, implying that our model should be more consistent and robust over different genres/domains that might have different characteristics from each other.
Our contributions are four-fold: (1) we present an effective model architecture for the video question answering task using dual-level attention and gates which fuse and select useful spatial-temporal information, (2) we employ dense captions as salient-region information and integrate it into a joint model to enhance the videoQA performance by locating proper information both spatially and temporally in rich textual semi-symbolic format, (3) we cast the frame selection sub-task as a multi-level classification task and introduce two new loss functions (IOFSM and BBCE) for enhanced supervision from human importance annotations (which could be also useful in other multi-label classification settings), and (4) our model's score on the test-public dataset is  $74.09\%$ , which is around  $3.6\%$  higher than the state-of-the-art result on the TVQA leaderboard (and our model's scores are more balanced/consistent across the diverse TV show genres). We also present several ablation and visualization analyses of our model components (e.g., the word/object-level and the frame-level attention).
Visual/Video Question Answering Understanding visual information conditioned on language is an important ability for an agent who is supposed to have integrated intelligence. Many tasks have been proposed to evaluate such ability, and visual question answering is one of those tasks (Antol et al., 2015; Lu et al., 2016; Fukui et al., 2016; Xu and Saenko, 2016; Yang et al., 2016; Zhu et al., 2016; Goyal et al., 2017; Anderson et al., 2018). Recently, beyond question answering on a single image, attention to understanding and extracting information from a sequence of images, i.e., a video, is rising (Tapaswi et al., 2016; Maharaj et al., 2017; Kim et al., 2017; Jang et al., 2017; Lei et al., 2018; Zadeh et al., 2019; Lei et al., 2020; Garcia et al., 2020). Answering questions on videos requires an
At the time of the ACL2020 submission deadline, the publicly visible rank-1 entry was  $70.52\%$ . Since then, there are some new entries, with results up to  $71.48\%$  (compared to our  $74.09\%$ ).
<sup>3</sup>https://competitions.codalab.org/competitions/20415#results
Figure 1: Our model consists of three parts: Dual-Level Attention, Video-DenseCapt Integration, and FrameSelection Gates. The new loss functions (IOFSM/BBCE) also help improve the model with enhanced supervision.
understanding of temporal information as well as spatial information, so it is more challenging than a single image question answering.
Temporal Localization Temporal localization is a task that is widely explored in event/object detection in video context. There has been work that solely processes visual information to detect objects/actions/activity (Gaidon et al., 2013; Weinzaepfel et al., 2015; Shou et al., 2016; Dai et al., 2017; Shou et al., 2017). At the same time, work on natural language-related temporal localization task is less explored with recent work that focuses on the retrieval of a certain moment in a video by natural language (Anne Hendricks et al., 2017; Gao et al., 2017). With deliberately designed gating and attention mechanisms, our work, in general, will greatly contribute to the task of temporal localization, especially under natural language context and multimodal data.
Dense Image Captioning Image captioning is another direction of understanding visual and language information jointly. Single-sentence captions (Karpathy and Fei-Fei, 2015; Anderson et al., 2018) capture the main concept of an image to describe it in a single sentence. However, an image could contain multiple aspects that are important/useful in different ways. Dense captions (Johnson et al., 2016; Yang et al., 2017) and paragraph captions (Krause et al., 2017; Liang et al., 2017; Melas-Kyriazi et al., 2018) have been introduced to densely and broadly capture the diverse aspects and salient regions of an image. Especially, dense caption describes an image in object level and gives useful salient regional information about objects such as attributes and actions. In this paper, we take advantage of this dense caption's ability to help our video QA model understand an image better for answering questions.
Our model consists of 2 parts: feature fusion and frame selection. For feature fusion, we introduce dual-level (word/object and frame level) attention, and we design the frame selection problem as a multi-label classification task and introduce 2 new loss functions for enhanced supervision (Figure 1).
3.1 Features
We follow the same approach of Lei et al. (2020)'s work to obtain features from video, question-answer pairs, and subtitle input and encode them. We sample frames at 0.5 fps and extract object features from each frame via Faster R-CNN (Girshick, 2015). Then we use PCA to get features of 300 dimension from top-20 object proposals. We also create five hypotheses by concatenating a question feature with each of five answer features, and we pair each visual frame feature with temporally neighboring subtitles. We encode all the features using convolutional encoder.
$$
\phi_ {e n} (x): \left\{ \begin{array}{c} x _ {0} ^ {0} = E _ {p o s} (x) \\ x _ {t} ^ {i} = f _ {i, t} \left(x _ {t - 1} ^ {i}\right) + x _ {t - 1} ^ {i}, \\ f _ {i} \left(x _ {0} ^ {i}\right) = g _ {n} \left(x _ {L} ^ {i}\right) \\ y = f _ {N} \circ \dots \circ f _ {1} \left(x _ {0} ^ {0}\right) \end{array} \right. \tag {1}
$$
where  $E_{pos}$  denotes positional encoding,  $f_{i,t}$  convolution preceded by Layer Normalization and followed by ReLU activation, and  $g_{n}$  the layer normalization. The encoder is composed of  $N$  blocks iterations. In each iteration, the encoded inputs are transformed  $L$  times of convolutions. The  $L$  is set to 2, and  $N$  to 1 in our experiment (Figure 2).
3.2 Dual-Level Attention
In dual-level attention, features are sequentially aligned in word/object-level and frame-level (Figure 3).
Figure 2: CNN encoder. We use this block to encode all the input features.
Word/Object-Level Attention The QA feature,  $qa = \{qa_0, qa_1, \dots, qa_{T_{qa}}\}$ , are combined with subtitle feature,  $s_t = \{s_{t0}, s_{t1}, \dots, s_{tT_{s_t}}\}$ , and visual feature,  $v_t = \{v_{t0}, v_{t1}, \dots, v_{tT_{v_t}}\}$ , of  $t$ -th frame respectively via word/object-level attention. To be specific, we calculate similarity matrices following Seo et al. (2017)'s approach,  $S_t^v \in \mathbb{R}^{T_{qa} \times T_{s_t}}$  and  $S_t^s \in \mathbb{R}^{T_{qa} \times T_{v_t}}$ , from QA/subtitle and QA/visual features respectively. From the similarity matrices, attended subtitle features are obtained and combined with the QA features by concatenating and applying a transforming function. Then, max-pooling operation is applied word-wise to reduce the dimension.
$$
\left(S _ {t} ^ {s}\right) _ {i j} = q a _ {i} ^ {\top} s _ {t j} \tag {2}
$$
$$
s _ {t} ^ {\text {a t t}} = \operatorname {s o f t m a x} \left(S _ {t} ^ {s}\right) \cdot s _ {t} \tag {3}
$$
$$
q a _ {s} ^ {m} = \operatorname {m a x p o o l} \left(f _ {1} \left(\left[ q a; s _ {t} ^ {a t t}; q a \odot s _ {t} ^ {a t t} \right]\right)\right) \tag {4}
$$
where  $f_{1}$  is a fully-connected layer followed by ReLU non-linearity. The same process is applied to the QA features.
$$
q a ^ {a t t} = \operatorname {s o f t m a x} \left(S _ {t} ^ {s \top}\right) \cdot q a \tag {5}
$$
$$
s _ {t} ^ {m} = \operatorname {m a x p o o l} \left(f _ {1} \left(\left[ s _ {t}; q a ^ {a t t}; s _ {t} \odot q a ^ {a t t} \right]\right)\right) \tag {6}
$$
The fused features from different directions are integrated by concatenating and being fed to a function as follows:
$$
s _ {t} ^ {w} = f _ {2} ([ q a _ {s} ^ {m}; s _ {t} ^ {m}; q a _ {s} ^ {m} \odot s _ {t} ^ {m}; q a _ {s} ^ {m} + s _ {t} ^ {m} ]) (7)
$$
where  $f_{2}$  is the same function as  $f_{1}$  with non-shared parameters. All this process is also applied to visual features to get word/object-level attended features.
$$
v _ {t} ^ {w} = f _ {2} \left(\left[ q a _ {v} ^ {m}; v _ {t} ^ {m}; q a _ {v} ^ {m} \odot v _ {t} ^ {m}; q a _ {v} ^ {m} + v _ {t} ^ {m} \right]\right) \tag {8}
$$
Figure 3: Dual-Level Attention. Our model performs two-level attentions (word/object and frame level) sequentially. In the word/object-level attention, each word/object is aligned to relevant words or objects. In the frame-level attention, each frame (which has integrated information from the word/object-level attention) is aligned to relevant frames.
Frame-Level Attention The fused features from word/object-level attention are integrated framewise via frame-level attention. Similar to the word/object-level attention, a similarity matrix,  $S \in \mathbb{R}^{T_F \times T_F}$ , is calculated, where  $T_F$  is the number of frames. Also, from the similarity matrix, attended frame-level features are calculated.
$$
(S) _ {k l} = s _ {k} ^ {w \top} v _ {l} ^ {w} \tag {9}
$$
$$
s ^ {a t t} = \operatorname {s o f t m a x} (S) \cdot s ^ {w} + s ^ {w} \tag {10}
$$
$$
\hat {v} = f _ {3} \left(\left[ v ^ {w}; s ^ {a t t}; v ^ {w} \odot s ^ {a t t}; v ^ {w} + s ^ {a t t} \right]\right) \tag {11}
$$
$$
v ^ {a t t} = \operatorname {s o f t m a x} \left(S ^ {\top}\right) \cdot v ^ {w} + v ^ {w} \tag {12}
$$
$$
\hat {s} = f _ {3} \left(\left[ s ^ {w}; v ^ {a t t}; s ^ {w} \odot v ^ {a t t}; s ^ {w} + v ^ {a t t} \right]\right) \tag {13}
$$
where  $f_{3}$  is the same function as  $f_{1}$  and  $f_{2}$  with non-shared parameters. The frame-wise attended features are added to get an integrated feature.
$$
u ^ {s v} = \hat {s} + \hat {v} \tag {14}
$$
3.3 Video and Dense Caption Integration
We also employ dense captions to help further improve the temporal localization of our video-QA model. They provide more diverse salient regional information (than the usual single non-dense image captions) about object-level details of image frames in a video clip, and also allow the model to explicitly (in textual/semi-symbolic form) match keywords/patterns between dense captions and questions to find relevant locations/frames.
Figure 4: Self-Cross Attention. We combine information each from the video (fused with subtitle and QA) and dense caption (fused with subtitle and QA) via the multi-head self attention. Before being fed to the multi-head self attention module, video and dense caption features are concatenated. Thus, self and cross attentions are performed simultaneously.
We apply the same procedure to the dense caption feature by substituting video features with dense caption features to obtain  $u^{sd}$ . To integrate  $u^{sv}$  and  $u^{sd}$ , we employ multi-head self attention (Figure 4). To be specific, we concatenate  $u^{sv}$  and  $u^{sd}$  frame-wise then feed them to the self attention function.
$$
\phi_ {\text {s e l f - a t t}} (x) \left\{ \begin{array}{l} h _ {\mathrm {i}} = g _ {a} \left(w _ {q} ^ {\top} x _ {i}, w _ {k} ^ {\top} x _ {i}, w _ {v} ^ {\top} x _ {i}\right) \\ y = w _ {m} ^ {\top} [ h _ {1}; \dots ; h _ {\mathrm {k}} ] \end{array} \right. \tag {15}
$$
where  $g_{a}$  denotes self-attention.
$$
u ^ {s v d} = \phi_ {\text {s e l f - a t t}} ([ u ^ {s v}; u ^ {s d} ]) \tag {16}
$$
In this way,  $u^{sv}$  and  $u^{sd}$  attend to themselves while attending to each other simultaneously. We split the output,  $u^{svd}$  into the same shape as the input, then add the two.
$$
z = u ^ {s v d} \left[ 0: T _ {F} \right] + u ^ {s v d} \left[ T _ {F}: 2 T _ {F} \right] \tag {17}
$$
3.4 Frame-Selection Gates
To select appropriate information from the frame-length features, we employ max-pooling and gates. Features from the video-dense caption integration are fed to the CNN encoder. A fully-connected layer and sigmoid function are applied sequentially to the output feature to get frame scores that indicate how relevant each frame is for answering a given question. We get weighted features by multiplying the output feature from the CNN encoder
with the scores.
$$
\hat {z} = \phi_ {\mathrm {e n} 2} (z) \tag {18}
$$
$$
g ^ {L} = \operatorname {s i g m o i d} (f ^ {L} (\hat {z})) \tag {19}
$$
$$
z ^ {g l} = \hat {z} \odot g ^ {L} \tag {20}
$$
We calculate another frame scores with a different function  $f^{G}$  to get another weighted feature.
$$
g ^ {G} = \operatorname {s i g m o i d} \left(f ^ {G} (\hat {z})\right) \tag {21}
$$
$$
z ^ {g g} = \hat {z} \odot g ^ {G} \tag {22}
$$
Finally, following Lei et al. (2020)'s work, we also apply frame-wise max-pooling.
$$
z ^ {\text {m a x}} = \operatorname {m a x p o o l} (\hat {z}) \tag {23}
$$
The three features (from local gate, global gate, and max-pooling, respectively), are then concatenated and fed to the classifier to give scores for each candidate answer.
$$
\operatorname {l o g i t} = \text {c l s s i f i e r} ([ z ^ {\max }; z ^ {g g}; z ^ {g l} ]) \tag {24}
$$
We get the logits for the five candidate answers and choose the highest value as the predicted answer.
$$
l o s s _ {c l s} = - \log \left(\frac {e ^ {s _ {g}}}{\sum_ {k} e ^ {s _ {k}}}\right) \tag {25}
$$
where  $s_g$  is the logit of ground-truth answer.
3.5 Novel Frame-Selection Supervision Loss Functions
We cast frame selection as a multi-label classification task. The frame scores from the local gate,  $g^{L}$ , are supervised by human importance annotations, which are time spans (start-end points pair) annotators think needed for selecting correct answers. To this end, we transform the time span into ground-truth frame scores, i.e., if a frame is within the time span, the frame has '1' as its label and a frame outside the span gets '0'. In this way, we can assign a label to each frame, and frames should get as close scores as their ground-truth labels. We train the local gate network with binary cross-entropy (BCE) loss.
$$
\operatorname {l o s s} _ {b c e} = - \sum_ {i} ^ {T _ {F}} \left(y \log \left(s _ {i} ^ {f}\right) + (1 - y) \log \left(1 - s _ {i} ^ {f}\right)\right) \tag {26}
$$
where  $s_i^f$  is a frame score of  $i$ -th frame, and  $y$  is a corresponding ground-truth label.
In-and-Out Frame Score Margin For additional supervision other than the binary cross-entropy loss, we create a novel loss function, In-and-Out Frame Score Margin (IOFSM).
$$
l o s s _ {i o} = 1 + \operatorname {A v g} (\mathrm {O F S}) - \operatorname {A v g} (\mathrm {I F S}) \tag {27}
$$
where OFS (Out Frame Score) is scores of frames whose labels are '0' and IFS (In Frame Score) is scores of frames whose labels are '1'.
Balanced Binary Cross-Entropy In our multi-label classification setting, each frame can be considered as one training example. Thus, the total number of examples and the proportion between positive and negative examples vary for every instance. This variation can cause unbalanced training since negative examples usually dominate. To balance the unbalanced training, we apply a simple but effective modification to the original BCE, and we call it Balanced Binary Cross-Entropy (BBCE). To be specific, instead of summing or averaging through the entire frame examples, we divide the positive and negative examples and calculate the average cross-entropy scores separately, then sum them together.
$$
\begin{array}{l} \operatorname {l o s s} _ {b b c e} = - \left(\sum_ {i} ^ {T _ {F _ {i n}}} \log \left(s _ {i} ^ {f _ {i n}}\right) / T _ {F _ {i n}} \right. \tag {28} \\ + \sum_ {j} ^ {T _ {F _ {o u t}}} \log \left(1 - s _ {j} ^ {f _ {o u t}}\right) / T _ {F _ {o u t}} \\ \end{array}
$$
where  $s_i^{f_{in}}$  and  $s_j^{f_{out}}$  are  $i$ -th in-frame score and  $j$ -th out-frame score respectively, and  $T_{F_{in}}$  and  $T_{F_{out}}$  are the number of in-frames and out-frames respectively.
Thus, the total loss is:
$$
l o s s = l o s s _ {c l s} + l o s s _ {(b) b c e} + l o s s _ {i o} \tag {29}
$$
TVQA Dataset TVQA dataset (Lei et al., 2018) consists of video frames, subtitles, and question-answer pairs from 6 TV shows. The number of examples for train/validation/test-public dataset are 122,039/15,253/7,623. Each example has five candidate answers with one of them the ground-truth.
So, TVQA is a classification task, in which models select one from the five candidate answers, and models can be evaluated on the accuracy metric.
Dense Captions We use Yang et al. (2017)'s pretrained model to extract dense captions from each video frame. We extract the dense captions in advance and use them as extra input data to the model.5
Training Details We use GloVe (Pennington et al., 2014) word vectors with dimension size of 300 and RoBERTa (Liu et al., 2019) with 768 dimension. The dimension of the visual feature is 300, and the base hidden size of the whole model is 128. We use Adam (Kingma and Ba, 2015) as the optimizer. We set the initial learning rate to 0.001 and drop it to 0.0002 after running 10 epochs. For dropout, we use the probability of 0.1.
5 Results and Ablation Analysis
As seen from Table 1, our model outperforms the state-of-the-art models in the TVQA leaderboard. Especially our model gets balanced scores for all the TV shows while some other models have high variances across the shows. As seen from Table 2, the standard deviation and 'max-min' value over our model's scores for each TV show are 0.65 and 1.83, respectively, which are the lowest values among all models in the list. This low variance could mean that our model is more consistent and robust across all the TV shows.