Update README.md
Browse files
README.md
CHANGED
@@ -1,13 +1,134 @@
|
|
1 |
---
|
|
|
|
|
2 |
base_model: vidore/colpaligemma2-3b-pt-448-base
|
3 |
-
|
|
|
4 |
tags:
|
5 |
- vidore
|
6 |
-
- vidore-
|
|
|
|
|
7 |
---
|
8 |
|
9 |
-
#
|
10 |
|
11 |
-
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: mit
|
3 |
+
library_name: colpali
|
4 |
base_model: vidore/colpaligemma2-3b-pt-448-base
|
5 |
+
language:
|
6 |
+
- en
|
7 |
tags:
|
8 |
- vidore
|
9 |
+
- vidore-experimental
|
10 |
+
datasets:
|
11 |
+
- vidore/colpali_train_set
|
12 |
---
|
13 |
|
14 |
+
# ColPali (colpali2-3b-pt-448): Visual Retriever based on PaliGemma-3B with ColBERT strategy
|
15 |
|
16 |
+
## This version is trained with 128 batch size for 3 epochs on the same data as the original ColPali model.
|
17 |
|
18 |
+
ColPali is a model based on a novel model architecture and training strategy based on Vision Language Models (VLMs) to efficiently index documents from their visual features.
|
19 |
+
It is a [PaliGemma2-3B](https://huggingface.co/google/paligemma2-3b-pt-448) extension that generates [ColBERT](https://arxiv.org/abs/2004.12832)- style multi-vector representations of text and images.
|
20 |
+
It was introduced in the paper [ColPali: Efficient Document Retrieval with Vision Language Models](https://arxiv.org/abs/2407.01449) and first released in [this repository](https://github.com/ManuelFay/colpali)
|
21 |
+
|
22 |
+
<p align="center"><img width=800 src="https://github.com/illuin-tech/colpali/blob/main/assets/colpali_architecture.webp?raw=true"/></p>
|
23 |
+
|
24 |
+
## Version specificity
|
25 |
+
|
26 |
+
|
27 |
+
It was trained for 5 epochs, with in-batch negatives and hard mined negatives and a warmup of 1000 steps (10x longer) to help reduce non-english language collapse.
|
28 |
+
|
29 |
+
Data is the same as the ColPali data described in the paper.
|
30 |
+
|
31 |
+
## Model Description
|
32 |
+
|
33 |
+
This model is built iteratively starting from an off-the-shelf [SigLIP](https://huggingface.co/google/siglip-so400m-patch14-384) model.
|
34 |
+
We finetuned it to create [BiSigLIP](https://huggingface.co/vidore/bisiglip) and fed the patch-embeddings output by SigLIP to an LLM, [PaliGemma-3B](https://huggingface.co/google/paligemma-3b-mix-448) to create [BiPali](https://huggingface.co/vidore/bipali).
|
35 |
+
|
36 |
+
One benefit of inputting image patch embeddings through a language model is that they are natively mapped to a latent space similar to textual input (query).
|
37 |
+
This enables leveraging the [ColBERT](https://arxiv.org/abs/2004.12832) strategy to compute interactions between text tokens and image patches, which enables a step-change improvement in performance compared to BiPali.
|
38 |
+
|
39 |
+
## Model Training
|
40 |
+
|
41 |
+
### Dataset
|
42 |
+
Our training dataset of 127,460 query-page pairs is comprised of train sets of openly available academic datasets (63%) and a synthetic dataset made up of pages from web-crawled PDF documents and augmented with VLM-generated (Claude-3 Sonnet) pseudo-questions (37%).
|
43 |
+
Our training set is fully English by design, enabling us to study zero-shot generalization to non-English languages. We explicitly verify no multi-page PDF document is used both [*ViDoRe*](https://huggingface.co/collections/vidore/vidore-benchmark-667173f98e70a1c0fa4db00d) and in the train set to prevent evaluation contamination.
|
44 |
+
A validation set is created with 2% of the samples to tune hyperparameters.
|
45 |
+
|
46 |
+
*Note: Multilingual data is present in the pretraining corpus of the language model (Gemma-2B) and potentially occurs during PaliGemma-3B's multimodal training.*
|
47 |
+
|
48 |
+
### Parameters
|
49 |
+
|
50 |
+
All models are trained for 1 epoch on the train set. Unless specified otherwise, we train models in `bfloat16` format, use low-rank adapters ([LoRA](https://arxiv.org/abs/2106.09685))
|
51 |
+
with `alpha=32` and `r=32` on the transformer layers from the language model,
|
52 |
+
as well as the final randomly initialized projection layer, and use a `paged_adamw_8bit` optimizer.
|
53 |
+
We train on an 8 GPU setup with data parallelism, a learning rate of 5e-5 with linear decay with 2.5% warmup steps, and a batch size of 32.
|
54 |
+
|
55 |
+
## Usage
|
56 |
+
|
57 |
+
Install [`colpali-engine`](https://github.com/illuin-tech/colpali):
|
58 |
+
|
59 |
+
```bash
|
60 |
+
pip install colpali-engine>=0.3.4,<0.4.0
|
61 |
+
```
|
62 |
+
|
63 |
+
Then run the following code:
|
64 |
+
|
65 |
+
```python
|
66 |
+
from typing import cast
|
67 |
+
|
68 |
+
import torch
|
69 |
+
from PIL import Image
|
70 |
+
|
71 |
+
from colpali_engine.models import ColPali, ColPaliProcessor
|
72 |
+
|
73 |
+
model_name = "vidore/colpali2-3b-pt-448"
|
74 |
+
|
75 |
+
model = ColPali.from_pretrained(
|
76 |
+
model_name,
|
77 |
+
torch_dtype=torch.bfloat16,
|
78 |
+
device_map="cuda:0", # or "mps" if on Apple Silicon
|
79 |
+
).eval()
|
80 |
+
|
81 |
+
processor = ColPaliProcessor.from_pretrained(model_name)
|
82 |
+
|
83 |
+
# Your inputs
|
84 |
+
images = [
|
85 |
+
Image.new("RGB", (32, 32), color="white"),
|
86 |
+
Image.new("RGB", (16, 16), color="black"),
|
87 |
+
]
|
88 |
+
queries = [
|
89 |
+
"Is attention really all you need?",
|
90 |
+
"Are Benjamin, Antoine, Merve, and Jo best friends?",
|
91 |
+
]
|
92 |
+
|
93 |
+
# Process the inputs
|
94 |
+
batch_images = processor.process_images(images).to(model.device)
|
95 |
+
batch_queries = processor.process_queries(queries).to(model.device)
|
96 |
+
|
97 |
+
# Forward pass
|
98 |
+
with torch.no_grad():
|
99 |
+
image_embeddings = model(**batch_images)
|
100 |
+
querry_embeddings = model(**batch_queries)
|
101 |
+
|
102 |
+
scores = processor.score_multi_vector(querry_embeddings, image_embeddings)
|
103 |
+
```
|
104 |
+
|
105 |
+
## Limitations
|
106 |
+
|
107 |
+
- **Focus**: The model primarily focuses on PDF-type documents and high-ressources languages, potentially limiting its generalization to other document types or less represented languages.
|
108 |
+
- **Support**: The model relies on multi-vector retreiving derived from the ColBERT late interaction mechanism, which may require engineering efforts to adapt to widely used vector retrieval frameworks that lack native multi-vector support.
|
109 |
+
|
110 |
+
## License
|
111 |
+
|
112 |
+
ColPali's vision language backbone model (PaliGemma) is under `gemma` license as specified in its [model card](https://huggingface.co/google/paligemma-3b-mix-448). The adapters attached to the model are under MIT license.
|
113 |
+
|
114 |
+
## Contact
|
115 |
+
|
116 |
+
- Manuel Faysse: manuel.faysse@illuin.tech
|
117 |
+
- Hugues Sibille: hugues.sibille@illuin.tech
|
118 |
+
- Tony Wu: tony.wu@illuin.tech
|
119 |
+
|
120 |
+
## Citation
|
121 |
+
|
122 |
+
If you use any datasets or models from this organization in your research, please cite the original dataset as follows:
|
123 |
+
|
124 |
+
```bibtex
|
125 |
+
@misc{faysse2024colpaliefficientdocumentretrieval,
|
126 |
+
title={ColPali: Efficient Document Retrieval with Vision Language Models},
|
127 |
+
author={Manuel Faysse and Hugues Sibille and Tony Wu and Bilel Omrani and Gautier Viaud and Céline Hudelot and Pierre Colombo},
|
128 |
+
year={2024},
|
129 |
+
eprint={2407.01449},
|
130 |
+
archivePrefix={arXiv},
|
131 |
+
primaryClass={cs.IR},
|
132 |
+
url={https://arxiv.org/abs/2407.01449},
|
133 |
+
}
|
134 |
+
```
|