01CLIP: contrastive training on captions the internet already wrote
CLIP trains two encoders — one for images, one for text — on roughly 400 million image-caption pairs scraped from the web. The captions are the free labels: nobody annotated anything, the internet had already described its own pictures.
The objective is contrastive. Take a batch of N pairs, embed all images and all texts, and compute the N×N similarity matrix. Maximise the similarity of the N correct pairs on the diagonal and minimise all N²−N incorrect ones. It's a classification problem over the batch, in both directions, and it is the same cross-entropy loss from Lesson 4 applied to a similarity matrix.
Zero-shot classification then falls out with no extra training. To classify an image into a set of categories, write each category as a sentence — 'a photo of a {label}' — embed them all, embed the image, and take the nearest. The set of classes is defined at inference time by what you type, which is a genuinely different capability from a fixed softmax head over 1,000 ImageNet classes.
Try it
Pull the pairs together, push the rest apart
Train the contrastive objective and watch zero-shot classification appear without being asked for.