HeadlinesBriefing favicon HeadlinesBriefing.com

PDF Outline Recovery via Body Typography for RAG

Towards Data Science •
×

Enterprise Document Intelligence [Vol.1 #5octies] presents a method to recover a PDF's table of contents from body typography when native outlines or printed contents pages are absent. This technique is crucial for RAG pipelines that depend on structured document outlines for retrieval and chunking. The approach uses six deterministic signals—font size ratio, boldness, numeric prefix, fitz artifact handling, short length, left alignment, and blank line above—to identify heading candidates.

An LLM loop then validates these candidates, reducing false positives. The process is part of a four-case cascade, where Case 4 (body typography reconstruction) is opt-in due to its expense. The cascade prioritizes cheaper methods first: native outline, linked contents page, and printed contents page.

When these fail, body typography analysis fills the gap. This method supports various scenarios: no structure, partial outlines, and composite documents. The article demonstrates the approach using the attention paper (data/paper/1706.03762v7.pdf), producing a 24-entry toc_df with 21 real headings and 3 false positives.

Parser differences affect available signals; Py MuPDF offers rich typography data, while OCR-based parsers rely on positional and textual cues. The solution integrates with existing Article 5B data models, ensuring compatibility with retrieval, chunking, and summarization components.