HyperAIHyperAI

Command Palette

Search for a command to run...

Route Multi-Document RAG Queries for Unrelated PDFs via Nested Outlines

Retrieval-Augmented Generation systems frequently encounter heterogeneous document collections where files lack shared metadata fields. Unlike homogeneous corpora that support relational indexing, a folder of unrelated PDFs—including mixed technical specifications, research papers, and market reports—functions effectively as a single long document with a nested outline. This architecture eliminates the need for complex schema extraction, ontologies, or SQL agents, relying instead on a lightweight two-level routing mechanism that treats the folder structure as the primary index. Ingestion generates two core artifacts. The first is a Level 0 index consisting of one summary line per file. These summaries serve as routing definitions rather than descriptive blurbs; they must capture subject matter, negative constraints, and user-aligned vocabulary to enable precise file selection. The second artifact is a Level 1 index derived from each file's table of contents. Modern parsers often extract this hierarchical structure natively, providing a map of sections and subsections. For files lacking native outlines, short documents are treated as leaves during retrieval, while longer unstructured texts may require outline reconstruction techniques. Query execution proceeds through two bounded stages. The routing call reads the Level 0 summary list to select candidate files, often incorporating keyword tallies to catch specific codes or terms omitted from the summaries. This stage remains computationally efficient and auditable, as the model evaluates a fixed number of short lines rather than processing the entire corpus. Once relevant files are identified, the system descends into the Level 1 index, applying standard hierarchical retrieval to navigate internal sections until a relevant leaf node is reached. This ensures that only a small fraction of total pages are ingested into the model context. While scalable for moderate collections, the flat Level 0 list may face accuracy degradation as file counts grow beyond a few thousand, prompting the introduction of intermediate grouping levels. Common operational challenges include vague summary lines that trigger excessive candidate matches and structureless documents that block hierarchical descent. These issues are mitigated through rigorous summary validation against test queries and robust parsing strategies. This approach provides a minimal-machinery solution for unstructured folders, enabling multi-document RAG without the overhead of building relational databases or entity links for disjointed information sets.

Related Links