Text-to-SQL systems allow non-SQL experts to interact with relational databases using natural language. However, their tendency to generate executable SQL for ambiguous, out-of-scope, or unanswerable queries introduces a hidden risk, as outputs may be misinterpreted as correct. This risk is especially serious in biomedical contexts, where precision is critical. We therefore present Query Carefully, a pipeline that integrates LLM-based SQL generation with explicit detection and handling of unanswerable inputs. Building on the OncoMX component of ScienceBenchmark, we construct OncoMX-NAQ (No-Answer Questions), a set of 80 no-answer questions spanning 8 categories (non-SQL, out-of-schema/domain, and multiple ambiguity types). Our approach employs llama3.3:70b with schema-aware prompts, explicit No-Answer Rules (NAR), and few-shot examples drawn from both answerable and unanswerable questions. We evaluate SQL exact match, result accuracy, and unanswerable-detection accuracy. On the OncoMX dev split, few-shot prompting with answerable examples increases result accuracy, and adding unanswerable examples does not degrade performance. On OncoMX-NAQ, balanced prompting achieves the highest unanswerable-detection accuracy (0.8), with near-perfect results for structurally defined categories (non-SQL, missing columns, out-of-domain) but persistent challenges for missing-value queries (0.5) and column ambiguity (0.3). A lightweight user interface surfaces interim SQL, execution results, and abstentions, supporting transparent and reliable text-to-SQL in biomedical applications.


翻译:文本到SQL系统允许非SQL专家使用自然语言与关系数据库交互。然而,这些系统倾向于为模糊、超出范围或不可回答的查询生成可执行的SQL,这带来了潜在风险,因为输出可能被误解为正确。在精度至关重要的生物医学领域,这种风险尤为严重。为此,我们提出"谨慎查询"(Query Carefully)流程,将基于大语言模型的SQL生成与不可回答输入的显式检测和处理相结合。基于ScienceBenchmark的OncoMX组件,我们构建了OncoMX-NAQ(不可答问题集),包含80个不可答问题,涵盖8个类别(非SQL问题、超出模式/领域问题及多种模糊类型)。我们的方法采用llama3.3:70b模型,结合模式感知提示、显式的不可答规则(NAR)以及从可答与不可答问题中选取的少量示例。我们评估了SQL精确匹配、结果准确性和不可答检测准确性。在OncoMX开发集上,使用可答示例的少量提示提高了结果准确性,而添加不可答示例并未降低性能。在OncoMX-NAQ上,平衡提示实现了最高的不可答检测准确率(0.8),在结构定义明确的类别(非SQL、缺失列、超出领域)上接近完美,但在缺失值查询(0.5)和列模糊性(0.3)方面仍存在持续挑战。轻量级用户界面展示了中间SQL、执行结果和弃权声明,为生物医学应用中的透明可靠文本到SQL交互提供了支持。

0
下载
关闭预览

相关内容

SQL 全名是结构化查询语言,是用于数据库中的标准数据查询语言,IBM 公司最早使用在其开发的数据库系统中。
【CVPR2024】ViewDiff: 3D一致的图像生成与文本到图像模型
专知会员服务
30+阅读 · 2024年3月10日
【AAAI2021】“可瘦身”的生成式对抗网络
专知会员服务
13+阅读 · 2020年12月12日
论文浅尝 | GEOM-GCN: Geometric Graph Convolutional Networks
开放知识图谱
14+阅读 · 2020年4月8日
【NeurIPS2019】图变换网络:Graph Transformer Network
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
VIP会员
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
Top
微信扫码咨询专知VIP会员