PDF Retrieval with Vision Language Models: ColPali Document Search on Vespa
Source: Vespa blog
Why PDFs are hard to retrieve
A large fraction of enterprise knowledge lives in PDFs. Classic retrieval pipelines extract text with OCR and layout parsing before indexing, but this approach is lossy:
- Tables, figures, charts, and forms lose their structure when flattened to text.
- OCR errors and reading-order mistakes corrupt the representation.
- Visual cues (colors, formatting, diagrams) carry semantics that text extraction discards.
- Store patch-level embeddings as a tensor field per page.
- Use a ranking function with MaxSim over query embeddings to compute late-interaction scores.
- Combine ColPali scores with cheaper signals (e.g., BM25 over extracted text or single-vector embeddings) in a phased ranking pipeline: candidate generation with fast signals, then re-ranking with ColPali on a smaller candidate set to control cost.
- Index size: hundreds of patch vectors per page vs. one vector per document — storage and memory costs rise substantially.
- Latency: late interaction is more expensive than single-vector ANN search, so it is best used for re-ranking, not first-phase retrieval.
- Query-side cost: query embeddings can be cached; page embeddings cannot.
- Accuracy: on visually complex documents (tables, forms, figures), ColPali significantly outperforms OCR-based text retrieval.
- Vision-language retrieval removes the fragile OCR/extraction stage for visually rich PDFs.
- Late-interaction multi-vector scoring fits naturally into Vespa's tensor framework.
- Practical deployments combine ColPali re-ranking with cheaper first-phase retrieval to balance quality, latency, and cost.
ColPali: retrieval over page images
ColPali sidesteps text extraction entirely. Instead of indexing extracted text, it indexes the page screenshot:
1. Each PDF page is rendered as an image. 2. A vision-language model (built on PaliGemma) produces a multi-vector representation: one embedding per image patch. 3. At query time, query tokens are embedded and scored against all patch embeddings using late interaction (MaxSim), in the spirit of ColBERT.
This preserves the full visual layout of the document and lets the vision-language model read tables and figures directly.
Serving ColPali with Vespa
Vespa supports ColPali-style retrieval because its tensor model natively represents multi-vector documents: