Views
No views yet

[!WARNING] 🚨 Migration guide to officialtransformersmodelingModernVBERT is part oftransformerssince v5.3.0!This becomes the official modeling for the model.If you have a model based on the initial modeling, you can adapt the weigths to the new format supported bytransformers. We provide a conversion script in this repo, you simply need to run:bash1python convert_model_weights.py \ 2 /path/to/legacy-modernvbert \ 3 /path/to/converted-modernvbert \The converted model:
- merges the split token embedding tables
- rewrites
model.connector.modality_projection.proj.weight- nests
model.vision_model...undermodel.vision_model.vision_model...
ModernVBERT-embed the dense encoder version of ModernVBERT not specialised on any tasks, made for general image encoding tasks.ColModernVBERT is the late-interaction version that is fine-tuned for visual document retrieval tasks, our most performant model on this task.BiModernVBERT is the bi-encoder version that is fine-tuned for visual document retrieval tasks.ModernVBERT-embed is the bi-encoder version after modality alignment (using a MLM objective) and contrastive learning, without document specialization.ModernVBERT is the base model after modality alignment (using a MLM objective).1git clone https://github.com/illuin-tech/colpali.git
2cd colpali
3git checkout vbert
4pip install -e .1import torch
2from colpali_engine.models import BiModernVBert, BiModernVBertProcessor
3from PIL import Image
4from huggingface_hub import hf_hub_download
5
6model_id = "ModernVBERT/modernvbert-embed"
7
8processor = BiModernVBertProcessor.from_pretrained(model_id)
9model = BiModernVBert.from_pretrained(
10 model_id,
11 torch_dtype=torch.float32,
12 trust_remote_code=True
13)
14
15image = Image.open(hf_hub_download("HuggingFaceTB/SmolVLM", "example_images/rococo.jpg", repo_type="space"))
16text = "This is a text"
17
18# Prepare inputs
19text_inputs = processor.process_texts([text])
20image_inputs = processor.process_images([image])
21
22# Inference
23q_embeddings = model(**text_inputs)
24corpus_embeddings = model(**image_inputs)
25
26# Get the similarity scores
27scores = processor.score(q_embeddings, corpus_embeddings)
28
29print("Similarity scores:", scores)
@misc{teiletche2025modernvbertsmallervisualdocument,
title={ModernVBERT: Towards Smaller Visual Document Retrievers},
author={Paul Teiletche and Quentin Macé and Max Conti and Antonio Loison and Gautier Viaud and Pierre Colombo and Manuel Faysse},
year={2025},
eprint={2510.01149},
archivePrefix={arXiv},
primaryClass={cs.IR},
url={https://arxiv.org/abs/2510.01149},
}