{'fraction_non_alphanumeric': 0.031603679925872, 'fraction_numerical': 0.008405586074525118, 'mean_word_length': 4.941604404246952, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
DVCFlow: Modeling Information Flow Towards Human-like Video Captioning

Dense video captioning (DVC) aims to generate multi-sentence descriptions to elucidate the multiple events in the video, which is challenging and demands visual consistency, discoursal coherence, and linguistic diversity. Existing methods mainly generate captions from individual video segments, lacking adaptation to the global visual context and progressive alignment between the fast-evolved visual content and textual descriptions, which results in redundant and spliced descriptions. In this paper, we introduce the concept of information flow to model the progressive information changing across video sequence and captions. By designing a Cross-modal Information Flow Alignment mechanism, the visual and textual information flows are captured and aligned, which endows the captioning process with richer context and dynamics on event/topic evolution. Based on the Cross-modal Information Flow Alignment module, we further put forward DVCFlow framework, which consists of a Global-local Visual Encoder to capture both global features and local features for each video segment, and a pre-trained Caption Generator to produce captions. Extensive experiments on the popular ActivityNet Captions and YouCookII datasets demonstrate that our method significantly outperforms competitive baselines, and generates more human-like text according to subject and objective tests.


Introduction
Video has become the dominant form of information delivery on the Internet, as it delivers richer information than pure images or text. However, most videos do not have corresponding descriptions. Therefore, dense video captioning is an essential task to benefit video content understanding, retrieval, and sharing. Despite the widespread avail- Figure 1. Comparison between the state-of-the-art video description approach MART [15] and our proposed DVCFlow. Our approach generates more visually consistent and semantically coherent descriptions with less redundancy. Videos are from ActivityNet Captions [2,14]; red/italic indicates repeated patterns, blue/underscore indicates visually consistent phrases, and green/bold highlights the coherence of the text. ability of video captioning at the sentence level [4,8,31,35,38,41], how to automatically generate fine-grained paragraphs [33,34,39] is need to be explored more comprehensively. Dense video captioning [14] is one of the potential research directions related to cross-media understanding and vision-language, which aims to recognize multiple meaningful segments in the long video and then describe these events by generating human-like textual descriptions.
Several methods have been proposed for dense video captioning. These methods mainly adopt a two-stage pipeline, where the systems first identify candidate events from the original videos and then generate multi-sentence paragraph descriptions in a progressive manner [8,14,30,33,36,38]. It has been stressed by previous work [15,21] that generating descriptions for videos with the two-stage framework is very challenging due to inaccurate event proposals. Therefore, the task is simplified as generating multisentence descriptions for the given list of segments, removing the event proposal process and focusing on decoding better captions. In this work, we follow their settings to focus on generating more human-like captions.
As shown in Figure 1, there are still many problems for the existing methods, such as repetitive sub-sentences, visual inconsistent phrases, and incoherent captions. These problems are mainly caused by the limitation on modeling the relationship among video event segments and the misalignment between video event segments and multisentence descriptions. For the first issue, several existing methods [14,21,36,46] only consider the current video event segment and ignore the relationship among events. This lack of global visual context limits the understanding of the current video event. Lei et al. [15] point out this problem and focus on historical visual information, but still discard the exploration of future events. For the second issue, the misalignment is mainly reflected in the repetitive and vague phrases among the captions, which misses the specific details of the video event segments. This is because almost all methods directly establish the translation from the video event segments to the corresponding captions, without modeling the impact of the event changing across video segments on the topic evolution of the caption sequence.
To tackle aforementioned issues, we aim to generate human-like paragraph descriptions. We consider that each video event segment can bring new information compared to the past video content. Correspondingly, the caption of the video segment should focus on the new information rather than the general content. Therefore, the progressive information changing across video event segments and multi-sentence captions should be modeled as a multimodal information flow, which is inspired by the human cognitive process that the historical and future information is beneficial for understanding the current video event segment.
Accordingly, we propose DVCFlow model, which consists of three modules, i.e., Global-local Visual Encoder, Cross-modal Information Flow Alignment Module, and Caption Generator. First, we employ the off-the-shelf bidirectional Transformer layers [28] as the Global-local Visual Encoder, which encodes the video event segments in a multi-level fashion. The Cross-modal Information Flow Alignment Module aims to model and align the visual and textual information flows. To model the visual information flow, we design a uni-directional visual flow module to capture the information changing across video event segments.
Considering the limited size of the dataset and the need for long text understanding for dense video captioning, we finetune the large-scale pre-trained language model as the textual representation that better captures the textual information flow across the captions. Then we align the visual and textual information flows by minimizing the divergence between them. On this basis, the visual information changing is used as the guidance to generate more visually consistent and semantically coherent captions. Here, the captions are generated by the Caption Generator progressively based on the multimodal input representations and the visual information changing.
DVCFlow could better understand video event segments globally and well model the impact of visual information changing on the topic evolution of the caption sequence. Therefore, our method significantly reduces sentence redundancy and generates human-like dense video captions. We conduct experiments on the ActivityNet Captions and YouCookII datasets. Automatic and human evaluation results show that DVCFlow can generate more visually consistent, discoursal coherent, and textually informative descriptions compared to the competitive baseline methods. In addition, ablation studies demonstrate the effectiveness of modeling global visual representations and aligning the visual and textual information flows.
Our contributions are as follows: • We propose a novel DVCFlow model to improve the visual consistency, discoursal coherence and textual diversity of dense video captioning. Specifically, our model encapsulates a global-local Transformer for visual representations and a fine-tuned language model for long-term text understanding.
• To exploit the cross-modal information, we introduce an information flow alignment mechanism, which sequentially models and aligns the intrinsic information changing across video events and text descriptions.
• We demonstrate that the DVCFlow surpasses competitive baselines and achieves a new state-of-the-art on the ActivityNet Captions and YouCookII datasets. To improve reproducibility and foster future research, we will release the source code in the future.

Dense Video Captioning
Most video captioning models [4,8,31,35,38] generate single captions for trimmed short video clips with an average duration of 6-25 seconds. The video paragraph captioning task [5,23,39] has also been proposed to provide multisentence descriptions with several segments. Afterward, Krishna et al. [14] introduced the task of dense-captioning events and proposed a large-scale benchmark named Activ-ityNet Captions.
The common paradigm in modern dense video captioning usually adopts a two-stage framework. The framework candidates events through video action detection and then generates a coherent paragraph [8,14,30,33,36,38]. The approaches can be mainly divided into two categories: enhancing the encoding ability and assisting the decoding process. On the one hand, Wang et al. [33] proposed a bidirectional sequence encoder to exploit both past and future contexts. Wang et al. [34] used a multi-level representation to enrich visual features. COOT [9] designed richer visual representations at different granularity levels. On the other hand, MFT [36] selected the key temporal segments to reduce the repetition issues. Wang et al. [32] and Hou et al. [11] further extracted the Part-Of-Speech information to ensure the correctness of the grammar. In addition, automatic speech recognition tokens were merged as input [10,12,13,18,24] to guide the generation by learning rich information across video, sound, and text. Recently, Transformer architecture [28] is employed, where the multi-head self-attention could learn a global interaction among input objects in different subspaces [15,26,46,47]. M.Transformer [46] proved that a Transformer-based model could achieve higher performance than the LSTM-based model [36,40,44]. In the next, a series of works are leveraged, e.g., VideoBERT [26], Transformer-XL [6], and MART [15]. DVCFlow is also based on Transformer, and the used segment features have the entire video context to model relationships among all events.

Cross-modal Alignment
The research on image-text cross-modal alignment has drawn intensive attention. Specifically, VisualBERT [17] directly migrates BERT to vision-language field. Unicoder-VL [16] and VL-BERT [25] further enhance the regionlevel vision-language alignment. Next, ViLBERT [19] and LXMERT [27] both utilize a more detailed two-stream encoder structure. Furthermore, VideoBERT [26] and Act-BERT [47] use a BERT-type objective to build a bridge between video and text. In short, our approach belongs to the Transformer-based encoder-decoder framework, where the decoder adopts a pre-trained language model. The novelty lies in the exploration of the sequential change in the semantic information of the captions, which has not been previously explored.

Approach
Focusing on human-like dense video captioning, we directly utilize the annotated video event segments in the ground-truth. Before introducing our method in detail, we first define some terms. Given a long video v = {v 1 , v 2 , · · · , v T }, containing T frames, which is divided into K temporally ordered event segments {s 1 , s 2 , · · · , s K }, the corresponding captions are denoted as {c 1 , c 2 , · · · , c K }. More specifically, the semantic information of the i-th caption c i is consistent with the visual feature of the i-th video segment s i , where i = 1, 2, · · · , K.

Model Overview
As shown in Figure 2, DVCFlow is based on the encoderdecoder framework, which consists of three modules: (a) The Global-local Visual Encoder aims to obtain the representations of local video event segments with global context. We employ the Transformer architecture for the visual encoder instead of LSTM since Xiong et al. [36] proved that the Transformer-based models hold better performance and speed.
(b) The Cross-modal Information Flow Alignment Module is designed to capture and align the visual information flow and textual information flow. We devise a unidirectional visual flow module to model the impact of visual information changing, referred to as incremental visual influence ∆F K v . For textual information flow, we finetune the pre-trained language model to model the semantic changing brought about by the current caption, referred to as incremental textual influence ∆F K c . Finally, we design an alignment loss to align the two incremental influences based on the multimodal information flow.
(c) The Caption Generator is utilized to generate the caption based on the global-local visual features and the aligned visual influence of the current video segment, which is implemented with a language model sharing weights with the one in the textual flow module.

Global-local Visual Encoder
For the input of the visual encoder, we directly utilize the extracted video features following previous works [15,36] for a fair comparison with state-of-the-art methods. Specifically, we incorporate a segment embedding layer into the embedding layers to mark the timestamps of different segments in the entire video, which serves as proposal-free processing.
All the embedded video features are fed into a Global Transformer. The representation of the i-th video event segment can be extracted from the output of the Global Transformer with annotated timestamps, denoted as s i , which holds a global view of the entire video, i.e., obtaining the historical and future information: where the Global-Transformer is implemented by a bidirectional Transformer, and K denotes the number of seg- ments/captions in the given long video v. Among the segments, future information is essential, especially when generating the first several captions of a paragraph. However, only using the global Transformer is difficult to express the more specific content from the current segment. To tackle this, we further develop a Local-Transformer to enhance the specific video event segment representations. Correspondingly, the Equation (1) is modified as: Note that the Local-Transformer has the same structure as Global-Transformer. Then we adopt a max-pooling layer to reduce redundant information so that we can obtain key representation f i , which is further fed into visual flow module:

Cross-modal Information Flow Alignment
Intuitively, when the video events among adjacent segments change, the differences in visual content will guide the topic evolution of the caption sequence. Therefore, aligning the visual content changes with the caption topic evolution is beneficial for generating visually consistent and semantically coherent descriptions. Therefore, we model visual and textual information flows to calculate the changes in segment and caption, respectively. For modeling the visual information flow, we design the Visual Flow Module utilizing a unidirectional Transformer layer with the masked multi-head attention. We calculate the i-th visual information flow F i v as the following: where f i denotes the i-th key representation among frames from Equation (3).
to record the dynamic visual information flow across K different segments, where the K-th flow F K v is based on all the previous historical key representations {f 1 , f 2 , · · · , f K }. Then, we define the difference between the new visual information flow F i v at the i-th video event segment and the previous information flow F i−1 v at the (i−1)-th segment as the incremental visual influence ∆F i v of the i-th segment, which can be formulated as: For the textual information flow, considering that there are lots of time spans in the untrimmed videos, the corresponding paragraph description is very long and the understanding procedure can be regarded as a long-text modeling task. However, it is difficult to train a caption encoder and decoder from scratch for multi-sentence long text understanding due to the insufficient data size in the dataset, especially the rare but important words. To tackle this issue, we fine-tune the pre-trained language model GPT-2 [22] as the textual flow module.
The input sequence of the textual flow module can be de- is a special token representing the caption interval. In other words, the i-th textual information flow F i c is the output of the textual flow module corresponding to the i-th special token [F ] in the input. The i-th textual information flow F i c contains the history text information, same as visual information flow F i v : So the incremental textual influence ∆F i c of the i-th caption can be formulated as:

Caption Generator
For caption generator, we fine-tune the language model as the decoder, which shares weight with the one in the Crossmodal Information Flow Alignment Module. It can generate high-quality captions conditioned on the multimodal input representation and the aligned incremental visual influence. Thus, we can shift the attention of the generated caption according to the specific video segment during the paragraph generation process. The Caption Generator takes input from both the i-th processed segment representation s i and the corresponding i-th text caption {c 1 i , · · · , c N −1 i , c N i } in sequence, where N is the length of the i-th caption and 1 ≤ i ≤ K. Note that in the Caption Generator, the visual part utilizes the multihead attention, while the caption part employs the masked multi-head attention. And we further add a trainable segment embedding layer to indicate whether the input token is from video or text, similar to BERT [7]: where [; ] denotes concatenation operation, 1 ≤ j ≤ N , MHA(·) and Masked-MHA(·) correspond to multi-head attention and masked multi-head attention, respectively. In contrast to the previous approaches, we additionally concatenate the hidden representations of the decoder v at each time-step and feed them to an output layer, which makes the model have the capacity to fuse the visual and textual representations. The fusion procedure can be summarized as below: where [;] denotes concatenation operation, W c and b c denote trainable weights and bias.

Training Objectives
The main target of DVCFlow is to generate a human-like multi-sentence description for the given video by exploiting the training procedure to optimize model parameters. In this work, we design two training objectives to optimize the model parameters, i.e., 1) Generation loss and 2) Alignment loss. Specifically, same as the conventional approaches, for generation loss, we calculate the Negative Log Likelihood (NLL) loss to ensure the semantic coherence and correctness of caption. Besides, as shown in Figure 2, we model the mutual influence between captions and the video event segments. To obtain visually consistent and semantically coherent captions, we also optimize the model by minimizing the Mean Square Error (MSE) loss between visual information flow and textual information flow.

Generation Loss
Our DVCFlow model generates the human-like captions c K of the video event segment v K based on the global-local video event segment representation s K and the incremental visual influence ∆F K v . Therefore, the generation loss could be formulated as follows: where F H j i denotes the estimated probability of the j-th token in the i-th caption. The projection function F is used to reflect the hidden states to the probability of tokens: where h j i denotes the hidden states, |V | refers to the vocabulary size, W c and b c are learnable parameters.

Alignment Loss
To bridge the gap between visual information flow and textual information flow, we design the Alignment loss, i.e., Mean Square Error (MSE) loss, which aims to induce the model to understand the inner relationships between incremental visual influence and incremental textual influence. Here, the incremental visual influence ∆F i v among video event segments is obtained by Equation (5), while the incremental textual influence ∆F i c is calculated by Equation (7). Thus, MSE loss is used to minimize the distance between the two incremental influences, i.e., ∆F i v and ∆F i c : The overall training objective of DVCFlow could be computed as follows:

Evaluation Metrics.
The main evaluation metrics of dense video captioning include BLEU@4 [20], METEOR [1], CIDEr [29], and R@4 [36]. Among these metrics, BLEU@4 and CIDEr are evaluation metrics based on n-gram matching, which calculate the usage accuracy of words and measure the overall sentence fluency. In comparison, METEOR is a metric based on embedding representations, which could calculate the semantic distance between synonyms and reflect the degree of semantic correctness. Therefore, it has a higher correlation with human judgment. R@4 evaluates the degree of repetition between ground-truth and generated text. In our opinion, to some extent, if R@4 becomes lower (the lower, the better), it will inevitably lead to a decrease in the performance of CIDEr and BLEU@4. Therefore, in order to evaluate the performance of dense video captioning more comprehensively, we advise the human evaluation, and focus on R@4 and METEOR, instead of pursuing the only improvement of CIDEr and BLEU@4.

Implementation Details.
For video features, we use aligned appearance and optical flow features sampled at 2FPS, provided by M.Transformer [46]. We truncate the video sequence longer than 900 frames. As for the text, we use the tokenizer of GPT-2 [22] to tokenize the text to tokens. In contrast to the prevalent approaches of discarding words that appeared less than 3 or 5 times, it is available with a larger vocabulary, which helps to produce more informative tokens. We set the hidden size to 768. The number of attention heads is set to 12. Specifically, we use AdamW optimizer with an initial learning rate of 1e-4, L2 weight decay of 0.01, and linear learning rate warmup over the first 5 epochs. During the training process, the alignment loss was going down with the generation loss and then tended to be stable. For decoding strategy, we use top-k sampling as we find that top-k sampling can generate more informative and diverse captions while greedy search always leads to general, repetitive sentences. k is set to 10. During the experiment, it costs about 24 hours on 4 GeForce RTX 3090 GPUs to train the model, and the inference time is about 1 hour on 1 GeForce RTX 3090 GPU on ActivityNet Captions dataset. Note that we used mixed precision for training. Table 1 shows the performances of different models. We can make some observations as bellows:

Quantitative Analysis
(1) Overall, the results across four evaluation metrics consistently indicate that our proposed DVCFlow achieves superior performances against other state-of-the-art techniques. In particular, the METEOR score, which can be considered the most valuable metric, can achieve 17.38 and 16.5 on two datasets. The reason why the R@4 score is lower than ground truth lies in that we filter out the captions with repetitive phrases in the decoding procedure.
(2) Richer basic visual features are crucial for performance improvement, e.g., COOT [9], OEG [42], and Sub-GC [43]. While we fed the general features without extra information into our model, same as MART, proving the effectiveness of our framework by higher scores.
(3)The improvement is obvious on the ActivityNet Captions dataset but a bit gentle on YouCookII dataset. This is because the videos of YouCookII are about cooking, and there are few semantic transformations among events.

Ablation Study
In this section, we further discuss the effectiveness of the three parts in our framework. First, we test the variant by removing the cross-modal information flow alignment module, which is designed to bridge the gap between video event segments and multi-sentence captions. Second, to explore the effectiveness of global features, we perform ablation studies, where we replace the global Transformer with an extra local Transformer to discard the global view while leaving the number of parameters unchanged. Moreover, we design a variant, where we train the caption generator and textual flow module from scratch, to verify the impact of the pre-trained language model on the long text representation. The evaluation results are reported in Table 2.
According to the results, all the three aforementioned techniques are effective (comparing Row 2-4 with Row 1). We observe that the alignment brings about a significant improvement. Besides, integrating the global features also improves the performance to some extent, which demonstrates that the global part is beneficial for understanding the video event segment. When removing the pre-trained weights, the score decreased significantly, indicating that the pre-trained language model is essential. When combing all three techniques, we find that they complement each other and see the highest gain on all metrics. Figure 3 shows some examples with human-annotated ground-truth and descriptions generated by MART and our DVCFlow. From these examples, it is obvious that our model achieves a big step towards human-like dense video captioning since there are more conjunctions and finegrained details instead of simple and general sentences. For the first case, compared to the sentence segment "two kids" in the sentence generated by MART, "wearing a black shirt and red shorts" in our DVCFlow depicts more detailed and non-repeatable video content, which alleviates the problem of frequently repeated and general phrases in descriptions. In addition, DVCFlow could obtain more phrases regarding temporal information, such as "begin to" and "continue to", probably because our model has a global visual view, which MART: Two kids are boxing in a boxing ring. The kids are engaged in a room. The kids are engaged in a game.

Qualitative Analysis
Ours: A man wearing a black shirt and red shorts is boxing in a ring. The woman then begins fighting with a man. The boy then kicks the girl back and fourth.
GT: A group of girls are inside a gym. They are engaged in a style of kickboxing. The girls kick and punch at each other for practice.

MART:
A man jumps onto a horse. He mounts the pommel horse. He does a hand stand before walking away.
Ours : A gymnast is seen standing ready with his arms up on a beam. He mounts the beam and begins to spin himself around and around. He then does a hand stand on the beam and walk away. .

GT:
A man is seen standing before a beam and leads into him performing a gymnastics routine. The man spins all around the beam and ends by jumping down with his arms up.
MART: People are paddling in a river . They are paddling down the river. They are paddling down the river.
Ours : A large group of people are seen riding down the river with rafts and paddling down a river. The people continue rafting down the river as well as swimming in the river. They raft down a river, trying to get out of the raft.
GT: People are sitting in a raft going down a river. They start paddling with their oars. They fall down a waterfall a few times.
MART: A girl is drinking from a cup of beer. She is drinking from a cup.
Ours : A girl is seen speaking to the camera while holding a drink and leads into her holding up various liquids. She continues to talk to the camera and shows off a bottle of beer.

GT:
A little girl is sitting on a table and have a glass of soda on the hand, other people is in the table and an elderly man toast with her. the girl uses a napkin and clean her mouth and drinks again from the soda.

Human Evaluation
According to the results of automatic metrics, our method demonstrates the capability of generating highquality paragraph descriptions for videos. Compared to those by other methods, the descriptions produced by our method are often more human-like.
To better understand how satisfactory the sentences generated from different methods are, we also conduct a human evaluation to compare our DVCFlow against state-of-the-art approach. Twelve well-educated evaluators are employed and a subset of 100 videos is randomly selected from Ac-tivityNet Captions test split for the subjective evaluation. All evaluators and videos are randomly organized into four groups. We show each group both the sentences generated by different approaches and ask them: which caption is better or the two models are in a draw, with respect to i.e., visual consistency, discoursal coherence, and textual diversity, respectively. Note that the models are anonymous, and the samples are shuffled. The results of the sample comparisons are obtained through a voting mechanism when each member of the group vote independently. We calculate the scores of the human evaluation in Table 3. We can obtain some observations from the results in the table. Overall, our DVCFlow is clearly the winner in terms of three different human-involved metrics. In particular, our DVCFlow has achieved a winning rate of more than 50% in consistency and diversity, which indicates that our model holds

Limitation
To solve the problem of generating multi-sentence texts for long videos, we propose a flow-based alignment mechanism. But the information flow requires that video clips have strong semantic relevance, which is suitable for natural long videos rather than synthetic videos. In addition, our model is the first attempt to solve the problem that sentence diversity will decrease when low frequency words are discarded in the pre-training stage, but it may lead to false associations. Details of bad cases are in the appendix.

Conclusion
In this paper, we propose a novel DVCFlow framework for informative, coherent and dense video captioning. We design an information flow mechanism to sequentially align the cross-modal context changing flow, based on a segment encoder with comprehensive global visual information and a pre-trained language decoder to enhance the language modeling capability for long text. Extensive experiments on two datasets, ActivityNet Captions and YouCookII, demonstrate that our proposed model achieves state-of-the-art performances and obtains more visually consistent and semantically coherent descriptions with less redundancy than advanced methods. In future works, towards more human-like descriptions, we are curious about extracting more effective basic video features, better utilization of the caption history, and solving the exposure bias issues.