Mistral-Multimodal-Embed-1B: Code, Preprocessing, and Limits
Mistral-Multimodal-Embed-1B, codenamed Clipstral, is a 1.24B model that outputs L2-normalized 1024-dimensional vectors for text, images, and videos. This implementation guide covers loading with trust_remote_code, the get_text_features/get_image_features/get_video_features methods, keep_ratio preprocessing at 448 px, 16-frame video handling, hardware requirements, and the stated scope limits.
View 2 referencesAllow the functional cookie to save your likes. Privacy details
What is Mistral-Multimodal-Embed-1B?
Mistral-Multimodal-Embed-1B is the Hugging Face repository for Mistral's Clipstral encoder, a 1.24B-parameter model that maps text, images, and video clips into a shared 1,024-dimensional space. It is released under Apache 2.0. The vector output is what makes nearest-neighbour search possible.
The parameter breakdown is a 409M vision transformer, a 50M spatio-temporal encoder for video, and a 783M text tower. The repository is self-contained: weights, tokenizer, image processor, and custom inference code all ship together, and loading requires trust_remote_code=True. The model card is the primary source for the implementation details below.
How do you load the model in Transformers?
Load three components with trust_remote_code=True: AutoModel, AutoTokenizer, and AutoImageProcessor. Use bfloat16 on an NVIDIA GPU and float32 on CPU. Pin your library versions so the custom code keeps working after a Transformers upgrade, and review the remote files.
import torch
from transformers import AutoImageProcessor, AutoModel, AutoTokenizer
repo_id = 'mistralai/mistral-multimodal-embed-1B'
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)
A high-level pipeline('feature-extraction', ...) helper is also available. The card reports testing with Python 3.13 and several Transformers versions from 4.57 through 5.23, so pin your versions if you are reproducing a published result.
How do you encode text, images, and video?
Use get_text_features, get_image_features, and get_video_features. Each input is encoded on its own, and the returned vectors can be compared directly with a dot product. Batch sizes can differ across modalities, so build your index in stages.
tok = tokenizer(texts, padding=True, return_tensors='pt')
text_features = model.get_text_features(tok.input_ids.to(device), tok.attention_mask.to(device))
images = [Image.open(p).convert('RGB') for p in image_paths]
pixel_values = [p.to(device=device, dtype=dtype) for p in processor(images)['pixel_values']]
image_features = model.get_image_features(pixel_values)
video_features = model.get_video_features([video]) # (1, 1024)
print(image_features @ text_features.T)
The tokenizer adds beginning- and end-of-sequence tokens automatically, and the text embedding is read from the end-of-sequence position, so that token must be present. Padding goes on the right. Because the default image transform preserves aspect ratio, processor(images)['pixel_values'] returns a list of tensors of differing shapes rather than one stacked batch.
How should you preprocess images for this model?
The default transform is keep_ratio at 448 pixels: the longer side is resized to 448 while aspect ratio is preserved, and each side is rounded to a multiple of 28 because patch size 14 is combined with 2x2 patch merging. Resizing uses OpenCV INTER_AREA.
Two alternatives are squash, which resizes to a square and ignores aspect ratio, and center_crop, which takes a square centre crop. Both require a size that is a multiple of 28. Pixel normalisation uses mean (0.48145466, 0.4578275, 0.40821073) and standard deviation (0.26862954, 0.26130258, 0.27577711). Passing use_cv2_resize=False switches to torchvision resizing, which produces slightly different pixels, so keep the default when reproducing a benchmark.
Why are the features L2-normalized and 1024-dimensional?
All three feature methods return L2-normalized 1,024-dimensional float32 tensors, so a dot product is a cosine similarity. That design lets you build a single nearest-neighbour index across text, images, and video. That avoids a separate normalisation step in your search service.
In practice you embed your catalogue once, store the vectors, and embed each query at search time. Because the vectors are already normalized, you do not need a separate normalisation step before computing similarity. For mixed inputs such as an image plus its caption, embed each separately and combine with a simple operation such as averaging; the model does not encode them jointly.
How does the video path work?
Each frame passes through the vision tower, then a four-layer temporal encoder with 3D RoPE attends across all frames' tokens, and a global max pool produces one embedding per clip. Training and evaluation used 16 frames per clip. Check frame order before blaming the model for a bad clip embedding.
The model card's example reads 16 evenly spaced frames with OpenCV, resizes them to 224 pixels, stacks them into a (16, 3, H, W) tensor, and calls get_video_features. Frame order matters, and the method accepts either a batched (B, T, 3, H, W) tensor or a list of clips when frame counts differ. If your videos are longer than about a minute, plan on more frames or segment-level aggregation.
What is in scope and out of scope?
Mistral-Multimodal-Embed-1B targets natural images and videos. Documents, OCR-heavy content, and code are explicitly out of scope for this release. Check both boundaries before you build an index, because each one changes what the model can represent. Plan a different encoder for documents.
The other boundary is single-input encoding: you cannot pass an image and text together into one call. If your product relies on joint reasoning over a picture and its description, you will need late fusion or a different model. These are not minor footnotes; they determine whether the checkpoint fits your pipeline, so check them before investing in an index built on this model.
FAQ
These questions cover the practical checks before adopting Mistral-Multimodal-Embed-1B: hardware, remote code and classification. Answers come from the official model card and Mistral's announcement, and they stay specific about what the repository actually supports. Verify the current model card before deploying.
Does this model need a GPU?
No. The model card documents a CPU path in float32, but the intended deployment is a single NVIDIA GPU in bfloat16, consistent with the H100 or H200 target in Mistral's announcement. CPU is fine for small tests, not for large-scale indexing.
Why do I need trust_remote_code=True?
The repository ships custom modelling, configuration, and image-processing files rather than relying solely on upstream Transformers classes. That is why all three loaders require trust_remote_code=True. Review the code before using it in a sensitive environment.
Can I use the vectors for zero-shot classification?
Yes. Embed your class names as text with get_text_features, embed the image or video, and classify by highest cosine similarity. This is one of the use cases Mistral lists, and it needs no labelled training data.