TempCLR: Temporal Alignment Representation with Contrastive Learning

Yuncong Yang, Jiawei Ma, Shiyuan Huang, Long Chen, Xudong Lin, Guangxing Han, Shih-Fu Chang

Introduction

Video representation learning has seen significant success in video-text pre-training for zero-shot transfer. However, most current methods rely on "unit-level" matching, where individual sentences are trained to be close to paired short video clips in a shared feature space. While effective for short snippets, this approach struggles with long videos. TempCLR introduces a contrastive learning framework designed to align long videos with descriptive paragraphs by explicitly modeling their temporal sequences, prioritizing global temporal context over mere visual similarity.

The Challenge of Long Video Alignment

The core issue with unit-level matching is that it ignores global temporal context. In a long instructional video, different segments might look visually similar—for instance, the same kitchen background, the same chef, and the same pans.

Comparison of unit-level vs. sequence-level alignment. Unit-level matching struggles with visually similar frames (e.g., adding oil in steps 1 and 4), while TempCLR's sequence-level approach correctly aligns them using temporal order.

A model looking only at local frames might incorrectly match a sentence about "adding salt" to a clip of "adding sugar" simply because the visual features are nearly identical. Furthermore, unit-level matching fails to account for the inherent chronological order of events, which is a vital cue for understanding complex, multi-step activities.

TempCLR: Sequence-Level Alignment

To address these limitations, TempCLR shifts the focus from matching individual units to matching entire sequences. The framework relies on three core components:

1. Sequence-Level Distance with DTW: Instead of simple averaging, TempCLR uses Dynamic Time Warping (DTW) to calculate the distance between a paragraph (a sequence of sentences) and a video (a sequence of clips). DTW finds the optimal alignment between these two sequences that minimizes cumulative cost while strictly respecting their temporal order. This provides a "soft" supervision, allowing for flexible many-to-many mappings while maintaining the monotonic constraint of time.

2. Contrastive Learning Objective: The model is trained to minimize the sequence-level distance between a paragraph and its paired video (a positive pair) while maximizing the distance to "negative" sequences.

3. Temporal Granularity Shuffling: To force the model to learn temporal dynamics, the authors propose a unique negative sampling strategy. They create "hard negatives" by taking a positive video and shuffling its clips at two levels:

  • Segment-level: Swapping the order of major video segments.
  • Unit-level: Shuffling the short clips within a specific segment.

By breaking the temporal consistency while keeping the visual content identical, the model is forced to realize that temporal order matters, preventing it from relying solely on static visual cues.

Experimental Setup and Key Results

The model was pre-trained on a 90k subset of the HowTo100M dataset, a massive collection of narrated instructional videos. It was then evaluated across several downstream tasks:

  • Full-Video Retrieval (YouCookII & DiDeMo): On the YouCookII dataset, TempCLR achieved an impressive 83.5% R@1 score, a massive improvement over the VideoCLIP baseline (56.0%) when both used DTW for evaluation. This demonstrates the model's superior ability to identify the correct full video for a given descriptive paragraph.
  • Action Step Localization (CrossTask): In zero-shot settings, TempCLR improved recall from 33.9% to 36.9%. When fine-tuned on just 100 videos, it reached 52.5%, demonstrating high data efficiency for assigning labels to specific time segments.
  • Few-Shot Recognition (Something-Something V2): On a dataset where temporal movement is critical, TempCLR outperformed specialized state-of-the-art models, achieving 47.8% in 1-shot and 67.7% in 5-shot accuracy.

Limitations and Future Directions

While highly effective, TempCLR has notable limitations. Calculating DTW for every pair in a contrastive batch introduces significant computational overhead compared to simple dot products, which restricted the pre-training data size in this study. Additionally, standard DTW assumes sequences start and end at the exact same time. While the authors experimented with variants that relax these boundaries, more sophisticated open-ended alignment remains an area for exploration. Finally, scaling this approach from a 90k subset to the full million-video HowTo100M dataset could likely yield even more robust representations in future work.

Summary updated

BibTeX
@inproceedings{yang2023tempclr,
  author = {Yuncong Yang and Jiawei Ma and Shiyuan Huang and Long Chen and Xudong Lin and Guangxing Han and Shih-Fu Chang},
  title = {{TempCLR: Temporal Alignment Representation with Contrastive Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=CIFOsnhZvON},
}
Figure