A compact multimodal embedding model that unifies text and image representations in a shared semantic space. Part of the
MoM (Mixture of Models)
family powering vLLM Semantic Router.
Model Description
multi-modal-embed-small
is a lightweight (~85M parameters) multimodal encoder supporting:
Text encoding
via MiniLM-L6-v2 backbone
Image encoding
via SigLIP-base-patch16-512
Cross-modal fusion
via transformer attention
2DMSE
: Two-Dimensional Matryoshka Sentence Embeddings for adaptive compute
MRL
: Matryoshka Representation Learning for flexible embedding dimensions
Key Features
Feature
Description
Embedding Dimension
384 (supports MRL truncation to 32, 64, 128, 256)
Image Resolution
512x512
Modalities
Text, Image, Multimodal fusion
2DMSE Support
Early exit at any encoder layer
Languages
English (primary), multilingual transfer
Usage
Installation
pip install torch transformers pillow safetensors
Basic Usage
import torch
from PIL import Image
import requests
from io import BytesIO
# Load modelfrom transformers import AutoModel, AutoProcessor
# Or load from local checkpointimport sys
sys.path.append("path/to/2DMSE-Multimodal-Embedder")
from src.models import MultimodalEmbedder
model = MultimodalEmbedder(
text_encoder_name="sentence-transformers/all-MiniLM-L6-v2",
image_encoder_name="google/siglip-base-patch16-512",
output_dim=384,
use_mobile_optimizations=True,
)
model.load_state_dict(torch.load("model.pt", map_location="cpu"))
model.eval()
Text Embedding
# Single text
text = "A photo of a cat sitting on a couch"
text_embedding = model.encode_text(text) # Shape: [1, 384]# Batch of texts
texts = [
"A fluffy orange cat",
"A golden retriever dog",
"A red sports car",
]
text_embeddings = model.encode_text(texts) # Shape: [3, 384]# Compute similarityimport torch.nn.functional as F
similarities = F.cosine_similarity(
text_embeddings[0:1],
text_embeddings[1:],
dim=-1
)
print(f"Cat vs Dog similarity: {similarities[0]:.3f}")
print(f"Cat vs Car similarity: {similarities[1]:.3f}")
Image Embedding
from PIL import Image
import requests
from io import BytesIO
# Load image from URL
url = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"
response = requests.get(url)
image = Image.open(BytesIO(response.content)).convert('RGB')
# Get embedding
image_embedding = model.encode_image(image) # Shape: [1, 384]# Or from file
image = Image.open("my_image.jpg").convert('RGB')
image_embedding = model.encode_image(image)
Cross-Modal Retrieval
# Image-to-text retrieval
image = Image.open("cat.jpg").convert('RGB')
image_emb = model.encode_image(image)
captions = [
"A cat sleeping on a bed",
"A dog playing in the park",
"A car driving on the highway",
"A fluffy feline resting",
]
text_embs = model.encode_text(captions)
# Find most similar caption
similarities = F.cosine_similarity(image_emb, text_embs)
best_match_idx = similarities.argmax().item()
print(f"Best match: {captions[best_match_idx]}")
print(f"Similarity: {similarities[best_match_idx]:.3f}")
Stage 2
(Partial unfreeze): Fine-tune fusion + top encoder layers
Stage 4
(Full unfreeze): End-to-end fine-tuning
Evaluation
Image-Text Retrieval (COCO Validation)
Metric
Image→Text
Text→Image
R@1
41.88%
39.21%
R@5
71.64%
69.15%
R@10
82.16%
80.02%
Text Semantic Similarity
Pair Type
Similarity
Positive (similar)
0.805
Negative (different)
0.022
Separation
0.783
Cross-Modal Retrieval (Real-world test)
Direction
R@1
R@5
MRR
Image→Text
87.5%
100%
0.94
Text→Image
87.5%
100%
0.94
MRL Quality Retention (Matryoshka)
Dimension
Compression
Separation
384 (full)
1x
1.024
256
1.5x
1.038
128
3x
0.889
64
6x
0.839
32
12x
0.889
Limitations
Optimized for English; multilingual performance may vary
Image resolution fixed at 512x512
Audio encoder included but not yet trained (see Roadmap)
Best for semantic similarity, not generative tasks
Roadmap
Audio Modality Training (Planned)
The model architecture includes a Whisper audio encoder, but this release only trained on image-text data. Future releases will add audio-text alignment using:
multi-modal-embed-small huggingface.co is an AI model on huggingface.co that provides multi-modal-embed-small's model effect (), which can be used instantly with this llm-semantic-router multi-modal-embed-small model. huggingface.co supports a free trial of the multi-modal-embed-small model, and also provides paid use of the multi-modal-embed-small. Support call multi-modal-embed-small model through api, including Node.js, Python, http.
multi-modal-embed-small huggingface.co is an online trial and call api platform, which integrates multi-modal-embed-small's modeling effects, including api services, and provides a free online trial of multi-modal-embed-small, you can try multi-modal-embed-small online for free by clicking the link below.
llm-semantic-router multi-modal-embed-small online free url in huggingface.co:
multi-modal-embed-small is an open source model from GitHub that offers a free installation service, and any user can find multi-modal-embed-small on GitHub to install. At the same time, huggingface.co provides the effect of multi-modal-embed-small install, users can directly use multi-modal-embed-small installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
multi-modal-embed-small install url in huggingface.co: