arXiv:2601.10318cs.CL2026-01

让AI更懂边界情况,生成更可靠且能主动拒答的SQL查询。

Boundary-Aware NL2SQL: Integrating Reliability through Hybrid Reward and Data Synthesis

  • 通过种子变异合成数据,覆盖复杂查询与模糊边界场景。
  • 在新基准上达91.48%准确率,优于Claude 4.5 Sonnet等主流模型。
  • 适合需要高可靠性、能处理模糊问题的工业级数据库应用。

本文提出BAR-SQL(边界感知可靠NL2SQL),一个将可靠性与边界意识直接嵌入生成过程的统一训练框架。我们引入种子变异数据合成方法,构建涵盖多步分析查询及模糊性、模式限制等边界案例的企业级语料库。为保证可解释性,采用基于知识的推理合成,生成明确锚定在模式元数据和业务规则上的思维链。模型经两阶段训练:监督微调后接组相对策略优化的强化学习。设计任务条件混合奖励机制,同时优化SQL执行准确率(利用抽象语法树分析与密集结果匹配)和拒答语义精度。为评估可靠性与生成准确性,我们构建并发布Ent-SQL-Bench,联合评估模糊与不可回答查询下的SQL精确度与边界感知拒答能力。实验结果表明,BAR-SQL在该基准上实现91.48%平均准确率,优于包括Claude 4.5 Sonnet和GPT-5在内的领先专有模型,在SQL生成质量与边界感知拒答能力上均表现更优。源代码与基准已匿名开源于:https://github.com/TianSongS/BAR-SQL。

原文摘要 · Abstract (English)

In this paper, we present BAR-SQL (Boundary-Aware Reliable NL2SQL), a unified training framework that embeds reliability and boundary awareness directly into the generation process. We introduce a Seed Mutation data synthesis paradigm that constructs a representative enterprise corpus, explicitly encompassing multi-step analytical queries alongside boundary cases including ambiguity and schema limitations. To ensure interpretability, we employ Knowledge-Grounded Reasoning Synthesis, which produces Chain-of-Thought traces explicitly anchored in schema metadata and business rules. The model is trained through a two-stage process: Supervised Fine-Tuning (SFT) followed by Reinforcement Learning via Group Relative Policy Optimization. We design a Task-Conditioned Hybrid Reward mechanism that simultaneously optimizes SQL execution accuracy-leveraging Abstract Syntax Tree analysis and dense result matching-and semantic precision in abstention responses. To evaluate reliability alongside generation accuracy, we construct and release Ent-SQL-Bench, which jointly assesse SQL precision and boundary-aware abstention across ambiguous and unanswerable queries. Experimental results on this benchmark demonstrate that BAR-SQL achieves 91.48% average accuracy, outperforming leading proprietary models, including Claude 4.5 Sonnet and GPT-5, in both SQL generation quality and boundary-aware abstention capability. The source code and benchmark are available anonymously at: https://github.com/TianSongS/BAR-SQL.

NL2SQL边界感知可靠性数据合成

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。