Multimodal Sentence Embeddings

Machine Learning
Introduced by
Frome et al. (DeViSE, 2013); popularized by Radford et al. (CLIP, 2021)
Year
2013–2021
Type
Representation learning model
Family
Deep learning / NLP / CV

What does it do?

Multimodal sentence embeddings place text and images (and, in some models, audio or other signals) in one shared vector space, so that matching items from different modalities end up close together.

In this name, 'sentence' refers to the text side: captions and queries are encoded as sentence-level vectors in the same space as images. Models such as CLIP learn this space from large collections of paired image-text data with a contrastive objective. The resulting vectors support cross-modal retrieval and zero-shot classification without task-specific training.

The intuition behind the method

Think of a shared address book in which a sentence and a picture that describe the same thing receive nearly the same address. A language encoder maps sentences to vectors, a vision encoder maps images to vectors, and a contrastive objective pulls matched image-caption pairs together while pushing mismatched pairs apart. After training, a photo of a dog can lie close to the phrase 'a dog on a beach', even if that exact pair never appeared in training. This is what makes it possible to search images with text, or to classify images by comparing them with class-name phrases.

History

Deep visual-semantic embeddings were introduced with DeViSE (Frome et al., 2013), which mapped image features into a word-embedding space. Later work refined the training objective for image-sentence retrieval. CLIP (Radford et al., 2021) showed that contrastive training on 400 million web-crawled image-text pairs yields general visual representations with strong zero-shot transfer. Subsequent work has extended the approach to larger datasets and to additional modalities.

When to use it

Choose these models when the task relates text to images: retrieving images from a text query or captions from an image, classifying images against a label set written in natural language without labelled training data for those labels, or supplying frozen visual-language features when labelled data for a downstream task is scarce. They are a poor choice when every input comes from one modality, because unimodal encoders are simpler and usually adequate. Avoid them when compute cannot support the large pretrained encoders at the required throughput, or when the target domain, such as specialised scientific or clinical imagery, differs strongly from web-scale pretraining data; in that case fine-tuning on domain-specific paired data is needed before the results can be trusted. For pure text similarity, a dedicated sentence-embedding model is usually the better choice.

Limitations and considerations

  • Pretraining depends on very large paired corpora (the best results rely on hundreds of millions of image-text pairs), which are costly to collect and clean.
  • Large encoders such as ViT-L and GPT-style text models need substantial GPU memory and add inference latency, which limits batch sizes and real-time use.
  • Coverage is uneven: domains underrepresented in web-scale pretraining are handled less reliably, and performance drops accordingly.
  • The contrastive objective relies on in-batch negatives, so results depend on how batches are built and how negatives are sampled.
  • Alignment is learned from how images and captions co-occur, so the space can encode surface correlations, such as objects that are often named together, rather than fine-grained grounding of phrases in image regions.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Because the shared space is learned from paired image-text data, a text query can be scored against images for which no task-specific labels were ever collected, which is what makes zero-shot retrieval and classification possible.
  • Once images and text are embedded, retrieval reduces to nearest-neighbour search in one vector space, so the same index can answer both image-to-text and text-to-image queries.
  • Frozen embeddings can be reused as features for linear probes on several downstream tasks without retraining the encoders.
  • Queries can be free-form sentences of any phrasing, because the text encoder is a language model rather than a fixed set of label strings.

Applications

  • Cross-modal image-text retrieval in search engines and digital asset management systems.
  • Zero-shot image classification by comparing image embeddings to text class name embeddings.
  • Visual question answering as a retrieval stage feeding downstream reasoning modules.
  • Multimodal content recommendation combining textual descriptions and visual thumbnails.
  • Medical image report retrieval linking radiology images to diagnostic text.
  • E-commerce product search from natural language queries matched against product images.

How it works

How it works

1

Each modality is processed by its own encoder. Text is usually handled by a Transformer language model (for example, a BERT variant or a GPT-style encoder) that produces a dense sentence-level vector. Images are handled by a vision encoder, typically a Transformer-based or convolutional network, that produces an image vector. Audio or video streams can be passed to additional specialised encoders when a model covers those modalities.

2

Each encoder output is mapped by a learned linear or MLP projection head into a common embedding space. The output size of these projections is a design choice shared across modalities. After projection, all modalities share one metric space in which cosine similarity or dot product measures semantic closeness.

Formula
\mathbf{z}_v = W_v \cdot f_v(x_v), \quad \mathbf{z}_t = W_t \cdot f_t(x_t)
3

The model is trained on mini-batches of matched image-caption pairs with a contrastive loss (InfoNCE, the same family as NT-Xent). For each image in the batch, its own caption is the positive example and the other captions in the batch are negatives. The formula in the mechanics section is written from the image side, summing over captions j for each image i. In the formula, sim(u, v) denotes cosine similarity, u·v / (‖u‖‖v‖), which is the dot product of L2-normalised embeddings. Many implementations, including the CLIP setup, also apply the same term from the text side and average the two, which makes the loss symmetric. The temperature parameter τ sets how sharply the similarity scores are weighted: matched pairs are pushed to be more similar than mismatched pairs in the batch.

Formula
\mathcal{L} = -\frac{1}{N}\sum_{i=1}^{N}\log\frac{\exp(\text{sim}(\mathbf{z}_v^i,\mathbf{z}_t^i)/\tau)}{\sum_{j=1}^{N}\exp(\text{sim}(\mathbf{z}_v^i,\mathbf{z}_t^j)/\tau)}
4

At inference time the trained encoders and projections are frozen. A query from one modality is embedded and compared with a gallery from another modality using nearest-neighbour search, exact or approximate. For zero-shot classification, each candidate class name is wrapped in a short text prompt and embedded, and an image is assigned to the class whose text embedding is most similar. For downstream tasks, the embeddings can serve as fixed features for a linear probe or as the starting point for fine-tuning.

Common pitfalls

  • Using a general-purpose pretrained model without fine-tuning on domain-specific paired data, causing poor recall in specialised corpora.
  • Ignoring the temperature hyperparameter τ in the contrastive loss, which strongly affects training stability and embedding quality.
  • Evaluating only on seen query-gallery combinations rather than on genuinely held-out pairs, inflating retrieval metrics.
  • Treating cosine similarity as a calibrated probability without additional calibration, leading to overconfident zero-shot classification.
  • Neglecting to normalise embeddings to unit length before computing cosine similarity, causing incorrect distance rankings.

Frequently asked questions

Do I need to train from scratch or can I use a pretrained model?

For most applications, using a publicly available pretrained contrastive model such as CLIP and fine-tuning on your domain data is far more practical and effective than training from scratch, which requires hundreds of millions of paired samples.

How do I evaluate retrieval quality?

Standard metrics are Recall@K (the fraction of queries whose true match appears in the top K retrieved items, typically K=1, 5, 10) and median rank. Evaluate on a genuinely held-out test split of paired data that was not seen during training or validation.

What is the role of the contrastive temperature τ?

Temperature τ scales the logits before the softmax in the InfoNCE loss. A lower τ sharpens the distribution and encourages the model to push negatives more aggressively apart; too low causes training instability. CLIP uses a learned log-temperature initialized near 0.07.

Can multimodal embeddings handle more than two modalities?

Yes. Some models extend the contrastive alignment framework beyond image and text, for example to audio. Each additional modality requires paired training data with an anchor modality.

Are these embeddings suitable for semantic textual similarity tasks without images?

The text encoder from a multimodal model can be used for pure text tasks, but dedicated sentence-embedding models are usually the better choice for pure text similarity, since the multimodal text encoder is trained mainly to align captions with images.

Related methods

Sources

  1. Radford, A., Kim, J. W., Hallacy, C., Ramesh, A., Goh, G., Agarwal, S., ... & Sutskever, I. (2021). Learning transferable visual models from natural language supervision. In Proceedings of the 38th International Conference on Machine Learning (ICML), pp. 8748–8763. PMLR.

    Open publication reference
  2. Frome, A., Corrado, G. S., Shlens, J., Bengio, S., Dean, J., Ranzato, M., & Mikolov, T. (2013). DeViSE: A deep visual-semantic embedding model. In Advances in Neural Information Processing Systems (NeurIPS), Vol. 26.

    Open publication reference