用细粒度反馈让小模型高效准确生成SQL,媲美大模型且更省资源。
FINER-SQL: Boosting Small Language Models for Text-to-SQL

- 用连续奖励替代0/1反馈,让错误生成也能获得学习信号。
- 在BIRD和Spider上用30亿参数模型达67.73%和85%执行准确率。
- 适合需要低延迟、本地部署、保护数据隐私的实用场景。
大型语言模型在文本转SQL任务中取得显著进展,但存在高计算成本、长延迟和数据隐私问题,难以在实际中应用。小语言模型(SLMs)虽能实现高效、私密的本地部署,却常因推理能力弱、指令遵循差而表现不佳。传统基于稀疏二值奖励(0/1)的强化学习在生成错误SQL时缺乏有效学习信号,导致训练不稳定或崩溃。为此,我们提出FINER-SQL,一个可扩展、可复用的强化学习框架,通过细粒度执行反馈增强小模型。基于组相对策略优化,该框架将稀疏监督替换为密集且可解释的奖励,即使在错误生成时也提供持续反馈。引入两种关键奖励函数:记忆奖励,对齐推理与验证轨迹以保证语义稳定;原子奖励,衡量操作级重叠,为结构正确但不完整的SQL给予部分得分。该方法将离散正确性转化为连续学习,实现无需评判器的稳定优化。在BIRD和Spider基准上的实验表明,使用30亿参数模型,FINER-SQL在执行准确率上分别达到67.73%和85%,媲美更大规模的LLM,同时将推理延迟降至5.57秒/样本。结果证明了一条低成本、高隐私保障的高性能文本转SQL路径。代码已开源。
原文摘要 · Abstract (English)
Large language models have driven major advances in Text-to-SQL generation. However, they suffer from high computational cost, long latency, and data privacy concerns, which make them impractical for many real-world applications. A natural alternative is to use small language models (SLMs), which enable efficient and private on-premise deployment. Yet, SLMs often struggle with weak reasoning and poor instruction following. Conventional reinforcement learning methods based on sparse binary rewards (0/1) provide little learning signal when the generated SQLs are incorrect, leading to unstable or collapsed training. To overcome these issues, we propose FINER-SQL, a scalable and reusable reinforcement learning framework that enhances SLMs through fine-grained execution feedback. Built on group relative policy optimization, FINER-SQL replaces sparse supervision with dense and interpretable rewards that offer continuous feedback even for incorrect SQLs. It introduces two key reward functions: a memory reward, which aligns reasoning with verified traces for semantic stability, and an atomic reward, which measures operation-level overlap to grant partial credit for structurally correct but incomplete SQLs. This approach transforms discrete correctness into continuous learning, enabling stable, critic-free optimization. Experiments on the BIRD and Spider benchmarks show that FINER-SQL achieves up to 67.73\% and 85\% execution accuracy with a 3B model -- matching much larger LLMs while reducing inference latency to 5.57~s/sample. These results highlight a cost-efficient and privacy-preserving path toward high-performance Text-to-SQL generation. Our code is available at https://github.com/thanhdath/finer-sql.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。