TL;DR
Docling is a fast, self-contained, MIT-licensed open-source Python library designed to convert complex PDF documents into clean JSON or Markdown formats. By combining a custom PDF parser with specialized, lightweight AI models for layout analysis and table recognition, Docling runs entirely locally on commodity hardware, bridging the long-standing gap between poor open-source parsers and expensive proprietary cloud solutions.
What Problem Does This Paper Address?
PDFs are ubiquitous, but they are fundamentally optimized for printing and display rather than machine processing. The format typically discards structural metadata like paragraphs, reading order, columns, and table hierarchies, leaving behind a flat soup of text characters and coordinates.
With the explosive growth of Large Language Models (LLMs) and Retrieval-Augmented Generation (RAG), extracting structured content from PDFs has become a critical bottleneck. While powerful commercial cloud APIs exist, the open-source ecosystem has historically been fragmented: tools are either fast but prone to breaking layout structures (e.g., merging text across distinct columns), or they lack the ability to accurately reconstruct complex elements like borderless tables. Docling addresses this by providing a high-quality, extensible, and completely local document conversion pipeline.
Methods
Docling implements a modular, linear processing pipeline that operates sequentially on a document's pages:
- PDF Backend Parsing: The document is first processed by a backend to extract programmatic text tokens (strings and coordinates) and render a bitmap image of each page. Docling introduces a custom-built parser called
docling-parse(built on the low-levelqpdflibrary) to overcome font encoding and text-merging bugs common in other open-source libraries. - Layout Analysis: A lightweight object detector derived from the RT-DETR architecture predicts bounding boxes for structural elements (titles, captions, paragraphs, tables, etc.). Operating at a modest 72 dpi, it achieves sub-second latency on a standard CPU.
- Table Structure Recognition: Detected tables are handed over to TableFormer, a specialized vision-transformer model. TableFormer predicts the logical row/column grid, spans, and headers, handling complex variations like borderless or empty cells.
- OCR (Optional): For scanned documents, Docling integrates EasyOCR to transcribe text from the page images.
- Assembly & Post-Processing: Instead of relying on expensive vision-based re-transcription, Docling matches the bounding boxes from the AI models back to the original programmatic PDF text tokens. A final post-processing step infers the correct reading order, resolves overlapping elements, attaches captions to figures, and generates a unified document object ready for Markdown or JSON serialization.
Datasets
- DocLayNet: A large, human-annotated document layout dataset used to train the layout analysis model, ensuring robustness across diverse document types (financial reports, scientific papers, patents, etc.).
- Standard Evaluation Test Set: A 225-page benchmark distributed with Docling, comprising three arXiv papers and two IBM Redbooks, used to evaluate processing speed and memory footprint.
Key Insights and Ideas
- The Best of Both Worlds (Vision + Programmatic Text): Rather than using heavy, end-to-end Vision-Language Models (VLMs) that visually read and re-type the entire text (introducing latency and hallucination risks), Docling uses vision only to discover structure. It then maps that structure back to the flawless programmatic text embedded in the PDF.
- CPU-First Efficiency: The authors demonstrate that state-of-the-art layout and table parsing do not require massive GPUs. By optimizing the models and processing at 72 dpi, the entire pipeline runs efficiently on standard consumer CPUs.
- Architectural Extensibility: The pipeline is designed around a
BaseModelPipelineclass, allowing developers to easily inject custom OCR engines, layout models, or new feature extractors (like equation or code recognizers) into the loop.
Key Results
The report establishes baseline performance numbers across different hardware configurations using a 225-page test set (with OCR disabled):
- Apple M3 Max (16 cores): Using the default
docling-parsebackend with a 4-thread budget, Docling achieves a throughput of 1.27 pages per second (Time-to-Solution: 177 seconds) with a peak memory footprint of 6.20 GB. Switching to the alternativepypdfiumbackend increases throughput to 2.18 pages per second and drops memory to 2.56 GB, though at the cost of lower table recognition quality. - Intel Xeon E5-2690 Server: Achieves 0.60 pages per second with 4 threads, scaling up to 0.92 pages per second when allowed 16 threads.
- Component Latency: The layout analysis model runs with sub-second latency per page on a single CPU, while TableFormer typically requires 2 to 6 seconds per table, heavily depending on cell density.
Limitations and Future Work
- OCR Bottleneck: While standard PDF parsing is fast, enabling OCR via EasyOCR slows the pipeline down significantly, taking upwards of 30 seconds per page on a CPU. The team is actively seeking faster OCR backends.
- GPU Acceleration: Native GPU acceleration support for the underlying PyTorch and ONNX runtimes is currently a work-in-progress and largely untested.
- Feature Roadmap: Future iterations plan to introduce specialized models for figure classification, formula/equation recognition, and code block extraction to further enrich the Markdown output.
Summary updated