Cross-Modal Embeddings (CLIP)

📌 The Language Barrier

In our earlier lessons, we learned how to turn text into mathematical coordinates (Text Embeddings). AI scientists have also known how to turn images into mathematical coordinates (Image Embeddings) for a long time.

Diagram showing text vectors living in a blue universe and image vectors living in a red universe, completely unable to communicate

But historically, there was a massive language barrier. The Text Vector space and the Image Vector space were completely separate universes. The computer had no idea that the text coordinates for the word "Dog" were supposed to be related to the image coordinates of a picture of a dog.

📌 OpenAI's CLIP (Contrastive Learning)

In 2021, OpenAI solved this problem by inventing CLIP (Contrastive Language-Image Pre-training). They forced both the text and the images to live in the exact same mathematical space!

They achieved this by downloading 400 million images from the internet, along with the text captions attached to those images. They used a mathematical trick called Contrastive Learning:

Diagram showing the math pulling the picture of a dog and the text "happy dog" together, while pushing the text "fast car" away
Diagram showing the math pulling the picture of a dog and the text "happy dog" together, while pushing the text "fast car" away
  • They fed the AI a picture of a dog and the correct text caption: "A happy dog." The algorithm mathematically pulled those two vectors closer together in space.
  • Then, they took the same picture of the dog and paired it with a random, incorrect caption: "A fast car." The algorithm mathematically pushed those two vectors far apart.

By doing this 400 million times, the AI built a unified Cross-Modal vector space where images and text describing the exact same concept share the exact same coordinates.

📌 Why CLIP Changed the World

Because text and images now share a coordinate system, you can do incredible things without any extra coding:

  • Zero-Shot Image Search: You can type the text "A red car". The system converts your text into a coordinate, looks at that exact spot in the vector space, and simply returns the images sitting closest to it!
  • Image Generation (Midjourney/DALL-E): When you type a prompt into an image generator, the AI converts your text into a CLIP coordinate. It then reverse-engineers random pixels until the resulting image perfectly matches that coordinate location.