Update README.md
Browse files
README.md
CHANGED
@@ -1,202 +1,149 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
library_name: peft
|
|
|
4 |
---
|
|
|
5 |
|
6 |
-
#
|
7 |
|
8 |
-
|
9 |
|
|
|
|
|
|
|
10 |
|
|
|
11 |
|
12 |
-
##
|
13 |
|
14 |
-
### Model Description
|
15 |
|
16 |
-
|
|
|
17 |
|
|
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
|
|
|
|
45 |
|
46 |
-
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
|
|
|
|
53 |
|
54 |
-
|
|
|
|
|
|
|
55 |
|
56 |
-
|
|
|
57 |
|
58 |
-
## Bias, Risks, and Limitations
|
59 |
|
60 |
-
|
61 |
|
62 |
-
|
|
|
63 |
|
64 |
-
|
65 |
|
66 |
-
|
67 |
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
|
70 |
-
##
|
71 |
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
200 |
-
### Framework versions
|
201 |
-
|
202 |
-
- PEFT 0.11.1
|
|
|
1 |
---
|
2 |
+
license: cc-by-nc-4.0
|
3 |
+
datasets:
|
4 |
+
- openbmb/VisRAG-Ret-Train-Synthetic-data
|
5 |
+
- openbmb/VisRAG-Ret-Train-In-domain-data
|
6 |
+
- Metric-AI/rag_docmatix_100k
|
7 |
+
- vidore/colpali_train_set
|
8 |
+
- llamaindex/vdr-multilingual-train
|
9 |
+
- Metric-AI/tabfquad_train_set
|
10 |
+
language:
|
11 |
+
- en
|
12 |
+
- fr
|
13 |
+
- es
|
14 |
+
- it
|
15 |
+
- de
|
16 |
+
base_model:
|
17 |
+
- Qwen/Qwen2.5-VL-3B-Instruct
|
18 |
+
tags:
|
19 |
+
- vidore
|
20 |
+
- multimodal_embedding
|
21 |
+
- multilingual_embedding
|
22 |
+
- Text-to-Visual Document (T→VD) retrieval
|
23 |
library_name: peft
|
24 |
+
pipeline_tag: visual-document-retrieval
|
25 |
---
|
26 |
+
# ColQwen2.5-3b-multilingual: Multilingual Visual Retriever based on Qwen2.5-VL-3B-Instruct with ColBERT strategy
|
27 |
|
28 |
+
## Ranked #1 among models smaller than 7B parameters and #2 overall on the Vidore benchmark (as of February 11, 2025). The reported scores on the [Vidore Leaderboard](https://huggingface.co/spaces/vidore/vidore-leaderboard) correspond to checkpoint-1800.
|
29 |
|
30 |
+
### This is the base version trained on 4xA100 80GB with per_device_batch_size=128 and gradient_accumulation_steps=2 for 5 epoch.
|
31 |
|
32 |
+
ColQwen 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.
|
33 |
+
It is a [Qwen2.5-VL-3B](https://huggingface.co/Qwen/Qwen2.5-VL-3B-Instruct) extension that generates [ColBERT](https://arxiv.org/abs/2004.12832)- style multi-vector representations of text and images.
|
34 |
+
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)
|
35 |
|
36 |
+
<p align="center"><img width=800 src="https://github.com/illuin-tech/colpali/blob/main/assets/colpali_architecture.webp?raw=true"/></p>
|
37 |
|
38 |
+
## Version specificity
|
39 |
|
|
|
40 |
|
41 |
+
This model takes dynamic image resolutions in input and does not resize them, changing their aspect ratio as in ColPali.
|
42 |
+
Maximal resolution is set so that 768 image patches are created at most. Experiments show clear improvements with larger amounts of image patches, at the cost of memory requirements.
|
43 |
|
44 |
+
This version is trained with `colpali-engine==0.3.7`.
|
45 |
|
46 |
+
## Data
|
47 |
+
- **Synthetic data**: Selected and preprocessed from the `openbmb/VisRAG-Ret-Train-Synthetic-data` dataset.
|
48 |
+
- **In-domain VQA dataset**: Drawn from `openbmb/VisRAG-Ret-Train-In-domain-data`.
|
49 |
+
- **Docmatix dataset**: Extracted from the `Metric-AI/rag_docmatix_100k` dataset.
|
50 |
+
- **Colpali dataset**: Taken from `vidore/colpali_train_set`.
|
51 |
+
- **Multilingual dataset**: Taken from `llamaindex/vdr-multilingual-train`.
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
+
## Model Training
|
55 |
|
56 |
+
### Parameters
|
57 |
+
We train models use low-rank adapters ([LoRA](https://arxiv.org/abs/2106.09685))
|
58 |
+
with `alpha=128` and `r=128` on the transformer layers from the language model,
|
59 |
+
as well as the final randomly initialized projection layer, and use a `paged_adamw_8bit` optimizer.
|
60 |
+
We train on an 4xA100 GPU setup with distributed data parallelism (via accelerate), a learning rate of 2e-4 with linear decay with 1% warmup steps, batch size per device is 128, gradient accumulation steps are 2, in `bfloat16` format
|
61 |
|
62 |
+
## Installation
|
|
|
|
|
63 |
|
64 |
+
Make sure `colpali-engine` is installed from source or with a version superior to 0.3.1.
|
65 |
+
`transformers` version must be > 4.45.0.
|
66 |
|
67 |
+
### ColPali
|
68 |
+
```bash
|
69 |
+
pip install git+https://github.com/illuin-tech/colpali
|
70 |
+
```
|
71 |
+
or
|
72 |
+
```bash
|
73 |
+
pip install git+https://github.com/illuin-tech/colpali@colqwen2_5
|
74 |
+
```
|
75 |
|
76 |
+
### Qwen2.5
|
77 |
+
The code of Qwen2.5-VL has been in the latest Hugging face transformers and we advise you to build from source with command:
|
78 |
+
```
|
79 |
+
pip install git+https://github.com/huggingface/transformers accelerate
|
80 |
+
```
|
81 |
+
or you might encounter the following error:
|
82 |
+
```
|
83 |
+
KeyError: 'qwen2_5_vl'
|
84 |
+
```
|
85 |
|
86 |
+
## Usage
|
87 |
|
88 |
+
```python
|
89 |
+
import torch
|
90 |
+
from PIL import Image
|
91 |
|
92 |
+
from colpali_engine.models import ColQwen2_5, ColQwen2_5_Processor
|
93 |
|
94 |
+
model = ColQwen2_5.from_pretrained(
|
95 |
+
"Metric-AI/colqwen2.5-3b-multilingual",
|
96 |
+
torch_dtype=torch.bfloat16,
|
97 |
+
device_map="cuda:0", # or "mps" if on Apple Silicon
|
98 |
+
).eval()
|
99 |
+
processor = ColQwen2_5_Processor.from_pretrained("Metric-AI/colqwen2.5-3b-multilingual")
|
100 |
|
101 |
+
# Your inputs
|
102 |
+
images = [
|
103 |
+
Image.new("RGB", (32, 32), color="white"),
|
104 |
+
Image.new("RGB", (16, 16), color="black"),
|
105 |
+
]
|
106 |
+
queries = [
|
107 |
+
"Is attention really all you need?",
|
108 |
+
"What is the amount of bananas farmed in Salvador?",
|
109 |
+
]
|
110 |
|
111 |
+
# Process the inputs
|
112 |
+
batch_images = processor.process_images(images).to(model.device)
|
113 |
+
batch_queries = processor.process_queries(queries).to(model.device)
|
114 |
|
115 |
+
# Forward pass
|
116 |
+
with torch.no_grad():
|
117 |
+
image_embeddings = model(**batch_images)
|
118 |
+
query_embeddings = model(**batch_queries)
|
119 |
|
120 |
+
scores = processor.score_multi_vector(query_embeddings, image_embeddings)
|
121 |
+
```
|
122 |
|
|
|
123 |
|
124 |
+
## Limitations
|
125 |
|
126 |
+
- **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.
|
127 |
+
- **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.
|
128 |
|
129 |
+
## License
|
130 |
|
131 |
+
ColQwen2.5's vision language backbone model (Qwen2.5-VL) is under `apache2.0` license. The adapters attached to the model are under MIT license.
|
132 |
|
|
|
133 |
|
134 |
+
## Citation
|
135 |
|
136 |
+
If you use this models from this organization in your research, please cite the original paper as follows:
|
137 |
|
138 |
+
```bibtex
|
139 |
+
@misc{faysse2024colpaliefficientdocumentretrieval,
|
140 |
+
title={ColPali: Efficient Document Retrieval with Vision Language Models},
|
141 |
+
author={Manuel Faysse and Hugues Sibille and Tony Wu and Bilel Omrani and Gautier Viaud and Céline Hudelot and Pierre Colombo},
|
142 |
+
year={2024},
|
143 |
+
eprint={2407.01449},
|
144 |
+
archivePrefix={arXiv},
|
145 |
+
primaryClass={cs.IR},
|
146 |
+
url={https://arxiv.org/abs/2407.01449},
|
147 |
+
}
|
148 |
+
```
|
149 |
+
- **Developed by:** [Metric AI Research Lab](https://metric.am/)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|