arXiv:2506.04494cs.CL2025-06NeurIPS被引 15

让大模型生成的SQL更准,自动发现并修正语义错误。

SQLens: An End-to-End Framework for Error Detection and Correction in Text-to-SQL

  • 结合数据库反馈与大模型自身判断,细粒度识别SQL语义错误。
  • 在两个公开数据集上,错误检测F1提升25.78%,执行准确率最高提高20%。
  • 适合想提升文本转SQL系统可靠性、尤其关注语义准确性的开发者。

文本转SQL系统将自然语言问题转化为SQL查询,使非技术人员也能操作结构化数据。尽管大语言模型(LLMs)在该任务上表现良好,但常生成语义错误却语法正确的查询,且缺乏对其可靠性的判断。我们提出SQLens,一个端到端框架,用于细粒度检测与纠正大模型生成的SQL语义错误。SQLens融合来自底层数据库和大模型的错误信号,识别SQL子句中的潜在语义错误,并利用这些信号指导查询修正。在两个公开基准上的实证结果表明,SQLens相比最佳的基于LLM的自评估方法,在错误检测的F1上提升25.78%,并将开箱即用的文本转SQL系统的执行准确率最高提升20%。

原文摘要 · Abstract (English)

Text-to-SQL systems translate natural language (NL) questions into SQL queries, enabling non-technical users to interact with structured data. While large language models (LLMs) have shown promising results on the text-to-SQL task, they often produce semantically incorrect yet syntactically valid queries, with limited insight into their reliability. We propose SQLens, an end-to-end framework for fine-grained detection and correction of semantic errors in LLM-generated SQL. SQLens integrates error signals from both the underlying database and the LLM to identify potential semantic errors within SQL clauses. It further leverages these signals to guide query correction. Empirical results on two public benchmarks show that SQLens outperforms the best LLM-based self-evaluation method by 25.78% in F1 for error detection, and improves execution accuracy of out-of-the-box text-to-SQL systems by up to 20%.

文本转SQL大模型错误检测数据库

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