AI Skills AI技能 5h ago Updated 54m ago 更新于 54分钟前 48

Multi-Document RAG: A Folder of Unrelated PDFs Is One Long Document with a Nested Outline 多文档RAG:不相关的PDF文件夹是一个带有嵌套大纲的长文档

When documents in a folder share no common fields, the RAG architecture shifts from indexed tables to a two-level routing system treating the folder as one long document with files as chapters Preparation collapses to two lightweight artefacts: one summary line per file (Level 0) and each file's table of contents (Level 1), eliminating the need for schema extraction Two diagnostic questions determine corpus type: whether documents reference each other, and whether a business user can name a shar 针对无共同字段、文档间无相互引用的异构文件夹,RAG系统无需构建传统索引表,而是将其视为"一个长文档"处理 预处理仅需生成两个产物:每个文件一行摘要(用于路由)+ 各文件自身的目录结构(嵌套大纲) 采用两级路由架构:先用摘要列表筛选相关文档,再深入具体文件,避免将整个大纲输入提示词 通过两个关键问题判断文件夹类型:文档间是否存在引用关系、业务用户能否命名共享字段 在63个公开PDF(4,211页,含NIST、arXiv、世界银行文档)的测试集中验证了该方案的有效性

65
Hot 热度
72
Quality 质量
68
Impact 影响力

Analysis 深度分析

TL;DR

  • When documents in a folder share no common fields, the RAG architecture shifts from indexed tables to a two-level routing system treating the folder as one long document with files as chapters
  • Preparation collapses to two lightweight artefacts: one summary line per file (Level 0) and each file's table of contents (Level 1), eliminating the need for schema extraction
  • Two diagnostic questions determine corpus type: whether documents reference each other, and whether a business user can name a shared field with consistent meaning across all documents
  • The two-level routing system filters irrelevant files before any page content is read, demonstrated on a 63-file, 4,211-page corpus of NIST, arXiv, and World Bank documents
  • This approach trades away filtering, aggregation, and shared vocabulary capabilities that homogeneous corpora enjoy, but requires minimal new machinery

Why It Matters

This article addresses a common real-world RAG challenge: enterprise document repositories rarely consist of uniform records with shared metadata fields. By providing a practical architecture for heterogeneous folders, it gives practitioners a concrete alternative to over-engineering or falling back to naive vector search. The diagnostic framework for classifying corpus types prevents costly architectural mismatches before implementation begins.

Technical Details

  • Two-question diagnostic: Documents are classified by (1) whether they cross-reference each other and (2) whether a business user can name a consistently-meaningful shared field; if both answers are no, the folder is treated as a single long document
  • Two-level index structure: Level 0 consists of one-line summaries per file written for a router (not a reader), and Level 1 is the parser-returned table of contents for each file, forming a nested outline
  • Two-level routing architecture: A routing call operates on the flat file list first, pruning irrelevant documents before any page content is ingested into the context window; the nested outline guides subsequent navigation without ever entering a prompt whole
  • Demonstration corpus: 63 public PDFs totaling 4,211 pages — 25 NIST publications (public domain), 31 arXiv papers, and 7 World Bank Commodity Markets Outlook issues (CC BY 3.0 IGO)
  • Four failure modes identified: Including the scaling limit where the flat file list approach breaks down, with companion notebook code available at doc-intel/notebooks-vol1

Industry Insight

  • Mixed folders are the norm, not the exception; splitting heterogeneous drives into homogeneous and heterogeneous partitions and applying the correct architecture to each avoids the cost of building the wrong system
  • Writing summary lines for a router rather than a reader is a subtle but critical design choice that affects retrieval quality — summaries must be discriminative enough to route queries, not informative enough to answer them
  • The "folder as one long document" mental model simplifies enterprise RAG design significantly, but practitioners should be aware of the scaling ceiling where flat file lists become a bottleneck and more sophisticated indexing becomes necessary

TL;DR

  • 针对无共同字段、文档间无相互引用的异构文件夹,RAG系统无需构建传统索引表,而是将其视为"一个长文档"处理
  • 预处理仅需生成两个产物:每个文件一行摘要(用于路由)+ 各文件自身的目录结构(嵌套大纲)
  • 采用两级路由架构:先用摘要列表筛选相关文档,再深入具体文件,避免将整个大纲输入提示词
  • 通过两个关键问题判断文件夹类型:文档间是否存在引用关系、业务用户能否命名共享字段
  • 在63个公开PDF(4,211页,含NIST、arXiv、世界银行文档)的测试集中验证了该方案的有效性

为什么值得看

本文针对企业RAG系统中最常见却最容易被错误处理的场景——异构文档文件夹,提供了清晰的分型判断标准和轻量级架构方案,避免了为不适合的文档集过度工程化。对于正在构建或优化企业级文档智能系统的工程师而言,这篇文章帮助识别何时不需要索引、如何设计两级路由机制,具有重要的实践指导价值。

技术解析

  • 文件夹类型判断:通过两个问题确定架构方向——(1) 文档间是否存在交叉引用(如修正案引用主协议);(2) 业务用户能否命名跨文档含义一致的共享字段(如客户、生效日期)。若两者均为否,则属于本文讨论的异构场景。
  • 预处理架构:仅需生成两个产物——Level 0为每个文件一行摘要(面向路由器而非读者编写),Level 1为各文件自身的目录结构。两者共同构成嵌套大纲,无需构建传统列式索引表。
  • 两级路由机制:查询时先用摘要列表进行路由筛选,将相关文档从候选集中选出,再深入具体文件。嵌套大纲不会整体进入提示词,避免上下文浪费。
  • 测试数据集:63个公开PDF共4,211页,包括25个NIST文件(安全控制目录、零信任架构规范等)、31篇arXiv机器学习论文、7期世界银行大宗商品市场报告,涵盖安全、AI风险、机器学习、商品市场等异构主题。
  • 适用边界:该方案不适用于同质化文档集(已有共享字段可建索引、支持SQL过滤和聚合查询),也不适用于文档间存在结构依赖关系的场景。

行业启示

  • 架构选择应先于实现:企业在构建RAG系统前,必须对文档集合进行类型诊断,错误的架构选择会导致严重的工程浪费或性能瓶颈,异构文件夹与同质化数据库需要完全不同的技术路径。
  • 轻量级方案的价值:对于无共同字段的文档集,"文件夹即长文档"的抽象思维可以大幅简化系统复杂度,避免过度设计,用两级路由替代传统向量检索+重排序的复杂管线。
  • 混合文件夹的处理策略:企业共享驱动器中常同时存在同质化合同和异构研究文档,应将其拆分为不同语料库分别处理,而非强行统一架构,这是实际部署中常见的优化机会。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

RAG 检索增强生成 LLM 大模型 Research 科学研究 Embedding Model 嵌入模型