Update README.md
Browse files
README.md
CHANGED
@@ -40,6 +40,54 @@ tags:
|
|
40 |
| Llama Index vdr-2b-multi-v1 | 58.4 | 63.1 | 52.8 | 61.0 | 60.6 | 50.3 | 51.2 | 56.9 | 68.8 | 61.2 |
|
41 |
| Voyage Multimodal 3 | 55.0 | 56.1 | 55.0 | 59.5 | 56.4 | 47.2 | 46.2 | 51.5 | 64.1 | 58.8 |
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
## Model Architecture
|
44 |
|
45 |
- **Total Parameters**: 3B
|
|
|
40 |
| Llama Index vdr-2b-multi-v1 | 58.4 | 63.1 | 52.8 | 61.0 | 60.6 | 50.3 | 51.2 | 56.9 | 68.8 | 61.2 |
|
41 |
| Voyage Multimodal 3 | 55.0 | 56.1 | 55.0 | 59.5 | 56.4 | 47.2 | 46.2 | 51.5 | 64.1 | 58.8 |
|
42 |
|
43 |
+
To use `colnomic-embed-multimodal-7b`, please install `colpali` from source
|
44 |
+
|
45 |
+
```bash
|
46 |
+
pip install git+https://github.com/nomic-ai/colpali.git
|
47 |
+
```
|
48 |
+
|
49 |
+
|
50 |
+
```python
|
51 |
+
import torch
|
52 |
+
from PIL import Image
|
53 |
+
from transformers.utils.import_utils import is_flash_attn_2_available
|
54 |
+
|
55 |
+
from colpali_engine.models import ColQwen2_5, ColQwen2_5_Processor
|
56 |
+
|
57 |
+
model_name = "nomic-ai/colnomic-embed-multimodal-3b"
|
58 |
+
|
59 |
+
model = ColQwen2_5.from_pretrained(
|
60 |
+
model_name,
|
61 |
+
torch_dtype=torch.bfloat16,
|
62 |
+
device_map="cuda:0", # or "mps" if on Apple Silicon
|
63 |
+
attn_implementation="flash_attention_2" if is_flash_attn_2_available() else None,
|
64 |
+
).eval()
|
65 |
+
|
66 |
+
processor = ColQwen2_5_Processor.from_pretrained(model_name)
|
67 |
+
|
68 |
+
# Your inputs
|
69 |
+
images = [
|
70 |
+
Image.new("RGB", (128, 128), color="white"),
|
71 |
+
Image.new("RGB", (64, 32), color="black"),
|
72 |
+
]
|
73 |
+
queries = [
|
74 |
+
"What is the organizational structure for our R&D department?",
|
75 |
+
"Can you provide a breakdown of last year’s financial performance?",
|
76 |
+
]
|
77 |
+
|
78 |
+
# Process the inputs
|
79 |
+
batch_images = processor.process_images(images).to(model.device)
|
80 |
+
batch_queries = processor.process_queries(queries).to(model.device)
|
81 |
+
|
82 |
+
# Forward pass
|
83 |
+
with torch.no_grad():
|
84 |
+
image_embeddings = model(**batch_images)
|
85 |
+
query_embeddings = model(**batch_queries)
|
86 |
+
|
87 |
+
scores = processor.score_multi_vector(query_embeddings, image_embeddings)
|
88 |
+
```
|
89 |
+
|
90 |
+
|
91 |
## Model Architecture
|
92 |
|
93 |
- **Total Parameters**: 3B
|