The Text-to-SQL task translates natural language questions into SQL queries, enabling intuitive database interaction for non-experts. While recent methods leveraging Large Language Models (LLMs) achieve strong performance, their reliance on proprietary models raise concerns about deployment feasibility and data privacy. In this work, we introduce LitE-SQL, a Lightweight and Efficient framework with two components: (i) a Schema Retriever that performs efficient schema linking using a vector database of pre-computed schema embeddings, optimized with a hard-negative supervised contrastive objective to distinguish semantically similar but functionally irrelevant columns, and (ii) a SQL Generator fine-tuned in two stages-supervised fine-tuning followed by execution-guided reinforcement-enabling execution-guided self-correction without multi-candidate sampling, which is commonly required by prior LLM-based approaches. On BIRD, LitE-SQL achieves 72.10% execution accuracy, and on Spider 1.0 it reaches 88.45%, demonstrating comparable or superior performance to LLM-based methods despite using 2x to 30x fewer parameters. Our findings demonstrate that high-quality Text-to-SQL generation is feasible with lightweight models, offering a practical solution for privacy-sensitive and resource-constrained settings.
翻译:文本到SQL任务旨在将自然语言问题转换为SQL查询,为非专家用户提供直观的数据库交互方式。尽管当前基于大语言模型的方法展现出优异性能,但其对专有模型的依赖引发了部署可行性与数据隐私方面的担忧。本研究提出LitE-SQL——一个包含双组件的轻量高效框架:(i)模式检索器:通过预计算模式嵌入的向量数据库实现高效模式链接,并采用硬负样本监督对比目标进行优化,以区分语义相似但功能无关的数据库列;(ii)SQL生成器:采用两阶段微调策略——监督微调后接执行引导的强化学习,无需传统基于大语言模型方法中常见的多候选采样即可实现执行引导的自校正。在BIRD基准测试中,LitE-SQL达到72.10%的执行准确率,在Spider 1.0数据集上达到88.45%,其参数量较基于大语言模型的方法减少2至30倍,却展现出相当或更优的性能。本研究证明:通过轻量级模型即可实现高质量的文本到SQL生成,为隐私敏感与资源受限场景提供了实用解决方案。