Know Your Context Bank: Repairing Inconsistency and Measuring Generalization in Context-Aware Text-to-SQL
Computer Science > Computation and Language arXiv:2611.26775 (cs) [Submitted on 19 Nov 2026] Title: Know Your Context Bank: Repairing Inconsistency and Measuring Generalization in Context-Aware Text-to-SQL Authors: Hailong Li, Mohammadreza Pourreza, Tal Neiman, Reza Sherkat, Per Jacobsson, Yannis Papakonstantinou.
计算机科学 > 计算与语言 arXiv:2611.26775 (cs) [提交于 2026 年 11 月 19 日] 标题:了解你的上下文库:修复上下文感知 Text-to-SQL 中的不一致性并衡量泛化能力 作者:Hailong Li, Mohammadreza Pourreza, Tal Neiman, Reza Sherkat, Per Jacobsson, Yannis Papakonstantinou。
Abstract: Text-to-SQL systems increasingly rely on context banks: curated collections of example queries, metric definitions, and domain knowledge that tell a model how an organization writes its queries. In the enterprise, a bank grows over years as many analysts add entries, checked one at a time for correctness (does the SQL answer its own question?) and rarely for consistency with one another.
摘要:Text-to-SQL 系统越来越依赖于上下文库:即由示例查询、指标定义和领域知识组成的精选集合,用于告知模型某个组织如何编写其查询。在企业中,随着许多分析师不断添加条目,上下文库会逐年增长;这些条目通常会被逐一检查其正确性(即 SQL 是否回答了其对应的问题?),但很少检查它们之间是否保持一致。
Yet correctness is often loosely defined: a question seldom fixes how an entity is counted or which table defines it, so two entries can each pass review yet resolve the same decision in opposite ways. We call this condition context bank rot. A second question follows: does a system that uses a bank generalize from it, or only reproduce it? Existing benchmarks cannot tell, as they do not control how far a test question sits from the context.
然而,正确性的定义往往比较模糊:一个问题很少明确规定如何计算某个实体或由哪个表来定义它,因此两个条目可能各自通过了审查,但在处理同一决策时却得出截然相反的结果。我们将这种情况称为“上下文库腐烂”。随之而来的第二个问题是:使用上下文库的系统是从中进行泛化,还是仅仅在复制它?现有的基准测试无法回答这个问题,因为它们无法控制测试问题与上下文之间的距离。
We answer both questions by comparing queries decision by decision, with a fast scorer distilled from human-calibrated LLM judges. Turned inward, the comparison diagnoses and repairs a bank. Fine-tuning on a cleaned BIRD-train bank beats a same-size random subset at every epoch (+2.6 points on average), and 92.4% of our removals had their SQL corrected by an independent expert audit, against 45.6% of audited entries.
我们通过逐项决策比较查询的方式回答了这两个问题,并使用了一种从人类校准的 LLM 评判员中提炼出的快速评分器。向内看,这种比较可以诊断并修复上下文库。在清理后的 BIRD-train 库上进行微调,在每个 epoch 中都优于相同大小的随机子集(平均高出 2.6 个百分点),并且我们移除的条目中有 92.4% 经独立专家审计确认其 SQL 确实需要修正,而审计条目中仅有 45.6% 需要修正。
In-context examples that follow one convention beat those following the opposite one by 13.3 points, while a mix is barely better than none. Turned outward, the comparison generates test questions at a controlled distance from a bank, a pipeline we call CAT (Context-Aware Testing). On CAT-BIRD, for retrieval and fine-tuning alike, the benefit of a bank falls step by step with distance and is largely gone once about three quarters of a question’s logic is new, and on CAT-Spider the benefit of retrieval likewise shrinks with distance.
遵循同一惯例的上下文示例比遵循相反惯例的示例高出 13.3 个百分点,而混合使用则几乎与不使用没有区别。向外看,这种比较生成了与上下文库保持受控距离的测试问题,我们将这一流程称为 CAT(上下文感知测试)。在 CAT-BIRD 上,无论是检索还是微调,上下文库的收益都会随着距离的增加而逐步下降,当问题中约四分之三的逻辑是全新的时,收益基本消失;在 CAT-Spider 上,检索的收益同样随距离增加而缩减。