tattrongvu
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -46,4 +46,74 @@ The dataset was extended from the original colpali train set with the gemini 1.5
|
|
46 |
We train models use low-rank adapters ([LoRA](https://arxiv.org/abs/2106.09685))
|
47 |
with `alpha=128` and `r=128` on the transformer layers from the language model,
|
48 |
as well as the final randomly initialized projection layer, and use a `paged_adamw_8bit` optimizer.
|
49 |
-
We train on an 8xH100 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, in `bfloat16` format
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
We train models use low-rank adapters ([LoRA](https://arxiv.org/abs/2106.09685))
|
47 |
with `alpha=128` and `r=128` on the transformer layers from the language model,
|
48 |
as well as the final randomly initialized projection layer, and use a `paged_adamw_8bit` optimizer.
|
49 |
+
We train on an 8xH100 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, in `bfloat16` format
|
50 |
+
|
51 |
+
## Usage
|
52 |
+
|
53 |
+
Make sure `colpali-engine` is installed from source or with a version superior to 0.3.4.
|
54 |
+
`transformers` version must be > 4.46.1.
|
55 |
+
|
56 |
+
```bash
|
57 |
+
pip install git+https://github.com/illuin-tech/colpali
|
58 |
+
```
|
59 |
+
|
60 |
+
```python
|
61 |
+
import torch
|
62 |
+
from PIL import Image
|
63 |
+
|
64 |
+
from colpali_engine.models import ColQwen2, ColQwen2Processor
|
65 |
+
|
66 |
+
model = ColQwen2.from_pretrained(
|
67 |
+
"tsystems/colqwen2-2b-v1.0",
|
68 |
+
torch_dtype=torch.bfloat16,
|
69 |
+
device_map="cuda:0", # or "mps" if on Apple Silicon
|
70 |
+
).eval()
|
71 |
+
processor = ColQwen2Processor.from_pretrained("tsystems/colqwen2-2b-v1.0")
|
72 |
+
|
73 |
+
# Your inputs
|
74 |
+
images = [
|
75 |
+
Image.new("RGB", (32, 32), color="white"),
|
76 |
+
Image.new("RGB", (16, 16), color="black"),
|
77 |
+
]
|
78 |
+
queries = [
|
79 |
+
"Is attention really all you need?",
|
80 |
+
"What is the amount of bananas farmed in Salvador?",
|
81 |
+
]
|
82 |
+
|
83 |
+
# Process the inputs
|
84 |
+
batch_images = processor.process_images(images).to(model.device)
|
85 |
+
batch_queries = processor.process_queries(queries).to(model.device)
|
86 |
+
|
87 |
+
# Forward pass
|
88 |
+
with torch.no_grad():
|
89 |
+
image_embeddings = model(**batch_images)
|
90 |
+
query_embeddings = model(**batch_queries)
|
91 |
+
|
92 |
+
scores = processor.score_multi_vector(query_embeddings, image_embeddings)
|
93 |
+
```
|
94 |
+
|
95 |
+
|
96 |
+
## Limitations
|
97 |
+
|
98 |
+
- **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.
|
99 |
+
- **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.
|
100 |
+
|
101 |
+
## License
|
102 |
+
|
103 |
+
ColQwen2's vision language backbone model (Qwen2-VL) is under `apache2.0` license. The adapters attached to the model are under MIT license.
|
104 |
+
|
105 |
+
## Citation
|
106 |
+
|
107 |
+
If you use any datasets or models from this organization in your research, please cite the original dataset as follows:
|
108 |
+
|
109 |
+
```bibtex
|
110 |
+
@misc{faysse2024colpaliefficientdocumentretrieval,
|
111 |
+
title={ColPali: Efficient Document Retrieval with Vision Language Models},
|
112 |
+
author={Manuel Faysse and Hugues Sibille and Tony Wu and Bilel Omrani and Gautier Viaud and Céline Hudelot and Pierre Colombo},
|
113 |
+
year={2024},
|
114 |
+
eprint={2407.01449},
|
115 |
+
archivePrefix={arXiv},
|
116 |
+
primaryClass={cs.IR},
|
117 |
+
url={https://arxiv.org/abs/2407.01449},
|
118 |
+
}
|
119 |
+
```
|