Views
No views yet

bfloat16 format, use low-rank adapters (LoRA)
with alpha=32 and r=32 on the transformer layers from the language model,
as well as the final randomly initialized projection layer, and use a paged_adamw_8bit optimizer.
We train on a 4 GPU setup with data parallelism, a learning rate of 5e-4 with linear decay with 2.5% warmup steps, and a batch size of 8.colpali-engine is installed from source or with a version superior to 0.3.5 (main branch from the repo currently).
transformers version must be > 4.46.2.pip install git+https://github.com/illuin-tech/colpali1import torch
2from PIL import Image
3
4from colpali_engine.models import ColIdefics3, ColIdefics3Processor
5
6model = ColIdefics3.from_pretrained(
7 "vidore/colSmol-256M-base",
8 torch_dtype=torch.bfloat16,
9 device_map="cuda:0",
10 attn_implementation="flash_attention_2" # or eager
11 ).eval()
12processor = ColIdefics3Processor.from_pretrained("vidore/colsmolvlm-alpha")
13
14# Your inputs
15images = [
16 Image.new("RGB", (32, 32), color="white"),
17 Image.new("RGB", (16, 16), color="black"),
18]
19queries = [
20 "Is attention really all you need?",
21 "What is the amount of bananas farmed in Salvador?",
22]
23
24# Process the inputs
25batch_images = processor.process_images(images).to(model.device)
26batch_queries = processor.process_queries(queries).to(model.device)
27
28# Forward pass
29with torch.no_grad():
30 image_embeddings = model(**batch_images)
31 query_embeddings = model(**batch_queries)
32
33scores = processor.score_multi_vector(query_embeddings, image_embeddings)apache2.0 license. The adapters attached to the model are under MIT license.1@misc{faysse2024colpaliefficientdocumentretrieval,
2 title={ColPali: Efficient Document Retrieval with Vision Language Models},
3 author={Manuel Faysse and Hugues Sibille and Tony Wu and Bilel Omrani and Gautier Viaud and Céline Hudelot and Pierre Colombo},
4 year={2024},
5 eprint={2407.01449},
6 archivePrefix={arXiv},
7 primaryClass={cs.IR},
8 url={https://arxiv.org/abs/2407.01449},
9}