FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Tools

Many RAG demos break at the PDF, before any model is called

Docling, an MIT-licensed open-source toolkit from IBM Research, keeps layout and tables intact when exporting to Markdown and runs entirely locally.

ShareLinkedInFacebookX

In brief

  • Docling uses DocLayNet to analyze layout and TableFormer to recover table structure, which preserves tables and reading order in the Markdown output.
  • It runs locally on commodity hardware and works in air-gapped environments, a deciding factor when client documents are sensitive.
  • HybridChunker splits by structure, then by tokens, and repeats table headers in every chunk; Docling has built-in integrations with LangChain, LlamaIndex, Crew AI and Haystack.
Two ways of reading the same three-column price table in a contract PDF. On the left, a plain-text reader flattens the table into one run of text: "SKU Price Unit A-102 45.000 box B-210 120.000 case", with the figure 120.000 highlighted and a question asking whether it is the price of A-102 or B-210. On the right, Docling outputs a Markdown table that preserves rows and columns, with 120.000 sitting in the B-210 row.
If a price table is flattened into text, an LLM cannot be sure which figure belongs to which SKU. Docling preserves the row and column structure when it exports Markdown. The figures in the graphic are illustrative only, as in the article's example.

A price table flattened into a string of text, its columns mixed together, is enough to make a RAG demo answer wrongly, whichever model sits behind it.

Say it is your first week on site. The client hands over a folder of supplier contracts as PDFs, each with a multi-column price table, and sets one condition: the documents must not leave its internal servers.

Docling targets this point of failure. It is an open-source package started by the AI for knowledge team at IBM Research Zurich.

The project’s technical report, posted on arXiv on August 19, 2024 by a group of IBM authors including Auer, Lysak, Nassar, Dolfi, Staar and colleagues, describes it as an easy-to-use, self-contained tool under the MIT license. In April 2025, IBM contributed Docling to LF AI & Data, part of the Linux Foundation.

The step deserves an FDE’s attention because it sits at the head of the pipeline. Ingestion is seldom discussed, yet every later answer rests on it. Whoever masters it is often the person who rescues the demo.

What does Docling do that an ordinary PDF reader does not?

An ordinary text extractor only reads characters by their position on the page. Docling tries to understand what the page looks like, using two specialized models: DocLayNet analyzes the layout, and TableFormer takes the table regions that have been detected and recovers their structure.

As a result, according to the project’s GitHub page, Docling understands page layout, reading order and table structure. That understanding is also what lets it export proper Markdown, in which headings remain headings and tables remain tables.

There is another reason it suits work at client sites. The technical report says Docling runs on commodity hardware, and the official documentation lists local execution for sensitive data and air-gapped environments.

So at the first meeting with the client’s security team, you can answer at once when they ask whether any data leaves the building.

A minimal example: from PDF to Markdown

The official guide shows that a few lines of Python are enough: create a DocumentConverter, convert the document and call export_to_markdown():

from docling.document_converter import DocumentConverter

source = "supplier_contract.pdf"
converter = DocumentConverter()
doc = converter.convert(source).document
print(doc.export_to_markdown())

Return to the price table in the contract. Take one with three columns: item code, unit price and unit of measure. Read as plain text, it can come out as a single unbroken line:

Item code Unit price Unit A-102 45,000 box B-210 120,000 carton

Looking at that line, an LLM has no way to be sure whether 120,000 is the price of A-102 or B-210. What you want to see after running Docling is a Markdown table with its rows and columns intact:

| Item code | Unit price | Unit   |
|-----------|------------|--------|
| A-102     | 45,000     | box    |
| B-210     | 120,000    | carton |

The figures are only illustrative, but the check is one you can use. Don’t stop once the code runs: open the Markdown output and go through each table, checking that every item code sits beside the right unit price and that units have not slipped into the neighboring column.

Markdown is not the only export format; the official documentation also lists HTML, WebVTT and DocLang. Markdown works well for feeding straight into a prompt and for checking by eye.

Checking one table is easy; measuring a batch is persuasive

Checking by eye is enough for only a few files. When the client asks how well it reads tables, you need a number from a whole batch of the client’s own documents.

The simplest method is to pick a sample of tables, type out a reference version of each by hand, then count how many come out with the right number of rows, the right number of columns and every cell in the right place.

Suppose the sample has 40 tables and 31 pass. The preservation rate is 31/40, or 77.5%. Run the same sample through the extractor the client uses now, and you have a before-and-after pair.

A pass/fail rate has a drawback: a table with one misplaced cell counts as a complete failure. For a finer measure, use TEDS (Tree-Edit-Distance-based Similarity), a metric proposed in a 2019 study of table recognition.

TEDS compares a predicted table with the reference on row and column structure as well as the content of each cell, producing a similarity score; the average across samples gives the score for the batch. Report both numbers to the client: the share of perfect tables because it is easy to grasp, and the TEDS score because it shows how severe the damage is.

Chunk by structure rather than character count

Conversion is only half the job. Cutting a document into 500-character pieces is the easiest way to split the price table you have just preserved, or to separate a clause from its heading.

Docling’s HybridChunker handles this. It splits along the document’s hierarchy first, then refines the result with a tokenizer, usually one matched to the embedding model. It splits only oversized chunks and merges small adjacent ones, so that each fits the token limit the model accepts.

from docling.chunking import HybridChunker

chunker = HybridChunker()
for i, chunk in enumerate(chunker.chunk(dl_doc=doc)):
    print(i, chunk.text[:80])

When a long table has to be split across several chunks, Docling by default repeats the table’s header row at the top of each one. Check for this when you print the results: the second chunk of the price table should still begin with “Item code | Unit price | Unit”.

The next step needs no hand-written glue code either. Docling has built-in integrations with LangChain, LlamaIndex, Crew AI and Haystack, so if the client has already built its stack on one of these frameworks, Docling replaces only the ingestion step.

Promise nothing until you have run the worst documents

A specialized model is still a model. A skewed, blurry scan with a stamp across the table is likely to be much harder for layout analysis and table recognition than a PDF exported from Word.

So don’t commit to an accuracy figure on a slide. Ask the client for samples of its worst documents, run them through Docling, measure table preservation as above and show the real results, including what is still wrong.

Running locally has a cost, too: compute is now your responsibility instead of an external API’s. With thousands of documents, measure processing time on the client’s own servers before promising a rollout date.

What to learn first, and what to put on your CV

Learn in this order: converting PDFs to Markdown, reading the output to spot broken tables, building a set of reference tables to measure against, and only then HybridChunker and the framework integrations. Reading the technical report on arXiv will help you understand what DocLayNet and TableFormer do, so that you can explain why a table was misread.

In job descriptions, look for phrases such as “document ingestion,” “unstructured data” or “on-prem deployment”; they signal that a company faces this problem.

On a CV, a line with a number carries far more weight than “experience with RAG.” For example: “Built a local ingestion pipeline for table-heavy documents, raising the share of tables with structure preserved from X% to Y% on a sample checked against reference tables.”

Clients will remember the FDE who made a RAG demo work on their own messy PDFs, and proved it with numbers, long after they have forgotten who picked the newest model. Docling is one of the shortest routes to getting there.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
8 sources
Read next on the roadmap · Stage 2: Broad engineeringA missed division turns 35°C into 350 at the first factory demoNode-RED bridges Modbus and OPC UA to MQTT in an afternoon; the traps are scaling raw values, restarting after installs and securing the editor.