II · THE IDEA · ARTIFICIAL INTELLIGENCE
Contrastive Learning Across Vision, Audio and Text
▶ Listen · narrated
Nobody labelled the sizzle in the frying pan. The model works out what frying sounds like because the picture, the sound and the spoken words all arrived inside the same clip.
At a glance
- What it is
- One shared vector space holding frames, sound and words together
- Training signal
- Matched triples pulled together, mismatched ones pushed apart
- Negatives
- The other clips in the same batch, free and unlabelled
- Main setting
- Instructional video, taken uncurated from the web [1912.06430]
- Known difficulty
- Narration that does not describe what is on screen
Think of a very large noticeboard with a pin for every clip you have. Each clip gives you 3 things: a few frames of video, a few seconds of sound, and a sentence someone said. You want to pin all 3 of a clip's things to the same spot, so that the sizzle, the frying pan and the words sit as neighbours.
Now the catch. If your only rule is put each clip's 3 things together, you can cheat: pin absolutely everything to one spot in the middle of the board. Every trio is united, and the board tells you nothing, because everything is in the same place.
So you add a second rule. When you pin one clip's things together, you must also keep them away from every other clip's things. Those other clips come free — they are already in front of you, and you know without checking that they are the wrong answers. Repeat this for millions of clips and the board organises itself. Kitchen sounds drift towards kitchen pictures and kitchen words. Traffic noise drifts somewhere else entirely.
Afterwards, the board is a measuring tool. Hand it a photograph and a sentence and it can tell you whether they belong near each other, because deciding exactly that is all it has ever practised.
Three encoders, one per modality, each mapping its input to a vector of the same dimension, typically L2-normalised so that a dot product between any 2 vectors is a cosine similarity. Given a batch of N aligned triples, you form similarity matrices between modality pairs. For video and text this is an N-by-N matrix whose diagonal holds the true correspondences. The loss is symmetric: a softmax over each row (which caption belongs to this video) and over each column (which video belongs to this caption), with a temperature dividing the logits before the softmax. Lower temperature sharpens the distribution and raises the penalty on hard negatives; it also tends to destabilise training. With 3 modalities you extend this to the pairings you care about and weight them, because the pairings are not equally reliable.
The in-batch negatives are what prevent collapse. Without them the objective admits a constant solution: every input maps to one vector and the loss is minimised trivially. Because gradient quality depends on the number of negatives per anchor, effective batch size becomes a hyperparameter with real accuracy consequences rather than a pure memory concern, which is why this family of methods is tied to large-scale training. That constraint is exactly what work on training transformers without enormous datasets targets [2104.05704].
The main practical limitation is that the positive pairs are assumed correct and often are not. Audio is genuinely synchronous with its frames. Transcribed narration is not: speech may precede, follow or simply fail to describe the visible action. Training end to end on uncurated instructional video means confronting that misalignment directly [1912.06430], and any method that treats every transcript segment as a clean caption for its co-occurring frames is fitting a substantial amount of noise.
What you get at the end is a similarity function over heterogeneous inputs, not a classifier. Zero-shot classification embeds candidate label strings and takes the nearest. Coverage is inherited from the training distribution exactly: concepts thinly represented in the matched triples occupy poorly determined regions of the space, and confidence in those regions is not calibrated to reliability.
Look closer
The wrong answers cost nothing, and that is the whole trick
Take a batch of clips. Lay the video vectors down the side of a grid and the caption vectors across the top, and put a similarity score in every cell. The cells on the diagonal are the true pairs. Every other cell is a mismatch that nobody had to label, because clip three's caption is automatically a wrong answer for clip one's video. Training means raising the diagonal and lowering the rest. A batch of a few hundred clips therefore hands you a few hundred wrong answers for every right one, at no labelling cost.
Three encoders, three shapes of input, one output size
Frames are a grid of pixels changing over time. Sound is a waveform. A caption is a sequence of tokens. The three encoders share almost nothing internally, and they do not need to. The only requirement is that each produces a vector of the same length, so that comparing a vector from one encoder with a vector from another gives a meaningful number. That shared output size is the joint space. Whatever the model knows about the relationship between a hiss and the word simmer lives in the geometry of that space, not inside any single encoder.
How harshly a near-miss is punished
The loss compares each true pair's similarity score against the mismatched scores, and one scale factor, usually called the temperature, decides how sharp that comparison is. A low temperature punishes near-misses almost as hard as absurd ones, which produces tightly separated clusters but can make training unstable. A high temperature is forgiving and yields a blurrier space. It is a knob with a genuine trade-off rather than a setting with a known correct value, and published choices vary.
The story
Start with the problem. You want a model that connects what a thing looks like, what it sounds like and what it is called. The obvious route is to pay people to write labels: this clip contains a violin, this one contains applause. Labelling by hand is slow and expensive, and it caps what the model can ever say, because it can only learn the words that appear on the label list. Contrastive learning takes a cheaper route. Video from the web already arrives as a bundle: the frames, the soundtrack, and often a transcript of whatever was said. All 3 were recorded at the same moment. Nobody had to assert that they belong together; the recording itself did. The method turns that accidental togetherness into the training signal.
The machinery begins with encoders. An encoder is a network that turns one kind of input into an embedding — a fixed-length list of numbers that works like an address in an abstract space. There are 3 encoders here, one per kind of input, and internally they share almost nothing. Frames are a grid of pixels changing over time; sound is a waveform; a caption is a sequence of word pieces. Each encoder can be built however suits its material. The only firm requirement is that all 3 produce lists of the same length, because 2 lists of the same length can be compared: the closer they are, the more the model treats their inputs as belonging together. That shared output size is the joint space. Everything the model comes to know about the link between a hiss and the word simmer lives in the geometry of that space — in what sits near what — not inside any single encoder.
Training is a matching game played on batches. Take a few hundred clips at once. Compute every clip's video, audio and text embeddings. Now lay the video embeddings down the side of a grid and the caption embeddings across the top, and fill every cell with a similarity score. The cells on the diagonal — clip one's video against clip one's caption, clip two's against clip two's — are the true pairs. Every other cell is a mismatch, and here is the economy of the whole method: nobody had to label those mismatches. Clip three's caption is automatically a wrong answer for clip one's video, simply because they came from different clips. Training means nudging the encoders so the diagonal scores rise and all the rest fall. A batch of a few hundred clips hands the model a few hundred wrong answers for every right one, free of charge.
The word contrastive names the pushing as well as the pulling, and the pushing is not optional. Pulling alone has a perfect, useless solution: send every input — every frame, every sound, every sentence — to the identical list of numbers. Then every true pair matches exactly, the training score is perfect, and the model has learned nothing, because it can no longer tell anything apart. This failure has a name, representation collapse. The mismatched pairs are what forbid it. Because the model is also punished whenever an impostor scores high, it cannot flatten everything into one point. It must hold different things apart while holding matched things together, and a space that does both is a space where distance carries meaning: near means related, far means unrelated.
One dial governs how harsh the game is. The loss compares each true pair's score against the impostors' scores, and a scale factor — usually called the temperature — decides how sharply. A low temperature punishes a near-miss almost as hard as an absurd guess, which carves tightly separated clusters but can make training unstable. A high temperature is forgiving and yields a blurrier space. There is no known correct value; published choices vary, and the setting is a genuine trade-off rather than a solved detail.
Going from 2 kinds of input to 3 is less tidy than it sounds. Video, audio and text give you 3 pairings to satisfy at once, and they are not equally trustworthy. A soundtrack really is simultaneous with its frames; the microphone and the camera ran together. Speech often is not. A narrator says now let it rest for 10 minutes and then, seconds later, does something else on screen. The work on uncurated instructional video [1912.06430] uses exactly this material — how-to video taken from the web as found, not assembled in a laboratory — and treats the loose fit between speech and action as part of the problem to solve, not a detail to ignore. That admission is worth holding on to: any tidy summary of these systems that assumes the transcript describes the picture is describing cleaner data than the models actually saw.
There is a second cost, quieter but real. Contrastive training is hungry for clips and for computing power, and part of the hunger comes directly from the mechanism. The training signal is stronger when there are many impostors to rule out at once, which pushes towards large batches, which demand large machines and large collections of video. The compact transformer paper [2104.05704] sits at the other end of that tension. It is explicitly about escaping what it calls the big data paradigm — getting transformer architectures to learn usefully from modest datasets rather than assuming enormous ones. The 2 papers are not about the same task, but together they mark the ends of a real trade-off. One shows how much can be learned when supervision is free and data is nearly unlimited. The other asks what to do when it is not.
If the training works, what you end up with is not a classifier — not a machine that sorts inputs into a fixed list of categories. It is a measuring device. Give it any image, any sound and any sentence, and it reports how close they sit in the shared space. That single ability supports everything else. Finding a photo by typing a description is a nearness query: your words become an embedding, and the nearest photos win. So is zero-shot classification, where the model labels an input it was never trained to categorise by embedding candidate sentences — a photo of a dog, a photo of a cat — and picking the nearest. None of these abilities was programmed in. Each falls out of the geometry the matching game produced.
Why it mattered then
The immediate appeal was economic. Labelling video by hand is slow, and the labels you can afford are coarse: one tag per clip, chosen from a fixed list. Instructional video, meanwhile, existed on the web in enormous quantity, and every clip carried 2 extra channels of information free of charge — its soundtrack and its transcribed speech. Learning directly from that uncurated material [1912.06430] meant the supervision grew with the amount of video available, not with the number of annotator hours paid for. The approach also changed what a trained model was for. A model trained to pick one of a thousand fixed categories can only answer questions phrased in those categories. A model trained to place 3 kinds of input in one shared space answers a broader question — how similar are these 2 things, whatever they are — and a broader question has more uses. That is why the idea spread so quickly beyond its original task. One qualifier belongs here. Success depended on scale, and scale was only just becoming affordable. The contemporaneous interest in doing more with less data [2104.05704] suggests the field already knew that a method demanding vast data and large batches is not a universal answer — only a very effective one when the conditions hold.
Why it matters now
Nearly every system that connects an image to a sentence rests on this idea. Text-to-image generation needs a text encoder whose output can be compared with visual content, and contrastive training is what makes those outputs comparable. Searching a photo library by typing a description works the same way: your words become an embedding — a position in the shared space — and the system returns the photos whose positions sit nearest. The framing also explains a family of failures that would otherwise look random. The shared space only encodes distinctions that appeared, repeatedly, in matched triples during training. If a sound, an object or a phrase was rare in that data, its position in the space is poorly pinned down, so the model's judgements about it are confident and unreliable at the same time. That is not a bug awaiting a patch. It follows directly from learning only from what happened to occur together. And the alignment problem has not gone away. Narration that describes something other than what is on screen [1912.06430] is the everyday case in web video, not the rare one, and any system trained on such video inherits that noise. When a model confidently mislabels a sound or misreads a scene, a loose fit between what was said and what was shown is one plausible cause — though pinning a particular error on a particular cause, after the fact, is rarely possible with confidence.
The surprising detail
The most important ingredient in the training signal is the part nobody supplies. Pulling matched things together, on its own, has a perfect and useless solution: map every input to the same point, and every true pair scores full marks while the model learns nothing. What blocks that collapse is the mismatched pairs — and nobody collects or labels them. They are simply the other clips that happened to share the batch. The load-bearing part of the method is a by-product of ordinary batching. It also means batch size is not just a memory setting. It fixes how many wrong answers the model must rule out at each step, and therefore how demanding the exercise is.
What is disputed
Two things are genuinely unsettled. First, how well spoken narration corresponds to visible action in web video is a matter of degree, and the mismatch is acknowledged rather than solved [1912.06430]; descriptions of these models as learning grounded meaning should be read cautiously. Second, how much data and compute this family of methods actually requires is contested, which is the premise of work aiming to train transformers on modest datasets [2104.05704]. Any specific claim about a minimum viable scale should be treated as architecture- and task-dependent, not settled.
Remember this
The model is never told what a sound is. It is told only which sound, which picture and which sentence arrived together — and that everything else in the batch did not.
Test yourself
Suppose you removed the mismatched pairs and trained only on the instruction pull matching embeddings closer together. The loss would fall smoothly towards zero. Why would the resulting model be worthless, and what does that tell you about where the information in contrastive learning actually comes from?
Because the easiest way to make every matched pair identical is to make every output identical. Send all frames, all sounds and all captions to the same vector and the loss is perfectly minimised while the model has learned no distinctions whatsoever. This is representation collapse. The mismatched pairs are what forbid it: the model is penalised for scoring an impostor highly, so it cannot flatten the space. The lesson is that the information does not come from the positive pairs alone. It comes from the contrast — from being told, implicitly, that this caption goes with this video and not with the several hundred others present. That is also why batch size matters more than it looks. A larger batch means more impostors to rule out per decision, which makes each update more informative and is one reason the method is compute-hungry [1912.06430], and one reason work on training with less data [2104.05704] addresses a real constraint.
Go deeper
- [1912.06430] End-to-End Learning of Visual Representations from Uncurated Instructional Videos · arxiv.org
- [2104.05704] Escaping the Big Data Paradigm with Compact Transformers · arxiv.org
Image: Original diagram, The Daily Triptych. Licence: Original work. Source.