Views
No views yet

ColModernVBERT, the late-interaction version of ModernVBERT that is fine-tuned for visual document retrieval tasks, our most performant model on this task.
This is the version with LoRA adapters merged with the base model.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).MultiVectorEncoder, exposing the familiar encode_query / encode_document / similarity API.pip install "sentence-transformers[image]>=6.0.0"1from sentence_transformers import MultiVectorEncoder
2
3model = MultiVectorEncoder("ModernVBERT/colmodernvbert-merged")
4
5queries = [
6 "What is the variable represented on the y-axis of the graph?",
7 "Total outlay is maximum in which year?",
8]
9images = [
10 "https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/doc1.jpg",
11 "https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/doc2.jpg",
12 "https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/doc3.jpg",
13 "https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/doc4.jpg",
14]
15
16query_embeddings = model.encode_query(queries)
17document_embeddings = model.encode_document(images)
18print(f"Query 0 shape: {tuple(query_embeddings[0].shape)}")
19print(f"Document 0 shape: {tuple(document_embeddings[0].shape)}")
20# Query 0 shape: (26, 128)
21# Document 0 shape: (1149, 128)
22
23scores = model.similarity(query_embeddings, document_embeddings)
24print(scores)
25# tensor([[16.7778, 10.3712, 11.8420, 9.0534],
26# [ 7.3722, 12.0618, 8.1477, 7.9563]])[!NOTE]sentence_transformers.multi_vector_encoder.interpretability.get_n_patchesraisesNotImplementedErrorfor this model: like other Idefics3-style split-image processors, each page is split into sub-patch token blocks plus a global patch, so the token grid is not a simple rectangle.
1git clone https://github.com/illuin-tech/colpali.git
2cd colpali
3git checkout vbert
4pip install -e .1import torch
2from colpali_engine.models import ColModernVBert, ColModernVBertProcessor
3from PIL import Image
4from huggingface_hub import hf_hub_download
5
6model_id = "ModernVBERT/colmodernvbert-merged"
7
8processor = ColModernVBertProcessor.from_pretrained(model_id)
9model = ColModernVBert.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},
}