brevitech's picture
Unmodified mirror of mistralai/Mistral-Multimodal-Embed-1B@bfdaf7bd6fd6
08d2a21 verified
|
Raw History Blame Contribute Delete
16.9 kB
---
license: apache-2.0
library_name: transformers
pipeline_tag: feature-extraction
tags:
- brevitech
- mirror
- video-text-retrieval
- text-to-video-retrieval
- image-text-retrieval
- zero-shot-classification
- contrastive
- embeddings
- multilingual
- custom_code
- sentence-transformers
---
# Mistral Multimodal Embed (Clipstral) β€” Brevitech Unmodified Mirror
> **Unmodified Mirror Notice:** Hosted by **Brevitech** (`brevitech`) as an unmodified mirror of [**`mistralai/Mistral-Multimodal-Embed-1B`**](https://huggingface.co/mistralai/Mistral-Multimodal-Embed-1B) by **Mistral AI** under the **Apache License 2.0**. Brevitech did not train or modify this model; original weights, custom modeling/processor code, model card, and `LICENSE` are preserved verbatim.
**Upstream repository:** `mistralai/Mistral-Multimodal-Embed-1B` (`bfdaf7bd6fd65a1c3c5cbb3cecf884ce153751ff`)
πŸ“„ [Paper](https://arxiv.org/abs/2611.40240) |
πŸ“ [Blog post](https://mistral.ai/news/mistral-multimodal-embed) |
πŸ’» [GitHub](https://github.com/mistralai/mistral-multimodal-embed)
<p align="center">
<img src="https://cdn-uploads.huggingface.co/production/uploads/69b0227fc166b6aed8902115/yO7LgHa-aUUQ0-tXS4LQh.png" alt="Clipstral maps multilingual text, images and videos into one shared embedding space, used for retrieval, zero-shot classification and deduplication" width="800">
</p>
Mistral Multimodal Embed (codename Clipstral) is a 1.24B-parameter
open-weight dual encoder that embeds **images, videos and multilingual text**
into one shared 1,024-dimensional space. Matching text and visuals lie close together, so the same
embeddings serve text-to-image and text-to-video search (and the reverse),
visual search with an image or video as the query,
zero-shot image and video classification,
and dataset curation such as deduplication and filtering of mismatched pairs.
- **Native resolution and aspect ratio.**
The vision transformer processes each image at its native size and aspect ratio, and
accuracy stays stable from 224 to 1036 px.
- **Video.**
A lightweight spatio-temporal encoder attends jointly to the patch tokens of all frames
(16 frames per clip in training and evaluation).
- **Long, multilingual text.**
The text tower has a 131k-entry multilingual tokenizer and no fixed context limit.
- **Compact and fast.**
1.24B parameters in total. Videos add only a 4-layer encoder on top of the per-frame vision transformer,
so large image and video collections can be indexed on a single NVIDIA H100.
This repository is a self-contained package: the weights, tokenizer, image processor and all custom
inference code are included.
The [GitHub repository](https://github.com/mistralai/mistral-multimodal-embed) adds a Gradio demo, an example notebook and the example media used below.
## Results
We compared Clipstral with 13 open-weight encoders up to 4B parameters, plus Qwen3-VL-Embedding-8B as a
larger reference, under one zero-shot protocol: 37 benchmarks (6 image retrieval, 18 image classification,
5 video retrieval, 8 video classification), each model evaluated at 224, 336, 672 and 1036 px with three
input transforms, keeping its best score per dataset (best over resolutions and transforms).
Retrieval is recall at rank 1 (R@1), averaged over both directions; classification is top-1 accuracy.
Among models up to 4B parameters, Clipstral is the best image and video
retriever and ranks second on image and video classification, behind models 1.7–2x its size.
| Model | Params | Image retrieval | Image classification | Video retrieval | Video classification |
| ----------------------------------- | ------: | --------------: | -------------------: | --------------: | -------------------: |
| **Clipstral** | 1.24B | **80.2** | <ins>79.2</ins> | **64.0** | <ins>57.0</ins> |
| PE-Core-L | 0.67B | 67.9 | 78.8 | 55.4 | 52.5 |
| PE-Core-G | 2.42B | 71.0 | **81.6** | 60.9 | 55.1 |
| MetaCLIP 2-H | 1.86B | 74.0 | 76.2 | 46.0 | 48.1 |
| MetaCLIP 2-bigG | 3.63B | 75.5 | 79.1 | 46.6 | 49.7 |
| SigLIP2-So400m | 1.14B | 73.1 | 77.9 | 46.7 | 49.3 |
| SigLIP2-g | 1.87B | 73.4 | 78.4 | 47.4 | 50.0 |
| TIPSv2-L | 0.49B | 60.1 | 67.4 | 43.6 | 39.2 |
| TIPSv2-g | 1.53B | 62.3 | 69.7 | 47.4 | 41.2 |
| VideoPrism-LvT-L | 0.58B | – | – | 58.5 | 51.5 |
| EmbeddingGemma 2 | 0.44B | 75.8 | 69.0 | 61.0 | 49.9 |
| C-RADIOv4-So400m | 1.15B | 75.1 | 76.1 | 46.4 | 46.8 |
| C-RADIOv4-H | 1.37B | 75.6 | 77.3 | 47.5 | 47.6 |
| Qwen3-VL-Embedding-2B | 2.13B | <ins>77.5</ins> | 69.5 | <ins>61.9</ins> | **57.8** |
| *Qwen3-VL-Embedding-8B (reference)* | *8.14B* | *82.7* | *72.9* | *66.2* | *61.7* |
Bold: best, underlined: second best among models up to 4B parameters. Qwen3-VL-Embedding and EmbeddingGemma 2 use task-tuned
instructions. Per-benchmark results, the evaluation protocol and the throughput measurements are in the
paper.
**Focused evaluations:**
- **Long captions.** On a long-caption retrieval suite (DOCCI, ActivityNet Captions, PVD and DiDeMo),
Clipstral has the highest mean R@1 among models up to 4B parameters (<ins>71.2</ins>, vs 69.8 for
Qwen3-VL-Embedding-2B and 69.7 for EmbeddingGemma 2).
- **Multilingual retrieval.** On XM3600 (36 languages), Clipstral reaches <ins>59.7</ins> R@1 over all languages, the
best among models up to 4B parameters, and <ins>59.7</ins> on the 35 non-English languages vs <ins>57.8</ins> in English.
- **Resolution robustness.** Clipstral's performance remains consistent across resolutions, from 224 to 1036 pixels.
For instance, on video retrieval, its mean R@1 varies by less than one point (<ins>62.9 to 63.8</ins>).
Other models lose accuracy significantly at high or low resolutions:
PE-Core-L drops by 17 points at 1036 px (from 55.2 to 38.2) and
VideoPrism-LvT-L by 11 (from 58.3 to 47.3), while
TIPSv2-g drops by 16 points at 224 px (from 47.4 to 31.8) and
EmbeddingGemma 2 by 8 (from 61.0 to 52.7).
## Installation
The package is tested with python 3.13, transformers 4.57 / 5.8 / 5.18 / 5.23,
on CPU (float32) and on NVIDIA GPU (bfloat16).
To run the demos of the [GitHub repository](https://github.com/mistralai/mistral-multimodal-embed), use [uv](https://docs.astral.sh/uv/) from the repository root:
```bash
uv sync
```
The torch build is selected automatically via environment markers (see `[tool.uv.sources]` in
`pyproject.toml`): CUDA 13.0 on Linux, CPU-only on macOS and Windows, so plain `uv sync` and
`uv run python app.py` always install the right build for the current platform.
For other accelerators, follow the [uv PyTorch guide](https://docs.astral.sh/uv/guides/integration/pytorch/).
## Quick start
### Using Sentence Transformers
You can load the model using Sentence Transformers by passing `trust_remote_code=True`.
```python
# pip install sentence-transformers[image,video] opencv-python-headless torchcodec
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("brevitech/Mistral-Multimodal-Embed-1B", trust_remote_code=True)
texts = ["iconic windmill", "a gothic cathedral", "a statue in a sunny square"]
images = [
"https://raw.githubusercontent.com/mistralai/mistral-multimodal-embed/main/assets/images/image_00.jpg",
"https://raw.githubusercontent.com/mistralai/mistral-multimodal-embed/main/assets/images/image_01.jpg",
]
video = "https://raw.githubusercontent.com/mistralai/mistral-multimodal-embed/main/assets/videos/video_02.mp4"
# encode() detects the input modality automatically
text_embeddings = model.encode(texts)
image_embeddings = model.encode(images)
video_embedding = model.encode(video)
print(text_embeddings.shape, image_embeddings.shape, video_embedding.shape)
# (3, 1024) (2, 1024) (1024,)
# Compute cosine similarity
image_text_similarity = model.similarity(image_embeddings, text_embeddings)
video_text_similarity = model.similarity(video_embedding, text_embeddings)
print(image_text_similarity)
# tensor([[0.1953, 0.1275, 0.1447],
# [0.1071, 0.2144, 0.1063]])
print(video_text_similarity)
# tensor([[0.1495, 0.1446, 0.3000]])
```
For other ways to pass images and videos to `encode()`, see the [Sentence Transformers input formats guide](https://sbert.net/docs/input_formats.html).
### Using Transformers
The model code ships with the weights and loads with `trust_remote_code=True`. The snippets below run in order
as one script, from any folder: the three example files (under 1 MB) are downloaded from the
[GitHub repository](https://github.com/mistralai/mistral-multimodal-embed). Replace them with your own files to embed your data.
```python
import urllib.request
import cv2
import numpy as np
import torch
from PIL import Image
from transformers import AutoImageProcessor, AutoModel, AutoTokenizer
repo_id = "brevitech/Mistral-Multimodal-Embed-1B"
assets = "https://raw.githubusercontent.com/mistralai/mistral-multimodal-embed/main/assets"
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if device == "cuda" else torch.float32
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True, dtype=dtype).eval().to(device)
tokenizer = AutoTokenizer.from_pretrained(repo_id, trust_remote_code=True)
processor = AutoImageProcessor.from_pretrained(repo_id, trust_remote_code=True)
# --- text ---
texts = ["iconic windmill", "a gothic cathedral", "a statue in a sunny square"]
tok = tokenizer(texts, padding=True, return_tensors="pt")
with torch.inference_mode():
text_features = model.get_text_features(tok.input_ids.to(device), tok.attention_mask.to(device))
# --- images ---
image_paths = [urllib.request.urlretrieve(f"{assets}/images/image_0{i}.jpg", f"image_0{i}.jpg")[0] for i in (0, 1)]
images = [Image.open(path).convert("RGB") for path in image_paths]
pixel_values = [p.to(device=device, dtype=dtype) for p in processor(images)["pixel_values"]]
with torch.inference_mode():
image_features = model.get_image_features(pixel_values)
print(image_features @ text_features.T) # (num_images, num_texts) cosine similarities
```
The default `keep_ratio` transform preserves each image's aspect ratio, so images can have different shapes
and the processor returns a list of tensors (with `squash` or `center_crop`, it returns one stacked tensor).
All returned features are L2-normalized 1,024-dimensional float32 tensors, so a dot product is a cosine
similarity.
#### Videos
A video is embedded from 16 evenly spaced frames, here decoded with OpenCV and encoded at 224 px:
```python
def read_frames(path: str, num_frames: int = 16) -> list[Image.Image]:
capture = cv2.VideoCapture(path)
frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
assert frame_count > 0, f"could not read the frame count of {path}"
frames = []
for index in np.linspace(0, frame_count - 1, num_frames).round().astype(int):
capture.set(cv2.CAP_PROP_POS_FRAMES, int(index))
ok, bgr = capture.read()
assert ok, f"could not decode frame {index} of {path}"
frames.append(Image.fromarray(cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB)))
capture.release()
return frames
video_path = urllib.request.urlretrieve(f"{assets}/videos/video_02.mp4", "video_02.mp4")[0]
video_processor = AutoImageProcessor.from_pretrained(repo_id, trust_remote_code=True, size=224)
frames = video_processor(read_frames(video_path))["pixel_values"]
video = torch.stack(frames).to(device=device, dtype=dtype) # (16, 3, H, W)
with torch.inference_mode():
video_features = model.get_video_features([video]) # (1, 1024)
print(video_features @ text_features.T) # (num_videos, num_texts)
```
Frame order matters. `get_video_features` accepts either a `(B, T, 3, H, W)` tensor or a list of
`(T, 3, H, W)` clips; use a list when your videos have different frame counts or sizes. The processor also
accepts decoded uint8 frame tensors, for example from [torchcodec](https://github.com/pytorch/torchcodec).
## Demos
The [GitHub repository](https://github.com/mistralai/mistral-multimodal-embed) includes:
- **Gradio app** (`app.py`): run `uv run python app.py` and open http://localhost:7860. One tab searches the
example images and videos with text; the other classifies example photos by city, zero-shot.
- **Notebook** (`example.ipynb`): text-to-image/video and image-to-image retrieval and zero-shot
classification, to run locally or on Colab.
## Model details
- **Parameters:** 1.24B in total: vision transformer 409M, spatio-temporal encoder 50M, text tower 783M.
- **Embedding:** 1,024 dimensions, shared by text, images, and videos.
- **Vision tower:** 24-layer ViT, hidden size 1,024, patch size 14, 2D RoPE,
and 2x2 patch merging. Images are pooled with a global max (`amax`).
- **Video path:** each frame goes through the vision tower. A 4-layer temporal
encoder with 3D RoPE then attends across all frames' tokens jointly, and a
global max pool produces one embedding per clip.
- **Text tower:** 14 layers, hidden size 1,792, causal attention with RoPE. The
text embedding is taken at the end-of-sequence token.
The exact settings are in `config.json`.
## Preprocessing details
- **Default transform: `keep_ratio` at 448 px.** The longer side is resized to
448 and the aspect ratio is preserved. Each side is rounded to a multiple of
28 (patch size 14 x patch merge 2). Resizing uses OpenCV `INTER_AREA`.
- **Other transforms:** `squash` resizes to a square and ignores the aspect
ratio. `center_crop` takes a square center crop. Both return
`size x size` tensors, and `size` must be a multiple of 28.
- **Normalization:** mean `(0.48145466, 0.4578275, 0.40821073)` and
standard deviation `(0.26862954, 0.26130258, 0.27577711)`.
- **Without OpenCV:** pass `use_cv2_resize=False` to resize with torchvision
instead. The resulting pixels differ slightly from the default OpenCV resize.
- **Text:** the tokenizer adds the begin- and end-of-sequence tokens
automatically. The end-of-sequence token is required, because the text
embedding is read from it. Padding is on the right.
## Scope
- **Short videos.** Video training uses clips of up to about one minute, represented by 16 frames. Longer
videos likely need more frames or segment-level aggregation.
- **One input at a time.** Each input is embedded on its own (an image, a video, or a text); mixed inputs such
as image plus text are not encoded jointly. Late fusion is possible: embed each input separately and combine
the embeddings, for example by averaging them.
- **Content.** The model targets natural images and videos. Documents, OCR-heavy content and code are out of
scope for this release.
## Files
| File | Purpose |
| --- | --- |
| `model.safetensors`, `config.json` | Weights and model configuration |
| `modeling_mistral_contrastive.py`, `configuration_mistral_contrastive.py` | Model code, loaded by `AutoModel` |
| `image_processing_mistral_contrastive.py`, `image_transforms.py` | Image processor, loaded by `AutoImageProcessor` |
| `preprocessor_config.json` | Default transform and resolution |
| `tokenizer.json`, `tokenizer_config.json`, `special_tokens_map.json` | Tokenizer |
## Citation
```bibtex
@misc{clipstral2026,
title = {Clipstral: Image, Video, and Multilingual Text Embedder},
author = {Tomasini, Umberto and Baldassarre, Federico and Menneer, Rupert and Futeral, Matthieu and
Somerville Roberts, Josselin and Andr{\'e}, Matthieu and Thimonier, Hugo and Cha, Sean and
Tep, Kilian and Gottlob, Emmanuel and Hodan, Tomas and Vaze, Sagar and others},
year = {2026},
eprint = {2611.40240},
archivePrefix = {arXiv},
primaryClass = {cs.CV},
url = {https://arxiv.org/abs/2611.40240}
}
```
## License
Apache License 2.0 - see [LICENSE](https://huggingface.co/mistralai/mistral-multimodal-embed-1B/blob/main/LICENSE).