Expectation-Maximization Contrastive Learning for Compact Video-and-Language Representations
Abstract
Most video-and-language representation learning approaches employ contrastive learning, e.g., CLIP [54], to project the video and text features into a common latent space according to the semantic similarities of text-video pairs.
However, such learned shared latent spaces are not often optimal, and the modality gap between visual and textual representation can not be fully eliminated.
In this paper, we propose Expectation-Maximization Contrastive Learning (EMCL) to learn compact video-and-language representations.
Specifically, we use the ExpectationMaximization algorithm to find a compact set of bases for the latent space, where the features could be concisely represented as the linear combinations of these bases.
Such feature decomposition of video-and-language representations reduces the rank of the latent space, resulting in increased representing power for the semantics.
Extensive experiments on three benchmark text-video retrieval datasets prove that our EMCL can learn more discriminative video-and-language representations than previous methods, and significantly outperform previous state-of-the-art methods across all metrics.
More encouragingly, the proposed method can be applied to boost the performance of existing approaches either as a jointly training layer or an out-of-the-box inference module with no extra training, making it easy to be incorporated into any existing methods ‡
Introduction
Text-video retrieval [77], which aims to fetch relevant videos using textual queries or vice versa, is an important yet challenging cross-modal task.
The dominating paradigm of text-video retrieval is contrastive learning [68, 24, 9, 23, 11, 10], which is a commonly adopted framework for videoand-language representation learning.
The core idea of contrastive learning is to pull the textual and visual representations of matched text-video pairs together and push the representations of unmatched text-video pairs apart.
In this manner, contrastive learning enables neural networks to learn discriminative video-and-language representations.
[Figure]
Hyperplane
[Figure] [Figure]
Text
[Figure]
horse
[Figure]
inside his stable.
[Figure]
riding
[Figure]
surfboard.
(a) shows that although the representations belonging to the same class are well-clustered, there is still a clear dividing line (see Hyperplane) between video representations and language representations.
Besides, the representations with different semantics (i.e., from different semantic classes) overlap with each other.
On the contrary, (b) shows that our method can learn more discriminative video-andlanguage representations.
In detail, the video-and-language representations with the same semantics (i.e., belonging to the same semantic class) are well-grouped; and there are clear dividing spaces between different semantic classes.
However, standard contrastive learning has intrinsic limitations for text-video retrieval tasks, since the success of contrastive learning largely depends on the volume and variety of negative samples [9].
Without adequate negative samples, it would be hard to guide the direction of sample learning, and the features could not be contrasted well.
As shown in Figure 1a, we randomly select three videos (each video has 20 text captions) from the benchmark dataset [71] and analyze the entire feature space of a recent standard contrastive learning method [21].
Here we visualize the feature space with t-SNE [43].
In an ideal feature space, the instances of the same semantic classes should be close to each other.
However, as shown in Figure 1a, we notice that the feature space learned by standard contrastive learning fails to preserve inter-modal semantic relatedness, where videos and texts with the same class semantics are still far away.
In other words, the semantic-relevant but modal-different instances can not be grouped together in this feature space.
To improve the performance of contrastive learning, recent image-text representation learning methods either increase batch sizes or maintain large data memory banks [9, 11, 45, 68, 23].
These works target to collect sufficient negative samples for contrastive learning.
However, such text-video retrieval approaches are relatively expensive due to the incurred extra computational costs, especially on large-scale datasets [58].
So an urgent challenge here is to find an efficient method to learn a semantically relevant feature space.
To efficiently bridge the modality gap and group visual and textual representation according to semantics, we propose to learn a low-rank and compact latent feature space.
For this purpose, we propose a novel method named Expectation-Maximization Contrastive Learning (EMCL), which uses the same parametric model to abstract and reconstruct both textual and visual representations.
In detail, we find a set of reconstruction bases for subspace representation by estimating the parameters in Expectation-Maximization (EM) algorithm
In the learned subspace, both video and text features are represented with the distributions over the same sets of hidden variables, which can preserve strong semantic relations across modalities.
As shown in Figure 1b, our EMCL effectively learns a semantically related subspace which has smaller intra-class variance and larger inter-class variance compared to the previous contrastive learning method (Figure 1a).
We further propose
EMCL-Net based on the EMCL and apply EMCL-Net to the task of text-video retrieval.
In particular, for better adapting the proposed EMCL into the downstream task, our EMCL-Net introduces a parameter initialization strategy of the EM algorithm.
Experimental results on three text-video retrieval benchmark datasets, i.e., MSR-VTT [71], ActivityNet [27], and LSMDC [56], show the advantages of the proposed EMCL.
The main contributions are as follows:
• We identify the intrinsic limitation of contrastive learning for text-video retrieval, i
e., the cross-modal representation bias could not be fully eliminated via standard contrastive learning approaches.
• To alleviate such limitation, we reformulate the contrastive learning for video-and-language representations into an expectation-maximization iteration manner and propose a plug-and-
play feature projection module named Expectation-Maximization Contrastive Learning (EMCL), which learns the subspace that aims to become semantic-relevant representation.
• Based on our EMCL, we further propose the EMCL-Net, which introduces a parameter initialization strategy for the EM algorithm.
Experiments show that our approach achieves state-of-the-art results on three text-video retrieval datasets.
More encouragingly, our method can be easily applied to boost the performances of existing approaches either as a jointly training layer or an out-of-the-box inference module with no extra training.
Related Work
Cross-modal learning is widely studied in many areas, including cross-modal retrieval [77, 68, 24], transfer learning [51, 46], domain adaptation [57, 34], and captioning [39] in which different modalities/domains come from different distributions.
The main challenge of cross-modal learning is to use given vision-and-language pairs to learn common representations shared between modalities [38].
Most existing works of text-video retrieval [9, 23, 22] map text and video to the same latent space, where the similarity between them can be directly calculated [20, 6, 64, 17, 66, 67, 7, 15, 74, 53].
In detail, CE [41] introduces a mixture-of-experts method that mixes the features of many different pre-training experts; MMT [21] shows a multi-modal transformer with multiple self-attended layers for video embedding.
Recently, contrastive learning methods, e.g., CLIP [54], show great success in advancing the state-of-the-art performances of cross-modal tasks [42].
Contrastive learning methods [19, 5, 23, 45, 10, 40] try to learn data representations from positive and negative pairs, making the representations of positive pairs (usually data augmentations that retain semantic information) have high similarity, and negative pairs (different semantic examples) have low similarity.
Inspired by the great success of contrastive learning, we employ CLIP [54] for learning video-and-language representations.
In this paper, a positive pair is a matching text-video pair, and a negative pair contains non-matching text and video.
However, due to the multi-modal nature and spatial-temporal evolution of video [12, 37], it is essential to capture the most important semantic concept for the video.
Meanwhile, the visualization in Figure 1 also shows that the feature space of video-and-language representations has semantically irrelevant redundancy which leads to non-ideal contrast in the feature space.
[35] analyzes the non-optimal feature space with modality gap impacts model’s performance and fairness.
Therefore, we propose to conduct contrastive learning in an expectation-maximization iteration manner to eliminate the non-optimal semantically redundant dimensions, acquiring compact representations.
Approach
In this section, we first introduce how to reformulate the Contrastive Learning into an expectationmaximization iteration manner, i.e., Expectation-Maximization Contrastive Learning (EMCL).
Then, we introduce how to incorporate the proposed EMCL into the neural network for video-and-language representations, which are used to perform the text-video retrieval task.
3.1 Preliminaries Expectation-Maximization Algorithm
The Expectation-Maximization (EM) algorithm
[16] is an iterative optimization strategy, which was originally designed to solve the problem when data are missing in the process of parameter estimation.
Briefly, given unobserved hidden variables Z = { z 1 , z 2 , ..., z N } and observed data sets X = { x 1 , x 2 , ..., x N } with N samples, the goal of EM algorithm is to estimate the maximum likelihood solution of model parameters ˆ θ = arg max (cid:80) Ni =1 log (cid:80)
z
i p ( x i , z
i ; θ ) .
In step E, the EM algorithm calculates the conditional probability expectation Q i ( z i )
=
p ( z i | x i , θ ) .
In the M step, the likelihood function is maximized to get the revised parameter ˆ θ = arg max (cid:80)
Ni =1 (cid:80) z i Q i ( z i ) log p ( x i ,z
i ; θ ) Q i ( z i ) .
Gaussian Mixture Model
The Gaussian Mixture Model (GMM) [55] combines multiple single Gaussian models.
Assuming that GMM consists of K Gaussians, given the input X
= { x 1 , x 2 , ..., x N } with hidden variables Y , the probability of GMM is as follows:
[Equation]
Require: X ∈ R 2 B × D (Video features and text features),
M ∈ R
(Initial Value Maintenance)
7: λ
, K do 9: λ : ,k ← λ : ,
Dj =
,k # Eq.
(7) 10: for 11: end for 12: Reconstruct
B
D λY T # k
14: return
D
[Figure]
Step
[Figure]
Input X
Bases 𝝀 Initial value
Initialize
Output where N ( ∗| µ k , Σ k ) is the probability function of the k th Gaussian and π k is the prior probability.
Through the E step of the EM algorithm, the estimated value of y n,k can be obtained by:
[Equation]
In the M step of the EM algorithm, the parameters of the Gaussian mixture model are updated as:
[Equation]
3.2 Expectation-Maximization Contrastive Learning (EMCL)
In this section, we introduce our EMCL in detail.
Representing the features in low-dimensional space is a fundamental method to eliminate the inherent redundancies in features, which is also the goal of our method.
We leverage these compact features for contrastive learning to efficiently bridge the gap and improve their performance.
The overview of our EMCL is shown in Figure 2 and Algorithm 1.
Mathematically, the subspace can be defined as follows: let
X ∈ R B
× D be the features, where B is the sample size, D is the dimension of the feature.
Suppose that these features are distributed in many unknown linear subspaces, where the intrinsic dimensions of the linear subspaces are less than D .
We define the union of K semantically related low-dimensional linear subspaces as the semantic subspace.
To this end, our method includes two parts: Firstly, we use the EM algorithm [16] to find the bases of the K optimal subspaces, which is called “ Maximum Probability Projection ”; Secondly, we need to re-represent the features in these subspaces, which is called “ Feature Reconstruction ”; Finally, in the “ Contrastive Learning ”, the compact features we re-represent are used in contrastive learning to bridge the gap and improve their performance.
Maximum Probability Projection
Given original video features C v ∈ R B × D and original text features C t ∈ R B × D , we combine both video features and text features to be the input data
X ∈ R 2 B × D , where x i,j is the j th coding bit of the i th sample.
In our method, each coding bit x i,j is assigned to a specific subspace, and meanwhile we introduce the hidden variable Y , where y j,k represents whether the k th subspace is selected by x i,j .
We take the base λ of the subspace as the parameter of EM algorithm [16], where λ ∈ R 2 B × K represents the distribution of samples in K semantically related low-dimensional linear subspaces.
Given input data X ∈ R 2 B × D and hidden variable Y ∈ R D × K , the complete likelihood of the input feature X can be expressed as:
[Equation]
where P ( ∗ ) is the probability function and p ( ∗ ) is a kernel function.
Here we assume that x i,j can be represented by K shared Gaussian distributions like GMM [55].
For simplicity, we freeze Σ and π , and only consider the mean λ = µ of the Gaussian model.
There are many choices for the kernel function p (ˆ x, ˆ y ) , such as linear kernel (ˆ x T
ˆ y + c )
, polynomial kernel ( a ˆ x T ˆ y + c ) d , Gaussian kernel exp ( − ˆ γ ∥ ˆ x − ˆ y ∥ 2 ) and so on.
We find that different kernel functions have slightly different impacts on the final results.
For easy implementation, we use
Gaussian kernel and rewrite it in a form similar to the attention model [2, 61].
The formula is:
[Equation]
where σ is a hyper-parameter to adjust the distribution, similar to the mean and covariance in the
Gaussian distribution.
In this paper, we define x : ,j to be the j th column of X , and λ : ,k to be the k th column of λ .
Reviewing the EM algorithm [16], it estimates the parameters of the model by continuously executing
E steps and M steps.
In step E, it calculates the conditional probability expectation with current parameters.
In step M, it maximizes the likelihood function to update the parameters.
In step E, referring to the Eq.
(2), the estimated value of y j,k can be obtained by:
[Equation]
In the M step, we update base λ i,k
according to Eq.
(3), which is formulated as:
[Equation]
By repeatedly iterating step E and step M, our algorithm forces this set of optimal subspaces to represent the original video features and original text features at the same time.
After several iterations, we could keep the information that appears in both the video and the text to remove the redundancy.
Feature Reconstruction
When reconstructing features, we use Y and λ to linearly reconstruct the original features.
Learning from the meaning of Y and λ mentioned above, y j,k indicates whether the k th subspace is selected by x : ,j and λ : ,k represents the base of the k th subspace.
The formula for feature reconstruction is:
[Equation]
As shown in Eq.
(8), we only use the corresponding base
λ i,k (for all k ∈ [1 , K ] ) to reconstruct the i th sample x i,j .
Therefore, we estimate different x i,j from K subspaces.
Contrastive Learning
The above feature reconstruction method generates the low-rank and compact features stripped of redundancy.
Therefore, we can leverage these compact features for contrastive learning to efficiently bridge the modality gap and improve task performance.
3.3 EMCL for Cross-Modal Learning
In this section, we discuss in detail how to incorporate the EMCL into the neural network for crossmodal downstream tasks.
Targeting on the cross-modal tasks, we propose the ECML-Net, which introduces a parameter initialization strategy for the EM algorithm that can establish the connection between batches.
At last, we take an important yet challenging cross-modal task, i.e., the text-video retrieval, as an example to illustrate how to employ our EMCL-Net to perform downstream tasks.
Initial Value Maintenance
Considering that a corpus of video-based cross-modal tasks usually contains thousands of text-video pairs, it is often not enough to only establish connections between samples within single batches.
Therefore, our module builds an inter-batch information transfer mechanism by maintaining a separate initial value M ∈ R K .
In implementations, each time a new batch of features is fed into the model, the EM algorithm needs to initialize the λ .
Rather than randomly initializing λ for each batch, we use M as the initial value of the λ .
For all i, k , we initialize λ with λ
i,k
= m k .
We update M using an average moving method similar to the Batch
Normalization (BN) layer [25].
The moving method is formulated as:
[Equation]
where α ∈ [0 , 1] is the momentum.
Similar to the average moving method in the BN layer, we don’t update M in the inference stage.
Because the initial value is crucial to the stability of the EM algorithm [1, 33], we need to limit the value range of the initial value.
In each iteration, we use the
L2 normalization operation to limit the value range of λ .
EMCL-Net
For fair comparisons, we follow common practice [42, 13, 63] to extract the video representations of input videos and the language representations of input texts.
In detail, for video representations, we first extract the frames from the video clip as the input sequence of video; Then we use ViT [18] to encode the frame sequence, by exploiting the transformer architecture to model the interactions between image patches; Followed by the CLIP [54], the output from the [class] token is used as the frame embedding; Finally, we aggregate the embedding of all frames and obtain the video representation C v ∈ R B × D .
For text representation, we directly use the text encoder of CLIP to acquire the text representation C t ∈ R B × D .
As a plug-and-play module, our proposed EMCL is inserted at the end of the video-text encoders.
We concatenate video features C v and text features C t , generating the input data of our method
X =
[ C v ; C t ] ∈ R 2 B × D .
Following [14], we add reconstructed features f EMCL ( X ) by the EMCL and original features X to obtain final text-video representations
ˆ X =
[ ˆ C v ; ˆ C t ]
= βf EMCL ( X ) +
X ∈ R 2 B × D where β is the scale factor.
Here, β is the scale factor which is used to balance the original and new embeddings.
By adjusting β , we can add some flexibility in the reconstructed video-and-language representations for the robustness of the model.
Training Objective
During the training stage, the EMCL module is trained with the neural network.
We use M to initialize the λ .
Then the components Y and λ are updated in unsupervised way by iteration, as shown in Algorithm 1.
Moreover, we update the initial value M using an average moving method.
The goal of the EMCL-Net is to map text and video into a joint representation space to measure the text-video similarity.
Following common practice, we use cosine similarity s ( t, v ) =
ˆ c
Tt ˆ c v ∥
ˆ c t
∥∥ ˆ c v ∥ as the similarity measure between text t and video v , where ˆ c t represents the reconstructed text representation of text t ; and ˆ c v represents the reconstructed video representation of video v .
We train our model with InfoNCE loss [60]:
[Equation]
where B is the batch size and τ is the temperature hyper-parameter.
This loss function maximizes the similarity of positive pairs s ( t i , v i ) and minimizes the similarity of negative pairs.
During the inference stage, given a set of queries (text/video) and a set of candidates (videos/texts), we use the trained M to initialize the λ .
Then Y and λ can be updated in an unsupervised way by iteration.
The goal of cross-modal retrieval task is to map the query and candidate into a joint video-and-language representation space to measure the query-candidate similarity s ( t, v ) .
In this way, we can output the similarity scores for all the input candidates, and take the candidates with the
Top-1/5/10/50 similarity scores with input query as the final prediction.
Experiments
Datasets, Metrics and Implementation Details Datasets.
We conduct the experiments on three popular text-video retrieval datasets, i.e., MSR-VTT [71], ActivityNet Captions [27], LSMDC [56], and follow common practice [42, 13, 63] to pre-process the datasets for fair comparison.
In detail,
MSR-VTT [71] contains 10,000 videos, each with 20 text descriptions; We follow the 1k-A split [41] with 9,000 videos for training and 1,000 for testing.
ActivityNet Captions [27] contains 20, videos with multiple sentence descriptions; We report results on the "vall" split (10,009 training, 4,917 testing) as in [21].
LSMDC [56] contains 118,081 video clips from 202 movies; We follow the split of [21] with 1,000 videos for testing.
[Figure]
Metrics.
We choose standard retrieval metrics: Recall at K (R@K) and Median Rank (MdR) to evaluate the text-to-video and video-to-text retrieval performance.
Implementation Details.
We utilize the CLIP (ViT-B/32) [54] equipped with Temporal Transformer [42] as pre-trained Bi-Encoder (Base Model).
Following previous works [42], the frame length and caption length are 12 and 32 for MSR-VTT and LSMDC.
For ActivityNet, a long video retrieval dataset, we set the frame length to 64 and caption length to 64.
We follow training schedules from previous works [42, 13, 63].
Concretely, we use the Adam optimizer [26] with a linear warmup.
The initial learning rate is 1e-7 for text encoder and video encoder and 1e-4 for other modules.
We set the temperature τ = 0 .
01 , σ = 1 , the momentum α = 0 .
9 , the number of iterations is set toand the parameter K is set to 32.
The network is optimized with the batch size of 128 in 5 epochs.
During the training stage, the EMCL module is trained with the neural network.
Each time a new batch of features is fed into the model, we use M to initialize the λ .
Then the components Y and λ are updated by iteration.
Moreover, we update the initial value M using an average moving method.
During the inference stage, given a set of queries (text/video) and a set of candidates (videos/texts), we use the trained M to initialize the λ .
Then the components Y and λ can be updated by iteration.
When the EMCL module is incorporated into trained baselines as an out-of-the-box inference module with no extra training, λ is randomly initialized.
Then the components Y and λ can be updated in an unsupervised way by iteration.
Comparisons to State-of-the-art
Table 1 shows the results of our method on three text-video retrieval datasets.
As we can see, our ECML-Net method consistently outperforms the recently proposed state-of-the-art methods on both text-to-video retrieval and video-to-text retrieval tasks across all datasets and metrics.
Generalization Analysis
Since the input and output dimensions of the EMCL module are the same, it is model-agnostic and can be applied to features extracted from any language and video encoders.
Therefore, we further equip our EMCL with three strong baseline models, i.e., MMT [21], CLIP4Clip [42], DCR [63], and evaluate the performance of these models on the MSR-VTT datasets.
Specifically, we insert the EMCL module at the end of the video-text encoders.
Tableshows that our EMCL can be applied to successfully boost all baselines either as a jointly training layer or an out-of-the-box inference module with no extra training.
Overall, our approach can boost the baselines with the most significant improvement up to 3.5% and 4.2% for text-to-video task and video-to-text task in terms of R@1 metric, respectively.
The significant improvements demonstrate the generalization ability of EMCL.
Comparisons to Other Baseline Methods
We further compare our method with other baseline methods in Table 3.
PCA [59] is a popular method for finding salient features shared by the two modalities so that the modality gap can be reduced to a certain extent.
“Transformer” represents using a shared transformer between two modalities, which can explicitly project the data from two modalities into a shared space.
“Fully Connected Layers” represents using two shared fully connected layers between two modalities.
“Sparse Autoencoders” is a common sparse autoencoder [47], which reduces the average response of the encoding layer and learns the compact representation.
Different from these representative dimensionality reduction methods, the motivation of our method is to use contrastive learning to preserve video-text semantic relatedness.
By maximizing the joint posterior probability of video and text, we find a semantically related subspace for compact video-text representation.
In contrast, PCA and its variants are feature dimension reduction methods, which aim to maximize the variance of projected data and cannot guarantee semantic relationships.
Sparse autoencoder reduces the average response of the encoding layer for sparsity, which may potentially
[Table] [Table]
[Table]
discard semantic information.
In addition, our method has linear complexity O ( BDK ) and does not require additional training.
In contrast, the complexity of PCA is O
( D 3 )
( D > B and D > K ), and the autoencoder requires additional training.
Ablative Analysis
Effect of the parameter initialization strategy.
As shown in Table 4, with or without parameter initialization strategy, our method can successfully promote the base model.
It is worth noting that the EM algorithm [16] is sensitive to initial values [1, 33].
In other words, the convergence of EM algorithm depends mainly on initial parameters.
Random initialization leads to large fluctuations in convergence results.
This fatal flaw limits the performance of our module.
Fortunately, with the proposed parameter initialization strategy, our EMCL method surpasses the base model by a large margin with 3.5% R@1 and 1.4% R@1 on the text-to-video and video-to-text tasks, respectively, proving the effectiveness of our parameter initialization strategy used for EMCL-Net.
Effect of the number of subspaces.
In Figure 3a, we show the effect of the number of subspaces
K .
On the one hand, we find that fewer subspaces mean fewer semantic centers, which limits our module’s ability to reconstruct the features.
On the other hand, a larger number of subspaces requires more training data, which increases the cost of our model learning.
We set the center size K = 32 to achieve the best performance in practice.
[Table] [Table]
[49], METEOR [3], ROUGE-L [36], and CIDEr [62] metrics.
All methods only use image modality as input.
[Table] [Table]
Effect of the iteration number.
In Figure 3b
[Table]
we show the influence of EM iteration number T .
Overall performance improves slightly before leveling off.
We find that the algorithm has converged when the number of iterations is 9, so we set the number of iterations to 9 as default.
Hyper-parameter selection.
The parameter σ are hyper-parameters to adjust the distribution (Eq. 5), similar to the mean and covariance in the Gaussian distribution.
We evaluate the scale range setting σ ∈ [0 . 3 , 2 . 0] as shown in Figure 3c.
We find that R@1 is improved from 43.8% to 51.6% when σ = 0 .
7 and saturated with σ = 1 .
As a result, we adopt σ = 1 to achieve the best performance.
Generalize to other tasks
Video captioning.
The purpose of video captioning is to describe the content of the video in fluent sentences.
“Base model cap ” uses CLIP [54] to extract video features and is trained with cross-entropy loss.
To generate higher-quality sentences, we apply EMCL between video features and ground-truth text features.
As shown in Table 5, using EMCL brings significant improvements on caption quality, e.g., gaining a relative improvement of 0.4% at METEOR.
Video question answering.
Visual question answering requires the model to predict an answer using visual information [30, 29].
We use the target vocabulary for MSRVTT-QA dataset [70], and train a fully connected layer on top of the final language features to classify the answer.
“Base model qa ” uses CLIP [54], a transformer-based [18, 31] visual-language pre-training model, to extract videoand-language features and is trained with cross-entropy loss.
To learn compact video-and-language representations, we apply EMCL between video features and question features.
Table 6 shows that
EMCL can be applied to boost video question answering successfully and boost the baseline with an improvement up to 0.8%.
Qualitative Analysis Analysis
of EMCL iterative process.
As shown in Figure 4a, reducing the intra-class variance makes videos and texts belonging to the same semantic class gather, and increasing the inter-class variance makes those belonging to different semantic classes separate from each other.
The two conclusions we get from Figure 4b and Figure 4c are as follows.
(1) EMCL module reduces the intra-class variance of the same semantic classes and increases the inter-class variance of different semantic classes.
The number K of subspaces has a great influence on the
EMCL module.
The effect of the EMCL module is limited if K is too small, while the intra-class variance increases if K is too large.
Video
Text
Different Classes
[Figure]
i n t r a - c l a ss v a r i a n ce
The iteration number T
The iteration number T i n t e r-
c l a ss v a r i a n ce
K= K=
K=
K=128 K=
[Figure]
X
[Figure]
Y
[Figure]
X-Y
[Figure]
X-Y-Z view
X-Y
[Figure]
Z
[Figure]
X
[Figure]
Y
[Figure]
X
[Figure]
Y
[Figure]
X
[Figure]
Y view
X
[Figure]
Y view
X
[Figure]
Y view
X
[Figure]
Y view
X
[Figure]
Y
[Figure]
Y
[Figure]
Z view
Y
[Figure]
view
Y
[Figure]
Y
[Figure]
Y
[Figure]
Z
[Figure]
Y
[Figure]
T h
e o r
i g
i n a l d a t a
T h e ou t pu t s o f E
M C L
[Figure]
To better understand EMCL, we provide the visualization form of both the original representations and the filtered representations.
We notice that the EMCL module eliminates the redundant dimensions, and the features reconstructed by our module are very compact in the feature space.
As shown in Figure 5, even though features have intense noise in the redundancy dimension, the EMCL module still learns semantic information.
The EMCL module forces the differences between classes in subspace to be more obvious than original, which is helpful for the contrastive learning to learn the semantic centers shared by videos and texts.
Conclusion
In this paper, we studied the intrinsic limitation of classic contrastive learning for text-video retrieval.
We found that the contrastive method in the entire representation space fails to preserve inter-modal semantic relatedness, which makes the features gather or separate in the subspace which is irrelevant to semantics.
To mitigate this effect, we propose to directly learn the subspace that is related to shared semantics and do contrastive learning in it.
By learning the subspaces related to semantics, we are able to learn the common semantic center of video and text in the semantic subspace.
Further, it is worth noting that our method could be applied for other contrastive learning tasks, which include similar samples containing redundant dimensions or with a limited number of negative samples.
Acknowledgements
This work is supported by the Nature Science Foundation of China (No.
61972217, 62081360152, 62006133, 32071459), Guangdong Basic and Applied Basic Research
Foundation (No.2019B1515120049) and Guangdong Science and Technology Department (No.
2020B1111340056).
Also, this work is supported in part by the National Institute for Health Research (NIHR)
Oxford Biomedical Research Centre; an InnoHK Project at the Hong Kong Centre for
Cerebro-cardiovascular Health Engineering; and the Pandemic Sciences Institute, University of
Oxford, Oxford, UK.
A Additional Discussions Potential negative societal impacts
Although our work improves the performance of text-video retrieval, but may reduce the difficulty of cross-modal retrieval of sensitive information on the network.
It may raise challenges to protecting information security.
Limitations of our work
Iterative approaches are sensitive to initialization and parameters such as the dimensions and the number of subspaces.
In our work, although we use the L2 normalization operation to limit the value range of the parameters, the EM algorithm [16] may still converge to bad results.
At the same time, the selection of the number of subspaces also has a relatively significant impact on the model effect.
In the future, it is still a promising research direction to explore more stable subspace search algorithms.
[Table]
B Datasets and Implementation Details Datasets
MSR-VTT [71] contains 10,000 YouTube videos, each with 20 text descriptions.
We follow the training protocol in [41, 21, 44] and evaluate on text-to-video and video-to-text search tasks on the 1k-A testing split with 1,000 video or text candidates defined by [76].
ActivityNet Captions [27] dataset consists densely annotated temporal segments of 20K YouTube videos.
Following [21, 50, 65], we concatenate descriptions of segments in a video to construct “video-paragraph” for retrieval.
We use the 10K training split to train or finetune the model and report the performance on the 5K “val1” split.
LSMDC [56] contains 118,081 video clips from 202 movies.
We follow the split of [21] with 1,000 videos for testing.
MSRVTT-QA [70] is based on the MSR-VTT dataset [71], and has 243k VideoQA pairs.
Implementation Details
The EMCL module is trained with the neural network.
During the training stage, the EMCL module is trained with the neural network.
Each time a new batch of features is fed into the model, we use M to initialize the λ .
Then the components Y and λ are updated by iteration.
Moreover, we update the initial value M using an average moving method.
During the inference stage, given a set of queries (text/video) and a set of candidates (videos/texts), we use the trained M to initialize the λ .
Then the components Y and λ can be updated by iteration.
When the EMCL module is incorporated into trained baselines as an out-of-the-box inference module with no extra training, λ is randomly initialized.
Then the components Y and λ can be updated in an unsupervised way by iteration.
We utilize the CLIP (ViT-B/32) [54] as pre-trained Bi-Encoder.
The temporal transformer is composed of 4-layer blocks, each including 8 heads and 512 hidden channels, and is initialized from the CLIP’s text encoder.
Following CLIP4Clip [42], the frame length and caption length are 12 and 32 for MSR-VTT and LSMDC.
For ActivityNet, a long video retrieval dataset, we set the frame length and caption length to 64 and 64.
We follow training schedules from CLIP4Clip [42].
Concretely, we use the Adam optimizer with a linear warmup.
The initial learning rate is 1e-7 for text encoder and video encoder and 1e-4 for other modules.
We set the temperature τ = 0 .
01 , σ = 1 , the momentum α = 0 .
9 , the number of iterations is set to 9 and the parameter K is set to 32.
The network is optimized with the batch size of 128 in 5 epochs.
All experiments are performed on V
GPUs.
The experiment setup in “Comparisons to other baseline methods”
We chose four baselines, e.g., PCA, “Transformer”, “Fully Connected Layers” and “Sparse Autoencoders”.
For all methods, we concatenate video features C v and text features C t , generating the input data X =
[ C v ; C t ] ∈ R 2 B × D .
Finally, we add reconstructed features f ( X ) and original features X to obtain final textvideo representations
ˆ X =
[ ˆ C v ; ˆ C t ] =
f ( X ) + X ∈ R 2 B × D .
All networks are optimized with the batch size of 128 in 5 epochs.
In “PCA”, we adopt PCA at the end of the video-text encoders.
We use PCA to reduce the dimensions of the original features from 512 to 32, then restore them to
[Table] [Table]
512 dimensions.
In “Transformer”, we pass the original features through a common Transformer where the inner-layer has a dimensionality of 512.
In “Fully Connected Layers”, we pass the original features through a common feed-forward network where the inner-layer has a dimensionality of 256, and the activation function is Relu.
In “Sparse Autoencoders”, we adopt Sparse Autoencoders at the end of the video-text encoders.
The inner-layer has a dimensionality of 256, and the activation function is Sigmoid.
We reduce the average response of the encoding layer to ρ = 0 . 05 .
The experiment setup in “Generalize to other tasks”
Video captioning.
The purpose of video captioning is to describe the content of the video in fluent sentences.
“Base model cap ” uses CLIP [54] to extract video features and is trained with cross-entropy loss in 50 epochs.
Our framework is based on DCD [73].
We refer the reader to DCD [73] for more detail.
Video question answering.
Visual question answering requires the model to predict an answer using visual information [30, 29].
We use the target vocabulary for MSRVTT-QA dataset [70], and train a fully connected layer on top of the final language features to classify the answer.
“Base model qa ” uses CLIP [54], a transformer-based [18, 31] visual-language pre-training model, to extract video-and-language features and is trained with cross-entropy loss.
We use the Adam optimizer with a linear warmup.
The initial learning rate is 1e-7 for text encoder and video encoder and 1e-4 for other modules.
The network is optimized with the batch size of 32 in 5 epochs.
C Additional Experiments Additional Generalization Analysis
To further verify the generalization of our method, we test it on other datasets such as ActivityNet [27] and LSMDC [56].
As a plug-and-play module, our approach EMCL can be easily integrated into existing contrastive learning methods.
Therefore, we
[Figure]
the video frame and the word that are closest in the semantic subspace with a line and place their similarity estimation besides the line.
Query 7060 ： a guy extinguishes something then talks into the camera with another guy.
[Figure]
Query 7894 ： a woman getting interviewed by a man.
[Figure]
further equip our EMCL with the baseline model, i.e., MMT [21], and evaluate the performance of the model on the ActivityNet and LSMDC datasets.
Table 7 shows that our EMCL can be applied to successfully boost the baseline either as a jointly training layer or an out-of-the-box inference module with no extra training.
For ActivityNet, our approach can boost the baseline with the improvement up to 3.2% and 2.4% for text-to-video task and video-to-text task in terms of R@1 metric, respectively.
For LSMDC, our approach can boost the baseline with the improvement up to 1.5% and 1.9% for text-to-video task and video-to-text task in terms of R@1 metric, respectively.
The improvements demonstrate the generalization ability of EMCL.
Effect of the scale factor β
The parameter β is the scale factor.
By adjusting β , we can add some flexibility in the reconstructed video-and-language representations.
We evaluate the scale range setting β ∈ [0 . 0 , 4 . 0] as shown in Table 8.
We find that R@1 is improved from 45.1% to 51.6% when β
= 2 . 0 and saturated with β = 3 . 0 .
As a result, we adopt β = 3 . 0 to achieve the best performance.
Generalize
to other contrastive learning tasks
To further verify the generalization of our method, we adopt the EMCL to other contrastive learning tasks, such as Self-supervised Visual representation and Few-shot Classification.
Table 9 shows that our EMCL can be applied to boost other contrastive learning tasks successfully.
For the Self-supervised Visual representation, our approach can boost the baseline with an improvement up to 0.16%.
For the few-shot classification, our approach with
EMCL outperforms the baseline by 0.2%.
It shows that EMCL can further improve the performance of contrastive learning, especially for the tasks with similar samples containing redundant dimensions and unable to maintain a large number of negative samples.
The generalization of our method for long videos
To further verify the generalization of our method for long videos, we adopt the EMCL to the zero-shot long video classification on the
ActivityNet dataset.
For the zero-shot long video classification, we use Prompt to transform the video classification task into a video text matching task.
The template is “human action of <label>”.
Tableshows that the EMCL can be beneficial to the zero-shot long video classification.
The reason may be that for the long video dataset, most of the rich information in the video is redundant information irrelevant to the task.
Therefore, by eliminating the redundancy between modalities, we can reduce the interference of noise information and improve the performance of the model.
D Additional Qualitative Analysis Visualization of semantic similarity in semantic subspace
In EMCL, we project video and text features into semantic subspaces.
We hope that videos and texts with similar semantics can share a common semantic center.
In Figure 6, we associate all video frames with words in the text.
As shown in Figure 6, all video frames assigned to “skateboard" contain content related to “skateboard".
An interesting observation is that in addition to the semantic information, quantitative information such as “person" and “others" are also distinguished in semantic subspace.
For example, all video frames assigned to “person" contain only one person, while video frames assigned to “others" contain more than one person.
All the semantic similarities in Figure 6 are low because limited training data are not sufficient to understand low-frequency words.
This experiment shows that the EMCL can help the model learn adequate semantic information in video-text retrieval
. Visualization of the text-to-video retrieval
We show two examples of the videos retrieved by the base model and our EMCL-Net.
As shown in Figure 7, our EMCL-Net successfully retrieves the ground-truth video while the model without the EMCL module returns several videos that are unrelated to the query sentence.
Our EMCL-Net retrieves the correct videos with higher confidence than the method without the EMCL module.
These results demonstrate that our EMCL module can effectively improve the retrieval performance of the model.