Skip to main content

OptiVision RAG

Quality-constrained, model-agnostic multi-vector compression.

OptiVision compresses the index of a late-interaction (multi-vector, MaxSim) retriever, such as a ColPali-style page encoder or a ColBERT-style text encoder, to a quality target you set. Give it your encoder's vectors and a few hundred real sample queries. It chooses token merging, dimension reduction and quantization, and reports the retention it measured on queries that played no part in the choice.

from optivision import MultiVectorCorpus, optimize

docs = MultiVectorCorpus.from_arrays(doc_vectors)       # list of [n_i, d] arrays
queries = MultiVectorCorpus.from_arrays(query_vectors)  # real sample queries (required)
result = optimize(docs, queries=queries, qrels=labels_or_None, quality_target=0.97)

Measured on held-out queries with default settings (20 random splits, labels):

target ColPali · ViDoRe DocVQA ColPali · ViDoRe InfoVQA ColBERT-small · SciFact (text)
0.99 3.9x · met 20/20 · held-out 100.1% 3.9x · met 20/20 · held-out 99.9% 3.9x · met 14/14 · held-out 99.9%
0.97 3.9x · met 19/20 · held-out 99.7% 43.4x · met 20/20 · held-out 99.6% 8.0x · met 20/20 · held-out 99.4%
0.95 11.8x · met 20/20 · held-out 98.6% 72.7x · met 20/20 · held-out 98.9% 12.4x · met 20/20 · held-out 98.7%

Each cell: median compression chosen (vs float32) · splits whose choice met the target on the held-out half · mean held-out retention. At SciFact 0.99 no configuration qualified in 6 of 20 splits.

Tested coverage is exactly three encoders: ColPali-v1.3 (ViDoRe V1 DocVQA and InfoVQA, 500 pages each), ColSmol-256M (a 60-page generated corpus only) and answerai-colbert-small-v1 (BEIR SciFact). Other models' vectors are accepted, but their compression behaviour is unmeasured. ColQwen, 2k–4k-dimensional models, ViDoRe V2/V3, million-page corpora and database connectors beyond numpy/Qdrant are not validated.

There is no guarantee that a target is met. The confidence bound applies to each configuration individually; choosing among many configurations is a multiple-testing problem that it does not correct for. Measured corpora have 500–5,183 documents, and retention falls as a corpus grows. The measurements, their limits and a release audit are in the repository.

The original recipe: pruning and binary codes for page images

ColPali-style models search scanned documents as images, with no OCR. They store one 128-dimensional float vector per image patch, so a single page costs about 512 KB of index.

The first release shrinks the index, not the model. The published checkpoint runs unmodified and retrieval is still late-interaction MaxSim. Only the number and the size of the stored vectors change:

page image
   ├─ VLM encoder ─────────► ~1000 patch vectors        (model unchanged)
   ├─ 1. spatial pruning ──► drop patches on blank paper
   ├─ 2. redundancy prune ─► collapse near-duplicate patches
   ├─ 3. binary quantize ──► 128 floats (512 B) -> 128 bits (16 B)
   └─ index ───────────────► Qdrant MaxSim, or an exact numpy index
setting encoder / corpus compression nDCG@5 retained
prune + binary ColSmol-256M, generated pages 113.5x 86.7%
prune + int8 ColSmol-256M, generated pages 14.2x 96.0%
prune + binary ColPali-v1.3, ViDoRe (4 splits) 53-60x 94.6-103.4%

Full results, the ablations and the analysis are in the repository.

Install

Python 3.10 or newer.

pip install optivision-rag                  # core pipeline + CLI
pip install "optivision-rag[corpus]"        # + synthetic test-corpus generator
pip install "optivision-rag[vlm]"           # + real encoders (torch, colpali-engine)
pip install "optivision-rag[merge]"         # + Ward merging (SciPy), used by optimize()'s default search
pip install "optivision-rag[vlm,corpus,bench]"

Or run the CLI through npm without touching pip yourself (it still needs Python 3.10+ on the machine):

npx optivision-rag --help

Quick start (offline, no model download)

The synthetic preset uses a deterministic stand-in encoder, so the whole pipeline runs in seconds on any laptop. Use it to try the tool, not for real results.

optivision make-corpus data/corpus --docs 10 --pages 2
optivision index data/corpus/pdfs -c synthetic
optivision search "renewal of vehicle insurance policy" -c synthetic
optivision stats -c synthetic

With a real model

Install the vlm extra, then switch the preset. colsmol is a 256M-parameter model that runs on a CPU laptop; colpali wants a GPU.

optivision index path/to/your/pdfs -c colsmol
optivision search "fire safety audit memorandum" -c colsmol
optivision explain path/to/your/pdfs -c colsmol --out figures

-c takes a bundled preset name (synthetic, colsmol, colpali, qdrant) or a path to your own YAML file. optivision init-config my.yaml writes one pre-filled with every default.

Python API

from optivision import Config, OptiVisionRAG

rag = OptiVisionRAG(Config.load("colsmol"))
report = rag.build("path/to/pdfs")
print(report.compression_ratio)
print(rag.search("office memorandum on fire safety audit").hits[0].ref.page_id)

Authors

T. Rithik Krishna, Amgovath Navanitha and Badavath Akhila, Mahatma Gandhi Institute of Technology, Hyderabad. MIT licensed.

Metadata

Release files for optivision-rag 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for optivision-rag 0.2.0
File Size Uploaded
optivision_rag-0.2.0.tar.gz 158.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for optivision-rag 0.2.0
File Interpreter ABI Platform
optivision_rag-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 296.8 kB

Release files / optivision_rag-0.2.0.tar.gz

Download URL optivision_rag-0.2.0.tar.gz
Size 158.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ae15494aba4cac3218140f06a471760579e26d1d7e3a464362c1c0a842201a4d
BLAKE2b-256 checksum
How to use checksums
6f0f53c71d2e6383bb5f97e18d45b70c8fce7275da065f90d3f2b0021da7b80d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / optivision_rag-0.2.0-py3-none-any.whl

Download URL optivision_rag-0.2.0-py3-none-any.whl
Size 138.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf946fcff5687c07453f81b1a4e2c573454ff52ea48ba0e4d7b768b42939833c
BLAKE2b-256 checksum
How to use checksums
88910ec0623c64996e0301c8e01a979c5ed84e89b4aaf81a851c51233d931677
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page