deep · 6 min
Document parsing
Turning PDFs and scans into clean text, with reading order and tables intact, before a model or search index sees them.
updated 29 Sept 2026
Take a two-column research paper and copy all its text out with a basic PDF tool. You can get back something like this (a made-up example, but a typical one):
Retrieval improves accuracy on all three We trained the model for datasets, with the largest gain on the two epochs using a learning long-document set. rate of 1e-4.
Two paragraphs from two columns, woven together line by line. Now picture that text cut into chunks and put in a search index for a retrieval system. Every answer built on it starts from garbage.
Document parsing is the step that prevents this. It turns a PDF or a scan into clean text, usually Markdown, with paragraphs in the right order and tables still shaped like tables. It happens once, before chunking, before retrieval, before extraction. Whatever it gets wrong, every later step inherits.
Why the PDF doesn't just hand over its text
A PDF doesn't store paragraphs or headings. It stores single characters, each with where it goes on the page, plus spacing and fonts. That's enough to draw the page. It's not enough to know that the left column comes first.
So a plain text dump breaks in a few predictable ways. Columns get woven together, like above. Tables come out as a stream of numbers with no rows or columns, so you can't tell which number goes with which label. And a scanned page is just a picture with no text in it at all, so something has to read the pixels (that's OCR).
A parser rebuilds what the PDF never stored: which blocks are text, headings, tables, figures or formulas, what order to read them in, and where the rows and columns of each table are.
Three ways to build one
The first way is a pipeline of small, specialised models. Docling, from IBM, is a clear example. It pulls every piece of text out of the PDF with its position, and also renders each page as an image. A layout model looks at the image and marks out the blocks. A table model rebuilds each table. OCR runs only if you turn it on, because it's slow (upwards of 30 seconds a page on a CPU, for the engine they used). Then a last step works out the reading order and puts it all together. The nice part is it runs on ordinary hardware, about 1.3 pages a second on an Apple M3 Max CPU in their tests.
The second way skips most of that. Render the page as a picture and ask a vision model to write it all out, like any other question about an image. olmOCR, from Ai2, is a 7B vision model trained for just this, on 260,000 pages. You might expect a big general model to do it better. The trouble is that general models make a specific kind of mistake here. Without help, GPT-4o would skip content, rewrite or finish sentences in its own words, or describe pictures nobody asked about. That's hallucination inside your source text, and it's hard to spot because it reads so smoothly.
olmOCR's fix is called document anchoring. Along with the page image, the prompt includes the text and positions the PDF already has, so the model isn't guessing every word from pixels. It also costs about $176 per million pages, where sending those pages to GPT-4o would cost over $6,240.
The third way mixes the two. Marker, from Datalab, takes the PDF's own text first, in its reading order, and detects the layout. Then page by page it asks: is this text usable? Only the garbled or scanned pages go to a vision model. Tables get rebuilt from the text with simple rules, and only the ones it's unsure about go to the model.
That gives a speed dial. In Marker's own runs on one GPU machine, its balanced mode did 2.9 pages a second. A fast mode with no OCR, on a plain CPU, did 23.7. But that fast mode scored zero on pages of math from research papers and on old scans of math, because without OCR there was nothing usable to read.
There's also the hosted route. Mistral OCR 4 is an API at $4 per 1,000 pages ($2 in batch), and it returns Markdown with a box around each block, the block's type, and confidence scores. Those scores are handy: they tell you which parts to check by hand.
And of course you can skip parsing and send the PDF straight to a model each time you ask something, which is PDF input. For one document and one question, that's fine. For a collection you'll search over and over, parsing once and storing the text is cheaper, and you get something you can check.
So which one is best?
This is where it gets murky. There are two public benchmarks people cite. OmniDocBench has 1,651 pages across 10 kinds of document (papers, financial reports, newspapers, textbooks, handwritten notes) and scores text, tables and formulas against reference answers, then averages the three. olmOCR-Bench has about 1,400 PDFs and thousands of small pass-or-fail tests: is this sentence there, does this line come before that one, is this table cell in the right place.
Here's a slice of the OmniDocBench leaderboard as of 2026-09:
Small models trained only for this job are at the top. TeleOCR has 1.2 billion parameters and beats Gemini 3 Pro. And most of the gap between top and bottom here is tables: about 97 for TeleOCR on table structure, about 66 for Marker.
So Marker is weak? Hold on. Marker's own README puts its balanced mode ahead of MinerU's pipeline on olmOCR-Bench (76.0 to 72.7), the reverse of the chart. The olmOCR paper's table puts olmOCR first on its own benchmark. Each team's table tends to put its own tool on top. That doesn't make anyone a liar. They test different documents, different versions (the Marker row above is a mid-2025 release), and different things.
And the answer keys have mistakes. Mistral's launch post lists them: reference answers with typos or missing text, two LaTeX formulas that look identical when rendered but count as different, and words split across columns marked as reading-order failures. These mostly punish correct output. OmniDocBench fixed some typos in its own answers in 2026-04 and changed how it matches output to answers, so scores from before and after don't compare cleanly. Mistral reports 93.07 for OCR 4 on OmniDocBench, but that's its own run and isn't on the public board.
One more thing. That overall score gives formulas a full third of the weight. If your documents are invoices with no formulas, that third tells you nothing about your case. (See benchmarks for more on reading public scores.)
If you plan to ship one of these, check licences too. Docling is MIT. Marker's code is Apache 2.0, but its model weights are free only for research, personal use and startups under $5M in funding or revenue.
Back to the two columns
Mistral's own advice, after all its benchmark claims, is to evaluate on your own documents. Which brings us back to that woven-together paper.
The test for it is easy to write as a script: "Retrieval improves accuracy on all three datasets" appears as one unbroken sentence, and it comes before "We trained the model for two epochs". That's the olmOCR-Bench style, a code-based eval, and it sidesteps the answer-key problems. A few dozen pages that look like your real documents (the tables, the two-column layouts, the scans, the formulas if you have them), a few checks per page, and two or three parsers run over them. Note the pages per second and the cost per 1,000 pages next to each score. Keep page numbers and block positions in the output, because you'll want them later for citations. Then parse once, store the clean text, and chunk from that.
Further reading
- olmOCR: Unlocking Trillions of Tokens in PDFs with Vision Language Models, Jake Poznanski et al. (Ai2), 2025. The best explanation of why PDFs are hard, plus document anchoring and the pass-or-fail benchmark. Start here.
- Docling Technical Report, Christoph Auer et al. (IBM Research), 2024. A pipeline parser walked through step by step, with CPU speeds.
- Marker, Datalab. A hybrid parser. The README's speed and score table is worth a look.
- OmniDocBench, OpenDataLab, leaderboard updated 2026-09-11. The leaderboard and its version history.
- Mistral OCR 4, Mistral AI, 2026. A hosted option with prices, and the clearest list of how parsing benchmarks mark correct output wrong.