文本到SQL系统使用户能够使用自然语言与结构化数据库进行交互,无需专业的编程知识。在本工作中,我们提出了GEMMA-SQL,这是一个基于开源Gemma 2B架构构建的轻量级高效文本到SQL模型。与许多大型语言模型(LLMs)不同,GEMMA-SQL以资源高效、迭代的方式进行微调,并且可以部署在低成本硬件上。利用SPIDER基准进行训练和评估,GEMMA-SQL结合了多种提示策略,包括少样本学习,以提高SQL查询生成的准确性。经过指令微调的变体GEMMA-SQL Instruct达到了66.8%的Test-Suite准确率和63.3%的Exact Set Match准确率,优于IRNet、RYANSQL和CodeXDavinci等多个最先进的基线模型。所提出的方法表明,有效的提示设计和有针对性的指令微调可以显著提升性能,同时保持高可扩展性和适应性。这些结果使GEMMA-SQL成为构建稳健且易用的文本到SQL系统的一种实用、开源的替代方案。
英文摘要:
Text-to-SQL systems enable users to interact with structured databases using natural language, eliminating the need for specialized programming knowledge. In this work, we introduce GEMMA-SQL, a lightweight and efficient text-to-SQL model built upon the open-source Gemma 2B architecture. Unlike many large language models (LLMs), GEMMA-SQL is fine-tuned in a resource-efficient, iterative manner and can be deployed on low-cost hardware. Leveraging the SPIDER benchmark for training and evaluation, GEMMA-SQL combines multiple prompting strategies, including few-shot learning, to enhance SQL query generation accuracy. The instruction-tuned variant, GEMMA-SQL Instruct, achieves 66.8% Test-Suite accuracy and 63.3% Exact Set Match accuracy, outperforming several state-of-the-art baselines such as IRNet, RYANSQL, and CodeXDavinci. The proposed approach demonstrates that effective prompt design and targeted instruction tuning can significantly boost performance while maintaining high scalability and adaptability. These results position GEMMA-SQL as a practical, open-source alternative for robust and accessible text-to-SQL systems.
A Survey on Text-to-SQL Parsing: Concepts, Methods, and Future Directions
Shenzhen Institutes of Advanced Technology, Chinese Academy of Sciences(中国科学院深圳先进技术研究院);University of Chinese Academy of Sciences(中国科学院大学);Alibaba Group(阿里巴巴集团);The University of Hong Kong(香港大学)
SQLFixAgent: Towards Semantic-Accurate Text-to-SQL Parsing via Consistency-Enhanced Multi-Agent Collaboration
School of Computer Science & Technology, Soochow University(苏州大学计算机科学与技术学院);School of Information, Renmin University of China(中国人民大学信息学院);International College (Suzhou Research Institute), Renmin University of China(中国人民大学国际学院(苏州研究院));iFLYTEK Research (Suzhou)(科大讯飞研究院(苏州))
SQLForge: Synthesizing Reliable and Diverse Data to Enhance Text-to-SQL Reasoning in LLMs
University of Science and Technology of China(中国科学技术大学);Institute of Artificial Intelligence, Hefei Comprehensive National Science Center(合肥综合性国家科学中心人工智能研究院)
Text-to-SQL as Dual-State Reasoning: Integrating Adaptive Context and Progressive Generation
School of Computer Science, Guangdong University of Technology(广东工业大学计算机科学学院);College of Science, Shantou University(汕头大学科学学院);Peng Cheng Laboratory(鹏城实验室)
ProSPy: A Profiling-Driven SQL-Python Agentic Framework for Enterprise Text-to-SQL
State Key Lab of CAD&CG(计算机辅助设计与图形学国家重点实验室);School of Software Technology(软件技术学院);Tencent TEG(腾讯科技集团);School of Mathematical Sciences, Peking University(北京大学数学科学学院);Zhejiang University(浙江大学)
From Natural Language to SQL: Review of LLM-based Text-to-SQL Systems
School of Computing and Informatics, University of Louisiana at Lafayette(路易斯安那大学拉斐特分校计算与信息学院);School of Mechanical Engineering, University of Louisiana at Lafayette(路易斯安那大学拉斐特分校机械工程学院)
SQLBench: A Comprehensive Evaluation for Text-to-SQL Capabilities of Large Language Models
Institute of Automation, Chinese Academy of Sciences(中国科学院自动化研究所);School of Artificial Intelligence, University of Chinese Academy of Sciences(中国科学院大学人工智能学院);SenseTime Research(商汤科技研究院);School of Artificial Intelligence, Shandong University(山东大学人工智能学院);School of Computer Science and Technology, Beijing Institute of Technology(北京理工大学计算机科学与技术学院);Technical University of Munich, Heilbronn Data Science Center, Munich Data Science Institute(慕尼黑技术大学,海德堡数据科学中心,慕尼黑数据科学研究所);Institute of Microelectronics, Chinese Academy of Sciences(中国科学院微电子研究所)
ErrorLLM: Modeling SQL Errors for Text-to-SQL Refinement
The Hong Kong Polytechnic University(香港理工大学);City University of Macau(澳门城市大学);Jilin University(吉林大学);Harbin Institute of Technology (Shenzhen)(哈尔滨工业大学(深圳));Beihang University(北航大学)
$R^3$: "This is My SQL, Are You With Me?" A Consensus-Based Multi-Agent System for Text-to-SQL Tasks
School of Engineering, Westlake University(西湖大学工程学院);University of Michigan(密歇根大学);Carnegie Mellon University(卡内基梅隆大学);School of Mathematical Science, Shanghai Jiao Tong University(上海交通大学数学科学学院)
DCG-SQL: Enhancing In-Context Learning for Text-to-SQL with Deep Contextual Schema Link Graph
Department of Artificial Intelligence, Sungkyunkwan University(人工智能系,成均馆大学);Department of Immersive Media Engineering, Sungkyunkwan University(沉浸媒体工程系,成均馆大学);Department of Computer Science and Engineering, Sungkyunkwan University(计算机科学与工程系,成均馆大学)
Next-Generation Database Interfaces: A Survey of LLM-based Text-to-SQL
Department of Computing, The Hong Kong Polytechnic University(香港理工大学计算机系);Faculty of Data Science, City University of Macau(澳门城市大学数据科学学院);College of Cyber Security, Jinan University(暨南大学网络安全学院)