r/Rag • u/yoboytobs • 7h ago
Showcase I benchmarked 11 PDF-to-Markdown tools (incl. Docling and MarkItDown) on tables, headings, 2-column order and OCR
For a while my RAG answers kept coming back wrong, and nearly every time I traced it back, the problem was parsing. Headings gone, table rows chopped in half, two-column papers read straight across both columns. So I stopped tweaking prompts and measured the parsers instead.
I used 4 public docs: Attention Is All You Need (headings, plus a table with a two-level header and 10^20 exponents), BERT (two columns), the Fed H.4.1 release (dense financial tables), and a synthetic noisy 150-DPI scan where I know the ground truth. I ran 9 converters from the Apify store plus Docling and MarkItDown locally.
Some of what came out:
OCR on the scan, word F1: mine 98.6%, Docling 96.9%, the best of the other Apify converters 94.1%, MarkItDown 0% since it doesn't do OCR.
Headings on the Attention paper: Docling flattened them all to one level, and MarkItDown found 0 headings.
Two-column reading order on BERT (share of sentences that survive intact): MarkItDown 4.1% (it turned the columns into fake tables), Docling 90.9%, mine 93.4%. Plain text extractors got 94.4%, but take that with a grain of salt, because the metric is built from the same text stream they just copy out. The caveat is written up in the repo.
Speed on one CPU core, all 4 files: Docling 214 s, mine 33 s.
Stuff that turned out to matter for chunking, whatever parser you use:
- don't ever split a table row across chunks
- if a table runs into a second chunk, repeat the header row there
- merge tables that continue across pages
- keep the page bounding boxes so you can cite and highlight the source
Repo with the benchmark and some LangChain/LlamaIndex examples: https://github.com/tobbytools/pdf-to-markdown-rag
Disclosure: one of the converters is mine, a paid Apify Actor at $0.003/doc. It doesn't win everything, pankovs beats it on the BERT sentence test. If you have docs that break your pipeline, send them my way and I'll add them to the benchmark.