Skip to content

Docling as the extractor

Docling (MIT, by IBM Research) can replace the built-in loaders for the formats it reads. It analyses each page's layout, puts the text in reading order, rebuilds tables (including tables in PDFs) and runs OCR on scans and images. It returns Markdown. It runs inside Pagelore and uses no LLM and no API key.

Install and turn on

uv sync --extra docling    # PyTorch + Docling (~0.5 GB of models, downloaded on first use)

The extractor is a chunking option, so it can be set at three levels, each overriding the one before:

# src/.env
DOCUMENT_EXTRACTOR="docling"
curl -X POST localhost:8000/api/v1/projects -H 'Content-Type: application/json' \
     -d '{"project_name": "contracts", "chunking": {"extractor": "docling"}}'
curl -X POST localhost:8000/api/v1/projects/1/documents \
     -F files=@report.pdf -F extractor=docling

What it reads

  • Docling reads: PDF, images, Word, PowerPoint, Excel / CSV, OpenDocument, HTML, Markdown, AsciiDoc, LaTeX, EPUB, e-mail and more. DOCLING_EXTENSIONS (for example pdf,docx,pptx) limits the list.
  • Native loaders keep: plain text, JSON, XML, archives, audio / video and subtitles.
  • Docling only: formats only Docling reads (XBRL, JATS .nxml, Box notes, ...) use it whenever it is installed, whatever the extractor setting. Without Docling, they are unsupported and the message says to install it.

Sections and citations

  • PDFs and images give one section per page, and slides one per slide, so citations keep their page numbers.
  • Word, HTML and similar files give one Markdown section; the markdown strategy then keeps the heading path.
  • Spreadsheet tables become table sections, as with the native loader.

Fallback

If Docling fails on a file, or is not installed, the native loader reads it and document_metadata.docling_error says why. Set DOCLING_FALLBACK=false to fail the file instead.

document_metadata.extractor records which extractor read each file. Re-chunking a document with another extractor extracts the kept original again (FILE_KEEP_ORIGINALS).

Settings

Setting Default
DOCUMENT_EXTRACTOR native native or docling, the server default
DOCLING_EXTENSIONS all it reads Comma-separated extensions Docling handles
DOCLING_FALLBACK true Use the native loader when Docling fails
DOCLING_OCR true OCR scanned pages and images
DOCLING_TABLE_STRUCTURE true Rebuild table structure (TableFormer)
DOCLING_TIMEOUT none Seconds per document
DOCLING_DEVICE auto cpu, cuda, mps, xpu or auto
DOCLING_ARTIFACTS_PATH none A folder of pre-downloaded models, for offline servers

Speed

Word, HTML, Markdown, spreadsheets and slides convert in well under a second. PDFs and images run the layout models: a few seconds per document on a laptop CPU, faster on a GPU (DOCLING_DEVICE=cuda or mps). Conversions run one at a time. The first PDF also downloads the models.

Offline servers

uv run docling-tools models download -o ./docling-models

Then set DOCLING_ARTIFACTS_PATH to that folder.

Is it better for my files?

It depends on the files. Docling helps most with two-column PDFs and tables in PDFs; for plain single-column text the native loader is as good and much faster. Measure it on your own documents with Native or Docling?.

FAISS on macOS

Docling uses PyTorch. With faiss-cpu in the same process on Apple silicon, the two OpenMP runtimes abort the process ("OMP: Error #15"). Use another vector DB with Docling on a Mac.