Popular searches
//

Indexing PDFs for RAG without parsing them: Visual Retrieval

Nov 30, 2026 | 22 minutes reading time

If you feed PDFs into a RAG pipeline, you first have to get at their text, and that is harder than it looks. A PDF does not store running text, but instructions for which glyph to paint where on the page. The text a parser reads from it (the text layer from here on) therefore does not always match what you see in the viewer: "Die Zahlung" ("the payment") turns into "Ejf [bimvoh", two columns get mixed line by line, a scan contains no text at all, and sometimes the text layer contains something nobody can see on the page. In the article on extracting text from PDFs I packed dozens of such pitfalls into one PDF and let a range of tools loose on it, from pypdf to a multimodal LLM, and none of them got through without errors.

A human, on the other hand, reads the same document without effort, because they see the rendered image. Whether the heading was drawn as text or as curves and whether the page is a scan -- none of that is visible in the image. So the obvious idea is to skip parsing for RAG altogether and to embed and search the page images directly. A large part of the pitfalls should then simply disappear.

Of course it is not quite that simple. Searching page images changes almost every step of the RAG pipeline a little: There are no chunks anymore, the embedding model has to be able to read, the vector database has more work to do, and generating the answer requires an LLM that understands images. So I start with an overview of what changes compared to the usual pipeline. After that I explain how the models work, using ColPali as the example. And then I let some of them loose on a test document: Which pitfalls are really gone, which remain and which new ones show up?

The title undersells it, by the way. A model that only sees the image does not care about the file format, so you can also search slides, web pages, screenshots and practically anything else that can be shown on a screen. I still stick with PDFs, because I already have a PDF full of pitfalls (and I still have a score to settle with the format).

To give away the result: A visual model indexes what gets rendered and nothing else. The pitfalls that only affect the text layer are therefore gone, although you get a large part of this gain with ordinary OCR as well. In the spirit of the no free lunch theorem, new pitfalls of course appear elsewhere: In a cross-check with pages that are hard for visual models, they fail at small print and at similar numbers.

Three ways from the PDF to the answer

The classic RAG pipeline, as described in my RAG overview article, has two phases. Offline, the documents are split into chunks, embedded and stored in the vector database. Online, the question is embedded, then the pipeline searches and answers. Somewhere along this way, someone has to read the page, that is, turn glyphs or pixels into text that a language model can work with. The approaches differ mainly in who does that and when. Figure 1 shows the three ways one below the other.

Figure 1: Three ways from the PDF to the answer. Highlighted is the step in which the page gets read.

In the classic text pipeline, a parser reads the text layer during indexing. Chunking, embedding, keyword search and generation then work on this text and inherit its errors.

In the second way, the page is rendered and a model takes over the parser's job: It writes down what it sees in the image. That can be a classic OCR program like Tesseract or a multimodal LLM. The text layer no longer plays a role, and the rest of the pipeline stays as it is.

In visual retrieval the page is rendered as well, but nobody writes down any text. An embedding model translates the page image directly into vectors, the question ends up as text in the same vector space, and the search looks for the most similar vectors as usual. The search then returns page images instead of text chunks. A page is only read when the answer is generated -- by a multimodal LLM, and only if it is among the hits.

For the usual pipeline, this third way has a number of consequences:

  • There is no chunking anymore. The page is the chunk, whether it holds three lines or twenty paragraphs.
  • The embedding model has to be able to read text in the image. An ordinary image embedding cannot do that, as we will see in a moment.
  • With the most accurate models, the vector database gets a few hundred to a thousand vectors per page instead of one per chunk, and it has to be able to compare them, too. For ColPali that is just under 258 KB per page according to the paper, for a text embedding like BGE-M3 less than 9 KB.
  • Keyword search has no text to work with. If you want BM25 alongside, you need OCR after all.
  • Generation receives page images and therefore needs a multimodal LLM. Depending on the provider, an A4 page at 150 dpi costs up to three times as much as the text on it would.
  • Checking the results gets harder. There is no extracted text anymore that you could look at.

This article is mainly about the embedding model and about what ends up being found. Storage, vector databases and the cost of generation I only touch on.

Why CLIP is not enough

Image embeddings have been around for a while, for example CLIP. CLIP maps an image and a text into the same vector space, each as a single vector. It was trained on images from the web with their captions. It therefore knows very well what "a dog on a meadow" looks like, but it does not read a paragraph of running text. To CLIP, every page of our test document is roughly "a page with text". In the experiment further down, the correct page among 171 pages lands in first place in 7 percent of the cases. That is better than guessing, but useless for search.

CLIP has three problems here that have nothing to do with each other. The first is the training: The model never learned to read text in images. The second is the resolution. The CLIP from the experiment scales every page down to 224×224 pixels (for A4 that is 27 dpi across the width), so even a model that had learned to read could no longer make out the text. The third is the single vector. It has to summarize a whole page, and that works quite well for "what is this roughly about", but not for the notice period in the third line of the second paragraph. We know the same from text embeddings, where the vector gets blurrier the larger the chunk is.

How ColPali works

ColPali (Faysse et al., ICLR 2025) tackles all three problems. It builds on a model that can read and processes more pixels, and it produces a separate vector for every image section.

A model that can read

The basis is a vision-language model (VLM), that is, a language model that takes images as input in addition to text. For ColPali this was originally PaliGemma-3B. Such a model splits the image into a grid of small sections, the patches, and an image encoder translates each patch into a vector. These vectors then sit in the context of the language model like tokens, together with the tokens of the text. To the language model, an image is therefore something like a sentence of a few hundred to a thousand patch tokens. PaliGemma was trained, among other things, to read text in images, and can therefore make something of a page full of letters.

Normally a VLM generates text from this input. ColPali skips that step and instead takes the vectors the language model outputs for the individual patches. Concretely, the page is scaled to 448×448 pixels (for A4 that is a mere 54 dpi across the width) and split into a grid of 32×32 = 1024 patches. Each patch runs through the language model, which sees the context of the whole page, and is finally projected onto a vector with 128 dimensions. On top of that come six vectors for the short text prompt the model puts in front of every image (it is always "Describe the image."). A page thus becomes a matrix with 1030 rows and 128 columns. The whole thing is trained on pairs of a question and the page that answers it. Figure 2 shows the way from the page image to the vectors as a diagram.

Figure 2: Every patch of the page image becomes a vector that knows the context of the whole page.

Many vectors instead of one

The question is treated the same way: Every token of the question gets its own vector with 128 dimensions. To compare question and page, you look for the patch that is most similar to each question token and add up these maxima. As with ordinary embeddings, the similarity between a question token qi and a patch dj is the dot product ⟨qi, dj⟩ of the two vectors (they are normalized, so it is the cosine similarity). Formally, the score of a page is

s(q, d) = Σi maxj ⟨qi, dj⟩,

where i runs over the tokens of the question and j over the vectors of the page. It is called MaxSim. The idea comes from text retrieval: ColBERT introduced this late interaction for text passages -- hence the "Col" in the name. Figure 3 works through MaxSim on a small example.

Figure 3: MaxSim on an example with four question tokens and nine patches.

If you ask for "notice period lease agreement", "notice period" gets the patch on which the phrase appears (or something very similar), and "lease agreement" perhaps the heading. A page on which both occur collects high maxima, while one that only roughly fits the topic ends up with many mediocre ones. The numbers in figure 3 are made up, and a real page has a thousand patches instead of nine, but the calculation is exactly the same. In NumPy it fits into a function with two lines (and gives me an opportunity to use Python's matrix multiplication operator @):

It is not cheap, though. The matrix product q @ d.T compares every question token with every patch. For a question with 20 tokens and the 1030 vectors of a ColPali page, that is 20,600 dot products per page, where the classic text embedding approach gets by with a single one per chunk.

This late interaction sits between the two kinds of models known from text retrieval: Bi-encoders embed question and chunk separately, so the embeddings of the chunks can be computed in advance. Cross-encoders see both together and are more accurate, but so expensive that they are only good for reranking. With late interaction, the pages are embedded in advance, but not as a whole, so the comparison happens at the level of individual question tokens and image patches.

One vector, many vectors or a reranker

Since ColPali, a whole family of models has emerged, and the leaderboard of the associated benchmark ViDoRe changes every few months.

The direct successors keep late interaction and swap the base model, usually for a Qwen-VL model as in ColQwen2. In addition, there are models with a single vector per page. If you take a vision-language model that can read and train it on pairs of question and page image, a single vector gets you surprisingly far (a current example is Qwen3-VL-Embedding). NVIDIA trained the same model once with one vector and once with late interaction and measures a difference of five to six points on ViDoRe v3. And as with text, there are rerankers, that is, cross-encoders for page images that score the candidates of the first search once more.

One vectorMany vectorsReranker
Text equivalentBi-encoderLate interactionCross-encoder
Embed pages in advanceyesyesno
Comparison with the questionone dot productMaxSim over all patchesone model pass per page
Index per pagea few KBa few hundred KBnone, only reorders candidates
Vector databaseanymust support MaxSim--

A test document full of pitfalls

But I promised to let all this loose on the pitfalls. The test document has 171 pages and consists of three parts. Like the questions, it is in German.

The first part are the 37 pages from the article on text extraction. Each of them has a heading and a few lines from the office routine of a made-up company: vacation rules, travel expenses, invoices, a job application. In the viewer this looks harmless, but every page is built so that text extraction trips at a different spot. For this article it is enough to distinguish three kinds:

  • With characters, the text layer does not match the image, for example because the table that maps glyphs to letters is missing. The viewer still shows "Die Zahlung", and the parser reads something like "Ejf [bimvoh".
  • Scans and other images have no text layer or a faulty one from an earlier OCR.
  • With layout, the characters are correct, but the order and context are not: Two columns get mixed line by line, words hyphenated at the end of a line stay split, and a table across two pages falls apart into two halves.

For visual retrieval, however, these pages are a home game, since they were built to make text extraction trip. The second part are therefore 30 pages with visual pitfalls, that is, pages with a flawless text layer that are hard to read if all you have is the image: footnotes in 8, 6 and 4.5 pt, pages of statutes two and four to a sheet, four invoices from the same template whose numbers differ only by swapped digits, and also faint text and text rotated by 90 degrees. The third part are distractors: nine German employment laws, 104 pages in total, that fit the topic of the other pages well.

The search always covers the whole test document, and the questions come in two rounds, with 55 questions on the pitfalls for text extraction and 45 on the visual pitfalls. In the second round, footnotes and statute pages come in three variants with the same content (three font sizes, or one, two or four pages per sheet). The questions on them count for each variant separately, and the two other variants are removed from the result list each time. That way the 45 questions turn into 73 scores.

The comparison covers the three ways from the overview. For the text pipeline, Docling reads the text layer, applies models for layout and tables on top and runs OCR where there is no text. Tesseract, in contrast, as an OCR tool only reads the rendered page image (at 300 dpi). Both texts are searched in a hybrid fashion, with BM25 and with embeddings from BGE-M3, combined with reciprocal rank fusion. To be fair, we want a competent stack as the comparison here. On the visual side there are CLIP as a baseline, ColQwen2 as a successor of ColPali with many vectors per page, and Qwen3-VL-Embedding-2B with one vector per page. Both run with their default settings, get the pages at 150 dpi and scale them down further themselves (more on that below). What counts is whether the correct page is among the top three results (recall@3). Only for the four similar invoices does first place count.

With a few dozen questions, a single one already makes up several percentage points. The numbers are therefore tendencies for individual classes of errors and not a benchmark (that is what ViDoRe is for).

The results at a glance

The table shows recall@3 on the pitfalls for text extraction (55 questions) and on the pitfalls for visual models (73 scores). Broken down by kind of page, the numbers are in figures 4 and 5 in the following sections.

Recall@3Text layer pitfallsVisual pitfalls
Docling, hybrid75%97%
Tesseract, hybrid85%89%
ColQwen298%71%
Qwen3-VL-Embedding84%68%

On the pages that are meant to be hard for text extraction, ColQwen2 does indeed find almost everything and the search over the Docling text only three quarters. On the pages that are meant to be hard for visual models it is the other way round, and Qwen3-VL-Embedding loses a little more there than ColQwen2.

Two models are missing from the table and the figures. CLIP finds only 9% of the pages even in the first round. The smaller ColModernVBERT with many vectors per page gets 73% and 59%, probably because of the language: On the English questions of the usual benchmark it is only a few points worse than ColQwen2, but on questions in other languages it loses half of its points there (launch blog for ViDoRe v3).

Pitfalls that disappeared

A visual model never gets to see the text layer, so all the pitfalls that come with it are gone. Whether "Effizienz" (efficiency) is set with an ffi ligature or the character table is missing makes no difference, the model sees the image of the word in both cases. In figure 4 this is the first row: Of the 13 pages with broken characters, the search over the Docling text finds only four, ColQwen2 finds all of them. The visual pipeline treats scans like any other page, while the text pipeline needs a separate OCR stage and a check for when it should kick in. For layout the difference is smaller. BM25 and BGE-M3 do not need any order, and as long as the words are intact, the text pipeline finds almost all pages as well.

Figure 4: Results on the pitfalls for text extraction, by kind of page.

A good part of this gain, however, you also get with ordinary OCR. Tesseract also only looks at the image and finds 12 of the 13 pages with broken characters, and over the whole first round it lies between Docling and ColQwen2 (table above).

What the visual model adds beyond OCR can be seen in the questions on which the search over the OCR text fails. BM25 alone does not find the page when the question is "Zu welchen Zeiten ist der Kundenservice erreichbar?" ("When can customer service be reached?") and the page says "Die Servicezeiten sind montags bis freitags von 8 bis 18 Uhr" ("Service hours are Monday to Friday from 8 am to 6 pm") (rank 14), and BGE-M3 alone struggles with plain numbers (the "Durchwahl 4711", extension 4711, lands at rank 56). The hybrid search only partly makes up for this. ColQwen2, on the other hand, has both pages among the top three, because every token of the question looks for its own patch. Qwen3-VL-Embedding, with its single vector, has the same weakness with numbers as BGE-M3 and has the correct page among the top three for only one of the five questions about numbers (the extension lands at rank 30).

Pitfalls that remain

Conversely, everything visible in the image ends up in the index, including headers and watermarks. A layout pipeline like Docling can detect headers and leave them out, with the page image you would have to crop them off before embedding. In the experiment this had no visible effect, even though 37 pages carry the same header ("VERTRAULICH -- nur für den internen Gebrauch", confidential -- for internal use only). It only becomes noticeable when a question contains words from the header: Then ColQwen2 returns almost nothing but pages with this header, while Docling does not even put it into the index.

In addition, the page now dictates how big a chunk is and where it ends. A sentence that runs across the page boundary is split over two hits, and so is a table across two pages, whose second half does not even have the heading. In the experiment this still worked out (for a question about the total of a two-page table, ColQwen2 finds both pages at ranks 1 and 2, see also the row "Page boundary" in figure 4), but probably only because the table is just two pages long and the test document does not contain many other multi-page tables.

New pitfalls

On the pages built for visual models, the picture is reversed (figure 5). The text pipelines read a flawless text layer there and find almost everything, while the visual models lose out on small print, on several pages per sheet and on similar numbers.

Figure 5: Results on the pitfalls for visual models, by kind of page.

The text pipelines do not care about font size. ColQwen2 finds all footnotes in 8 and 6 pt and only misses two of the six in 4.5 pt. Qwen3-VL-Embedding, in contrast, finds only a third at every font size.

It gets clearer with several pages per sheet. On their own, ColQwen2 finds almost all statute pages, at two pages per sheet only a quarter and at four pages per sheet just a single one, while the text pipelines still find all of them. Qwen3-VL-Embedding holds up better here and finds seven of eight in both cases.

Both are largely due to the resolution. By default, ColQwen2 scales every sheet down to at most 768 patches of 28×28 pixels each (for A4 that is about 77 dpi), no matter how much is on it. A lowercase letter in 6 pt is then just over three pixels high. This limit can be adjusted, though. With four times the number of patches, that is, twice the resolution, ColQwen2 finds all footnotes and all statute pages, even at four pages per sheet. Qwen3-VL-Embedding already works with about 1300 image tokens of 32×32 pixels each per page by default (about 115 dpi for A4), which probably explains why it copes better with several pages per sheet. For the footnotes, however, more resolution hardly helps: With just over 3000 image tokens it finds five of the six in 8 pt, but only one in 4.5 pt. Here the single vector probably comes into play as well: The footnotes have nothing to do with the rest of their page, and in a vector that summarizes what the page is about, such a side note is easily lost.

The higher resolution does not come for free. Embedding a page takes correspondingly longer, and for models with many vectors per page the database grows as well. The resolution is therefore a knob between cost and legibility, which has to be set according to the smallest print that occurs in your documents. If you have handouts with six slides per page, package leaflets or terms and conditions in small print, you should check this beforehand.

You should not rely on numbers either. For the four invoices from the same template, whose numbers differ only by swapped digits (RE-2026-08817, -08871, -08187 and -08718), the text pipelines have the correct invoice in first place for three of the four numbers (BM25 alone for all four). ColQwen2 has the correct one in front for two and Qwen3-VL-Embedding for one, which with four candidates amounts to guessing. For invoice numbers, article numbers or case numbers, keyword search therefore remains necessary.

Pitfalls that did not show up

Two cases I had intended as pitfalls for the visual models. But it turned out that they are none at all. Both models find the page rotated by 90 degrees and the paragraph in almost white grey (barely visible in the viewer), while Tesseract fails at both.

On the ordinary statute pages, ColQwen2 with 16 of 19 control questions is just behind the text pipelines with 18 (last row in figure 5). So on clean, dense text there is no advantage over the text pipeline.

Where the model looks

With visual retrieval there is no extracted text to read anymore. But since every patch has a fixed position on the page, you can color the patches by their similarity to a question token and lay the result over the page as a heatmap. These similarity maps are therefore the best inspection tool this technique offers.

Figure 6: Similarity maps from ColQwen2 for one word of the question each on three pages of the test document.

Figure 6 shows three pages, each with one word from the question (framed in blue). The model finds the words, but the brightest patches are often only nearby or in the whitespace (the ColPali authors describe something similar in the appendix of their paper). This is possible because every patch has the whole page as context on its way through image encoder and language model. So its vector does not have to describe what can be seen on the patch itself, and an empty patch in particular is a kind of joker that can take on meaning from the rest of the page. For retrieval this does not matter, because MaxSim only asks whether any patch fits. But when a question finds the wrong page, the similarity maps sometimes give a hint as to what lured the model there.

Not a replacement, but one more tool

Visual retrieval has a different error profile than text extraction and therefore does not replace it. It pays off when the text layer is unreliable because the PDFs come from many sources, include many scans or carry their information in graphics, and when the page is a meaningful unit, as with presentations, data sheets or forms. For cleanly generated, text-heavy documents the text pipeline stays cheaper, and in the experiment it was at least as good on such pages.

You can rarely do entirely without text. For numbers of all kinds keyword search remains necessary, and it needs text (from the text layer or OCR) alongside the page images. In addition, the resolution has to match the smallest print in your documents, which makes indexing and storage more expensive.

As always, you should run evaluations on your own documents, and here all the more: The approach completely rebuilds an existing RAG pipeline, and the models in part perform considerably worse on German texts.

But for certain classes of documents, this approach can deliver better results than the classic pipeline. In my opinion it therefore enriches the toolbox and can turn out to be very useful for tricky use cases.

//

More articles in this subject area

Discover exciting further topics and let the codecentric world inspire you.