MLGuerrillaStart M1 →
Vision-language·14 min read·Updated 24 September 2026

CLIP

CLIP is a pair of encoders that put images and text into one vector space, so you can compare a photo to a sentence. It is what lets you classify or search images with words you type.

CLIP, short for Contrastive Language-Image Pre-training, came out of OpenAI in 2021. It runs two encoders, one for images and one for text, and trains them so that a photo and its caption land close together as vectors. Once both live in the same space, comparing them is a cosine similarity, which is how a model that was never trained on your categories can still sort your photos into them.

The paper's headline result was that this matched "the accuracy of the original ResNet-50 on ImageNet zero-shot without needing to use any of the 1.28 million training examples it was trained on". This page covers what the scores mean and how the training works. The last section covers where the approach falls over.

What it is

Images and captions become vectors in one space, and you compare them

Feeding an image through the image encoder gives a vector. Feeding a sentence through the text encoder gives a vector of the same size. The cosine similarity between them is a single number, and the whole method follows from that.

To classify with no training, you write one short caption per class and embed them once, then take the caption whose vector is closest to the image's. To search a library, you embed every image once, then embed the query text and return the nearest images.

Scoring five images against five captions with the smallest CLIP model puts real numbers on that.

A figure titled "CLIP scores every image against every caption", showing a 5 by 5 grid of cosine similarities. The rows are thumbnails: the whole street photo, a crop of a stroller, a crop of a bicycle, a crop of a car and a crop of a striped hat. The columns are the captions: a baby stroller, a bicycle, a small black car, a striped knitted hat, and a busy city crosswalk. Cells are shaded terracotta by value. The highest value in each row is the matching pair: the whole photo scores 0.294 for the crosswalk caption, the stroller crop 0.312 for the stroller caption, the bicycle crop 0.289 for the bicycle caption, the car crop 0.281 for the car caption and the hat crop 0.298 for the hat caption. Every value in the grid sits between 0.185 and 0.312. A note says the right pairing is only the highest value in its row, and the caption says softmax turns the bicycle row's 0.026 gap into 93% against 7%, so treat these scores as a ranking.
The whole photo scores highest for the crosswalk caption and only 0.213 for the stroller, even though the stroller is in it. One vector has to stand for the whole image.

The right answer is always the highest score in its row, so ranking works. The numbers themselves sit in a narrow band, between 0.185 and 0.312, with no natural cutoff between "matches" and "doesn't". Libraries hide this by multiplying the scores by a scale learned during training and running a softmax over them, which turns the bicycle row's gap of 0.026 into 93% against 7%. Those percentages only compare the captions you supplied.

That narrow band has a cause, and you can see it by looking at where the vectors sit.

A figure titled "Images and captions share a space, and they sit in different parts of it", built from the same five images and five captions embedded with CLIP ViT-B/32 and placed on the one axis that separates them. On the left, ten labeled rows each carry a dot at its position along the first principal component, which accounts for 47.7% of the variance. The five images, the street photo, the stroller crop, the bicycle crop, the car crop and the hat crop, all sit as terracotta dots on the left side. The five captions, a busy city crosswalk, a baby stroller, a bicycle, a small black car and a striped knitted hat, all sit as dark dots on the right side. A shaded band between the two groups is labeled "the gap", and a note says only the dot's position is data and the rows are spread out so the labels fit. On the right, four measured averages over the same ten vectors are shown as bars: between two images 0.657, between two captions 0.655, image to its own caption 0.295 highlighted in terracotta, and any image to any caption 0.229. A note says two images look far more alike to CLIP than an image and its own caption do. The caption reads: this is why a raw image-caption score never reaches 1, and why 0.3 is a good match rather than a weak one.
The two encoders were never trained to put an image on top of its caption. They were trained to make the right pair score higher than the wrong ones, and that is a weaker requirement.

Two images average 0.657 with each other and two captions average 0.655, while an image and its own caption average 0.295. The image vectors and the text vectors occupy separate regions, and every cross-modal score you ever read is a comparison across that divide. Liang et al. (2022) named this the modality gap and traced it to how these models are initialized and trained, showing that the two modalities end up "embedded at arm's length in their shared representation".

Keep reading

The rest of this article is free with an account

Create a free account to read the remaining 6 sections. It takes about twenty seconds and there's nothing to pay. The same account opens the slide decks and CV reviews.

  1. 02It shows up wherever text and images have to meet
  2. 03Training pulls matching pairs together and pushes the rest apart
  3. 04The versions you'll see, as of September 2026
  4. 05Pick CLIP when words have to meet images, and a neighbor when they don't
  5. 06How to try it
  6. and 1 more