HeadlinesBriefing favicon HeadlinesBriefing.com

Multi-Document RAG for Unrelated PDFs

Towards Data Science •
×

Building a Retrieval-Augmented Generation system beyond a single document typically requires an index with shared filterable fields. Yet many enterprise folders contain unrelated PDFs lacking common metadata. When no consistent column exists across documents, traditional indexing fails. Instead, preparation collapses into two artifacts: a single summary line per file paired with each document’s native table of contents.

This method relies on two-level routing rather than flat search. The first level matches queries against summary lines to select relevant files, while the second navigates their nested outlines. Crucially, the full outline never enters a prompt simultaneously, preserving context windows and reducing overhead. The router optimizes selection before any page content is consumed.

Validation uses a folder of 63 public PDFs totaling 4,211 pages, comprising 25 NIST publications, 31 arXiv papers, and seven World Bank reports. Treating unrelated documents as a single long text with a nested structure bypasses complex schema design. This architecture scales efficiently until the initial file list reaches its own limit, requiring manual curation or hierarchical grouping thereafter.