Multimodal Embedding & Reranker Models with Sentence Transformers
Sentence Transformers is a Python library for using and training embedding and reranker models for applications like retrieval augmented generation, semantic search, and more. With the v5.4 update, you can now encode and compare texts, images, audio, and videos using the same familiar API. In this blogpost, I'll show you how to use these new multimodal capabilities for both embedding and reranking.
Multimodal embedding models map inputs from different modalities into a shared embedding space, while multimodal reranker models score the relevance of mixed-modality pairs. This opens up use cases like visual document retrieval, cross-modal search, and multimodal RAG pipelines.
If you want to train your own multimodal models, check out the companion blogpost: Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers.
Table of Contents#
- What are Multimodal Models?
- Installation
- Multimodal Embedding Models
- Multimodal Reranker Models
- Retrieve and Rerank
- Input Formats and Configuration
- Supported Models
- Additional Resources
What are Multimodal Models?#
Traditional embedding models convert text into fixed-size vectors. Multimodal embedding models extend this by mapping inputs from different modalities (text, images, audio, or video) into a shared embedding space. This means you can compare a text query against image documents (or vice versa) using the same similarity functions you're already familiar with.
Similarly, traditional reranker (Cross Encoder) models compute relevance scores between pairs of texts. Multimodal rerankers can score pairs where one or both elements are images, combined text-image documents, or other modalities.
For example, you can compare a text query against image documents, find video clips matching a description, or build RAG pipelines that work across modalities.
Installation#
Multimodal models require some extra dependencies. Install the extras for the modalities you need (see Installation for more details):
# For image support
# For audio support
# For video support
# Mix and match as needed
VLM-based models like Qwen3-VL-2B require a GPU with at least ~8 GB of VRAM. For the 8B variants, expect ~20 GB. If you don't have a local GPU, consider using a cloud GPU service or Google Colab. On CPU, these models will be extremely slow; text-only or CLIP models are better suited for CPU inference.
Multimodal Embedding Models#
Loading a Model#
Loading a multimodal embedding model works exactly like loading a text-only model:
=
Some models might require a
revisionargument for now if the integration pull requests for the model is still pending. Once they're merged, you'll be able to load them without specifying a revision, like above.
The model automatically detects which modalities it supports, so there's nothing extra to configure. See Processor and Model kwargs if you want to control things like image resolution or model precision.
Encoding Images#
With a multimodal model loaded, model.encode() accepts images alongside text. Images can be provided as URLs, local file paths, or PIL Image objects (see Supported Input Types for all accepted formats):
=
# Encode images from URLs
=
# (2, 2048)
Cross-Modal Similarity#
You can compute similarities between text embeddings and image embeddings, since the model maps both into the same space:
=
# Encode images
=
# Encode text queries (one matching + one hard negative per image)
=
# Compute cross-modal similarities
=
# tensor([[0.5115, 0.1078],
# [0.1999, 0.1108],
# [0.1255, 0.6749],
# [0.1283, 0.2704]])
As expected, "A green car parked in front of a yellow building" is most similar to the car image (0.51), and "A bee on a pink flower" is most similar to the bee image (0.67). The hard negatives ("A red car driving on a highway", "A wasp on a wooden table") correctly receive lower scores.
You might notice that even the best matching scores (0.51, 0.67) aren't very close to 1.0. This is due to the modality gap: embeddings from different modalities tend to cluster in separate regions of the space. Cross-modal similarities are typically lower than within-modal ones (e.g., text-to-text), but the relative ordering is preserved, so retrieval still works well.
Encoding Queries and Documents#
For retrieval tasks, encode_query() and encode_document() are the recommended methods. Many retrieval models prepend different instruction prompts depending on whether the input is a query or a document, similar to how chat models might apply different system prompts depending on the goal. Model authors can specify their prompts in the model config, and encode_query() / encode_document() automatically load and apply the correct one:
encode_query()uses the model's"query"prompt (if available) and setstask="query".encode_document()uses the first available prompt from"document","passage", or"corpus", and setstask="document".
Under the hood, both are thin wrappers around encode(), they just handle prompt selection for you. Here's what cross-modal retrieval looks like:
=
# Encode text queries with the query prompt
=
# Encode document screenshots with the document prompt
=
# Compute similarities
=
# tensor([[0.3907, 0.1490],
# [0.1235, 0.4872]])
These methods accept the same input types as encode() (images, URLs, multimodal dicts, etc.) and pass through the same parameters. For models without specialized query/document prompts, they behave identically to encode().
Multimodal Reranker Models#
Multimodal reranker (CrossEncoder) models score the relevance between pairs of inputs, where each element can be text, an image, audio, video, or a combination. They tend to outperform embedding models in terms of quality, but are slower since they process each pair individually. The currently available pretrained multimodal rerankers focus on text and image inputs, but the architecture supports any modality that the underlying model can handle.
Ranking Mixed-Modality Documents#
The rank() method scores and ranks a list of documents against a query, supporting mixed modalities:
=
=
=
=
"""
0.9375 (document 0)
0.5000 (document 3)
-1.2500 (document 2)
-2.4375 (document 1)
"""
The reranker correctly identifies the car image (document 0) as the most relevant result, followed by the combined text+image document about a car in a European city (document 3). The bee image (document 1) scores lowest. Keep in mind that the modality gap can influence absolute scores: text-image pair scores may occupy a different range than text-text or image-image pair scores.
You can also check which modalities a reranker supports using modalities and supports(), just like with embedding models:
# ['text', 'image', 'video', 'message']
# True
# Check if the model supports a specific pair of modalities
# True
Predicting Pair Scores#
You can also use predict() to get raw relevance scores for specific pairs of inputs:
=
=
# [0.9389156 0.96922314 0.46063158]
Retrieve and Rerank#
A common pattern is to use an embedding model for fast initial retrieval, then refine the top results with a reranker:
# Step 1: Retrieve with an embedding model
=
=
=
# Pre-compute corpus embeddings (do this once, then store them)
=
=
# Simple cosine similarity retrieval, viable as long as embeddings fit in memory
=
=
# Step 2: Rerank the top-k results with a reranker model
=
=
=
Since the corpus embeddings are pre-computed, the initial retrieval is fast even over millions of documents. The reranker then provides more accurate scoring over the smaller candidate set.
Input Formats and Configuration#
Supported Input Types#
Multimodal models accept a variety of input formats. Here's a summary of what you can pass to model.encode():
| Modality | Accepted Formats |
|---|---|
| Text | - Strings |
| Image | - PIL.Image.Image objects - File paths (e.g. "./photo.jpg") - URLs (e.g. "https://.../image.jpg") - Numpy arrays, torch tensors |
| Audio | - File paths (e.g. "./audio.wav") - URLs (e.g. "https://.../audio.wav") - Numpy/torch arrays - Dicts with "array" and "sampling_rate" keys - torchcodec.AudioDecoder instances |
| Video | - File paths (e.g. "./video.mp4") - URLs (e.g. "https://.../video.mp4") - Numpy/torch arrays - Dicts with "array" and "video_metadata" keys - torchcodec.VideoDecoder instances |
| Multimodal | - Dicts mapping modality names to values, e.g. {"text": "a caption", "image": "https://.../image.jpg"} Valid keys: "text", "image", "audio", "video" |
| Message | - List of message dicts with "role" and "content" keys, e.g. [{"role": "user", "content": [...]}] |
Checking Modality Support#
You can check which modalities a model supports using the modalities property and supports() method:
=
# List all supported modalities
# ['text', 'image', 'video', 'message']
# Check for a specific modality
# True
# False
The "message" modality indicates that the model accepts chat-style message inputs with interleaved content. In practice, you rarely need to use this directly. When you pass strings, URLs, or multimodal dicts, the model converts them to the appropriate message format internally. Sentence Transformers supports two message formats:
- Structured (most VLMs, e.g. Qwen3-VL): Content is a list of typed dicts, e.g.
[{"type": "text", "text": "..."}, {"type": "image", "image": ...}] - Flat (e.g. Deepseek-V3): Content is a direct value, e.g.
"some text"
The format is auto-detected from the model's chat template.
Since all inputs get converted into the same message format internally, you can mix input types in a single encode() call:
=
Click here if you need to pass raw message inputs
If a model doesn't follow either format and you need full control, you can pass raw message dicts with role and content keys directly:
=
This bypasses the automatic format conversion and passes the messages directly to the processor's apply_chat_template().
Processor and Model kwargs#
You may want to control image resolution bounds or model precision. Use processor_kwargs and model_kwargs when loading the model:
=
processor_kwargscontrols how inputs are preprocessed (e.g., image resolution bounds). Highermax_pixelsmeans higher quality but more memory and compute. These are passed directly toAutoProcessor.from_pretrained(...).model_kwargscontrols how the underlying model is loaded (e.g., precision, attention implementation). These are passed directly to the appropriateAutoModel.from_pretrained(...)call (e.g.,AutoModel,AutoModelForCausalLM,AutoModelForSequenceClassification, etc., depending on the configuration of the model modules).
See the SentenceTransformer API Reference documentation for more details on these kwargs.
In Sentence Transformers v5.4,
tokenizer_kwargshas been renamed toprocessor_kwargsto reflect that multimodal models use processors rather than just tokenizers. The old name is still accepted but deprecated.
Supported Models#
Here are the multimodal models supported in v5.4, also available in the v5.4 integrations collection:
Supported Multimodal Embedding Models#
| Model | Parameters | Modalities | Revision |
|---|---|---|---|
| Qwen/Qwen3-VL-Embedding-2B | 2B | Text, Image, Video | No revision needed |
| Qwen/Qwen3-VL-Embedding-8B | 8B | Text, Image, Video | No revision needed |
| nvidia/llama-nemotron-embed-vl-1b-v2 | 1.7B | Text, Image | No revision needed |
| nvidia/omni-embed-nemotron-3b | 4.7B | Text, Image | No revision needed |
| LCO-Embedding/LCO-Embedding-Omni-3B | 5B | Text, Image, Audio, Video | No revision needed |
| LCO-Embedding/LCO-Embedding-Omni-7B | 9B | Text, Image, Audio, Video | No revision needed |
| BidirLM/BidirLM-Omni-2.5B-Embedding | 2.5B | Text, Image, Audio | No revision needed |
| BAAI/BGE-VL-base | 0.1B | Text, Image | No revision needed |
| BAAI/BGE-VL-large | 0.4B | Text, Image | No revision needed |
| BAAI/BGE-VL-MLLM-S1 | 8B | Text, Image | No revision needed |
| BAAI/BGE-VL-MLLM-S2 | 8B | Text, Image | No revision needed |
| BAAI/BGE-VL-v1.5-zs | 8B | Text, Image | No revision needed |
| BAAI/BGE-VL-v1.5-mmeb | 8B | Text, Image | No revision needed |
| BAAI/BGE-VL-Screenshot | 4B | Text, Image | No revision needed |
| royokong/e5-v | 8B | Text, Image | No revision needed |
| eagerworks/eager-embed-v1 | 4B | Text, Image | revision="refs/pr/2" |
| nomic-ai/nomic-embed-multimodal-3b | 5B | Text, Image | revision="refs/pr/4" |
| nomic-ai/nomic-embed-multimodal-7b | 9B | Text, Image | revision="refs/pr/3" |
| Haon-Chen/e5-omni-3B | 5B | Text, Image, Audio, Video | revision="refs/pr/2" |
| Haon-Chen/e5-omni-7B | 9B | Text, Image, Audio, Video | revision="refs/pr/1" |
Supported Multimodal Reranker Models#
| Model | Parameters | Modalities | Revision |
|---|---|---|---|
| Qwen/Qwen3-VL-Reranker-2B | 2B | Text, Image, Video | No revision needed |
| Qwen/Qwen3-VL-Reranker-8B | 8B | Text, Image, Video | No revision needed |
| nvidia/llama-nemotron-rerank-vl-1b-v2 | 2B | Text, Image | No revision needed |
| jinaai/jina-reranker-m0 | 2B | Text, Image | No revision needed |
Text-Only Reranker Models (also new in v5.4)#
| Model | Parameters | Revision |
|---|---|---|
| Qwen/Qwen3-Reranker-0.6B | 0.6B | No revision needed |
| Qwen/Qwen3-Reranker-4B | 4B | No revision needed |
| Qwen/Qwen3-Reranker-8B | 8B | No revision needed |
| mixedbread-ai/mxbai-rerank-base-v2 | 0.5B | No revision needed |
| mixedbread-ai/mxbai-rerank-large-v2 | 2B | No revision needed |
| ContextualAI/ctxl-rerank-v2-instruct-multilingual-1b | 1B | revision="refs/pr/2" |
| ContextualAI/ctxl-rerank-v2-instruct-multilingual-2b | 3B | revision="refs/pr/1" |
| ContextualAI/ctxl-rerank-v2-instruct-multilingual-6b | 7B | revision="refs/pr/1" |
Click here for a text-only reranker usage example
=
=
=
=
=
# [ 7.3077507 -2.6217823 8.724761 -2.2488995]
=
# 8.7248 To bake sourdough, mix your starter with flour, water, and salt, then let it rise overnight.
# 7.3078 Sourdough bread requires a starter made from flour and water, fermented over several days.
# -2.2489 Rye bread is a popular alternative to wheat-based breads in Northern Europe.
# -2.6218 The history of bread dates back to ancient Egypt around 8000 BCE.
CLIP Models#
The older CLIP models continue to be supported:
| Model | ImageNet Zero-Shot Top-1 Accuracy | Notes |
|---|---|---|
| sentence-transformers/clip-ViT-L-14 | 75.4 | |
| sentence-transformers/clip-ViT-B-16 | 68.1 | |
| sentence-transformers/clip-ViT-B-32 | 63.3 | |
| sentence-transformers/clip-ViT-B-32-multilingual-v1 | N/A | Multilingual text encoder, 50+ languages |
These simple CLIP models still work well on lower-resource hardware.
Click here for a CLIP usage example
=
=
=
=
=
# (3, 768) (4, 768)
=
# tensor([[0.2208, 0.1042, 0.0617, 0.0907], First image (car) is most similar to "A green car"
# [0.1205, 0.2303, 0.0632, 0.0917], Second image (bee) is most similar to "A bee on a flower"
# [0.1107, 0.0196, 0.2425, 0.1162]]) Third image (multiple cats) is most similar to "Some cats on a couch"
Additional Resources#
Documentation#
- Sentence Transformer > Usage
- Sentence Transformer > Pretrained Models
- Cross Encoder > Usage
- Cross Encoder > Pretrained Models
- Installation
Training#
To learn how to finetune these multimodal models on your own data, see the companion blogpost: Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers.
- Sentence Transformer > Training Overview
- Sentence Transformer > Training Examples
- Cross Encoder > Training Overview
- Cross Encoder > Training Examples
- Sparse Encoder > Training Overview
- Sparse Encoder > Training Examples
Hugging Face Hub#
- Sentence Transformers models on the Hub
- Sentence Transformers datasets on the Hub
- v5.4 Integrations Collection
Companion Blogposts#
The training companion to this post and adjacent Sentence Transformers guides:
- Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers: the direct training companion to this post, with a Visual Document Retrieval walkthrough.
- Training and Finetuning Embedding Models with Sentence Transformers: the general training guide for text-only bi-encoder embedding models.
- Training and Finetuning Reranker Models with Sentence Transformers: Cross Encoder (reranker) training, applicable to text-only and multimodal rerankers.
- Training and Finetuning Sparse Embedding Models with Sentence Transformers: SPLADE training for sparse retrieval.
- 🪆 Introduction to Matryoshka Embedding Models: variable-size embeddings; also applied to multimodal models in the training companion post.
- Train 400x faster Static Embedding Models with Sentence Transformers: CPU-friendly text embedding models.
- Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval: post-training compression of embedding vectors.