arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.28387cs.IRcs.AI
收藏

Schema-First Retrieval: 面向自然语言分析的模式优先检索

Schema-First Retrieval: Embedding Catalogs for Natural Language Analytics

Adarsh Agrawal, Shashank Indukuri

AI总结:

提出Schema-First Retrieval方法,通过索引目录元数据而非数据行,结合向量搜索、重排序和工作负载记忆,显著提升文本到SQL的表和列召回率,减少SQL执行错误。

摘要:

企业文本到SQL系统常常在生成SQL之前就失败:模型接收到错误的模式上下文。现代数据仓库包含数千张表、缩写列名、非正式指标、隐藏的连接约定以及权限边界,这些都无法通过原始表名捕获。我们引入Schema-First Retrieval,这是一个检索层,它嵌入目录元数据而非数据仓库行。该系统使用对象特定的文本模板索引五种类型的目录对象:表、列、指标、关系和查询历史。在查询时,它在SQL生成之前结合并行向量搜索、谱系扩展、交叉编码器重排序、工作负载记忆和确定性访问控制门。在CRUSH4SQL(1534个问题)上,Schema-First Retrieval达到96.4%的表召回率@20,交叉编码器重排序在列召回率@10上增加+11.1个百分点;与同等模板化的BM25基线相比,语义检索在表召回率@5上高出+32.8个百分点。在SEDE(857个问题)上,查询历史将表召回率@5从52.1%提升到92.3%。在BIRD(96个问题)上,模式优先上下文将SQL执行错误从15.6%减少到6.2%,减少了2.5倍。这些结果表明,对于自然语言分析,目录选择是一个一流的检索问题,而不是一个提示格式细节。

英文摘要:

Enterprise text-to-SQL systems often fail before SQL is generated: the model receives the wrong schema context. Modern warehouses contain thousands of tables, abbreviated columns, informal metrics, hidden join conventions, and permission boundaries that are not captured by raw table names. We introduce Schema-First Retrieval, a retrieval layer that embeds catalog metadata rather than warehouse rows. The system indexes five typed catalog objects, tables, columns, metrics, relationships, and query history, using object-specific text templates. At query time, it combines parallel vector search, lineage expansion, cross-encoder reranking, workload memory, and deterministic access-control gates before SQL generation. On CRUSH4SQL (1,534 questions), Schema-First Retrieval reaches 96.4% table recall@20 and cross-encoder reranking adds +11.1 points at column recall@10; against an equally-templated BM25 baseline, semantic retrieval is +32.8 points at table recall@5. On SEDE (857 questions), query history raises table recall@5 from 52.1% to 92.3%. On BIRD (96 questions), schema-first context reduces SQL execution errors from 15.6% to 6.2%, a 2.5x reduction. These results show that catalog selection is a first-class retrieval problem for natural language analytics, not a prompt formatting detail.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑