From Pixels to Points

Compressing Visual Document Search

Some AI models search documents by looking at the pages, like we do. They need hundreds of vectors per page. How many does a page really need?

Quality kept vs memory per page
Quality kept vs memory per page, for every method.

Code, results and full details: github.com/ALI-AL-MARJANI/Pixels-To-Points

Built on

ColPali

Searches page images with one vector per patch. The models compressed here.

Token Pooling (Clavié et al.)

Merges similar vectors of a page. The main compression method.

MUVERA (Dhulipala et al.)

Turns many vectors into one. Used as a fast first step.

ViDoRe benchmark

The visual document retrieval benchmark used for every test.

TL;DR

The problem

A company has millions of PDF pages. Someone asks: "How much did we spend on stock buybacks in 2024?" The answer is one number, in one table, on one page.

The old way is to turn the pages into text (OCR) and search the text. It often breaks on tables, charts and scans. Models like ColPali skip that step: they look at the page image directly.

How ColPali-style models search a page
How ColPali-style models search a page.

The catch: a page becomes hundreds of vectors, not one. With ColQwen2, that is 757 vectors of 128 numbers per page, so 1 million pages take 194 GB of fast memory. The smaller model, ColSmol, is even worse (264 GB), because it cuts pages into more pieces.

So the question is simple: how few vectors, and how few bits, does a page really need?

Four ways to make it smaller

Token pooling (Clavié et al.). Group similar vectors and keep their average. To check that the grouping matters, it is compared with a dumb baseline: throw away the same number of vectors at random.

Which patches get merged on a real page
Which patches get merged on a real page.

Binarization. Keep only the sign of each number: 1 bit instead of 16. Each vector becomes 16× smaller.

MUVERA (Dhulipala et al.). Build one long vector per page that behaves almost like the full set. Any normal vector database can search it. Then the best 100 pages are checked again with the full vectors.

Mix them. Fewer vectors and fewer bits per vector work together.

Results

Two models (ColQwen2-2B and ColSmol-256M), four kinds of pages (finance reports, slides, economic reports, science figures) from the ViDoRe benchmark. "Quality kept" compares the ranking score (nDCG@5) with the uncompressed version.

Method1M pages (ColQwen2)Quality kept, ColQwen2Quality kept, ColSmol
Full194 GB100%100%
Pooling 4×49 GB99.2%98.5%
Pooling 16×12 GB95.7%93.3%
Random dropping 16×12 GB86.9%74.4%
1 bit per number12 GB95.9%93.5%
Pooling 4× + 1 bit3 GB93.3%90.9%
MUVERA, one vector1 to 20 GB60 to 82%35 to 63%
MUVERA, then exact check of top 10098.5 to 100%95.8 to 99.4%

Every number comes from results/ in the GitHub repo. The full table is in results/table.md.

Pooling vs random dropping
Smart merging vs random dropping.

Two things stand out. Smart merging beats random dropping by a wide margin, so which vectors get merged really matters. And the bigger model handles compression better at every setting.

Two-step search
One vector as a fast first filter, then an exact check of the top 100.

Where it hurts

The type of page that suffers most depends on the model. ColQwen2 loses most on dense finance pages (92% kept at 16×). ColSmol loses most on slides (88%). Science figures are the safest for both.

Quality kept per page type
Quality kept per page type.

Below, each query word picks its best patch, and that patch lights up. With the full vectors, a few exact spots win. After heavy merging, a "winner" is the average of a whole group of patches, so the signal gets spread out and the wrong pages start to win.

What the model looks at, before and after pooling
What the model looks at, before and after pooling.

Surprises

How it was tested

Run it

git clone https://github.com/ALI-AL-MARJANI/Pixels-To-Points
cd Pixels-To-Points
uv sync --extra encode --extra dev
uv run pytest
uv run python -m p2p.encode --model colqwen2 --dataset economics_v2
uv run python -m p2p.run_experiments
uv run python -m p2p.plots