Skip to content

Video understanding, tracking, generation, and world models · Video-language learning · VID043 · Model

Frozen in Time

Jointly trains image-text and video-text retrieval representations using a space-time visual encoder and a text encoder.

Runs as a notebook Complete calculation CodeSplash's run and the reference's record

In CodeSplash

No method yet, but the reference's example runs here as a notebook.

Do it in CodeSplash Open the reference's example as a Python or R notebook.

Availability
Runs as a notebook
Code example
Complete calculation
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Jointly trains image-text and video-text retrieval representations using a space-time visual encoder and a text encoder. Images become a special short-sequence case, allowing image data to help train a video retrieval system.

Question / objective

Align video evidence with language for retrieval, recognition, captioning or grounded answers. This is a learning or inference objective, not a test of a statistical null hypothesis.

Method type and supervision

model · Video-language learning. Weak paired video/text pretraining and/or supervised instruction learning, depending on the entry.

Architecture / computational structure

Space-time visual encoder and text encoder jointly trained on image/video pairs.

Assumptions

Inputs must satisfy the temporal, modality and annotation protocol described below. Image-rich pretraining can favor appearance over temporal structure. Multiple correct captions or duplicate videos require multi-positive-aware evaluation rather than blindly treating every off-diagonal pair as wrong.

Formula / computational definition

Sij=⟨vˉi,tˉj⟩/τS_{ij}=\langle \bar v_i,\bar t_j\rangle/\tau forms normalized visual/text similarities; symmetric row and column cross-entropy aligns paired examples. Bars denote unit-normalized embeddings and τ\tau sets logit scale.

Parameters and notation

Learned/estimated quantities: Modality encoders, connectors, projections and language-model weights may be learned or frozen according to the stated stage; token IDs and timestamps are inputs. Symbols specific to the objective are defined with the equation. Hyperparameters and design choices: Image/video mixture, temporal embedding initialization, frame count, batch construction and text truncation influence transfer.

Fitting, fine-tuning, and adaptation

Fit retrieval adapters or tune late encoder blocks. Adjust image/video mixture when extending training, and retain both image and video validation to detect modality forgetting. Use a separate adaptation validation split, monitor the target metric and retention of previously useful behavior, and save the exact preprocessing and training configuration.

How to use and calibrate

Fix the input protocol and target before fitting; choose design settings on held-out source videos, then freeze the evaluation procedure. Report text-to-video and video-to-text recall, median rank and image-versus-video ablations.

Example application

Search mixed image and video collections with text queries.

Interpretation / pitfalls

Watch out

An optimized training objective or a favorable example does not establish generalization. Report text-to-video and video-to-text recall, median rank and image-versus-video ablations. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.

Python and R code examples

Component: Compute symmetric video-text contrastive cross-entropy. Dependencies: NumPy in Python; base R in R; run the shared setup above. Python component: executed successfully. R component: unexecuted. No complete model training or pretrained inference was executed.

Full implementation route — Python: Use the authors' dual-encoder recipe with explicit handling of image and video batches. R: Normalize and rank embeddings in R; use a Python bridge for the visual/text models and preserve pairing IDs.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Complete calculation — Compute symmetric video-text contrastive cross-entropy.

Shared setup for this chapter
import numpy as np

def softmax(x):
    z = np.asarray(x, dtype=float)
    e = np.exp(z - z.max())
    return e / e.sum()
scores = np.array([[2.,.2],[.3,1.8]])
row_loss = np.mean([-np.log(softmax(scores[i])[i]) for i in range(2)])
column_loss = np.mean([-np.log(softmax(scores[:,i])[i]) for i in range(2)])
print("symmetric loss",(row_loss+column_loss)/2)
R

Complete calculation — Compute symmetric video-text contrastive cross-entropy.

Shared setup for this chapter
softmax <- function(x) {
  e <- exp(x - max(x))
  e / sum(e)
}
scores <- rbind(c(2,.2),c(.3,1.8))
row_loss <- mean(sapply(1:2,function(i)-log(softmax(scores[i,])[i])))
column_loss <- mean(sapply(1:2,function(i)-log(softmax(scores[,i])[i])))
print((row_loss+column_loss)/2)

Sources

From the CodeSplash reference, entry VID043.