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).
What runs in CodeSplash
- VID040VideoBERT Explained here
- VID041UniVL Explained here
- VID042VideoCLIP Explained here
- VID043Frozen in Time Runs as a notebook
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
Speech as cheap labels
ReadInstructional 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.
VideoBERT: clips as words
ReadVideoBERT 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?
Data
Starting centers
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 to see the result.
UniVL: understand and generate
ReadUniVL 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:
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.
VideoCLIP: positives that overlap in time
ReadVideoCLIP 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.
Overlap isn't agreement
PredictPredict 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?
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.
Frozen in Time: images are short videos
ReadFrozen 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.
Reporting retrieval
Read- Recall at 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.
What runs here
Read| Entry | In CodeSplash |
|---|---|
| VID040 · VideoBERT | Explained here |
| VID041 · UniVL | Explained here |
| VID042 · VideoCLIP | Explained here |
| VID043 · Frozen in Time | Runs as a notebook (the reference program; no method) |
Check: video–language pretraining
CheckpointCheck 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.
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