把语义编译到数据摄入阶段,让问答系统更高效
RAG Deserves an Index: Why Ingest-Time Compilation Beats Query-Time Interpretation
- 在数据入库时预先编译语义,生成可查询的结构化索引
- 相比传统方法,检索效率提升33.7倍,且精度更高
- 适合追求低延迟、高精度的生产级RAG系统使用
几乎每个生产环境中的检索增强问答系统都隐含一个解释器:每次查询时,语言模型都要重新解析原始文本并丢弃结果。尽管模型成本下降,但推理开销反而上升,因为上下文量增长快于成本下降。这如同数据库的全表扫描,解决办法是数据库50年前就用过的:将昂贵工作一次性在写入时完成,构建可维护的结构以实现低成本读取。已知读取模式的语料库理应在摄入时就建立索引。我们提出摄入时语义编译(ISC)范式:通过两个耦合层——增量维护的嵌入表示和经过验证来源的原子命题——将语义编译为可查询的底层结构,并将其视为具有独立DDL、维护合同、迁移合同与成本模型的一等数据库对象。两个实证证明支持该方案:结构维护开销随变更量增长而非语料规模,增量更新比重建便宜33.7倍且保持浮点精度;在500段广播访谈样本上,编译后的命题作为检索内容,在所有32个预算-模型组合中均胜出:仅用约2.2k读取标记实现85.2%准确率,远超最佳分块配置的72.5%(需16.3k标记)。唯一能匹敌的是混合检索与重排序的上下文分块流水线,其性能与编译结果无统计差异,但查询路径标记数达21倍;我们认为它能追平,正是因为它已开始进行类似编译。
原文摘要 · Abstract (English)
Nearly every retrieval-augmented question-answering system in production ships with a hidden interpreter: on each query a language model re-derives the meaning of raw corpus text and then throws that work away. Cheaper models do not close the gap: per-token prices have fallen by orders of magnitude while inference spend has risen, because context volume grows faster than prices fall. This is the modern equivalent of the full-table scan, and the remedy is the one databases found fifty years ago: do the expensive work once, at write time, into a maintained structure that makes reads cheap. A corpus whose read pattern is known before it ever meets a user can and should be indexed too. We call the paradigm ingest-time semantic compilation (ISC): compile a corpus's meaning into a queryable substrate with two coupled layers - incrementally maintained embeddings, and atomic claims whose provenance is validated at compile time - and treat that substrate as a first-class database object with its own DDL, maintenance contract, migration contract, and cost model. Two existence proofs support it. Substrate upkeep scales with change rather than corpus size: incremental updates run 33.7x cheaper than reconstruction while tracking it to floating-point precision. And on a held-out sample of 500 broadcast-interview transcripts, compiled claims as the retrieval payload win all 32 budget-by-model cells: 85.2% correct from roughly 2.2k reader tokens against 72.5% from 16.3k for the best chunk configuration anywhere. The only baseline that keeps pace is a contextualized-chunk pipeline with hybrid retrieval and reranking, statistically indistinguishable from compiled claims at roughly twenty-one times the query-path tokens - and it reaches that parity, we argue, precisely because it has itself begun to compile. We close with the systems agenda this opens, from compilation planners to read planning.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。