Multimodal Embedding Models
Multimodal data is data in more than one form, and it can be retrieved either through metadata such as titles, tags, and captions, or through its content.
A Photo Collection and a Sentence
Suppose you have a large collection of photographs, and you want to find the ones that match a sentence you type, such as a request for a picture of a dog on a beach. The photographs are one kind of data and the sentence is another. Data that comes in more than one form, such as images and text, is called multimodal data. Retrieving it means finding the items in a collection that are relevant to a query, even when the query and the items are in different forms.
The central question is how a system decides that a photograph and a sentence belong together. There are two broad answers. The first relies on the words that already describe the image. The second relies on the visual content of the image itself. This article takes these two answers in turn, and then shows how a single model makes the second answer work for text queries.
What do you think happens?
Suppose a system can only read the words attached to each photo. One photo has a caption about a dog on a beach and another photo has no caption at all. Which photo can the system find for the query a dog on a beach?
Reveal answer
Only the captioned photo.
A system that works only with the text describing an image never examines the image. If there is no caption, there is no text for the system to judge against the query, so that photo cannot be retrieved this way.
Metadata Versus Content
The first route uses metadata. Metadata is information attached to an item that describes it. For images, the common forms are titles, tags, and captions. If an image carries a caption, the system can retrieve the image whenever that caption is judged relevant to the query. The image itself is never examined. The system works only with the text that describes it, so this route is essentially a text-matching problem applied to the descriptions.
The second route uses the content of the image. If you want to retrieve images based on what they actually show, you need a way to compare images to queries. When the queries are text, that comparison requires a multimodal embedding model, one that can generate embeddings for both images and texts. An embedding is a representation of an item as a set of numbers. A model that produces embeddings for both kinds of data places images and sentences in a form that can be compared directly.
| Question | Metadata route | Content route |
|---|---|---|
| What is examined? | Titles, tags, and captions | The image or content itself |
| What is needed for a match? | Relevant descriptive text | Embeddings for both images and texts |
| What fails if the item has no description? | The item cannot be judged | The item can still be represented from its content |
Two ways a system can decide that a photograph and a query belong together
Why Images and Sentences Need a Shared Space
Think about what a comparison without a translator would require. A sentence can be compared to another sentence, and a picture can be compared to another picture. But a sentence and a picture have no shared form unless something translates between them. A multimodal embedding model acts as that translator. It turns an image into an embedding and a text into an embedding, and both embeddings live in a form the system can compare against each other.
The source uses CLIP, described by Radford and colleagues in 2021, as its example of such a model. The defining property of CLIP, as the source describes it, is that it can generate embeddings for both images and texts. That is why the retriever is built around it. Once every item and every query is represented by CLIP embeddings, the retrieval problem becomes a problem of comparing embeddings.
Three Steps of the CLIP Retriever
The retriever has three steps. The first step happens once, before any queries arrive: generate CLIP embeddings for all of your data, both texts and images, and store them in a vector database. A vector database is a database designed to store and query embeddings. The second step happens each time a query arrives: generate the CLIP embedding of that query. The third step is the search: query the vector database for all images and texts whose embeddings are close to the query embedding.
The diagram shows the retriever as two phases that meet at the vector database. The indexing phase fills the database. The query phase reads from it. Notice that the query is embedded with the same kind of model used for the collection. That shared model is what allows the query embedding to be compared with the stored embeddings of images and texts.
Tracing the Dog-on-a-Beach Collection
Indexing three items and answering one query
The collection holds three items: a photograph with the caption about a dog on a beach, a second photograph with no caption, and a short text note that reads a dog runs along the sand. A user then types the query a dog on a beach. Trace what the retriever does with each item and then with the query.
- 1Index the captioned photograph
CLIP generates an embedding of the photograph itself, and that embedding is stored in the vector database. The caption is not needed for this step because CLIP represents the image's content.
- 2Index the uncaptioned photograph
CLIP still generates an embedding from the image content, so this photograph is stored too. A metadata-only system would have nothing to judge for this item.
- 3Index the text note
CLIP generates an embedding of the sentence, which is stored in the same database as the image embeddings. Now the database holds embeddings for both kinds of data.
- 4Embed the query
When the query a dog on a beach arrives, CLIP generates its embedding using the same model that produced the stored embeddings.
- 5Search for close embeddings
The vector database is searched for the stored embeddings closest to the query embedding. Because the embeddings share one space, the query can be compared directly with photographs and with the text note.
The retriever returns the stored items whose embeddings are close to the query embedding. The uncaptioned photograph can be returned because its match depends on its visual content, not on any caption.
What Changes When a Query Arrives
After indexing, the vector database holds one embedding for each item in the collection. Nothing about the query exists yet. When a query arrives, the database itself does not change. What changes is that a new embedding, the query embedding, is produced and used for comparison. The search then returns the stored items whose embeddings are close to it.
Mistakes Beginners Make
Common mistake Assuming the metadata route looks inside the image
What it looks likeA captionless photograph is expected to appear for the query a dog on a beach because it clearly shows a dog.
Why it failsThe metadata route works only with the text attached to an item. It never examines the image, so with no caption there is nothing for it to judge.
Do this insteadUse the content route, with a multimodal embedding model, when the match depends on what the image shows.
Common mistake Embedding the collection and the query with different models
What it looks likePhotographs are embedded with CLIP, while the query is embedded with a text-only model.
Why it failsThe embeddings must be comparable directly. The same model must embed both the collection and the query.
Do this insteadEmbed every item and every incoming query with the same multimodal model, such as CLIP.
Common mistake Believing the query is stored in the database during indexing
What it looks likeA learner expects the database to already contain the dog-on-a-beach query before any user types it.
Why it failsIndexing happens once, before queries arrive. The query embedding is generated only when the query arrives.
Do this insteadAfter indexing, the database holds the item embeddings. Each query adds a new embedding for comparison at search time.
Common mistake Treating a sentence and a picture as comparable without a translating model
Predicting a Mismatched Setup
A colleague embeds every photograph in a collection with CLIP and stores the results in a vector database. For queries, the colleague uses a different text-only embedding model. Explain what goes wrong when a query arrives, and describe the change that fixes it.
Hints
- Think about what the search step requires: it compares the query embedding with the stored embeddings.
- Recall why the same model must embed both the collection and the query.
- The fix involves which model is used for the query, not the database.
Key Takeaways
- Metadata retrieval matches a query against titles, tags, and captions, and never examines the image itself.
- Content retrieval of images for text queries needs a multimodal embedding model such as CLIP, which generates embeddings for both images and texts in a form that can be compared directly.
- The CLIP-based retriever embeds and stores all data in a vector database, embeds each incoming query with the same model, and searches for embeddings close to the query embedding.
- After indexing, the vector database holds the embeddings of the collection; when a query arrives, its embedding is produced and compared against those stored embeddings.