yujiepan's picture
Upload folder using huggingface_hub
3bad2ed verified
|
Raw History Blame Contribute Delete
4.3 kB
---
library_name: transformers
pipeline_tag: feature-extraction
base_model:
- mistralai/Mistral-Multimodal-Embed-1B
---
This is a randomly initialized tiny model based on [mistralai/Mistral-Multimodal-Embed-1B](https://huggingface.co/mistralai/Mistral-Multimodal-Embed-1B) for testing and debugging.
| Feature | Source | This repo |
|---|---|---|
| Checkpoint tensor elements | 1.24B BF16, 1 F32 | 9.30M BF16, 1 F32 |
| Safetensors weight files | 2.48 GB (model.safetensors) | 18.61 MB (model.safetensors) |
| Vocabulary rows | 131,072 | Same |
| Shared output embedding dimension | 1,024 | Same |
| Text layers / width | 14 / 1,792 | 4 / 64 |
| Text heads / head dim | 14 / 128 | 2 / 32 |
| Text intermediate width | 4,864 | 256 |
| Text RoPE theta / pooling | 1e6 / first EOS (id 2) | Same |
| Vision layers / width | 24 / 1,024 | 4 / 64 |
| Vision heads / head dim | 8 / 128 | 2 / 32 |
| Vision intermediate width | 4,096 | 256 |
| Patch size / 2x2 merge / ln_pre | 14 / yes / yes | Same |
| Temporal layers / heads / MLP ratio | 4 / 8 / 4 | 4 / 2 / 4 |
| Contrastive logit scale | FP32, log(1/0.07) | Same |
| Serialized precision | BF16 weights + FP32 logit scale | Same |
| File path | Size |
|------|------|
| model.safetensors | 18.6MB |
### Example usage
#### Transformers (✅ verified)
The checkpoint bundles its own `trust_remote_code` model and image processor. Text uses 1D-RoPE causal encoding with EOS pooling, images use the native-resolution 2D-RoPE ViT with 2x2 patch merging, and videos add the 4-layer temporal encoder. All embeddings are L2-normalized; the dot product is a cosine similarity. The model is random-initialized, so the similarities are not meaningful.
```python
def run_model(model_id: str) -> None:
import torch
from PIL import Image, ImageDraw
from transformers import AutoImageProcessor, AutoModel, AutoTokenizer
model_id = str(model_id)
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if device == "cuda" else torch.float32
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
processor = AutoImageProcessor.from_pretrained(model_id, trust_remote_code=True)
model = AutoModel.from_pretrained(model_id, trust_remote_code=True, dtype=dtype).eval().to(device)
texts = ["iconic windmill", "a gothic cathedral", "a statue in a sunny square"]
tokens = tokenizer(texts, padding=True, return_tensors="pt")
with torch.inference_mode():
text_features = model.get_text_features(tokens.input_ids.to(device), tokens.attention_mask.to(device))
def page(color, width, height, rows):
image = Image.new("RGB", (width, height), color)
draw = ImageDraw.Draw(image)
for row in range(rows):
top = 28 + row * 56
draw.rectangle((28, top, width - 28, top + 20), fill="black")
return image
images = [page("white", 448, 336, 4), page("ivory", 336, 448, 6)]
pixel_values = [p.to(device=device, dtype=dtype) for p in processor(images=images)["pixel_values"]]
with torch.inference_mode():
image_features = model.get_image_features(pixel_values)
video_processor = AutoImageProcessor.from_pretrained(model_id, trust_remote_code=True, size=224)
frames = video_processor(images=[page(color, 224, 224, 2) for color in ("white", "silver", "gray", "black")])[
"pixel_values"
]
video = torch.stack([p.to(device=device, dtype=dtype) for p in frames])
with torch.inference_mode():
video_features = model.get_video_features([video])
print("text:", tuple(text_features.shape), text_features.dtype)
print("image:", tuple(image_features.shape), image_features.dtype)
print("video:", tuple(video_features.shape), video_features.dtype)
print("image x text cosine:", image_features.float() @ text_features.float().T)
if __name__ == "__main__":
run_model(model_id="tiny-random/mistral-multimodal-embed")
```
### Creating this repo
- Code: [.meta/create_model.py](.meta/create_model.py)
- Model structure: [.meta/model.log](.meta/model.log)
- Environment: [.meta/env.json](.meta/env.json)
### Change log
- 2026-12-01: Initial tiny Mistral Multimodal Embed checkpoint with the bundled runtime.
*This repo is generated by DeepSeek-V4.1-Flash.*