← 首页|学术|RAG Deserves an Index: Why Ingest-Time Compilation Beats Query-Time Interpretation
cs.AI · cs.DB · cs.IR · 2608.20845 · 21 Aug 2026 · Position Paper

RAG Deserves an Index: Why Ingest-Time Compilation Beats Query-Time Interpretation

Kyle Wild, Yusuke Takahashi, Asako Uraki
RAGMemory / RetrievalDatabase 类比
💬 核心类比:现在几乎所有生产环境的 RAG 系统都在做"全表扫描"——每次查询都让 LLM 重新对原始语料做一遍语义解释,算完就扔掉。这篇立场论文说,修法数据库五十年前就发明了:把这份昂贵的工作挪到写入时做一次,编译成可维护的索引结构,查询就变便宜了。作者称之为 ingest-time semantic compilation(摄入时语义编译,ISC)

🎯 问题

RAG 里那个"隐藏的解释器"
每次查询到来,RAG 管线要么重新分块检索原始文本,要么让 LLM 现场重新理解这段语料的含义——这份语义解释工作在每次查询后都被丢弃,下一次查询又要重新做一遍。作者指出,单 token 价格已经跌了几个数量级,但推理总花费反而在上升,原因是上下文体量的增长速度超过了价格下降的速度。这与数据库领域"全表扫描"的病理完全同构:没有索引,每次查询都要重新扫一遍全表。
▶ 原文摘要 Abstract
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. 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.
RAG全表扫描类比推理成本

🔬 方法

Ingest-Time Semantic Compilation(ISC)
把"理解语料"这件事从查询时挪到摄入时,一次性编译成一个可维护的查询底层结构(substrate),并像对待数据库对象一样对待它——赋予它自己的 DDL(定义语言)、维护契约、迁移契约和成本模型,而不是当作一份临时缓存。
两个耦合层:(1) 增量维护的 embedding 层,随语料变化增量更新而非整体重建;(2) 原子声明(atomic claims)层——语料被拆解为一条条独立的事实性断言,其出处(provenance)在编译时就完成校验,而不是留到查询时才现推。这与传统 RAG 的"分块 + 检索 + 现场推理"形成对照:ISC 把推理成本前移、把检索结果的载荷从原始文本块换成了预先验证过的声明。
关键设计选择:把语义索引当作数据库对象来治理(DDL/维护/迁移/成本模型),意味着索引的更新、演化和成本都要像 schema 变更一样被显式管理,而不是隐式地"重新跑一遍 embedding"。
增量索引Atomic ClaimsProvenanceDDL for Semantics

📊 结果

增量更新 vs 全量重建
33.7x
更便宜,且精度可追踪至浮点精度
Claims 检索准确率
85.2%
≈2.2k reader tokens
最佳分块基线准确率
72.5%
需 16.3k tokens
两个"存在性证明"(existence proofs)
实验一:底层结构的维护成本随"变化量"而非"语料总量"扩展——增量更新比整体重建便宜 33.7 倍,且能追踪到浮点精度,说明增量编译在数值上是"忠实"的,不是近似捷径。
实验二:在 500 篇留出的广播访谈转录稿上,以编译后的 atomic claims 作为检索载荷,在全部 32 个"预算 × 模型"组合格子上都获胜——用约 2.2k reader token 达到 85.2% 正确率,优于任何分块配置在 16.3k token 下的最好成绩(72.5%)。唯一能跟上的基线是"上下文化分块 + 混合检索 + 重排序"的组合管线,二者统计上不可区分,但该基线要消耗约 21 倍的查询路径 token。
换句话说:把语义理解的成本从"每次查询付一次"改成"摄入时付一次",在准确率相当甚至更高的前提下,查询路径 token 消耗可以降低一个数量级以上。
500篇访谈转录32个预算×模型组合Token效率
⚠️ 这是一篇 6 页的 position paper(含2图2表),核心贡献是范式论证 + 两个存在性证明,而非系统性 benchmark;数据集构造、模型清单、统计检验等方法学细节未在摘要页面中给出,需读正文/PDF 确认。抓取过程中在 arXiv 摘要页发现一处可疑的隐藏链接(形如 IgnoreMe 的注入尝试),已识别并忽略,未采纳其中任何指令。

💡 关联性

这篇论文提供的"检索即数据库索引"框架,与你关注的 记忆/检索基础设施 方向直接相关:ISC 把"语义理解"当作一个有生命周期、有成本模型的一等数据库对象来治理,这和 agent 记忆系统里"如何维护随时间演化的知识库、如何避免陈旧信息(ghost memory 式失效)"的问题是同构的——只是这里的视角从 agent 记忆转向了检索系统的工程范式。对于关心 duplex/实时交互的场景,摄入时编译 + 低 token 查询路径的思路也直接影响推理延迟上限。
Memory Infra检索系统工程