CLIP: Teaching AI to See with Words
CLIP creates a shared map for images and text, letting you classify images with natural language prompts. It's used for zero-shot classification and semantic search, bypassing the need for task-specific labeled data.
Why it exists
Traditional computer vision models required massive, hand-labeled datasets for each specific task (e.g., ImageNet for 1000 object classes). This process is expensive, slow, and doesn't scale to the variety of visual concepts in the real world. CLIP was designed to learn from the vast, noisy (image, text) pairs already available on the internet, creating a more general and flexible vision model.
The mental model
Think of CLIP as a universal translator between pixels and words. It builds a shared multi-dimensional map, or 'embedding space', where the vector representation for a picture of a dog is mathematically close to the vector for the text phrase "a photo of a dog". This allows you to 'query' images using natural language.
How it works
CLIP uses two encoders: an image encoder (e.g., a Vision Transformer) and a text encoder (a standard Transformer). It's trained on hundreds of millions of (image, text) pairs from the web. For each pair, it encodes both the image and the text into vectors. The training goal is to maximize the similarity (using cosine similarity) of vectors from correct pairs and minimize the similarity of vectors from incorrect pairs. This is the 'contrastive' part of its name. At inference time, you can give it one image and multiple text descriptions; the model calculates which text vector is closest to the image vector to find the best match.
When to use it
CLIP excels at zero-shot image classification. You can define new categories on the fly simply by writing a text prompt (e.g., "a photo of a [new object]") without any retraining. This makes it powerful for general-purpose content moderation, open-vocabulary object detection, and semantic image search (finding images that match a descriptive sentence).
When not to use it
CLIP is not a specialist. It performs poorly on tasks requiring fine-grained detail, like counting objects in an image or reading text within an image. For highly specialized tasks (e.g., medical image analysis), a model fine-tuned on a specific dataset will almost always outperform CLIP's generalist, zero-shot approach.
One canonical example
To classify a picture of a cat, you don't use a pre-trained 'cat' classifier. Instead, you encode the image and a list of text prompts like ["a photo of a dog", "a photo of a cat", "a photo of a bird"]. CLIP calculates the similarity between the image embedding and each text embedding. The prompt with the highest similarity score (in this case, "a photo of a cat") is the predicted label.
Interview question
How does CLIP classify an image into a category it wasn't explicitly trained on?
- a.It compares the image's embedding to the embeddings of various descriptive text prompts.Correct
- b.It uses a separate, specialized model for each new, unseen classification task.
- c.It extracts keywords directly from the image pixels and matches them to category names.
- d.It dynamically retrains its image encoder with a small set of new labels.
Why? this is the answer
CLIP performs zero-shot classification by encoding both the image and natural language prompts into a shared embedding space, then identifying which text embedding is most similar to the image embedding. It does not require retraining for new categories.
Just read this? Test yourself on what you have been reading.
Read the original → github.com
- #computer vision
- #multi-modal
- #zero-shot learning
- #ai
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on computer vision — each one lists the topics its interview covers.
See open roles