Skip to content

Learning from narrated video: VideoBERT, UniVL, VideoCLIP, Frozen in Time

Millions of videos come with speech or captions. Turn clips into visual tokens and mask them like words (VideoBERT), train for retrieval and captions together (UniVL), or align clips and text contrastively (VideoCLIP, Frozen in Time).

Advanced ~15 min10 steps

What runs in CodeSplash

You will be able to

  • Explain why narration is weak supervision and how it can mislead
  • Describe turning clip features into discrete visual tokens for masked modeling
  • Keep retrieval and captioning objectives separately inspectable
  • Build timestamp-overlap positives and say what they assume
  • Report video–text retrieval with recall in both directions and multiple correct captions

Read first

01

Speech as cheap labels

Read

Instructional videos come with someone talking: "now add the flour". Speech recognition turns that into text with timestamps. Pairing each clip with what was said around the same time, narration alignmentNarration alignmentPairing a clip with speech said around the same time. Cheap labels, but speakers often describe things not on screen., gives millions of video–text pairs for free.

They are weak supervisionWeak supervisionTraining with imperfect labels: coarse, indirect, noisy or written by rules. More of them doesn't remove a shared bias.. People describe what they did a moment ago, what comes next, or nothing on screen at all ("don't forget to subscribe"). Every method below inherits that noise.

02

VideoBERT: clips as words

Read
Reference · VID040 · Explained hereVideoBERTBuilds joint representations of language tokens and discrete visual tokens extracted from video. Masked prediction over these token sequences connects events with narration and provides a historical bridge from video…

VideoBERT turns each clip's continuous features into a discrete visual token by assigning it to the nearest entry of a learned codebook, much like image tokensDiscrete image tokensAn image encoded as a grid of codebook indices, so a Transformer can generate it token by token like text.. Text tokens and visual tokens form one sequence, and a BERT-style model predicts masked ones, as in masked language modelingMasked language modelingPretraining by hiding a share of tokens and predicting them from both sides: the objective behind BERT and RoBERTa..

In the reference's toy, two clip features snap to codebook entries 0 and 1; predicting the second masked token costs 0.170. Snapping to the nearest entry is k-means assignment, and it throws detail away.

AExplorable · Step through k-means

How does k-means find clusters, and when does it find the wrong ones?

Assign each point to its nearest center, move each center to its points' mean, repeat. How many iterations until nothing changes?

11
How sure?

Data

3

Starting centers

0
150
best of ten starts

Crosses mark the centers; dashed lines show how far each moved at this iteration.

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

03

UniVL: understand and generate

Read
Reference · VID041 · Explained hereUniVLCombines modality-specific encoders, a cross-modal encoder and a decoder to support both understanding and generation.

UniVL has separate text and video encoders, a cross-modal encoder that mixes them and a decoder that writes captions. It trains on a mix of objectives, retrieval, masked prediction and captioning:

L=λrLretrieval+λmLmasked+λcLcaption.L = \lambda_r L_{\text{retrieval}} + \lambda_m L_{\text{masked}} + \lambda_c L_{\text{caption}}.

Keep the terms visible: in the reference's toy the retrieval and caption losses are 0.127 and 0.364, summing to 0.490. A falling total can hide one objective getting worse; the two needn't favor the same features.

04

VideoCLIP: positives that overlap in time

Read
Reference · VID042 · Explained hereVideoCLIPAligns video and text using contrastive learning with temporally overlapping positives and informative negatives.

VideoCLIP is a dual encoderDual encoderTwo separate networks map images and texts into one embedding space, compared by cosine similarity; neither sees the other.: a video tower and a text tower trained contrastively, so matching clips and sentences land close together. Its positives are text spans that overlap the clip in time; it also picks harder negatives from similar videos.

In the reference's toy, a clip from two to five seconds is compared with three narration spans, and only the span at index 1 overlaps it, so it alone is a positive.

05

Overlap isn't agreement

Predict

Predict first

A clip shows a person whisking eggs. The narration overlapping it says: "Earlier I preheated the oven." VideoCLIP treats the pair as a positive. Is it right?

It is a correct positive: they overlap in timeIt may be a false positive: the speech refers to something not on screenIt is a negative
Reveal

It may be a false positive. Overlapping timestamps don't guarantee the words describe the picture. And a "hard negative" from another cooking video might describe whisking exactly. Check a sample of pairs by eye before trusting retrieval scores.

06

Frozen in Time: images are short videos

Read
Reference · VID043 · Runs as a notebookFrozen in TimeJointly trains image-text and video-text retrieval representations using a space-time visual encoder and a text encoder.

Frozen in Time trains one space-time visual encoder on both image–text and video–text pairs, treating an image as a one-frame video. Similarities between normalized video and text embeddings form a matrix, and a symmetric cross-entropy rewards the diagonal in both directions (video to text and text to video), with batch partners as in-batch negativesIn-batch negatives (contrastive training)In contrastive training, every other pair in the batch counts as a wrong match for each image and each caption..

In the reference's toy, a two-by-two similarity matrix gives a symmetric loss of 0.177. Lots of image data can make such a model lean on appearance over time.

07

Reporting retrieval

Read
  • Recall at kk and median rank, both text-to-video and video-to-text.
  • Allow multiple correct captions and duplicate videos: an off-diagonal pair isn't always wrong.
  • Split by source video, so a clip's neighbors aren't in the training set.
  • Check grounding with controls, for example shuffled or blank frames, and look at what the top results actually show.
  • For captioning, add human grounding checks: fluent captions can describe a generic version of the scene.
08

What runs here

Read
EntryIn CodeSplash
VID040 · VideoBERTExplained here
VID041 · UniVLExplained here
VID042 · VideoCLIPExplained here
VID043 · Frozen in TimeRuns as a notebook (the reference program; no method)
09

Check: video–language pretraining

Checkpoint

Check yourself

How does VideoBERT turn video into tokens?

Show the answer

Answer: a

Vector quantization makes discrete visual words that can be masked like text tokens.

Check yourself

VideoBERT predicts masked tokens very accurately. What should you still check?

Show the answer

Answer: b

Masked-token accuracy can come from language patterns; check downstream tasks and grounding.

Check yourself

Why keep UniVL's retrieval and caption losses separately visible?

Show the answer

Answer: b

Track each objective, and isolate which training stage and modality helps each task.

Check yourself

A video captioner writes fluent, plausible captions. What evaluation shows whether they describe this video?

Show the answer

Answer: b

Generic captions can read well and match many videos; grounding checks catch that.

Check yourself

What makes a text span a positive for a clip in VideoCLIP?

Show the answer

Answer: b

Timestamp overlap is cheap and noisy: words and pictures don't always agree.

Check yourself

VideoCLIP mines hard negatives from similar videos. What can go wrong?

Show the answer

Answer: a

The harder the negative, the more likely it is a hidden positive. Test robustness to this.

Check yourself

How does Frozen in Time use image–text data for a video model?

Show the answer

Answer: b

Images become short sequences; the cost is a pull toward appearance over temporal structure.

Check yourself

A test set has five correct captions per video. Scoring with "only the paired caption is right" will…

Show the answer

Answer: b

Off-diagonal pairs aren't always wrong. Use multi-positive-aware evaluation.

10

Recap

Recap
  • Narration gives cheap, noisy video–text pairs: weak supervision.
  • VideoBERT masks visual and text tokens; UniVL mixes retrieval, masked and caption objectives.
  • VideoCLIP and Frozen in Time align clips and text contrastively; overlap and hard negatives can both be wrong.
  • Report recall both ways, allow multiple correct captions, split by source video and check grounding.

Concepts in this lesson