Chapter 1 hand-placed six points so cross-modal search would obviously work. Nobody hand-places the coordinates in a real model — and nobody labels "this pixel region means dog." So what actually pulls a dog photo and "a dog running" together, with no supervision except which pairs happened to appear together?
Before training, every image and every caption embed to the same point — there's no signal to tell them apart, so the model can only guess uniformly among the three captions for any image. After training (Chapter 1's exact placements), the probability matrix sharpens hard onto the diagonal: each image's own caption dominates.
Score every image against every caption with a similarity function, turn each image's row of scores into a probability distribution over captions with softmax, and push that distribution toward the true pairing — exactly Part II's cross-entropy loss, just computed in both directions at once:
- — the contrastive loss being minimized, averaged over both directions.
- — the number of image-caption pairs in the batch.
- , — the -th image and its true, paired caption.
- — the probability the model assigns to the true caption given the image (and symmetrically for the other direction).
- No hand-written labels anywhere
The "true pairing" is just whichever image and caption arrived together in the training data — nobody annotated what's in either one.
- Negatives come for free
Every other image in the same batch automatically becomes a negative example for every other caption, with no extra labeling effort.
Compare raw similarity scores to what softmax turns them into. The raw numbers are just negative distances — useful, but not yet a probability. Softmax is what turns "closer" into "more likely," and it's exactly the same softmax from Part II's cross-entropy chapter and Part IV's attention chapter, doing the same job a third time.
Three images, three captions, correctly paired:
- Before training
Every embedding collapses to the same point, so every similarity score is and softmax gives exactly to each caption. The loss is — precisely the entropy of a uniform guess over three options, because that's genuinely all the model can do.
- After training
Using Chapter 1's placements, the dog image assigns its true caption a probability of about — more than ten times any rival caption's share.
- The loss reflects that gap
Averaged over both directions and all three pairs, the loss drops to about — roughly a tenth of where it started, without a single hand-written label anywhere in the process.
- It falls smoothly, not in one jump
Halfway through training (linearly interpolating every embedding between its start and end position), the loss sits at about — already down from , but nowhere near yet. The curve is concave: most of the improvement happens in the second half of training, not the first.
Set training progress so the contrastive loss lands within 0.02 of exactly 0.2 — not just below it.
This is the core idea behind CLIP — short for Contrastive Language–Image Pretraining — and every model like it: pull matched pairs together, push every mismatched pair apart, using nothing but which examples arrived side by side. Chapter 1's space didn't come from nowhere — this loss, minimized over millions of image-caption pairs instead of three, is what places it. The next chapter asks what a model does with that shared space once it has one: not just measuring distance, but letting one modality directly query the other.