arXiv:2603.18018cs.CLcs.DB2026-03

用小模型+错误检测机制,让自然语言转SQL更省资源、更快

An Agentic System for Schema Aware NL2SQL Generation

  • 用小模型做主要翻译,仅在出错时才调大模型,减少计算开销
  • 在BIRD数据集上准确率达47.78%,90%以上查询由本地小模型完成
  • 单次查询成本降至0.0085,相比纯大模型系统降低超90%

自然语言转SQL任务使非专业用户能通过自然语言访问关系型数据库。尽管近期框架通过任务专业化提升了翻译准确率,但依赖大语言模型(LLMs)带来计算开销大、隐私风险高及资源受限环境下部署困难等问题。为此,我们提出一种基于模式的智能体系统,以小语言模型(SLMs)为主代理,辅以选择性大模型回退机制。仅当检测到小模型输出错误时才调用大模型,显著降低计算支出。在BIRD基准测试中,系统执行准确率达到47.78%,验证效率得分为51.05%,相比纯大模型基线实现超过90%的成本降低,约67%的查询由本地小模型解决。单次查询平均成本为0.0085,远低于纯大模型系统的0.094,本地执行查询接近零运营成本。

原文摘要 · Abstract (English)

The natural language to SQL (NL2SQL) task plays a pivotal role in democratizing data access by enabling non-expert users to interact with relational databases through intuitive language. While recent frameworks have enhanced translation accuracy via task specialization, their reliance on Large Language Models (LLMs) raises significant concerns regarding computational overhead, data privacy, and real-world deployability in resource-constrained environments. To address these challenges, we propose a schema based agentic system that strategically employs Small Language Models (SLMs) as primary agents, complemented by a selective LLM fallback mechanism. The LLM is invoked only upon detection of errors in SLM-generated output, the proposed system significantly minimizes computational expenditure. Experimental results on the BIRD benchmark demonstrate that our system achieves an execution accuracy of 47.78% and a validation efficiency score of 51.05%, achieving over 90% cost reduction compared to LLM-centric baselines as approximately 67% of queries are resolved using local SLMs. The system achieves an average cost per query of 0.0085 compared to 0.094 for LLM-only systems, achieving near-zero operational costs for locally executed queries. [Github repository: https://github.com/mindslab25/CESMA.]

NL2SQL小模型成本优化

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