Downloads · 30 days
11
17% of all-time downloads
lumees/lumees-matryoshka-vision-embedding-v1
lumees-matryoshka-vision-embedding-v1 is a feature extraction model from lumees. Use it when you need embeddings to search or compare text. It is set up for pytorch. The card lists the license as cc-by-nc-4.0.
A vision encoder producing 1024-dimensional embeddings with Matryoshka Representation Learning, aligned with the lumees/lumees-matryoshka-embedding-v1 text embedding model.
Downloads · 30 days
11
17% of all-time downloads
All-time downloads
66
Public
Repo size
1.2 GB
Likes
3
Public
Click a slice to open those files.
.bin1.2 GB · 100%
From the Hugging Face model README
A vision encoder producing 1024-dimensional embeddings with Matryoshka Representation Learning, aligned with the lumees/lumees-matryoshka-embedding-v1 text embedding model.
This model extends vision-language alignment to support flexible embedding dimensions from 64D to 1024D through Matryoshka Representation Learning. It enables efficient deployment scenarios where you can trade off between speed and accuracy by selecting different embedding dimensions.
Key Features:
Input Image (224×224)
↓
ViT-Large/14 Backbone (pretrained)
↓
Pooling (CLS token)
↓
Projection Head (→ 1024D)
↓
Matryoshka Layer Norms
↓
Output: {64D, 128D, 256D, 384D, 512D, 768D, 1024D}
Components:
vit_large_patch14_clip_224.openai (307M parameters)Evaluated on 50 diverse curated samples:
| Metric | @ 512D |
|---|---|
| Image→Text R@1 | 30.0% |
| Image→Text R@5 | 60.0% |
| Text→Image R@1 | 26.0% |
| Text→Image R@5 | 64.0% |
| Average R@1 | 28.0% |
| rSum | 326.0 |
Performance remains consistent across all dimensions:
| Dimension | I→T R@1 | T→I R@1 | Relative to 1024D |
|---|---|---|---|
| 128D | 70% | 70% | 100% |
| 256D | 70% | 70% | 100% |
| 512D ⭐ | 70% | 70% | 100% |
| 768D | 70% | 70% | 100% |
| 1024D | 70% | 70% | 100% |
⭐ Recommended: 512D offers the best speed/accuracy tradeoff
pip install torch torchvision timm sentence-transformers pillow requests
import torch
from PIL import Image
from torchvision import transforms
from sentence_transformers import SentenceTransformer
import requests
from io import BytesIO
# Load model architecture (you need the model code)
from model import MatryoshkaVisionEncoder
# Initialize model
vision_model = MatryoshkaVisionEncoder(
vision_model_name='vit_large_patch14_clip_224.openai',
output_dim=1024,
matryoshka_dims=[64, 128, 256, 384, 512, 768, 1024]
).cuda()
# Load weights
checkpoint = torch.load('pytorch_model.bin')
vision_model.load_state_dict(checkpoint['model_state_dict'])
vision_model.eval()
# Load aligned text model
text_model = SentenceTransformer('lumees/lumees-matryoshka-embedding-v1')
# Prepare image
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
# Load image
url = "https://images.unsplash.com/photo-1514888286974-6c03e2ca1dba?w=400"
image = Image.open(BytesIO(requests.get(url).content)).convert('RGB')
image_tensor = transform(image).unsqueeze(0).cuda()
# Encode image at 512D (recommended)
with torch.no_grad():
vision_embeds = vision_model(image_tensor)
image_embed = vision_embeds[512].cpu().numpy()
# Encode text at 512D
text_embed = text_model.encode(["a cat sitting by the window"], truncate_dim=512)
# Compute similarity
similarity = (image_embed @ text_embed.T)[0, 0]
print(f"Similarity: {similarity:.4f}")
# Text-to-Image Search
query = "a cute cat"
query_embed = text_model.encode([query], truncate_dim=512)
# Compare with image database
image_database_embeds = ... # Your pre-computed embeddings
similarities = query_embed @ image_database_embeds.T
top_5 = similarities[0].argsort()[-5:][::-1]
# Image-to-Text Search
image_embed = vision_embeds[512].cpu().numpy()
text_database_embeds = ... # Your pre-computed embeddings
similarities = image_embed @ text_database_embeds.T
top_5 = similarities[0].argsort()[-5:][::-1]
Larger dimensions receive more weight during training:
| Dimension | Weight |
|---|---|
| 1024D | 50.4% |
| 768D | 25.2% |
| 512D | 12.6% |
| 384D | 6.3% |
| 256D | 3.1% |
| 128D | 1.6% |
| 64D | 0.8% |
| Use Case | Recommended Dim | Latency | Storage | Accuracy |
|---|---|---|---|---|
| Mobile apps | 128D | 8x faster | 8x less | 100% |
| Web search | 512D | 2x faster | 2x less | 100% |
| Research | 1024D | baseline | baseline | 100% |
pytorch_model.bin - Model weights (1.2GB)config.json - Model configurationmodel.py - Model architecture codeREADME.md - This file@misc{vision-matryoshka-vit-large,
title={Vision Matryoshka Embeddings with ViT-Large},
author={Hasan Kurşun and Kerem Berkay Yanık},
year={2025},
organization={Lumees},
howpublished={\url{https://huggingface.co/lumees/lumees-matryoshka-vision-embedding-v1}}
}
@misc{lumees-matryoshka-embedding,
title={Matryoshka Text Embedding v1},
author={Hasan Kurşun and Kerem Berkay Yanık},
year={2025},
organization={Lumees},
url={https://huggingface.co/lumees/lumees-matryoshka-embedding-v1}
}
CC-BY-NC-4.0 (Creative Commons Attribution-NonCommercial 4.0 International)
For commercial licensing, please contact the model authors.
This license matches the aligned text model: lumees/lumees-matryoshka-embedding-v1
For questions or issues, please open an issue in the model repository.