LuthorSQL:作为较慢LLM智能体系统1的单遍文本到SQL模型

·

研究论文 · 2026/11/17

前沿LLM智能体通过工具查询数据库是当前最准确的文本到SQL系统之一,但每次查询调用托管模型速度慢、成本高,且将敏感查询暴露给外部API。例如,Claude Opus 5.5智能体每天处理1万次查询,按标价每年成本超过7万美元。本文提出LuthorSQL,一个非自回归的7B文本到SQL模型,作为慢速LLM智能体(系统2)的快速系统1门控,仅在不确定时升级查询。LuthorSQL通过单次前向传播预测有界语法下查询计划的槽位分数,编译并运行最多32个候选计划,并使用训练好的验证器选择答案。在BIRD隐藏测试集上,LuthorSQL单GPU每问题0.84秒达到68.03%执行准确率,8位量化权重下在9GB内存中保持准确率,并零样本迁移到Snowflake、BigQuery、MySQL、PostgreSQL和DuckDB,与原生SQLite准确率相差3.1个百分点以内。与Claude Opus 5.5在预注册的置信级联中结合,在Opus训练截止后发布的数据库上的227个问题上,LuthorSQL本地回答近一半问题,在相同准确率下将API成本降低33.3%。最后,污染探测显示Opus在未见模式的情况下逐字复现48-92%的公共基准金标准查询;然而,其工具辅助准确率在重命名模式上保持,并在截止后数据库上达到95.6-97.4%。

该研究提出了一种实用的混合架构,利用本地硬件上的小型高效模型显著降低LLM智能体的查询成本和延迟,同时保持准确性,并揭示了公共基准污染问题,对实际部署和评估具有重要参考价值。

Frontier LLM agents that query databases with tools are among the most accurate text-to-SQL systems, but per-query calls to a hosted model are slow, costly, and expose sensitive organizational queries to external APIs. For example, a Claude Opus 5.5 agent serving 10,000 queries a day costs over $70,000 a year at list price. To what extent can local hardware already owned by an organization offload this burden without compromising the agent's accuracy? We present LuthorSQL, a non-autoregressive 7B text-to-SQL model that serves as a rapid System 1 gate for a slower LLM agent (System 2), escalating queries only when uncertain. LuthorSQL makes a single forward pass to predict slot scores over a bounded grammar for query plans, compiles and runs up to 32 candidate plans, and chooses an answer using a trained validator. On its own, LuthorSQL reaches 68.03% execution accuracy on BIRD's hidden test set at 0.84 s per question on a single GPU, maintains its accuracy in 9 GB with 8-bit quantized weights, and transfers zero-shot to Snowflake, BigQuery, MySQL, PostgreSQL, and DuckDB within 3.1 points of its native SQLite accuracy. Combined with Claude Opus 5.5 in a pre-registered confidence cascade over 227 questions on databases published after Opus's training cutoff, LuthorSQL answers nearly half of all questions locally and cuts API cost by 33.3% at the same accuracy. Finally, contamination probing shows that Opus reproduces 48-92% of public benchmark gold queries verbatim without seeing the schema; however, its tool-assisted accuracy holds on renamed schemas and reaches 95.6-97.4% on post-cutoff databases. Code and data: https://github.com/IAMIbrahimmemon/luthorsql

阅读原文

参与讨论