visual-rag-toolkit 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/PKG-INFO +87 -15
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/README.md +86 -14
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/indexing.py +31 -2
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/pyproject.toml +1 -1
- visual_rag_toolkit-0.1.1/benchmarks/vidore_tatdqa_test/COMMANDS.md +0 -83
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/.github/workflows/ci.yaml +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/.github/workflows/publish_pypi.yaml +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/.gitignore +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/LICENSE +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/README.md +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/analyze_results.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/benchmark_datasets.txt +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/prepare_submission.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/quick_test.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/run_vidore.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_beir_qdrant/run_qdrant_beir.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/dataset_loader.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/metrics.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/run_qdrant.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/sweep_eval.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/app.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/commands.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/config.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/download_models.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/evaluation.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/example_metadata_mapping_sigir.json +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/qdrant_utils.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/results.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/test_qdrant_connection.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/ui/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/ui/benchmark.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/ui/header.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/ui/playground.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/ui/sidebar.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/ui/upload.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/examples/config.yaml +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/examples/process_pdfs.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/examples/search_demo.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/requirements.txt +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/tests/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/tests/test_config.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/tests/test_pdf_processor.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/tests/test_pooling.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/tests/test_strategies.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/cli/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/cli/main.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/config.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/demo_runner.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/embedding/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/embedding/pooling.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/embedding/visual_embedder.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/indexing/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/indexing/cloudinary_uploader.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/indexing/pdf_processor.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/indexing/pipeline.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/indexing/qdrant_indexer.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/preprocessing/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/preprocessing/crop_empty.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/qdrant_admin.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/retrieval/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/retrieval/multi_vector.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/retrieval/single_stage.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/retrieval/three_stage.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/retrieval/two_stage.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/visualization/__init__.py +0 -0
- {visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/visualization/saliency.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: visual-rag-toolkit
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: End-to-end visual document retrieval with ColPali, featuring two-stage pooling for scalable search
|
|
5
5
|
Project-URL: Homepage, https://github.com/Ara-Yeroyan/visual-rag-toolkit
|
|
6
6
|
Project-URL: Documentation, https://github.com/Ara-Yeroyan/visual-rag-toolkit#readme
|
|
@@ -85,10 +85,14 @@ Description-Content-Type: text/markdown
|
|
|
85
85
|
|
|
86
86
|
# Visual RAG Toolkit
|
|
87
87
|
|
|
88
|
-
[](https://pypi.org/project/visual-rag-toolkit/)
|
|
89
|
+
[](https://pypi.org/project/visual-rag-toolkit/)
|
|
90
|
+
[](LICENSE)
|
|
91
|
+
[](https://github.com/Ara-Yeroyan/visual-rag-toolkit/actions/workflows/ci.yaml)
|
|
92
|
+
|
|
93
|
+
Note:
|
|
94
|
+
- The **PyPI badge** shows “not found” until the first release is published.
|
|
95
|
+
- The **CI badge** requires the GitHub repo to be **public** (GitHub does not serve Actions badges for private repos).
|
|
92
96
|
|
|
93
97
|
End-to-end visual document retrieval toolkit featuring **fast multi-stage retrieval** (prefetch with pooled vectors + exact MaxSim reranking).
|
|
94
98
|
|
|
@@ -112,11 +116,10 @@ This repo contains:
|
|
|
112
116
|
pip install visual-rag-toolkit
|
|
113
117
|
|
|
114
118
|
# With specific features
|
|
115
|
-
pip install visual-rag-toolkit[
|
|
116
|
-
pip install visual-rag-toolkit[pdf] # PDF processing
|
|
119
|
+
pip install visual-rag-toolkit[ui] # Streamlit demo dependencies
|
|
117
120
|
pip install visual-rag-toolkit[qdrant] # Vector database
|
|
121
|
+
pip install visual-rag-toolkit[embedding] # ColSmol/ColPali embedding support
|
|
118
122
|
pip install visual-rag-toolkit[cloudinary] # Image CDN
|
|
119
|
-
pip install visual-rag-toolkit[ui] # Streamlit demo dependencies
|
|
120
123
|
|
|
121
124
|
# All dependencies
|
|
122
125
|
pip install visual-rag-toolkit[all]
|
|
@@ -157,6 +160,80 @@ for r in results[:3]:
|
|
|
157
160
|
print(r["id"], r["score_final"])
|
|
158
161
|
```
|
|
159
162
|
|
|
163
|
+
### End-to-end: ingest PDFs (with cropping) → index in Qdrant
|
|
164
|
+
|
|
165
|
+
This is the “SDK-style” pipeline: PDF → images → optional crop → embed → store vectors + payload in Qdrant.
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
import os
|
|
169
|
+
from pathlib import Path
|
|
170
|
+
|
|
171
|
+
import numpy as np
|
|
172
|
+
import torch
|
|
173
|
+
|
|
174
|
+
from visual_rag import VisualEmbedder
|
|
175
|
+
from visual_rag.indexing import ProcessingPipeline, QdrantIndexer
|
|
176
|
+
|
|
177
|
+
QDRANT_URL = os.environ["SIGIR_QDRANT_URL"] # or QDRANT_URL
|
|
178
|
+
QDRANT_KEY = os.getenv("SIGIR_QDRANT_KEY", "") # or QDRANT_API_KEY
|
|
179
|
+
|
|
180
|
+
collection = "my_visual_docs"
|
|
181
|
+
|
|
182
|
+
embedder = VisualEmbedder(
|
|
183
|
+
model_name="vidore/colSmol-500M",
|
|
184
|
+
torch_dtype=torch.float16,
|
|
185
|
+
output_dtype=np.float16,
|
|
186
|
+
batch_size=8,
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
indexer = QdrantIndexer(
|
|
190
|
+
url=QDRANT_URL,
|
|
191
|
+
api_key=QDRANT_KEY,
|
|
192
|
+
collection_name=collection,
|
|
193
|
+
prefer_grpc=True,
|
|
194
|
+
vector_datatype="float16",
|
|
195
|
+
)
|
|
196
|
+
indexer.create_collection(force_recreate=False)
|
|
197
|
+
|
|
198
|
+
pipeline = ProcessingPipeline(
|
|
199
|
+
embedder=embedder,
|
|
200
|
+
indexer=indexer,
|
|
201
|
+
embedding_strategy="all", # store full tokens + pooled vectors in one pass
|
|
202
|
+
crop_empty=True,
|
|
203
|
+
crop_empty_percentage_to_remove=0.99, # kept for traceability
|
|
204
|
+
crop_empty_remove_page_number=True,
|
|
205
|
+
crop_empty_preserve_border_px=1,
|
|
206
|
+
crop_empty_uniform_rowcol_std_threshold=3.0,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
pdfs = [Path("docs/a.pdf"), Path("docs/b.pdf")]
|
|
210
|
+
for pdf_path in pdfs:
|
|
211
|
+
pipeline.process_pdf(
|
|
212
|
+
pdf_path,
|
|
213
|
+
skip_existing=True,
|
|
214
|
+
upload_to_cloudinary=False,
|
|
215
|
+
upload_to_qdrant=True,
|
|
216
|
+
)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
CLI equivalent:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
export SIGIR_QDRANT_URL="https://YOUR_QDRANT"
|
|
223
|
+
export SIGIR_QDRANT_KEY="YOUR_KEY"
|
|
224
|
+
|
|
225
|
+
visual-rag process \
|
|
226
|
+
--reports-dir ./docs \
|
|
227
|
+
--collection my_visual_docs \
|
|
228
|
+
--model vidore/colSmol-500M \
|
|
229
|
+
--strategy all \
|
|
230
|
+
--batch-size 8 \
|
|
231
|
+
--qdrant-vector-dtype float16 \
|
|
232
|
+
--prefer-grpc \
|
|
233
|
+
--crop-empty \
|
|
234
|
+
--crop-empty-remove-page-number
|
|
235
|
+
```
|
|
236
|
+
|
|
160
237
|
### Process a PDF into images (no embedding, no vector DB)
|
|
161
238
|
|
|
162
239
|
```python
|
|
@@ -209,16 +286,11 @@ visual-rag-toolkit/
|
|
|
209
286
|
Configure via environment variables or YAML:
|
|
210
287
|
|
|
211
288
|
```bash
|
|
212
|
-
# Qdrant credentials (preferred names used by the demo + scripts)
|
|
213
|
-
export SIGIR_QDRANT_URL="https://your-cluster.qdrant.io"
|
|
214
|
-
export SIGIR_QDRANT_KEY="your-api-key"
|
|
215
289
|
|
|
216
|
-
#
|
|
290
|
+
# Qdrant credentials (preferred names used by the demo + scripts)
|
|
217
291
|
export QDRANT_URL="https://your-cluster.qdrant.io"
|
|
218
292
|
export QDRANT_API_KEY="your-api-key"
|
|
219
293
|
|
|
220
|
-
export VISUALRAG_MODEL="vidore/colSmol-500M"
|
|
221
|
-
|
|
222
294
|
# Special token handling (default: filter them out)
|
|
223
295
|
export VISUALRAG_INCLUDE_SPECIAL_TOKENS=true # Include special tokens
|
|
224
296
|
```
|
|
@@ -269,7 +341,7 @@ python -m benchmarks.vidore_beir_qdrant.run_qdrant_beir \
|
|
|
269
341
|
```
|
|
270
342
|
|
|
271
343
|
More commands (including multi-stage variants and cropping configs) live in:
|
|
272
|
-
- `
|
|
344
|
+
- `examples/COMMANDS.md`
|
|
273
345
|
|
|
274
346
|
## 🔧 Development
|
|
275
347
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# Visual RAG Toolkit
|
|
2
2
|
|
|
3
|
-
[](https://pypi.org/project/visual-rag-toolkit/)
|
|
4
|
+
[](https://pypi.org/project/visual-rag-toolkit/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/Ara-Yeroyan/visual-rag-toolkit/actions/workflows/ci.yaml)
|
|
7
|
+
|
|
8
|
+
Note:
|
|
9
|
+
- The **PyPI badge** shows “not found” until the first release is published.
|
|
10
|
+
- The **CI badge** requires the GitHub repo to be **public** (GitHub does not serve Actions badges for private repos).
|
|
7
11
|
|
|
8
12
|
End-to-end visual document retrieval toolkit featuring **fast multi-stage retrieval** (prefetch with pooled vectors + exact MaxSim reranking).
|
|
9
13
|
|
|
@@ -27,11 +31,10 @@ This repo contains:
|
|
|
27
31
|
pip install visual-rag-toolkit
|
|
28
32
|
|
|
29
33
|
# With specific features
|
|
30
|
-
pip install visual-rag-toolkit[
|
|
31
|
-
pip install visual-rag-toolkit[pdf] # PDF processing
|
|
34
|
+
pip install visual-rag-toolkit[ui] # Streamlit demo dependencies
|
|
32
35
|
pip install visual-rag-toolkit[qdrant] # Vector database
|
|
36
|
+
pip install visual-rag-toolkit[embedding] # ColSmol/ColPali embedding support
|
|
33
37
|
pip install visual-rag-toolkit[cloudinary] # Image CDN
|
|
34
|
-
pip install visual-rag-toolkit[ui] # Streamlit demo dependencies
|
|
35
38
|
|
|
36
39
|
# All dependencies
|
|
37
40
|
pip install visual-rag-toolkit[all]
|
|
@@ -72,6 +75,80 @@ for r in results[:3]:
|
|
|
72
75
|
print(r["id"], r["score_final"])
|
|
73
76
|
```
|
|
74
77
|
|
|
78
|
+
### End-to-end: ingest PDFs (with cropping) → index in Qdrant
|
|
79
|
+
|
|
80
|
+
This is the “SDK-style” pipeline: PDF → images → optional crop → embed → store vectors + payload in Qdrant.
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
import os
|
|
84
|
+
from pathlib import Path
|
|
85
|
+
|
|
86
|
+
import numpy as np
|
|
87
|
+
import torch
|
|
88
|
+
|
|
89
|
+
from visual_rag import VisualEmbedder
|
|
90
|
+
from visual_rag.indexing import ProcessingPipeline, QdrantIndexer
|
|
91
|
+
|
|
92
|
+
QDRANT_URL = os.environ["SIGIR_QDRANT_URL"] # or QDRANT_URL
|
|
93
|
+
QDRANT_KEY = os.getenv("SIGIR_QDRANT_KEY", "") # or QDRANT_API_KEY
|
|
94
|
+
|
|
95
|
+
collection = "my_visual_docs"
|
|
96
|
+
|
|
97
|
+
embedder = VisualEmbedder(
|
|
98
|
+
model_name="vidore/colSmol-500M",
|
|
99
|
+
torch_dtype=torch.float16,
|
|
100
|
+
output_dtype=np.float16,
|
|
101
|
+
batch_size=8,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
indexer = QdrantIndexer(
|
|
105
|
+
url=QDRANT_URL,
|
|
106
|
+
api_key=QDRANT_KEY,
|
|
107
|
+
collection_name=collection,
|
|
108
|
+
prefer_grpc=True,
|
|
109
|
+
vector_datatype="float16",
|
|
110
|
+
)
|
|
111
|
+
indexer.create_collection(force_recreate=False)
|
|
112
|
+
|
|
113
|
+
pipeline = ProcessingPipeline(
|
|
114
|
+
embedder=embedder,
|
|
115
|
+
indexer=indexer,
|
|
116
|
+
embedding_strategy="all", # store full tokens + pooled vectors in one pass
|
|
117
|
+
crop_empty=True,
|
|
118
|
+
crop_empty_percentage_to_remove=0.99, # kept for traceability
|
|
119
|
+
crop_empty_remove_page_number=True,
|
|
120
|
+
crop_empty_preserve_border_px=1,
|
|
121
|
+
crop_empty_uniform_rowcol_std_threshold=3.0,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
pdfs = [Path("docs/a.pdf"), Path("docs/b.pdf")]
|
|
125
|
+
for pdf_path in pdfs:
|
|
126
|
+
pipeline.process_pdf(
|
|
127
|
+
pdf_path,
|
|
128
|
+
skip_existing=True,
|
|
129
|
+
upload_to_cloudinary=False,
|
|
130
|
+
upload_to_qdrant=True,
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
CLI equivalent:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
export SIGIR_QDRANT_URL="https://YOUR_QDRANT"
|
|
138
|
+
export SIGIR_QDRANT_KEY="YOUR_KEY"
|
|
139
|
+
|
|
140
|
+
visual-rag process \
|
|
141
|
+
--reports-dir ./docs \
|
|
142
|
+
--collection my_visual_docs \
|
|
143
|
+
--model vidore/colSmol-500M \
|
|
144
|
+
--strategy all \
|
|
145
|
+
--batch-size 8 \
|
|
146
|
+
--qdrant-vector-dtype float16 \
|
|
147
|
+
--prefer-grpc \
|
|
148
|
+
--crop-empty \
|
|
149
|
+
--crop-empty-remove-page-number
|
|
150
|
+
```
|
|
151
|
+
|
|
75
152
|
### Process a PDF into images (no embedding, no vector DB)
|
|
76
153
|
|
|
77
154
|
```python
|
|
@@ -124,16 +201,11 @@ visual-rag-toolkit/
|
|
|
124
201
|
Configure via environment variables or YAML:
|
|
125
202
|
|
|
126
203
|
```bash
|
|
127
|
-
# Qdrant credentials (preferred names used by the demo + scripts)
|
|
128
|
-
export SIGIR_QDRANT_URL="https://your-cluster.qdrant.io"
|
|
129
|
-
export SIGIR_QDRANT_KEY="your-api-key"
|
|
130
204
|
|
|
131
|
-
#
|
|
205
|
+
# Qdrant credentials (preferred names used by the demo + scripts)
|
|
132
206
|
export QDRANT_URL="https://your-cluster.qdrant.io"
|
|
133
207
|
export QDRANT_API_KEY="your-api-key"
|
|
134
208
|
|
|
135
|
-
export VISUALRAG_MODEL="vidore/colSmol-500M"
|
|
136
|
-
|
|
137
209
|
# Special token handling (default: filter them out)
|
|
138
210
|
export VISUALRAG_INCLUDE_SPECIAL_TOKENS=true # Include special tokens
|
|
139
211
|
```
|
|
@@ -184,7 +256,7 @@ python -m benchmarks.vidore_beir_qdrant.run_qdrant_beir \
|
|
|
184
256
|
```
|
|
185
257
|
|
|
186
258
|
More commands (including multi-stage variants and cropping configs) live in:
|
|
187
|
-
- `
|
|
259
|
+
- `examples/COMMANDS.md`
|
|
188
260
|
|
|
189
261
|
## 🔧 Development
|
|
190
262
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"""Indexing runner with UI updates."""
|
|
2
2
|
|
|
3
3
|
import hashlib
|
|
4
|
+
import importlib.util
|
|
4
5
|
import json
|
|
5
6
|
import time
|
|
6
7
|
import traceback
|
|
7
8
|
from datetime import datetime
|
|
9
|
+
from pathlib import Path
|
|
8
10
|
from typing import Any, Dict, Optional
|
|
9
11
|
|
|
10
12
|
import numpy as np
|
|
@@ -19,8 +21,35 @@ TORCH_DTYPE_MAP = {
|
|
|
19
21
|
"float32": torch.float32,
|
|
20
22
|
"bfloat16": torch.bfloat16,
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
|
|
25
|
+
# --- Robust imports (Spaces-friendly) ---
|
|
26
|
+
# Some environments can have a third-party `benchmarks` package installed, or
|
|
27
|
+
# resolve `visual_rag.indexing` oddly. These fallbacks keep the demo working.
|
|
28
|
+
try:
|
|
29
|
+
from visual_rag.indexing import QdrantIndexer
|
|
30
|
+
except Exception: # pragma: no cover
|
|
31
|
+
from visual_rag.indexing.qdrant_indexer import QdrantIndexer
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _load_local_benchmark_module(module_filename: str):
|
|
35
|
+
root = Path(__file__).resolve().parents[1] # demo/.. = repo root
|
|
36
|
+
target = root / "benchmarks" / "vidore_tatdqa_test" / module_filename
|
|
37
|
+
if not target.exists():
|
|
38
|
+
raise ModuleNotFoundError(f"Missing local benchmark module file: {target}")
|
|
39
|
+
name = f"_visual_rag_toolkit_local_{target.stem}"
|
|
40
|
+
spec = importlib.util.spec_from_file_location(name, str(target))
|
|
41
|
+
if spec is None or spec.loader is None:
|
|
42
|
+
raise ModuleNotFoundError(f"Could not load module spec for: {target}")
|
|
43
|
+
mod = importlib.util.module_from_spec(spec)
|
|
44
|
+
spec.loader.exec_module(mod) # type: ignore[attr-defined]
|
|
45
|
+
return mod
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
from benchmarks.vidore_tatdqa_test.dataset_loader import load_vidore_beir_dataset
|
|
50
|
+
except ModuleNotFoundError: # pragma: no cover
|
|
51
|
+
_dl = _load_local_benchmark_module("dataset_loader.py")
|
|
52
|
+
load_vidore_beir_dataset = _dl.load_vidore_beir_dataset
|
|
24
53
|
|
|
25
54
|
from demo.qdrant_utils import get_qdrant_credentials
|
|
26
55
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "visual-rag-toolkit"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "End-to-end visual document retrieval with ColPali, featuring two-stage pooling for scalable search"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {file = "LICENSE"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# ViDoRe TAT-DQA (Qdrant) — commands
|
|
2
|
-
|
|
3
|
-
## Environment
|
|
4
|
-
|
|
5
|
-
Either export:
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
export QDRANT_URL="..."
|
|
9
|
-
export QDRANT_API_KEY="..." # optional
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Or create a `.env` file in `visual-rag-toolkit/` with the same variables.
|
|
13
|
-
|
|
14
|
-
## Index + evaluate (single run)
|
|
15
|
-
|
|
16
|
-
This is the “all-in-one” script (indexes, then evaluates once):
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
python -m benchmarks.vidore_tatdqa_test.run_qdrant \
|
|
20
|
-
--dataset vidore/tatdqa_test \
|
|
21
|
-
--collection vidore_tatdqa_test \
|
|
22
|
-
--recreate --index \
|
|
23
|
-
--indexing-threshold 0 \
|
|
24
|
-
--batch-size 6 \
|
|
25
|
-
--upload-batch-size 12 \
|
|
26
|
-
--upload-workers 0 \
|
|
27
|
-
--loader-workers 0 \
|
|
28
|
-
--prefer-grpc \
|
|
29
|
-
--torch-dtype float16 \
|
|
30
|
-
--no-upsert-wait \
|
|
31
|
-
--qdrant-vector-dtype float16
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Evaluate only (no re-index) — baseline + sweeps
|
|
35
|
-
|
|
36
|
-
These commands assume the Qdrant collection already exists and is populated.
|
|
37
|
-
|
|
38
|
-
### Baseline: single-stage full MaxSim
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
python -m benchmarks.vidore_tatdqa_test.sweep_eval \
|
|
42
|
-
--dataset vidore/tatdqa_test \
|
|
43
|
-
--collection vidore_tatdqa_test \
|
|
44
|
-
--prefer-grpc \
|
|
45
|
-
--mode single_full \
|
|
46
|
-
--torch-dtype auto \
|
|
47
|
-
--query-batch-size 32 \
|
|
48
|
-
--top-k 10 \
|
|
49
|
-
--out-dir results/sweeps
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Two-stage sweep (preferred): stage-1 tokens vs tiles, stage-2 full rerank
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
python -m benchmarks.vidore_tatdqa_test.sweep_eval \
|
|
56
|
-
--dataset vidore/tatdqa_test \
|
|
57
|
-
--collection vidore_tatdqa_test \
|
|
58
|
-
--prefer-grpc \
|
|
59
|
-
--mode two_stage \
|
|
60
|
-
--stage1-mode tokens_vs_tiles \
|
|
61
|
-
--prefetch-ks 20,50,100,200,400 \
|
|
62
|
-
--torch-dtype auto \
|
|
63
|
-
--query-batch-size 32 \
|
|
64
|
-
--top-k 10 \
|
|
65
|
-
--out-dir results/sweeps
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Smoke test (optional): run only N queries
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
python -m benchmarks.vidore_tatdqa_test.sweep_eval \
|
|
72
|
-
--dataset vidore/tatdqa_test \
|
|
73
|
-
--collection vidore_tatdqa_test \
|
|
74
|
-
--prefer-grpc \
|
|
75
|
-
--mode single_full \
|
|
76
|
-
--torch-dtype auto \
|
|
77
|
-
--query-batch-size 32 \
|
|
78
|
-
--top-k 10 \
|
|
79
|
-
--max-queries 50 \
|
|
80
|
-
--out-dir results/sweeps
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/metrics.py
RENAMED
|
File without changes
|
{visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/run_qdrant.py
RENAMED
|
File without changes
|
{visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/benchmarks/vidore_tatdqa_test/sweep_eval.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/demo/example_metadata_mapping_sigir.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/embedding/visual_embedder.py
RENAMED
|
File without changes
|
|
File without changes
|
{visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/indexing/cloudinary_uploader.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{visual_rag_toolkit-0.1.1 → visual_rag_toolkit-0.1.2}/visual_rag/preprocessing/crop_empty.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|