Red Hat engineer cuts PDF parsing costs by 50 times

AI Engineer////3 min read

The Costly Mess of Unstructured PDFs

Red Hat engineer cuts PDF parsing costs by 50 times
Structuring the Unstructured - Cedric Clyburn, Red Hat

Unstructured data sits in silos. Organizations run on PDFs, slide decks, and scanned invoices, but large language models cannot read them natively. Simple text parsers fail quickly because they merge side-by-side columns, drop images, or turn tables into unreadable strings.

Bad parsing leads to bad outputs. A recent academic paper highlighted this issue when an AI tool merged two separate columns from an old, scanned document, creating a non-existent word that other researchers eventually cited. Accurate extraction is the foundation of reliable AI systems. An open-source parser called Docling, supported by the Linux Foundation, resolves these layout issues locally without sending sensitive files to third-party APIs.

Prerequisites and Tooling

To follow this tutorial, you need a basic understanding of Python and command-line interfaces. We will use several libraries to build our processing pipeline:

  • Docling: The core document conversion library.
  • Ollama: For running local vision language models.
  • Pydantic: For structured data validation.

Install the primary package using pip:

pip install docling

Extracting Tables and Text with DocumentConverter

The central class in the library is DocumentConverter. This component orchestrates layout analysis and Optical Character Recognition (OCR) models to identify headers, text blocks, images, and tables. Here is how to run a basic conversion:

from docling.document_converter import DocumentConverter

converter = DocumentConverter()
result = converter.convert("https://arxiv.org/pdf/2408.09869")
print(result.document.export_to_markdown())

This script downloads a remote research PDF, analyzes the structure, and outputs clean markdown.

If your documents contain critical tabular data, you can isolate those elements and convert them directly into Pandas DataFrames for analysis:

for table in result.document.tables:
    df = table.to_dataframe()
    print(df.head())

Because Docling represents the parsed output as a Pydantic model, you can programmatically inspect pages, bounding boxes, and specific document segments without writing fragile regular expressions.

Chunkless RAG and Agentic Workflows

Traditional Retrieval-Augmented Generation (RAG) pipelines cut text into arbitrary, fixed-size chunks, encode them into vectors, and store them in databases. This process often breaks paragraph context.

Using structured document parsing, you can implement chunkless RAG. Instead of a vector database, the markdown outline of the document serves as your index:

# Use the structural outline as the search index
outline = result.document.export_to_markdown()

An LLM agent reviews this hierarchical outline first, identifies the exact section containing the answer, and retrieves only that specific block of text. This setup completely bypasses embedding models and vector search.

Scaling with Microservices and MCP

Processing thousands of documents in a single script is slow. You can scale your pipeline by running the parser as a REST API service:

pip install docling-serve
docling-serve --port 8000

For developer environments, configure the Docling Model Context Protocol (MCP) server in your AI editor. This lets development assistants natively parse local files during chat sessions. When running these workflows, watch your CPU resources; layout detection and image OCR are intensive tasks.

Topic DensityMention share of the most discussed topics · 13 mentions across 11 distinct topics
Docling
23%· products
Cedric Clyburn
8%· people
Claude
8%· products
Hugging Face
8%· companies
Leandro
8%· people
Other topics
46%
End of Article
Source video
Red Hat engineer cuts PDF parsing costs by 50 times

Structuring the Unstructured - Cedric Clyburn, Red Hat

Watch

AI Engineer // 20:41

We turn high signal in-person events for the top AI engineers, founders, leaders, and researchers in the world into the best free learning opportunities for millions around the world here on YouTube. Your subscribes, likes, comments, speaking, attendance, or sponsorships goes a long way toward making our biz model sustainable indefinitely. We strongly believe this industry deserves a better class of community and that we know how to do this well; we just need your support.

Who and what they mention most
Anthropic
26.9%21
Claude
21.8%17
OpenAI
19.2%15
Cursor
15.4%12
3 min read0%
3 min read