Document ingestion and multimodal retrieval: PDFs, tables, images

The stage before chunking, measured on real files: what a PDF contains, how rule-based extractors, layout-aware parsers and OCR rebuild it, what each loses on the topic's QASPER papers, tables, figures and other formats, the metadata a citation needs, re-indexing only what changed, and retrieving page images directly. Reading: 28 min, plus 8 in closed details. Data as of October 2026.

Ingestion in one picture

The idea in one sentenceA PDF stores glyphs at coordinates, not paragraphs, so every parser reconstructs reading order, tables and structure (by rules, by a layout model, by OCR, or not at all when the page image itself is embedded), and retrieval can only find what that reconstruction kept.

Fig. 1: retrieval only finds what ingestion kept. Two routes from a file to an index, each stage with what it lost or cost on this page's runs (the topic's QASPER papers, an olmOCR-bench sample and three ViDoRe sets, Apple M1 Pro, October 2026; measured unless marked).

  1. A PDF page is drawing instructions. Page 1 of arXiv 1909.00175, a paper of the running example: its 90 text lines lift off the page as the text layer, glyphs at x, y with no paragraphs. None of the 38 files downloaded here is tagged with a structure tree (section 1).
  2. Rebuild text, layout and order. A rule-based extractor reads the text layer in 0.01 s per page; OCR, only where the layer is missing, takes 2.2 s per page; a layout model finds columns and order. Evidence paragraphs kept intact range from 1 to 94 of 107 depending on the parser (sections 2 to 5).
  3. Tables and figures, then chunks that carry metadata. Only 1 of 6 table tools kept every header over its numbers on the test table (section 6); each chunk keeps its page, box, heading path and ACL, so it can cite itself and be filtered (section 8).
  4. Hash, then embed only what is new. One vector per chunk goes into the index. When a file changes, fixed windows re-embed 76% of the words for 15% changed (section 9).
  5. Or skip the parser. The page image is cut into patches, 1,030 vectors per page, scored with MaxSim. On figures (ArxivQA) nDCG@5 74.2 against 37.9 for OCR + BM25; on text-heavy reports a tie, 97.7 against 95.0 (sections 10 and 11).

You need: the parent Topic: rag-and-retrieval (this page is the stage before its clean text); MaxSim from Rerankers and late interaction and patch tokens from Vision-language models for sections 10 and 11. The Parser viewer tab is a tool, not a read.

Ingestion: everything before the first chunk is embedded, including keeping the index in step when files change.
Text layer: the glyphs a born-digital PDF draws, decodable to Unicode; a scan has none.
Layout-aware parser: renders the page and detects text, title, table, figure, header and footer boxes before reading text.
Content hash: a fingerprint (SHA-256) of a file or chunk, used to re-embed only what changed.

Elsewhere: chunking strategy (The retrieval pipeline), text embedders (Embedding models), freshness, deletes and access control (RAG in production), OCR for pretraining corpora (Extraction and filtering).

1. What a PDF page actually contains

A PDF is a page description: drawing instructions that put glyphs at coordinates so the page looks right (ISO 32000-2:2020, PDF 2.0; overview). Paragraphs, columns, tables and captions are not stored; every parser's output is rebuilt from those instructions, or from pixels. Four facts cause most ingestion bugs:

  • Text is positioned, not flowing. In each page's content stream, Tm and Td move a text cursor and Tj or TJ draw glyphs there (section 9.4); nothing marks a line continuing or a second column, and spaces are often only a gap the parser must notice.
  • Stream order is the producer's order: a typesetter may draw the left column, the right, then the header and footnotes, or a table cell by cell; a Word export draws text boxes in creation order. An extractor that follows the stream inherits it.
  • Glyphs are font codes, not letters: they become Unicode only through the font's encoding or a ToUnicode map (section 9.10), and a subset font without one decodes to garbage although the page looks perfect. Ligatures (one glyph for "fi", U+FB01) and line-end hyphens add damage.
  • A scan is a picture with no text, unless an earlier OCR run added an invisible layer (text render mode 3) of whatever quality that OCR had.

A structure tree (Tagged PDF, section 14.8, required by accessibility rules such as PDF/UA, ISO 14289) does record paragraphs, headings, tables and reading order; use it when present and correct. None of the 38 arXiv PDF files downloaded for this page (24 papers, every version) has one (no StructTreeRoot, checked with PyMuPDF).

Fig. 2: the same page, three reading orders; only the layout model reads the columns as a person does. The page image lies flat; every slab is one text line at its PDF coordinates, and the purple path joins them in the order the text comes out. Predict first: which reader runs lines across both columns?

  1. The text layer. The 90 text lines PyMuPDF 1.28.2 reads on page 1 of arXiv 1909.00175 (3,701 characters in 5 fonts, 4 ligature glyphs) lift off the page image, each at its own coordinates.
  2. Content-stream order. The order the producer (here pdfTeX) drew the lines. On this LaTeX page it is close to reading order, except the rotated arXiv stamp in the left margin, drawn last.
  3. pdfplumber. extract_text() clusters characters into lines by vertical position across the whole page width, so a line of the left column and the line beside it in the right column become one: it merges 34 of its 60 lines across the gutter. Its default 3-point x tolerance also drops many spaces on this page.
  4. Docling. A layout model found the two columns, so the left column is read top to bottom, then the right; the arXiv stamp is classified as page furniture and dropped.

2. Rule-based extractors: geometry and thresholds

A rule-based extractor rebuilds words, lines and blocks from glyph coordinates with no learned model. The steps are the same everywhere; only the thresholds and the final sort differ.

The tools differ mainly in the last step: pypdf (6.20.1) keeps content-stream order; PyMuPDF (1.28.2) too, unless sort=True sorts blocks by top then left (recipes); pdfplumber (0.11.10) clusters characters into lines (x_tolerance 3 points) and reads them across the full width; pdftotext (poppler 26.02) detects columns; pymupdf4llm (1.28.2) adds headings by font size, tables by ruling lines, Markdown, and here called RapidOCR on pages it judged to be images. Milliseconds per page and no model: the right first stage for clean single-column files; columns, headers, footnotes, tables and scans break the rules.

pdfminer.six's parameters at the pinned version, and how it orders boxes
class LAParams:
    line_overlap = 0.5  # overlap, relative to the smaller char height, to share a line
    char_margin  = 2.0  # chars closer than 2 char widths join the same line
    line_margin  = 0.5  # lines closer than 0.5 line heights join the same box
    word_margin  = 0.1  # a gap over 0.1 char widths inserts a space
    boxes_flow   = 0.5  # -1: order boxes by x only ... +1: by y only; None: no grouping

pdfminer/layout.py, pdfminer.six 20260107, lines 48 to 90; comments condensed from the docstring at lines 50 to 74. With boxes_flow set, LTLayoutContainer.analyze (lines 907 to 937) merges the closest pair of boxes again and again into a tree (group_textboxes, line 814) and reads the tree in order; with None it sorts boxes top to bottom, left to right.

Three thresholds and a sort: where two columns go wrong

Glyphs to words and lines, lines to boxes, boxes to an order, with pdfminer.six's LAParams defaults on illustrative glyphs: word_margin 0.1, char_margin 2.0, line_overlap 0.5, line_margin 0.5. The final sort decides columns: top to bottom over the full width interleaves them.

3. Layout-aware parsers: let a model look at the page

A person finds columns, headers and tables by looking. A layout-aware parser renders the page and runs a layout detection model, an object detector trained on labelled pages (the eleven classes of IBM's DocLayNet: Text, Title, Section-header, Table, Picture, Caption, Formula, List-item, Page-header, Page-footer, Footnote); it fills each box from the text layer where it is good and OCR where not, orders the boxes, sends tables to a table-structure model, and drops headers and footers by class, not by guessing.

Four open layout-aware parsers ran here on the CPU: Docling, Marker (fast mode, OCR off, so it reads scans like a text extractor), MinerU and Unstructured. Licences differ: Docling MIT, Unstructured Apache 2.0, MinerU its own licence with extra conditions, and Marker's model weights a modified OpenRAIL-M, free below $5M revenue.

Docling's pipeline: parse the PDF, then a model pipeline of OCR, layout analysis and table structure

Docling's default processing pipeline: PDF pages are parsed, passed through OCR, layout analysis and table-structure models, then assembled and serialised as JSON or Markdown
Notice that the text layer is parsed first and the models only add structure; OCR runs only where the text layer is missing. Figure 1 of the Docling technical report (Auer et al., 2024), CC BY 4.0.
The four layout-aware parsers run here: models, tables, OCR and licence (versions checked 2026-10-13; volatile)
Tool (version run)LayoutTablesText and OCRLicence
Docling 2.138.0 (IBM, LF AI and Data)docling-layout-heron detector (RT-DETRv2; Livathinos et al., 2025)TableFormer, cells matched to the text layerown PDF backend; OCR engine chosen at start-upMIT code, models on Hugging Face
Marker 2.0.0 (Datalab)fast (default on CPU and Apple MPS): rf-detr; balanced: the Surya VLMrebuilt from the text layer, VLM fallback when unsurepdftext; Surya VLM via llama.cpp or vLLM for OCR and equationsApache 2.0 code; weights modified OpenRAIL-M (free below $5M revenue)
MinerU 4.0.12 (OpenDataLab, Shanghai AI Lab)flash (native, no model), basic (ONNX, about 0.8 GB), standard/advanced (adds a VLM, about 2 GB)model-basedown OCR modelsMinerU Open Source License (Apache 2.0 with extra conditions)
Unstructured 0.27.25fast: none (pdfminer); hi_res: YOLOXhi_res + infer_table_structure: table transformer, HTMLpdfminer text; Tesseract for image regionsApache 2.0

Sources: each project's README at the pinned release (Marker v2.0.0 lines 100 to 110 and 65, MinerU mineru-4.0.12-released lines 449 to 460 and 1026), Docling's pipeline options read from the installed package, Unstructured's partition_pdf strategies. Only the open packages ran here, all on the CPU: Docling with its default pipeline (it picked RapidOCR, PP-OCRv6 small, for image regions), Unstructured fast and hi_res, MinerU flash and basic (ONNX), and Marker in fast mode with --disable_ocr, the text-layer path of the vendor table's "fast, no OCR (CPU)" row. With OCR on, Marker sends scanned or garbled pages to its Surya VLM (a 1.27 GB GGUF served by llama.cpp on the Mac's GPU); that path was not measured here, so Marker's scores below are for text-layer pages only and it scores like a text extractor on scans.

4. Measured: what each parser keeps

Does the answer evidence survive? (24 QASPER papers)

QASPER, the topic's long-document set, marks the paragraphs that answer each question. The root uses the text QASPER ships (S2ORC's parse); here the same papers start as arXiv PDFs. Each evidence paragraph's word trigrams are looked for in each parser's output: intact at 90% or more, damaged at 50 to 90% (hyphens, glued words, a column jump or footer inside), lost below. Then BM25 with the root's settings ranks the root's chunks of each output (256 tokens, 32 overlap): recall@3 is the share of questions whose evidence is in the top 3.

Predict: of the 107 evidence paragraphs, which tool loses the most? (All three read the same text layer.)

Retrieval barely notices the middle group. Recall@3 of BM25 is 43 to 53% for every tool except pdfplumber (19%), and QASPER's own clean text scores 53%: a paragraph keeping 85% of its words still matches, and only lost word boundaries break it. Damage matters where exact spans matter (quoting, citing, embedding a chunk cut by a column jump). With 58 questions, differences under about 15 points are noise: a broken tokenizer input is fatal, a hyphen is not. And recall on text someone else cleaned says nothing about your parser: run the golden set through your own ingestion at least once.

How the evidence measurement was made

Measured on Apple M1 Pro (CPU), 2026-10-14: 24 QASPER validation papers (arXiv PDFs, latest version; 12 drawn at random from papers with a question answerable only from a table or figure, 12 from the rest, seed 0), 107 distinct evidence paragraphs behind 58 questions with text evidence. QASPER's BIBREF and INLINEFORM placeholders excluded. A recall hit is a top-3 chunk covering at least half of an evidence paragraph. Top row of the chart: QASPER's own S2ORC text of the same papers, the root's starting point. Script: src/scripts/score_qasper.py.

Evidence survives in three groups; recall moves only when word boundaries break

Layout parsers and tools that join line-end hyphens keep almost every paragraph whole (MinerU flash 94 intact, Docling 93, Marker 92, MinerU basic and pymupdf4llm 91, pdftotext 86); plain stream readers break about four in ten at hyphens and ligatures (pypdf 60, pdfminer.six 59, PyMuPDF 61, Unstructured 60 and 62, Tesseract on the rendered pages 64); pdfplumber keeps 1. Little is lost outright, because pdfTeX draws each column in order. Top row: QASPER's own text.

Which failure each parser has (olmOCR-bench sample)

olmOCR-bench (Allen AI, 1,403 single-page PDFs, 7,010 pass/fail tests) checks facts, not edit distance: a sentence present, a page number absent, sentence A before B, a table cell beside a given neighbour. Five of its seven categories ran here on a seeded sample with the benchmark's own tests.py (v0.4.27, lines 520 to 620 and 621 onward); the two maths categories need a KaTeX renderer. Cells: share of tests passed.

Each category isolates one failure. Headers and footers: layout models drop them (Marker 95, MinerU basic 95, Docling 93), every text extractor keeps them (30 to 39), and so does Unstructured hi_res (28). Tables: text extractors pass 1 of 108 tests, MinerU flash 28%, the other table-aware tools 44 to 73%. Multi column: pdftotext's own column detection (69) beats pypdf (46) and PyMuPDF's sort=True collapses (12). Old scans defeat everything (17 to 26): many are handwritten Library of Congress letters on which Tesseract returns nothing. Long tiny text rewards OCR and line grouping (MinerU 87, Docling 79, Tesseract 72). A 110-page sample on CPU defaults, not a leaderboard.

How the sample was drawn

Measured on Apple M1 Pro (CPU), 2026-10-14, every tool at its default settings. Seeded sample (seed 0) of olmOCR-bench at revision 54a96a6f: 25 PDFs each from multi column, headers and footers, tables and old scans, 10 from long tiny text; tests restricted to those PDFs (counts in the header: 97, 61, 108, 119 and 61). Score per category = share of its tests passed, as the benchmark computes it; Mean = mean of the five categories, with a 95% bootstrap interval over PDFs. The two maths categories and the baseline category are not included, so this mean is not comparable with the published Overall column. Script: src/scripts/score_olmocr.py.

Published scores on the full benchmark, and why a vendor table is not a choice (not run here; volatile)

Benchmark authors' table: olmOCR README at v0.4.27, "reproduced in-house, except those marked with *, which are reported by model authors". Vendor table: Marker README at v2.0.0 (Datalab, Marker's maker), all eight categories, GPU runs. The two disagree on the same tools (MinerU 75.2* against 72.7, different MinerU versions); neither includes this page's CPU defaults. Marker's README puts Docling at 50.3; the olmOCR authors' table does not list Docling; this page's sample gives a third reading on another subset and settings. Scores move with version, mode (OCR on or off, GPU or CPU path), categories included and who ran it: read every row as "this tool, this version, this mode, on that hardware, run by that party", and run the candidates on fifty of your own pages.

Cost on this CPU, QASPER pages: text extractors 0.01 to 0.13 s per page; layout parsers 0.22 (MinerU flash, no model) to 4.98 s (Unstructured hi_res), Docling 1.41.

Seconds per page for every tool

Wall seconds per page on this machine's CPU (no GPU, no MPS), at low priority while other jobs ran (load average 7 to 30), so read the ratios, not the absolute times; they were not taken under the bench lock. QASPER: 277 born-digital pages; olmOCR sample: 110 single pages, many scanned, where OCR dominates. Marker ran as one batch, so its figure is the batch time divided by pages.

5. OCR: route only the pages that need it

Scans, photos and some exports have no usable text layer (none, an old invisible OCR layer, or glyphs without a Unicode mapping). Optical character recognition (OCR) reads characters from pixels; it replaces exact text with a guess and costs seconds per page, so it is routed per page, never run on everything.

Classic engines. Tesseract (5.4.1, Apache 2.0) binarises the page, finds lines with its page-layout analysis (--psm 3, the default, assumes a full page of any layout) and since version 4 reads each line with an LSTM trained per language (documentation); it knows nothing of tables or reading order beyond its block finder. Layout-aware parsers OCR only image-text regions or broken pages: Docling through whichever engine its OcrAutoOptions finds (pipeline_options.py line 312; here RapidOCR, PP-OCRv6 small), Unstructured hi_res through Tesseract, MinerU and Marker through their own models.

VLM OCR. Since 2025 the strongest systems on olmOCR-bench are vision-language models that read a page image and write Markdown, tables as HTML and maths as LaTeX: olmOCR 2 (7B), PaddleOCR-VL, Chandra, dots.ocr, DeepSeek-OCR. They handle reading order, tables and handwriting jointly, need a GPU and a few seconds per page, and can hallucinate text that is not on the page or repeat a line forever (olmOCR-bench's baseline test checks for runaway repetition). None ran here (reference pipelines target NVIDIA GPUs with vLLM; published scores in section 4). How to check any OCR: character error rate against a hand transcription of a sample.

Check the text layer first; OCR only what fails the check

The check: characters per page area, share of replacement or private-use characters, share of dictionary words, a single full-page image. Times on this CPU: Tesseract at 300 dpi took 2.18 s per page on the QASPER papers and 3.15 s on the olmOCR sample; VLM OCR was not run here.

6. Tables: structure is the content

A number means nothing until you know its row and column. A text extractor emits cells as a stream (by row, by column, headers scattered), and retrieval fails twice: the chunk has no words matching the question, and if retrieved the generator cannot tell which number answers it.

How much it matters. In QASPER validation (281 papers, 1,005 questions), a table or figure is evidence for 164 (17.4%) of the 945 answerable questions, and for 35 of them a table or figure is the only evidence (30 tables, 5 figures; src/scripts/qasper_stats.py, FLOAT SELECTED entries). The root's set keeps only questions with text evidence, so these never reach its recall numbers: an ingestion choice hidden by an evaluation choice.

Extraction in four steps: detect the region (a Table box, or ruling lines); recognise structure, rows, columns, spanning and header cells (pdfplumber, Camelot and pymupdf4llm use ruling lines or whitespace; Docling's TableFormer predicts structure from the image, Nassar et al., 2022, then matches cells to the PDF's own text, do_cell_matching=True by default in docling 2.138.0); fill cells from the text layer or OCR; serialise as HTML (keeps spans) or Markdown (cannot express a spanning cell, so merged headers repeat or vanish).

  • Plain-text extractors kept the numbers, lost the table: pypdf one line per row with the headers as loose words; pdftotext each row cut in halves; PyMuPDF one cell per line; pdfminer.six and Unstructured fast column by column. Nothing says that 92.19 is homographic detection F1.
  • Docling kept every number under the right headers (100%, answer cells in place), merging the three header rows into one ("Homographic - Detection - F1"), already a row serialisation.
  • Other table tools: body right, headers wrong. MinerU (basic and flash) and pymupdf4llm put every number in the right cell (adjacency F1 0.93 to 0.99) but split header words ("Detectio" / "nF 1"), so only 0 to 18% of numbers sit under all three headers. Marker split names across columns ("Pramanick | and | Das"); Unstructured hi_res OCRed the image: "F1" became "Fi", "89.19" became "89,19", a header row lost.
How the table was scored

Adjacency F1: pairs of horizontally or vertically adjacent non-empty cells where at least one is a number, compared as text with the ground truth (the relation idea of the ICDAR 2013 table competition, restricted to the body so that merging the three header rows into one, as Docling does, is not penalised). Header association: the share of the table's numbers found in the right row whose column header text contains all three ground-truth header words; it was added after the first scoring, because plain adjacency F1 ranked MinerU above Docling although MinerU's headers were split mid-word. A parser that emits no table has no grid, so neither score applies; "cells whose text appears" still counts a number found anywhere. Ground truth: the tabular in the paper's pun.tex (lines 244 to 277 of the arXiv source, kept in src/inputs/). Script: src/scripts/table_score.py.

Making a table retrievable: keep it whole with its caption, or split by rows with the header repeated (a chunker that cuts a Markdown table mid-way leaves rows without headers); row serialisation ("Model: BERT-base; Dataset: SQuAD; F1: 88.5", values illustrative) gives each value its headers in words BM25 and an embedder can match; or embed a model-written summary and pass the full table to the generator. SQL over tables is on GraphRAG and structured retrieval. How to check: TEDS (tree-edit distance between HTML trees, Zhong et al., 2020), the adjacency F1 of the ICDAR 2013 competition, or olmOCR-bench's single facts ("a cell reads 4.5% and the cell above it reads 2.4%", its README's example).

One real table, before and after: every text extractor kept the numbers and lost the grid

Ground truth (LaTeX source)

Numbers kept under the right headers, every parser

Table 1 of arXiv 1909.00175 v1 (Zou and Lu, 2019), page 4: 15 rows, 13 columns, three header rows with spanning cells; ground truth from the paper's LaTeX source. Pick a parser, then switch views. Apple M1 Pro (CPU), default settings (Marker without OCR), 2026-10-14; one table shows kinds of failure, not a ranking.

7. Figures, images and other formats

A chart, diagram or photo carries information no text extractor sees. Three things can be recovered, at rising cost:

  1. The caption, which layout parsers label as its own element (caption in Docling, Caption in Marker, FigureCaption in Unstructured): keep it attached to its figure and make it its own chunk, since "Figure 3: accuracy against context length for four models" is often exactly what a question matches. A rule-based extractor emits it as an ordinary line, often inside the paragraph that flows around the figure.
  2. Text inside the figure: axis labels and legends are real text in vector figures (a scatter of short lines) and need OCR in raster ones.
  3. What the figure shows, which only a VLM can describe. Captioning for retrieval: crop each figure, ask a VLM for its quantities, axes and main finding, index that beside the caption, labelled as generated. One VLM call per figure; the risk is a confident wrong description. In the ColPali paper's Table 2, Claude 3 Sonnet captions raised BM25 on ArxivQA (figure questions) from 31.6 to 40.1 nDCG@5 over OCR text alone (the authors' runs).

Images as items. For standalone images (product photos, diagrams) a single-vector image-text embedding of the CLIP or SigLIP kind puts pictures and queries in one space (Vision encoders). A page full of small text is too much for one vector; when answers live in charts, infographics or slides, section 10 keeps one vector per patch instead of translating figures into words.

FormatWhat the file already holdsWhat still goes wrong
HTMLheadings, lists and tables as DOM elementsboilerplate (navigation, footers, banners) and text rendered by JavaScript; boilerplate removal at web scale is on Extraction and filtering
DOCXa zip of XML parts (Office Open XML, ECMA-376): paragraphs, heading styles, tables with rows and cellsheadings faked with bold text instead of styles; text boxes and tracked changes
PPTXone XML part per slide; text in shapes, speaker notes apartshapes are stored in drawing order, not always reading order; the content is often the chart or picture, so slides suit section 10
XLSX, CSVtyped cells and formulasread cells natively rather than rendering them; merged and multi-row headers break exactly as in section 6, and rows need their headers when serialised

Docling and Unstructured both read DOCX, PPTX, XLSX and HTML directly (each project's README); only PDFs were measured on this page.

8. Metadata: what every chunk must carry

Once a chunk leaves its file, three jobs need facts only the parser had: a citation the user can check ("page 4 of the 2020 annual report, section 3.2"), a filter inside the search ("contracts signed after 2024", "documents this user may read"), and an update (replace every chunk of a changed file). Store each chunk as a record, not a string.

  • Source and version: document id, URL, the file's content hash and parse time; without the version a citation can point at text that no longer exists.
  • Location: page and bounding box, so a viewer opens the page and highlights the passage, how a user checks a citation in seconds.
  • Structure: heading path ("4 Experiments > 4.2 Results") and element type; prepending the path to the embedded text gives a chunk context (contextual prefixes: The retrieval pipeline).
  • Filters and permissions: dates, document type, tenant and access-control list as indexed fields the vector store filters inside the search (RAG in production shows why access enforced in the prompt leaks).
  • Ingestion facts: parser name and version, OCR used and its confidence, so a parser fix says which documents to re-parse; replace a document atomically so old and new chunks are never both live.

Cost: a few hundred bytes per chunk, small next to a 1,024-dimension float32 vector (4,096 bytes); dropping them costs a full re-parse later. How to check: open the cited page of twenty retrieved chunks from the metadata alone.

A record that can cite itself: page and box point back to the exact paragraph

A paragraph of QASPER paper 1909.00175 parsed by Docling 2.138.0: page, bounding box (PDF points, origin bottom left; drawn in orange on page 3), heading and element type are its real output; hashes computed by src/scripts/make_record.py; the acl value is illustrative and the field names are this page's choice, not a standard. Docling reported the heading as "3.1 Datasets and Settings" without its parent "3"; rebuilding the full path from heading numbers is a small post-processing step.

9. Incremental updates: re-embed only what changed

A contract gets an amendment, an arXiv paper a v2. Re-embedding the whole corpus on every change costs compute and stale time; the goal is to touch only chunks whose text changed and delete chunks of text that is gone, with three levels of content hash:

  1. File: same hash, skip it without parsing (an unchanged file re-synced).
  2. Chunk: hash each chunk's normalised text and compare with the document's stored hashes: embed only new hashes, delete vanished ones, keep the rest with their vectors.
  3. Embedding: key vectors by (chunk hash, embedding model, model version), so a model upgrade is a deliberate full re-embed, never a silent mix of two vector spaces.

The trap: chunk boundaries move. With fixed 200-word windows, one sentence inserted near the top shifts every later boundary and every later hash. Boundaries tied to content survive edits: paragraph and heading boundaries from the parser (structure-aware), or content-defined chunking, which cuts where a rolling hash of the last few words hits a chosen value, as the LBFS file system did with Rabin fingerprints (Muthitacharoen et al., SOSP 2001). Which chunking retrieves best is The retrieval pipeline's question; this is what each costs when documents change.

Predict: arXiv 1801.02073 v2 differs from v1 by one word: an author's middle initial, "Jinho Choi" became "Jinho D. Choi", in the author line at the top. With 200-word fixed windows, how many of the paper's 17 chunks must be embedded again?

Fig. 6: one revision, four chunkers. The front strip is the new version's words to scale, with the words the revision changed in red; each slab is a chunk as wide as its words, green when its hash is already stored (the vector is reused), orange when it goes through the embedding model again. Pick a paper, or follow the sample's predicted case:

  1. The revision. arXiv 1801.02073 v2 differs from v1 by one word near the top (the red mark): 1 of 3,377 words, the floor of what must be embedded again.
  2. Fixed 200 words. The inserted word shifts every later window by one word, so every window's text and hash change and all 17 chunks go back through the model.
  3. Fixed, 50 words of overlap. The same shift with more, overlapping chunks: all 23 are embedded again, and the overlapping words twice.
  4. Structure-aware. Chunks follow the parser's paragraphs and headings, so only the first chunk, the 33 words around the author line, changed: 1 of 26 chunks embedded again.
  5. Content-defined. Boundaries sit where the rolling hash of the last three words hits the chosen value, so they move with the text, not with word counts: 1 of 40.
  6. All ten revised papers of the QASPER sample (Docling, last two versions): the revisions changed 15.0% of the words (the red floor). Fixed 200-word windows re-embedded 75.8% of the words, and 76.4% with 50 words of overlap; structure-aware chunks 49.2%; content-defined chunks 44.2%.

A rewrite of a third of a paper (1910.14599, 39.5% changed) re-embeds most of it under any strategy; for a word or a sentence, boundaries decide between one chunk and the whole document.

Every revised paper, and how it was measured

The 10 papers of the sample with two or more arXiv versions (1802.00396 is excluded: its v2 is a withdrawal notice), last two versions compared, both parsed by Docling 2.138.0 on CPU. Words changed: difflib over lower-cased words of the new version, inserted or replaced. Content-defined chunking: a boundary where zlib.crc32 of the last three words is divisible by 24, 60 to 400 words per chunk. Script: src/scripts/change_detect.py.

Deletes are the half people forget: chunks of removed text must leave the index, or retrieval keeps citing a removed clause (in HNSW stores a delete is usually a tombstone until compaction; purging and freshness are on RAG in production). How to check: after a sync, a document's chunk hashes in the index equal those computed from its current version, no more and no fewer.

10. Skip the parser: retrieve the page image

Parsing loses what text cannot hold: a chart's shape, an infographic's layout, a diagram's arrows. A vision-language model reads a page as a picture cut into patches (small squares, each a vector); page-image retrieval embeds each page's screenshot and searches it with the text query, with no parsing at all.

ColPali (Faysse et al., 2024) takes PaliGemma-3B and keeps one 128-dimension vector per image patch: 1,024 patch vectors plus 6 for the text prompt, 1,030 per page (paper section 4.1 and footnote 10); a query keeps one vector per token. The score is late interaction as in ColBERT: each query token takes its best dot product with any patch and the maxima are summed (MaxSim), so "revenue" can match a bar label's patches and "2019" an axis tick's. MaxSim, ColBERT and PLAID-style indexing are owned by Rerankers and late interaction; this section is what changes when the document tokens are image patches.

score(q, page) = ∑i ∈ query tokens maxj ∈ patches qi · pj

Fig. 7: one vector per chunk against one per patch, 18 times less indexing time for 30 times the storage.

  1. The page as a picture. An infographic page of ViDoRe's InfoVQA set (this page's small copy). No text layer is read and no parser runs.
  2. Squeezed to 448 × 448, cut into patches. ColPali feeds PaliGemma-3B a square input of 448 pixels, as a 32 × 32 grid of 14-pixel patches (one shown filled).
  3. One patch, one vector. Each patch becomes one vector of 128 numbers; the camera moves in on the filled patch.
  4. A page is a block of vectors. Every patch does the same: the glass block holds the 1,024 patch vectors, the column beside it the 6 prompt vectors.
  5. MaxSim. Each query token (front) finds its best patch and the maxima are summed into the page's score; where each token lands here is illustrative, not recorded. Scoring costs 1 dot product per chunk against query tokens × 1,030 per page.
  6. Token pooling. The paper's token pooling (mean-pooling similar patch vectors, pool factor 3) cuts the vectors by 66.7% and keeps 97.8% of the retrieval quality (paper section 5.2, the authors' runs).
  7. What it costs, to scale. Storage per page: BGE-M3 text chunk 8.6 KB against ColPali 257.5 KB = 1,030 × 128 × 2 bytes = 263,680 B. Offline indexing on an NVIDIA L4: 7.22 s for the text pipeline (layout 0.81, OCR 2.67, captioning 3.71, encode 0.03) against 0.39 s for ColPali. Paper Tables 4 and 5, the authors' runs.

Published results. ViDoRe (Visual Document Retrieval benchmark, same paper) pairs text queries with page images, scored by nDCG@5 (normalised discounted cumulative gain over the top five pages). In its Table 2 ColPali averages 81.3 against 65.5 for Unstructured + OCR + BM25 and 67.0 for the best text pipeline (Unstructured + captions written by Claude 3 Sonnet + BGE-M3); the gap is largest on figures (ArxivQA 79.1 against 31.6) and smallest on text-heavy reports (Energy 91.0 against 85.9). The authors' runs; section 11 reruns it with a small open model.

11. Measured: page images against OCR text

Rerun here with laptop-sized models on 100-query, 200-page subsets of three ViDoRe v1 sets, InfoVQA (infographics), ArxivQA (figures from papers) and Energy (text-heavy reports): Tesseract OCR then BM25; the same OCR text embedded by bge-small-en-v1.5 (the root's small embedder); and the page image embedded by colSmol-256M (vidore/colSmol-256M: the ColPali recipe on SmolVLM-256M, MIT licence, 128 dimensions per vector).

Predict: on the Energy set (text-heavy industrial reports), does the 256M page-image model beat plain BM25 over Tesseract OCR?

On figures OCR text barely helps (the words in a plot are not what the question asks), so BM25 and the dense embedder both land near 38 and the 256M image model doubles that. On infographics the image model leads by 15 points, beyond both intervals. On text-heavy reports the methods tie, and plain BM25 beats the dense text embedder (95.0 against 88.2): rare domain terms favour exact matching. The shape matches the paper's, at smaller scale.

The page image wins where the text is not the content, and ties on text

nDCG@5, solid bars measured here with ± half the 95% interval; lighter bar: BM25 on the full set, for scale; dashed bars: the ColPali paper's Table 2 (the authors' runs on the full sets), not a reproduction.

Cost here: colSmol produced 699 to 1,103 vectors of 128 numbers per page (mean per set), about 175 to 280 KB per page in float16, against one vector for bge-small. Encoding took 4.3 to 5.9 s per page on this CPU in float32, against 0.3 to 1.6 s for Tesseract (the paper's 3B ColPali: 0.39 s on a GPU). What transfers: the ranking by document type and the storage arithmetic; not the absolute times or nDCG, since 200-page subsets are easier than full sets (BM25 on the full InfoVQA set: 67.5 against 72.6 on the subset).

How the ViDoRe comparison was run

Measured on Apple M1 Pro, 2026-10-14, on seeded subsets (seed 0) of three ViDoRe v1 test sets at pinned revisions: 100 queries and 200 pages each (the queries' relevant pages plus random others), so every retriever ranks the same 200 pages. OCR: Tesseract 5.4.1 (LSTM, English, --psm 3) on each page image as ViDoRe ships it. Text retrieval: BM25 (bm25s, Lucene variant, k1 1.2, b 0.75, stemming) and bge-small-en-v1.5 over the whole OCR page. Page images: vidore/colSmol-256M with colpali-engine 0.3.18, float32 on the CPU, because the MPS runs failed on the shared machine: one segfaulted while loading, one had not finished 500 InfoVQA pages after 30 minutes, with the 16 GB of memory deep in swap. nDCG@5 with one relevant page per query; ± is half the 95% bootstrap interval over queries. The full sets for the lighter bar have 500, 500 and 977 pages. Published bars: Unstructured with OCR (the paper citing the Tesseract overview) or with captions written by Claude 3 Sonnet, and ColPali 3B. Scripts: src/scripts/vidore_*.py.

Same query, three retrievers: the relevant page outlined in green

Top pages each retriever returned for sample queries; thumbnails are this page's small copies of the ViDoRe page images, cropped to their top for tall infographics.

12. Choosing an ingestion pipeline

Your documentsStart withWhy (evidence on this page)
Born-digital, single column, mostly prose (reports, contracts, editor exports)A fast text-layer extractor (PyMuPDF, pdftotext), with de-hyphenation and ligature normalisationMilliseconds per page; on LaTeX papers stream order was already close to reading order; hyphens and ligatures were the main damage (section 4)
Born-digital with columns, tables, captions, running headers (papers, filings, manuals)A layout-aware parser (Docling, Marker, MinerU), tables kept as HTML or Markdown with headersHighest evidence survival and the only correct table grid here; about a second per page on CPU (sections 4 and 6)
Scans and photosOCR routed per page (Tesseract or a parser's OCR), or VLM OCR on a GPU for hard layoutsText-layer tools return nothing on scans; published VLM OCR scores lead the full benchmark (sections 4 and 5)
Charts, infographics, slides, figure-heavy pagesPage-image retrieval (ColPali family), alone or fused with text retrievalSection 11 and the ColPali paper's Table 2
A corpus that changesStructure-aware or content-defined chunk boundaries, chunk hashes, vectors keyed by model versionSection 9: 49% or 44% of words re-embedded against 76% for fixed windows, with a 15% floor
Interview rehearsal: ingest 5 million mixed documents for an enterprise assistant with citations and per-user permissions
  1. Intake: a queue of (document id, version, ACL) events from each source; a file hash skips unchanged files.
  2. Triage per page: text-layer quality check; born-digital pages to a fast layout-aware parser on CPU workers, broken or scanned pages to an OCR or VLM-OCR pool on GPUs; spreadsheets read natively, not as images.
  3. Elements, not strings: keep type, page, bounding box and heading path; tables as HTML with a row serialisation; figures with captions, and VLM descriptions for figure-heavy collections.
  4. Chunk by structure; hash chunks; embed only new hashes, keyed by model version; write vectors and metadata (ACL, tenant, dates) to a store that filters inside the search; delete chunks whose hashes vanished in the same transaction.
  5. Optional visual index for slide decks and reports with charts: page-image embeddings (ColPali family) fused with text results, if you can afford about 30 times the vector storage and a multi-vector index.
  6. Evaluate on a golden set built from the original files, per document type; track parse failures, OCR share and pages per second as production metrics; re-parse by parser version when a parser improves.

Latency and cost of serving belong to RAG in production.

Built from runs on an Apple M1 Pro (10 CPU cores, 16 GB) on 13 and 14 October 2026. Every script, small result file and input is in this page's src/ folder (src/scripts/, src/data/, src/inputs/); large downloads stay outside the repository. Published numbers are labelled with who ran them and when.