Article(id=1329419612044767459, tenantId=1146029695717560320, journalId=1324759914146529478, issueId=1329419577676641015, articleNumber=null, orderNo=null, doi=10.7544/issn1000-1239.202550355, pmid=null, cstr=null, oa=null, hot=null, price=null, onlineType=0, articleFormat=0, articleType=null, articleTypeStr=null, receivedDate=1748188800000, receivedDateStr=2025-05-26, revisedDate=1765123200000, revisedDateStr=2025-12-08, acceptedDate=1767715200000, acceptedDateStr=2026-01-07, onlineDate=1794887934933, onlineDateStr=2026-11-17, pubDate=1777564800000, pubDateStr=2026-05-01, doiRegisterDate=null, doiRegisterDateStr=null, onlineIssueDate=1794887934933, onlineIssueDateStr=2026-11-17, onlineJustAcceptDate=null, onlineJustAcceptDateStr=null, onlineFirstDate=null, onlineFirstDateStr=null, sourceXml=null, magXml=null, createTime=1794887934933, creator=13701087609, updateTime=1794887934933, updator=13701087609, issue=Issue{id=1329419577676641015, tenantId=1146029695717560320, journalId=1324759914146529478, year='2026', volume='63', issue='5', pageStart='1095', pageEnd='1375', issueExtLink='null', onlineDate='null', pubDate='1777564800000', pubDateStr='2026-05-01', beforeIssueId=null, nextIssueId=null, price=null, status=1, issueComplete=1, articleOrder=1, issueType=-1, specialIssue=null, createTime=1794887926739, creator='13701087609', updateTime=1794887926739, updator='13701087609', preIssue=null, nextIssue=null, articleTotal=null, ext=null, issueFiles=null, downloadFileDto=null}, startPage=1261, endPage=1272, ext={EN=ArticleExt(id=1329419612208345316, articleId=1329419612044767459, tenantId=1146029695717560320, journalId=1324759914146529478, language=EN, title=Iterative Two-Stage Schema-Enhanced SQL Generation with Large Language Models, columnId=1325489891789910943, journalTitle=Journal of Computer Research and Development, columnName=Artificial Intelligence, runingTitle=null, highlight=null, articleAbstract=

With the advent of the big data era, various enterprises and organizations have accumulated massive amounts of data driven by the growing demands for business expansion and information. This data are typically stored in relational databases in structured or semi-structured formats. SQL, as a structured database query language, has long been widely used for data retrieval and processing. It provides professionals with an efficient way to interact with databases, thereby facilitating quicker and more convenient data sharing and analysis. With the exponential advancement of large language models (LLMs), in-context learning (ICL) has shown significant promise for the text-to-SQL task, where LLMs utilize reference examples to accurately generate SQL queries. To fully harness the potential of LLMs through ICL for text-to-SQL, we propose a new SQL generation pipeline comprising three parts: first, we propose a schema enhancement component to strengthen LLMs’ focus on question-related information. Second, we leverage the inherent structure of SQL to preselect semantically similar, aiding in the generation of initial pseudo-SQL queries. Third, a selection strategy is proposed for selecting reference examples, which considers the similarities between the question and the pseudo-SQL structure to enhance the accuracy of the generated SQL queries. We implement an iterative refinement process in both stages, employing a boosting-like mechanism that progressively improves selection until stabilization is achieved. Extensive experiments across various models and datasets demonstrate the effectiveness of our approach.

, authors=Wei Zhang1, 2, Dong’ao Zhou3, *, Yongshun Gong1, Yilong Yin1, authorsList=Wei Zhang, Dong’ao Zhou, Yongshun Gong, Yilong Yin, authorCompany=null, correspAuthors=Dong’ao Zhou, authorNote=

born in 1999. Master. His main research interests include natural language processing and data mining

born in 1990. PhD, assistant researcher. His main research interests include artificial intelligence and signal detection

born in 1990. PhD, professor. His main research interests include data mining and machine learning

born in 1972. PhD, professor. His main research interests include data mining and machine learning

, correspAuthorsNote=null, copyrightStatement=Copyright © 2026 Journal of Computer Research and Development. All rights reserved., copyrightOwner=null, extLink=null, articleAbsUrl=null, sourceXml=null, magXml=null, pdfUrl=null, pdf=null, pdfFileSize=null, pdfExtLink=null, richHtmlUrl=null, mobilePdfUrl=null, reviewReport=null, pdfFirstPage=null, abstractGraph=null, abstractGraphContent=null, abstractVideo=null, citation=null, cebUrl=null, magXmlContent=null, mapNumber=null, fund=null), CN=ArticleExt(id=1329419614074810617, articleId=1329419612044767459, tenantId=1146029695717560320, journalId=1324759914146529478, language=CN, title=基于大语言模型的2阶段迭代模式增强SQL生成, columnId=1325489892104483745, journalTitle=计算机研究与发展, columnName=人工智能, runingTitle=null, highlight=null, articleAbstract=

随着大数据时代的到来,各种企业和组织在日益增长的业务拓展以及信息需求的推动下积累了海量的数据。这些数据通常以结构化或半结构化的形式存储在对应的关系型数据库中。SQL作为一种结构化的数据库查询语言,长期以来被广泛应用于数据的检索和处理。它为相关专业技术人员提供了一种高效的方式来与数据库进行交互,从而能够更快捷方便地实现对于数据的分析。随着大语言模型(large language models,LLMs)的快速发展,上下文学习(in-context learning,ICL)在文本生成SQL(text-to-SQL)任务中展现出巨大潜力。ICL能够使大语言模型通过利用参考示例生成准确的SQL查询。为了充分利用大语言模型在ICL机制下进行文本生成SQL,提出了一个新的SQL生成流程,该流程包括3个部分:首先,提出了迭代式的模式增强,以强化大语言模型对解决问题相关信息的关注。其次,利用SQL的骨架结构进行语义相似度筛选,从而辅助生成伪SQL(pseudo-SQL)查询。最后设计了一种参考示例选择策略,该策略结合问题与伪SQL骨架之间的相似性,以提高生成SQL查询的准确性。同时,在2个关键阶段中都引入了迭代优化过程,以逐步优化示例选择策略,直至达到稳定状态。在多个大语言模型和数据集上进行了广泛的实验,验证了所提出方法的有效性。

, authors=张伟1, 2, 周东傲3, *, 宫永顺1, 尹义龙1, authorsList=张伟, 周东傲, 宫永顺, 尹义龙, authorCompany=null, correspAuthors=周东傲, authorNote=

作者贡献声明

张伟提出算法思路,完成实验并撰写论文;周东傲、宫永顺和尹义龙提出指导意见并修改论文。

1999年生。硕士。主要研究方向为自然语言处理、数据挖掘

1990年生。博士,助理研究员。主要研究方向为人工智能、信号检测

1990年生。博士,教授。主要研究方向为数据挖掘、机器学习

1972年生。博士,教授。主要研究方向为数据挖掘、机器学习

, correspAuthorsNote=
周东傲()
, copyrightStatement=版权所有 © 2026 计算机研究与发展编辑部, copyrightOwner=null, extLink=null, articleAbsUrl=null, sourceXml=3c04soLeaCgqnkk/ODD4IA==, magXml=qkyUOi1ubFAsp3Z5JOZKkA==, pdfUrl=null, pdf=WOe6DbSo7JBcqpRg4zrdBw==, pdfFileSize=1304299, pdfExtLink=null, richHtmlUrl=null, mobilePdfUrl=null, reviewReport=null, pdfFirstPage=null, abstractGraph=Ef834vNg5J2Wz1PC3IALBA==, abstractGraphContent=null, abstractVideo=null, citation=null, cebUrl=null, magXmlContent=yJI0jk/UVoGoend9oM7wbQ==, mapNumber=null, fund=null)}, authors=[Author(id=1329419614565544196, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, orderNo=0, firstName=null, middleName=null, lastName=null, nameCn=null, orcid=null, stid=null, country=null, authorPic=null, dead=0, email=zhangwei4@sd.chinamobile.com, emailSecond=null, emailThird=null, correspondingAuthor=0, authorType=1, ext={EN=AuthorExt(id=1329419614657818887, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614565544196, language=EN, stringName=Wei Zhang, firstName=Wei, middleName=null, lastName=Zhang, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, 2, address=1School of Software, Shandong University, Jinan 250101
2China Mobile Qilu Innovation Research Institute, Jinan 250102, bio={"content":"

born in 1999. Master. His main research interests include natural language processing and data mining

"}, bioImg=null, bioContent=

born in 1999. Master. His main research interests include natural language processing and data mining

, aboutCorrespAuthor=null), CN=AuthorExt(id=1329419614720733448, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614565544196, language=CN, stringName=张伟, firstName=null, middleName=null, lastName=null, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, 2, address=1山东大学软件学院 济南 250101
2中国移动通信集团山东有限公司中移齐鲁创新院分公司 济南 250102, bio={"img":"PEnX18KgBht6ogdNGHHAXw==","content":"

1999年生。硕士。主要研究方向为自然语言处理、数据挖掘

"}, bioImg=PEnX18KgBht6ogdNGHHAXw==, bioContent=

1999年生。硕士。主要研究方向为自然语言处理、数据挖掘

, aboutCorrespAuthor=null)}, companyList=[AuthorCompany(id=1329419614305497338, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=1, ext=[AuthorCompanyExt(id=1329419614313885947, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1School of Software, Shandong University, Jinan 250101), AuthorCompanyExt(id=1329419614322274556, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1山东大学软件学院 济南 250101)]), AuthorCompany(id=1329419614385189117, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=2, ext=[AuthorCompanyExt(id=1329419614389383422, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614385189117, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=2China Mobile Qilu Innovation Research Institute, Jinan 250102), AuthorCompanyExt(id=1329419614397772031, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614385189117, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=2中国移动通信集团山东有限公司中移齐鲁创新院分公司 济南 250102)])]), Author(id=1329419614783648010, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, orderNo=1, firstName=null, middleName=null, lastName=null, nameCn=null, orcid=null, stid=null, country=null, authorPic=null, dead=0, email=zhoudongao08@nudt.edu.cn, emailSecond=null, emailThird=null, correspondingAuthor=1, authorType=1, ext={EN=AuthorExt(id=1329419614859145484, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614783648010, language=EN, stringName=Dong’ao Zhou, firstName=Dong’ao, middleName=null, lastName=Zhou, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=3, *, address=3Academy of Military Science, Beijing 100080, bio={"content":"

born in 1990. PhD, assistant researcher. His main research interests include artificial intelligence and signal detection

"}, bioImg=null, bioContent=

born in 1990. PhD, assistant researcher. His main research interests include artificial intelligence and signal detection

, aboutCorrespAuthor=null), CN=AuthorExt(id=1329419614922060045, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614783648010, language=CN, stringName=周东傲, firstName=null, middleName=null, lastName=null, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=3, *, address=3中国人民解放军军事科学院 北京 100080, bio={"img":"VhpXexrwzLxereaXqBccsg==","content":"

1990年生。博士,助理研究员。主要研究方向为人工智能、信号检测

"}, bioImg=VhpXexrwzLxereaXqBccsg==, bioContent=

1990年生。博士,助理研究员。主要研究方向为人工智能、信号检测

, aboutCorrespAuthor=null)}, companyList=[AuthorCompany(id=1329419614473269504, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=3, ext=[AuthorCompanyExt(id=1329419614481658113, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614473269504, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=3Academy of Military Science, Beijing 100080), AuthorCompanyExt(id=1329419614490046722, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614473269504, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=3中国人民解放军军事科学院 北京 100080)])]), Author(id=1329419614984974607, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, orderNo=2, firstName=null, middleName=null, lastName=null, nameCn=null, orcid=null, stid=null, country=null, authorPic=null, dead=0, email=null, emailSecond=null, emailThird=null, correspondingAuthor=0, authorType=1, ext={EN=AuthorExt(id=1329419615064666385, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614984974607, language=EN, stringName=Yongshun Gong, firstName=Yongshun, middleName=null, lastName=Gong, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, address=1School of Software, Shandong University, Jinan 250101, bio={"content":"

born in 1990. PhD, professor. His main research interests include data mining and machine learning

"}, bioImg=null, bioContent=

born in 1990. PhD, professor. His main research interests include data mining and machine learning

, aboutCorrespAuthor=null), CN=AuthorExt(id=1329419615123386642, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614984974607, language=CN, stringName=宫永顺, firstName=null, middleName=null, lastName=null, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, address=1山东大学软件学院 济南 250101, bio={"img":"MQvEkN30J0ZDEzIMZcZiDA==","content":"

1990年生。博士,教授。主要研究方向为数据挖掘、机器学习

"}, bioImg=MQvEkN30J0ZDEzIMZcZiDA==, bioContent=

1990年生。博士,教授。主要研究方向为数据挖掘、机器学习

, aboutCorrespAuthor=null)}, companyList=[AuthorCompany(id=1329419614305497338, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=1, ext=[AuthorCompanyExt(id=1329419614313885947, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1School of Software, Shandong University, Jinan 250101), AuthorCompanyExt(id=1329419614322274556, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1山东大学软件学院 济南 250101)])]), Author(id=1329419615190495508, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, orderNo=3, firstName=null, middleName=null, lastName=null, nameCn=null, orcid=null, stid=null, country=null, authorPic=null, dead=0, email=null, emailSecond=null, emailThird=null, correspondingAuthor=0, authorType=1, ext={EN=AuthorExt(id=1329419615261798678, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419615190495508, language=EN, stringName=Yilong Yin, firstName=Yilong, middleName=null, lastName=Yin, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, address=1School of Software, Shandong University, Jinan 250101, bio={"content":"

born in 1972. PhD, professor. His main research interests include data mining and machine learning

"}, bioImg=null, bioContent=

born in 1972. PhD, professor. His main research interests include data mining and machine learning

, aboutCorrespAuthor=null), CN=AuthorExt(id=1329419615328907543, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419615190495508, language=CN, stringName=尹义龙, firstName=null, middleName=null, lastName=null, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, address=1山东大学软件学院 济南 250101, bio={"img":"KmhdD0sUuGObKb4/nl8Rgw==","content":"

1972年生。博士,教授。主要研究方向为数据挖掘、机器学习

"}, bioImg=KmhdD0sUuGObKb4/nl8Rgw==, bioContent=

1972年生。博士,教授。主要研究方向为数据挖掘、机器学习

, aboutCorrespAuthor=null)}, companyList=[AuthorCompany(id=1329419614305497338, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=1, ext=[AuthorCompanyExt(id=1329419614313885947, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1School of Software, Shandong University, Jinan 250101), AuthorCompanyExt(id=1329419614322274556, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1山东大学软件学院 济南 250101)])])], keywords=[Keyword(id=1329419615421182232, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, orderNo=1, keyword=large language models), Keyword(id=1329419615492485401, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, orderNo=2, keyword=text-to-SQL), Keyword(id=1329419615567982874, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, orderNo=3, keyword=in-context learning), Keyword(id=1329419615635091739, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, orderNo=4, keyword=database management), Keyword(id=1329419615698006300, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, orderNo=5, keyword=data analysis), Keyword(id=1329419615756726557, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, orderNo=1, keyword=大语言模型), Keyword(id=1329419615815446814, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, orderNo=2, keyword=文本生成SQL), Keyword(id=1329419615874167071, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, orderNo=3, keyword=上下文学习), Keyword(id=1329419615941275936, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, orderNo=4, keyword=数据库管理), Keyword(id=1329419616008384801, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, orderNo=5, keyword=数据分析)], refs=[Reference(id=1329419618105536827, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=1, rfOrder=0, authorNames=null, journalName=null, refType=null, unstructuredReference=Labrinidis A, Jagadish H V. Challenges and opportunities with big data[J]. Proceedings of the VLDB Endowment, 2012, 5(12): 2032−2033, articleTitle=null, refAbstract=null), Reference(id=1329419618172645692, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=2, rfOrder=1, authorNames=null, journalName=null, refType=null, unstructuredReference=潘青峰, 徐辰. 基于查询编译的SQL执行技术研究进展[J]. 计算机研究与发展, 2024, 61(7): 1754−1770, articleTitle=null, refAbstract=null), Reference(id=1329419618243948861, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=2, rfOrder=2, authorNames=null, journalName=null, refType=null, unstructuredReference=Pan Qingfeng, Xu Chen. Advances in SQL execution techniques based on query compilation[J]. Journal of Computer Research and Development, 2024, 61(7): 1754−1770 (in Chinese), articleTitle=null, refAbstract=null), Reference(id=1329419618302669118, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=3, rfOrder=3, authorNames=null, journalName=null, refType=null, unstructuredReference=Agarwal S, Mozafari B, Panda A, et al. BlinkDB: Queries with bounded errors and bounded response times on very large data[C]//Proc of the 8th ACM European Conf on Computer Systems. New York: ACM, 2013: 29−42, articleTitle=null, refAbstract=null), Reference(id=1329419618365583679, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=4, rfOrder=4, authorNames=null, journalName=null, refType=null, unstructuredReference=Deng Naihao, Chen Yulong, Zhang Yue. Recent advances in text-to-SQL: A survey of what we have and what we expect[C]//Proc of the 29th Int Conf on Computational Linguistics. Stroudsburg, PA: ACL, 2022: 2166−2187, articleTitle=null, refAbstract=null), Reference(id=1329419618462052672, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=5, rfOrder=5, authorNames=null, journalName=null, refType=null, unstructuredReference=Katsogiannis-Meimarakis G, Koutrika G. A survey on deep learning approaches for text-to-SQL[J]. The VLDB Journal, 2023, 32(4): 905−936, articleTitle=null, refAbstract=null), Reference(id=1329419618545938753, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=6, rfOrder=6, authorNames=null, journalName=null, refType=null, unstructuredReference=Khot T, Trivedi H, Finlayson M, et al. Decomposed prompting: A modular approach for solving complex tasks[J]. arXiv preprint, arXiv: 2210.02406, 2022, articleTitle=null, refAbstract=null), Reference(id=1329419618663379266, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=7, rfOrder=7, authorNames=null, journalName=null, refType=null, unstructuredReference=Chowdhery A, Narang S, Devlin J, et al. Palm: Scaling language modeling with pathways[J]. Journal of Machine Learning Research, 2023, 24(240): 1−113, articleTitle=null, refAbstract=null), Reference(id=1329419618722099523, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=8, rfOrder=8, authorNames=null, journalName=null, refType=null, unstructuredReference=Yu Tao, Zhang Rui, Yang Kai, et al. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-SQL task[C]// Proc of the 27th Conf on Empirical Methods in Natural Language Processing. Stroudsburg, PA: ACL, 2018: 3911−3921, articleTitle=null, refAbstract=null), Reference(id=1329419618785014084, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=9, rfOrder=9, authorNames=null, journalName=null, refType=null, unstructuredReference=Josh A, Steven A, Sandhini A, et al. GPT-4 technical report[J]. arXiv preprint, arXiv: 2303.08774, 2024, articleTitle=null, refAbstract=null), Reference(id=1329419618856317253, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=10, rfOrder=10, authorNames=null, journalName=null, refType=null, unstructuredReference=Qu Ge, Li Jinyang, Li Bowen, et al. Before generation, align it! A novel and effective strategy for mitigating hallucinations in text-to-SQL generation[J]. arXiv preprint, arXiv: 2405.15307, 2024, articleTitle=null, refAbstract=null), Reference(id=1329419618923426118, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=11, rfOrder=11, authorNames=null, journalName=null, refType=null, unstructuredReference=Parciak M, Vandevoort B, Neven F, et al. Schema matching with large language models: An experimental study[J]. arXiv preprint, arXiv: 2307.07306, 2023, articleTitle=null, refAbstract=null), Reference(id=1329419618986340679, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=12, rfOrder=12, authorNames=null, journalName=null, refType=null, unstructuredReference=Dong Qingxiu, Li Lei, Dai Damai, et al. A survey on in-context learning[C]//Proc of the 29th Conf on Empirical Methods in Natural Language Processing. Stroudsburg, PA : ACL, 2024: 1107−1128, articleTitle=null, refAbstract=null), Reference(id=1329419619053449544, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=13, rfOrder=13, authorNames=null, journalName=null, refType=null, unstructuredReference=Liu Jiachang, Shen Dinghan, Zhang Yizhe, et al. What makes good in-context examples for GPT-3? [J]. arXiv preprint, arXiv: 2101.06804, 2021, articleTitle=null, refAbstract=null), Reference(id=1329419619116364105, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=14, rfOrder=14, authorNames=null, journalName=null, refType=null, unstructuredReference=Wang Liang, Yang Nan, Wei Furu. Learning to retrieve in-context examples for large language models[C]//Proc of the 18th Conf of the European Chapter of the Association for Computational Linguistics. Stroudsburg, PA : ACL, 2024: 1752−1767, articleTitle=null, refAbstract=null), Reference(id=1329419619187667274, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=15, rfOrder=15, authorNames=null, journalName=null, refType=null, unstructuredReference=Nguyen T, Wong E. In-context example selection with influences[J]. arXiv preprint, arXiv: 2302.11042, 2023, articleTitle=null, refAbstract=null), Reference(id=1329419619263164747, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=16, rfOrder=16, authorNames=null, journalName=null, refType=null, unstructuredReference=Radford A, Narasimhan K, Salimans T, et al. Improving language understanding by generative pre-training[EB/OL]. 2018[2025-03-02]. https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf, articleTitle=null, refAbstract=null), Reference(id=1329419619330273612, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=17, rfOrder=17, authorNames=null, journalName=null, refType=null, unstructuredReference=Anil R, Borgeaud S, Alayrac J, et al. Gemini: A family of highly capable multimodal models[J]. arXiv preprint, arXiv: 2312.11805, 2025, articleTitle=null, refAbstract=null), Reference(id=1329419619405771085, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=18, rfOrder=18, authorNames=null, journalName=null, refType=null, unstructuredReference=Touvron H, Lavril T, Izacard G, et al. LLaMA: Open and efficient foundation language models[J]. arXiv preprint, arXiv: 2302.13971, 2023, articleTitle=null, refAbstract=null), Reference(id=1329419619472879950, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=19, rfOrder=19, authorNames=null, journalName=null, refType=null, unstructuredReference=Bi Xiao, Chen Deli, Chen Guanting, et al. DeepSeek LLM: Scaling open-source language models with long termism[J]. arXiv preprint, arXiv: 2401.02954, 2024, articleTitle=null, refAbstract=null), Reference(id=1329419619556766031, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=20, rfOrder=20, authorNames=null, journalName=null, refType=null, unstructuredReference=Radford A, Wu J, Child R, et al. Language models are unsupervised multitask learners[EB/OL]. 2019[2024-04-23]. https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf, articleTitle=null, refAbstract=null), Reference(id=1329419619636457808, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=21, rfOrder=21, authorNames=null, journalName=null, refType=null, unstructuredReference=Pourreza M, Rafiei D. DIN-SQL: Decomposed in-context learning of text-to-SQL with self-correction[C]// Proc of the 37th Int Conf on Neural Information Processing Systems. New York: ACM, 2023: 36339−36348, articleTitle=null, refAbstract=null), Reference(id=1329419619707760977, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=22, rfOrder=22, authorNames=null, journalName=null, refType=null, unstructuredReference=Gao Dawei, Wang Haibin, Li Yaliang, et al. Text-to-SQL empowered by large language models: A benchmark evaluation[J]. Proceedings of the VLDB Endowment, 2024, 17(5): 1132−1145, articleTitle=null, refAbstract=null), Reference(id=1329419619787452754, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=23, rfOrder=23, authorNames=null, journalName=null, refType=null, unstructuredReference=Dong Xuemei, Zhang Chao, Ge Yuhang, et al. C3: Zero-shot text-to-SQL with ChatGPT[J]. arXiv preprint, arXiv: 2307.07306, 2023, articleTitle=null, refAbstract=null), Reference(id=1329419619862950227, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=24, rfOrder=24, authorNames=null, journalName=null, refType=null, unstructuredReference=Wang Bing, Ren Changyu, Yang Jian, et al. MAC-SQL: A multi-agent collaborative framework for text-to-SQL[C]//Proc of the 32nd Int Conf on Computational Linguistics. Stroudsburg, PA : ACL, 2025: 540−557, articleTitle=null, refAbstract=null), Reference(id=1329419619934253396, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=25, rfOrder=25, authorNames=null, journalName=null, refType=null, unstructuredReference=Maamari K, Abubaker F, Jaroslawicz D, et al. The death of schema linking? Text-to-SQL in the age of well-reasoned language models[C]//Proc of the 38th Advances in Neural Information Processing Systems. New York: ACM, 2024: 1−10, articleTitle=null, refAbstract=null), Reference(id=1329419620001362261, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=26, rfOrder=26, authorNames=null, journalName=null, refType=null, unstructuredReference=Hasan A C, Özgür U. E-SQL: Direct schema linking via question enrichment in text-to-SQL[J]. arXiv preprint, arXiv: 2409.16751, 2025, articleTitle=null, refAbstract=null), Reference(id=1329419620072665430, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=27, rfOrder=27, authorNames=null, journalName=null, refType=null, unstructuredReference=Li Haoyang, Zhang Jing, Liu Hanbing, et al. Codes: Towards building open-source language models for text-to-sSQL[J]. Proceedings of the ACM on Management of Data, 2024, 2(3): 1−28, articleTitle=null, refAbstract=null), Reference(id=1329419620152357207, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=28, rfOrder=28, authorNames=null, journalName=null, refType=null, unstructuredReference=Peter F B, Vincent P J D, Peter V D, et al. Class-based n-gram models of natural language[J]. Computational Linguistics, 1992, 18(4): 467−480, articleTitle=null, refAbstract=null), Reference(id=1329419620236243288, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=29, rfOrder=29, authorNames=null, journalName=null, refType=null, unstructuredReference=Li Zehan, Zhang Xin, Zhang Yanzhao, et al. Towards general text embeddings with multi-stage contrastive learning[J]. arXiv preprint, arXiv: 2308.03281, 2023, articleTitle=null, refAbstract=null), Reference(id=1329419620303352153, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=30, rfOrder=30, authorNames=null, journalName=null, refType=null, unstructuredReference=Alomari Z, Halimi O E, Sivaprasad K, et al. Comparative studies of six programming languages[J]. arXiv preprint, arXiv: 1504.00693, 2015, articleTitle=null, refAbstract=null), Reference(id=1329419620374655322, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, doi=null, pmid=null, pmcid=null, year=null, volume=null, issue=null, pageStart=null, pageEnd=null, url=null, language=null, rfNumber=31, rfOrder=31, authorNames=null, journalName=null, refType=null, unstructuredReference=Li Jinyang, Hui Binyuan, Qu Ge, et al. Can LLM already serve as a database interface? A big bench for large-scale database grounded text-to-SQLs[C]//Proc of the 37th Int Conf on Neural Information Processing Systems. New York: ACM, 2024: 42330−42357, articleTitle=null, refAbstract=null)], funds=null, companyList=[AuthorCompany(id=1329419614305497338, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=1, ext=[AuthorCompanyExt(id=1329419614313885947, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1School of Software, Shandong University, Jinan 250101), AuthorCompanyExt(id=1329419614322274556, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1山东大学软件学院 济南 250101)]), AuthorCompany(id=1329419614385189117, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=2, ext=[AuthorCompanyExt(id=1329419614389383422, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614385189117, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=2China Mobile Qilu Innovation Research Institute, Jinan 250102), AuthorCompanyExt(id=1329419614397772031, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614385189117, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=2中国移动通信集团山东有限公司中移齐鲁创新院分公司 济南 250102)]), AuthorCompany(id=1329419614473269504, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=3, ext=[AuthorCompanyExt(id=1329419614481658113, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614473269504, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=3Academy of Military Science, Beijing 100080), AuthorCompanyExt(id=1329419614490046722, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614473269504, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=3中国人民解放军军事科学院 北京 100080)])], figs=[ArticleFig(id=1329419616113242402, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Figure 1, caption=Database schema enhancement, figureFileSmall=TIdh/wDi/X7qeZ06H7R+vw==, figureFileBig=Ef834vNg5J2Wz1PC3IALBA==, tableContent=null), ArticleFig(id=1329419616180351267, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=图1, caption=数据库模式增强, figureFileSmall=TIdh/wDi/X7qeZ06H7R+vw==, figureFileBig=Ef834vNg5J2Wz1PC3IALBA==, tableContent=null), ArticleFig(id=1329419616377483556, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Figure 2, caption=Filtration mode deletes key information by mistake, resulting in wrong results, figureFileSmall=zsx/I/Zq2A998fqDjRkMjg==, figureFileBig=EXwznl581s3yDN7AQKvckg==, tableContent=null), ArticleFig(id=1329419616440398117, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=图2, caption=模式过滤误删关键信息导致错误结果, figureFileSmall=zsx/I/Zq2A998fqDjRkMjg==, figureFileBig=EXwznl581s3yDN7AQKvckg==, tableContent=null), ArticleFig(id=1329419616528478502, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Figure 3, caption=Misleading example prompt, figureFileSmall=JAdMLG+0arQQTtawhDTuyQ==, figureFileBig=P9zzRpJL++D+CPgsgNihwg==, tableContent=null), ArticleFig(id=1329419616603975975, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=图3, caption=误导性的示例提示, figureFileSmall=JAdMLG+0arQQTtawhDTuyQ==, figureFileBig=P9zzRpJL++D+CPgsgNihwg==, tableContent=null), ArticleFig(id=1329419616692056360, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Figure 4, caption=Flowchart of ITS-SQL, figureFileSmall=9k9ZVSbkDESO/xf67qYfMQ==, figureFileBig=dqzo+6UZkIQHcEmeV6Vo3g==, tableContent=null), ArticleFig(id=1329419616759165225, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=图4, caption=ITS-SQL 流程图, figureFileSmall=9k9ZVSbkDESO/xf67qYfMQ==, figureFileBig=dqzo+6UZkIQHcEmeV6Vo3g==, tableContent=null), ArticleFig(id=1329419616830468394, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Figure 5, caption=Improving performance on different difficulty levels of BIRD dataset, figureFileSmall=NTwt+h6URpp8FuXtd4RQnQ==, figureFileBig=QgHMOfTy+WeHMIEqSfqSOw==, tableContent=null), ArticleFig(id=1329419616952103211, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=图5, caption=在BIRD数据集不同难度部分的性能改进, figureFileSmall=NTwt+h6URpp8FuXtd4RQnQ==, figureFileBig=QgHMOfTy+WeHMIEqSfqSOw==, tableContent=null), ArticleFig(id=1329419617048572204, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Figure 6, caption=Detailed case study, figureFileSmall=e7g/iCpd03RxNQoAVv0Kag==, figureFileBig=lErW2qmTbthBG9V9Lnje0w==, tableContent=null), ArticleFig(id=1329419617124069677, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=图6, caption=详细案例研究, figureFileSmall=e7g/iCpd03RxNQoAVv0Kag==, figureFileBig=lErW2qmTbthBG9V9Lnje0w==, tableContent=null), ArticleFig(id=1329419617191178542, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Table 1, caption=

Execution Accuracy of Large Language Models on Spider-dev Dataset Under Different Few-Shot Example Selections %

, figureFileSmall=null, figureFileBig=null, tableContent=
样本数量样本选择策略CodeLlamaDeepSeekDeepSeek-V2Qwen2.5Llama3Qwen2DeepSeek-V3
0-shot71.072.675.083.075.579.278.6
1-shot随机69.574.275.085.078.081.880.4
问题语义相似度69.475.676.284.878.279.681.1
掩码问题相似度69.676.575.886.078.279.881.2
SQL语义相似度69.974.175.384.879.080.781.4
SQL骨架相似度71.675.175.684.280.080.881.2
ITS-SQL(本文)71.978.776.885.882.483.482.3
3-shot随机70.675.474.085.479.480.980.5
问题语义相似度70.976.176.584.378.780.982.3
掩码问题相似度69.475.676.985.478.279.682.4
SQL语义相似度72.076.275.384.478.882.580.2
SQL骨架相似度72.375.175.185.178.881.880.9
ITS-SQL(本文)73.480.877.286.382.984.482.5
5-shot随机72.976.275.185.578.980.880.3
问题语义相似度71.576.776.384.678.781.082.4
掩码问题相似度69.475.677.184.878.279.681.8
SQL语义相似度72.277.174.485.178.982.081.8
SQL骨架相似度72.075.374.785.378.781.182.3
ITS-SQL(本文)73.980.777.786.882.984.583.1
), ArticleFig(id=1329419617283453231, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=表1, caption=

各大语言模型在不同少样本示例选择下 Spider-dev 数据集上的执行正确率

, figureFileSmall=null, figureFileBig=null, tableContent=
样本数量样本选择策略CodeLlamaDeepSeekDeepSeek-V2Qwen2.5Llama3Qwen2DeepSeek-V3
0-shot71.072.675.083.075.579.278.6
1-shot随机69.574.275.085.078.081.880.4
问题语义相似度69.475.676.284.878.279.681.1
掩码问题相似度69.676.575.886.078.279.881.2
SQL语义相似度69.974.175.384.879.080.781.4
SQL骨架相似度71.675.175.684.280.080.881.2
ITS-SQL(本文)71.978.776.885.882.483.482.3
3-shot随机70.675.474.085.479.480.980.5
问题语义相似度70.976.176.584.378.780.982.3
掩码问题相似度69.475.676.985.478.279.682.4
SQL语义相似度72.076.275.384.478.882.580.2
SQL骨架相似度72.375.175.185.178.881.880.9
ITS-SQL(本文)73.480.877.286.382.984.482.5
5-shot随机72.976.275.185.578.980.880.3
问题语义相似度71.576.776.384.678.781.082.4
掩码问题相似度69.475.677.184.878.279.681.8
SQL语义相似度72.277.174.485.178.982.081.8
SQL骨架相似度72.075.374.785.378.781.182.3
ITS-SQL(本文)73.980.777.786.882.984.583.1
), ArticleFig(id=1329419617358950704, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Table 2, caption=

Execution Accuracy on Spider %

, figureFileSmall=null, figureFileBig=null, tableContent=
方法验证集测试集
T5-3B71.574.4
RAT-SQL75.073.3
RATSAT+PICARD80.575.5
Graphix-T581.077.6
RESDSQL-3B84.179.9
Codex71.772.1
PaLM-269.970.5
ChatGPT72.874.3
COT+ChatGPT75.576.7
GPT-476.683.9
COT+GPT-478.283.9
C3+ChatGPT81.882.3
DAIL-SQL+GPT-482.486.6
DINSQL+GPT-482.885.3
GPT-4o77.882.8
ITS-SQL+GPT-4o(本文)85.886.9
ITS-SQL+Qwen2.5-Coder(本文)86.887.5
), ArticleFig(id=1329419617434448177, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=表2, caption=

在Spider上的执行正确率

, figureFileSmall=null, figureFileBig=null, tableContent=
方法验证集测试集
T5-3B71.574.4
RAT-SQL75.073.3
RATSAT+PICARD80.575.5
Graphix-T581.077.6
RESDSQL-3B84.179.9
Codex71.772.1
PaLM-269.970.5
ChatGPT72.874.3
COT+ChatGPT75.576.7
GPT-476.683.9
COT+GPT-478.283.9
C3+ChatGPT81.882.3
DAIL-SQL+GPT-482.486.6
DINSQL+GPT-482.885.3
GPT-4o77.882.8
ITS-SQL+GPT-4o(本文)85.886.9
ITS-SQL+Qwen2.5-Coder(本文)86.887.5
), ArticleFig(id=1329419617493168434, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Table 3, caption=

Execution Accuracy on BIRD Validation Set %

, figureFileSmall=null, figureFileBig=null, tableContent=
方法执行正确率
RESDSQL-3B43.9
T5-3B23.34
Palm-227.38
Codex34.35
ChatGPT37.22
ChatGPT+COT36.64
Claude-242.70
GPT-446.35
C3+ChatGPT50.2
DIN-SQL+GPT-450.72
DAIL-SQL+GPT-454.76
TA-SQL+GPT-456.19
ITS-SQL+Qwen2.5-Coder(本文)60.17
ITS-SQL+GPT-4o(本文)60.23
), ArticleFig(id=1329419617560277300, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=表3, caption=

在BIRD验证集上的执行正确率

, figureFileSmall=null, figureFileBig=null, tableContent=
方法执行正确率
RESDSQL-3B43.9
T5-3B23.34
Palm-227.38
Codex34.35
ChatGPT37.22
ChatGPT+COT36.64
Claude-242.70
GPT-446.35
C3+ChatGPT50.2
DIN-SQL+GPT-450.72
DAIL-SQL+GPT-454.76
TA-SQL+GPT-456.19
ITS-SQL+Qwen2.5-Coder(本文)60.17
ITS-SQL+GPT-4o(本文)60.23
), ArticleFig(id=1329419617644163381, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Table 4, caption=

Execution Accuracy of Module Ablation study of Different Models on Spider Dataset %

, figureFileSmall=null, figureFileBig=null, tableContent=
模型w/o 伪
SQL
w/o 最终
SQL
w/o 模式
增强
ITS-SQL
(本文)
上限
CodeLlama73.873.073.974.576.7
DeepSeek-Coder80.478.378.780.782.7
DeepSeek-Coder-V277.174.475.777.779.5
Qwen2.5-Coder85.485.185.386.888.1
Llama381.280.680.782.985.0
Qwen283.282.184.084.585.8
DeepSeek-V382.382.482.183.184.5
), ArticleFig(id=1329419617715466550, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=表4, caption=

各模型在Spider数据集上的模块消融实验执行正确率

, figureFileSmall=null, figureFileBig=null, tableContent=
模型w/o 伪
SQL
w/o 最终
SQL
w/o 模式
增强
ITS-SQL
(本文)
上限
CodeLlama73.873.073.974.576.7
DeepSeek-Coder80.478.378.780.782.7
DeepSeek-Coder-V277.174.475.777.779.5
Qwen2.5-Coder85.485.185.386.888.1
Llama381.280.680.782.985.0
Qwen283.282.184.084.585.8
DeepSeek-V382.382.482.183.184.5
), ArticleFig(id=1329419617782575415, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Table 5, caption=

Execution Accuracy of Module Ablation study of Different Models on BIRD Dataset %

, figureFileSmall=null, figureFileBig=null, tableContent=
模型w/o 伪
SQL
w/o 最终
SQL
w/o 模式
增强
ITS-SQL
(本文)
上限
CodeLlama34.0333.7734.3234.4236.44
DeepSeek-Coder46.2845.7647.2047.3349.67
DeepSeek-Coder-V243.0239.7744.3344.9246.22
Qwen2.5-Coder59.4557.3757.9160.1760.82
Llama350.9850.8551.2454.5056.39
Qwen254.3053.9854.9556.4558.28
DeepSeek-V351.0448.8951.5052.1553.72
), ArticleFig(id=1329419617858072888, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=表5, caption=

各模型在BIRD数据集上的模块消融实验执行正确率

, figureFileSmall=null, figureFileBig=null, tableContent=
模型w/o 伪
SQL
w/o 最终
SQL
w/o 模式
增强
ITS-SQL
(本文)
上限
CodeLlama34.0333.7734.3234.4236.44
DeepSeek-Coder46.2845.7647.2047.3349.67
DeepSeek-Coder-V243.0239.7744.3344.9246.22
Qwen2.5-Coder59.4557.3757.9160.1760.82
Llama350.9850.8551.2454.5056.39
Qwen254.3053.9854.9556.4558.28
DeepSeek-V351.0448.8951.5052.1553.72
), ArticleFig(id=1329419617946153273, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=EN, label=Table 6, caption=

Execution Accuracy on Different Databases Within BIRD-dev Dataset

, figureFileSmall=null, figureFileBig=null, tableContent=
数据库数量困难比/%不同方法的执行正确率/%变化
GPT-4oITS-SQL(本文)
california_schools8939.3325.8440.45+14.61个百分点
card_games19134.5539.2752.36+13.09个百分点
codebase_community18618.8256.9964.52+7.53个百分点
debit_card_specializing6432.8139.0656.25+17.19个百分点
european_football_212949.6151.9469.77+17.83个百分点
financial10640.5736.7947.17+10.38个百分点
formula_117432.7635.0647.13+12.07个百分点
student_club15836.0853.8076.58+22.78个百分点
superhero12937.2171.3284.50+13.18个百分点
thrombosis_prediction16369.9428.8353.37+25.54个百分点
toxicology14547.5948.9764.14+15.17个百分点
), ArticleFig(id=1329419618013262138, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, language=CN, label=表6, caption=

BIRD-dev数据集的不同数据库上的执行正确率

, figureFileSmall=null, figureFileBig=null, tableContent=
数据库数量困难比/%不同方法的执行正确率/%变化
GPT-4oITS-SQL(本文)
california_schools8939.3325.8440.45+14.61个百分点
card_games19134.5539.2752.36+13.09个百分点
codebase_community18618.8256.9964.52+7.53个百分点
debit_card_specializing6432.8139.0656.25+17.19个百分点
european_football_212949.6151.9469.77+17.83个百分点
financial10640.5736.7947.17+10.38个百分点
formula_117432.7635.0647.13+12.07个百分点
student_club15836.0853.8076.58+22.78个百分点
superhero12937.2171.3284.50+13.18个百分点
thrombosis_prediction16369.9428.8353.37+25.54个百分点
toxicology14547.5948.9764.14+15.17个百分点
)], attaches=null, journal=Journal(id=1324759606947315908, delFlag=0, nameCn=计算机研究与发展, nameEn=Journal of Computer Research and Development, nameHistory1=null, nameHistory2=null, issn=1000-1239, eissn=null, cn=11-1777/TP, coden=null, periodic=0, language=CN, oaType=null, ccby=null, superviseOffice=null, ownerOffice=null, pubOffice=null, editorOffice=null, officeType=null, aims=null, clcCode=null, officeProv=null, officeCity=null, officeAddr=null, officeZip=null, officeEmail=null, officePhone=null, editDirector=null, officeDirector=null, officeDirectorPhone=null, officeStaffNum=null, officeEmpNum=null, coverPicUrl=k2l8zgqwstuxxevFX2qxVA==, journalPrice=null, startedYear=null, abbrevIsoEn=Journal of Computer Research and Development, journalRemark=null, publicationField=null, createdTime=1793776903141, updatedTime=1793850698612, createdBy=18614031015, updatedBy=13701087609, firstLetterCn=J, firstLetterEn=J, subjectCode=Electronic Information, subjectName=null, subjectCodeEn=Electronic Information, subjectNameEn=null, picCn=k2l8zgqwstuxxevFX2qxVA==, picEn=r6k0Ry+RD+c/VXj5QarmDw==, jcr=null, cjcr=null, exts=[JournalExt(id=1325069127710286688, language=CN, name=计算机研究与发展, nameHistory1=null, nameHistory2=null, managedBy=, sponsoredBy=, publishedBy=, editorOffice=, officeProv=null, officeCity=null, officeAddr=, officeZip=, editDirector=, officeDirector=null, officePhone=null, coverPicUrl=null, journalRemark=, submitArticleUrl=null, websiteUrl=, createdTime=1793850698640, updatedTime=1793850698640, createdBy=13701087609, updatedBy=13701087609, submissionGuidelinesUrl=, submissionAuthorUrl=https://crad.ict.ac.cn/journalx/authorLogOn.action, submissionEditorUrl=https://crad.ict.ac.cn/journalx/editorLogOn.action, submissionReviewUrl=https://crad.ict.ac.cn/journalx/expertLogOn.action, submissionCeEditorUrl=https://crad.ict.ac.cn/journalx/editorInChiefLogOn.action, submissionAeEditorUrl=, option={"copyright":""}), JournalExt(id=1325069127777395553, language=EN, name=Journal of Computer Research and Development, nameHistory1=null, nameHistory2=null, managedBy=, sponsoredBy=, publishedBy=, editorOffice=, officeProv=null, officeCity=null, officeAddr=, officeZip=, editDirector=, officeDirector=null, officePhone=null, coverPicUrl=null, journalRemark=, submitArticleUrl=null, websiteUrl=, createdTime=1793850698656, updatedTime=1793850698656, createdBy=13701087609, updatedBy=13701087609, submissionGuidelinesUrl=, submissionAuthorUrl=https://crad.ict.ac.cn/journalx/authorLogOn.action, submissionEditorUrl=https://crad.ict.ac.cn/journalx/editorLogOn.action, submissionReviewUrl=https://crad.ict.ac.cn/journalx/expertLogOn.action, submissionCeEditorUrl=https://crad.ict.ac.cn/journalx/editorInChiefLogOn.action, submissionAeEditorUrl=, option={"copyright":""})], databaseList=null, tenantJournalId=1324759914146529478, websiteList=[Website(id=1325070300139892771, webName=null, webTitle=null, webDomain=null, webCopyrigh=null, webIpcNo=null, seoTitle=null, seoKeywords=null, seoDescription=null, tenantJournalId=null, journalId=1324759914146529478, journalNameCn=null, journalNameEn=null, grayFlag=null, tenantId=1146029695717560320, platformId=null, journalGroupId=null, journalGroupNameCn=null, journalGroupNameEn=null, type=1, domain=https://castjournals.cast.org.cn/joweb/jsjyjyfz/CN, language=CN, createTime=1793850978169, createBy=18614031015, updateTime=1793851040259, updateBy=18614031015, name=计算机研究与发展-中文, tplId=1146099689490845704, title=计算机研究与发展, delFlag=0, indexPage=/home, props=[WebsiteProps(id=1325070893751349360, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=articleTextType, value=kx, createTime=1793851119697, updateTime=1793851119697, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893730377837, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=banner, value=null, createTime=1793851119692, updateTime=1793851119692, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893772320883, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=grayFlag, value=0, createTime=1793851119702, updateTime=1793851119702, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893721989228, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=logo, value=https://castjournals.cast.org.cn/joweb/jsjyjyfz/CN/file/pic?fileId=U27tDsy717YF7XSPA+Vwdw==, createTime=1793851119690, updateTime=1793851119690, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893784903797, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=minRunFlag, value=0, createTime=1793851119705, updateTime=1793851119705, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893742960751, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=picServerUrl, value=https://castjournals.cast.org.cn/joweb/jsjyjyfz/CN/file/pic, createTime=1793851119695, updateTime=1793851119695, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893780709492, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=silenceFlag, value=0, createTime=1793851119704, updateTime=1793851119704, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893738766446, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=staticResourcePath, value=https://castjournals.cast.org.cn/joweb/cast_kjdb_cn_619/, createTime=1793851119694, updateTime=1793851119694, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893755543665, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=themeColor, value=null, createTime=1793851119698, updateTime=1793851119698, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070893763932274, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300139892771, code=themeStyle, value=null, createTime=1793851119700, updateTime=1793851119700, creator=18614031015, updator=18614031015)]), Website(id=1325070300580294698, webName=null, webTitle=null, webDomain=null, webCopyrigh=null, webIpcNo=null, seoTitle=null, seoKeywords=null, seoDescription=null, tenantJournalId=null, journalId=1324759914146529478, journalNameCn=null, journalNameEn=null, grayFlag=null, tenantId=1146029695717560320, platformId=null, journalGroupId=null, journalGroupNameCn=null, journalGroupNameEn=null, type=1, domain=https://castjournals.cast.org.cn/joweb/jsjyjyfz/EN, language=EN, createTime=1793850978274, createBy=18614031015, updateTime=1793851036638, updateBy=18614031015, name=计算机研究与发展-英文, tplId=1146101810881728533, title=Journal of Computer Research and Development, delFlag=0, indexPage=/home, props=[WebsiteProps(id=1325070925288321148, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=articleTextType, value=kx, createTime=1793851127216, updateTime=1793851127216, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925263155321, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=banner, value=null, createTime=1793851127210, updateTime=1793851127210, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925309292671, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=grayFlag, value=0, createTime=1793851127221, updateTime=1793851127221, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925254766712, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=logo, value=https://castjournals.cast.org.cn/joweb/jsjyjyfz/EN/file/pic?fileId=U27tDsy717YF7XSPA+Vwdw==, createTime=1793851127208, updateTime=1793851127208, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925326069889, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=minRunFlag, value=0, createTime=1793851127225, updateTime=1793851127225, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925279932539, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=picServerUrl, value=https://castjournals.cast.org.cn/joweb/jsjyjyfz/EN/file/pic, createTime=1793851127214, updateTime=1793851127214, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925317681280, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=silenceFlag, value=0, createTime=1793851127223, updateTime=1793851127223, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925271543930, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=staticResourcePath, value=https://castjournals.cast.org.cn/joweb/cast_kjdb_en_623/, createTime=1793851127212, updateTime=1793851127212, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925292515453, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=themeColor, value=null, createTime=1793851127217, updateTime=1793851127217, creator=18614031015, updator=18614031015), WebsiteProps(id=1325070925300904062, tenantId=1146029695717560320, journalId=null, journalGroupId=null, siteId=1325070300580294698, code=themeStyle, value=null, createTime=1793851127219, updateTime=1793851127219, creator=18614031015, updator=18614031015)])], journalTitle=计算机研究与发展, weixinUrl=null, journalUrl=https://crad.ict.ac.cn/, iacademicId=null, status=1, seqNo=null, journalTitleEn=Journal of Computer Research and Development, journalPhotoCn=k2l8zgqwstuxxevFX2qxVA==, journalPhotoEn=r6k0Ry+RD+c/VXj5QarmDw==, journalFirstLetter=J, journalRecommend=null, journalNew=null, journalCollection=null, jcrJf=null, cjcrJf=null, jcrJfStr=null, cjcrJfStr=null, submissionFirstDecision=null, sciSubjectClassification=null, casSubjectClassification=null, citeScore=null, totalCitationFrequency=null, icpCode=null, psCode=null, advertisingLicenseCode=null, copyrightInformation=null, country=null, option=, provinceCode=null, provinceName=null, collectFlag=false, interPubPlatform=, interPubPlatformUrl=null), detailUrlCn=https://castjournals.cast.org.cn/joweb/jsjyjyfz/CN/10.7544/issn1000-1239.202550355, detailUrlEn=https://castjournals.cast.org.cn/joweb/jsjyjyfz/EN/10.7544/issn1000-1239.202550355, pdfUrlCn=https://castjournals.cast.org.cn/joweb/jsjyjyfz/CN/PDF/10.7544/issn1000-1239.202550355, pdfUrlEn=https://castjournals.cast.org.cn/joweb/jsjyjyfz/EN/PDF/10.7544/issn1000-1239.202550355, aliStartDate=0, aliEndDate=0, collectionFlag=false, citedCount=null, citedUrl=null, previewStatus=0, delFlag=0, hasFullText=1, orderTime=1777564800000, fullTextJson=null, articleText=null, reference=null)
收藏切换
基于大语言模型的2阶段迭代模式增强SQL生成
张伟 1, 2 , 周东傲 3, * , 宫永顺 1 , 尹义龙 1
计算机研究与发展 | 人工智能 2026,63(5): 1261-1272
收起
收藏切换
计算机研究与发展 |人工智能 2026 , 63 (5) : 1261 -1272
基于大语言模型的2阶段迭代模式增强SQL生成
全屏
[Author(id=1329419614565544196, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, orderNo=0, firstName=null, middleName=null, lastName=null, nameCn=null, orcid=null, stid=null, country=null, authorPic=null, dead=0, email=zhangwei4@sd.chinamobile.com, emailSecond=null, emailThird=null, correspondingAuthor=0, authorType=1, ext={EN=AuthorExt(id=1329419614657818887, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614565544196, language=EN, stringName=Wei Zhang, firstName=Wei, middleName=null, lastName=Zhang, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, 2, address=1School of Software, Shandong University, Jinan 250101
2China Mobile Qilu Innovation Research Institute, Jinan 250102, bio={"content":"

born in 1999. Master. His main research interests include natural language processing and data mining

"}, bioImg=null, bioContent=

born in 1999. Master. His main research interests include natural language processing and data mining

, aboutCorrespAuthor=null), CN=AuthorExt(id=1329419614720733448, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614565544196, language=CN, stringName=张伟, firstName=null, middleName=null, lastName=null, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, 2, address=1山东大学软件学院 济南 250101
2中国移动通信集团山东有限公司中移齐鲁创新院分公司 济南 250102, bio={"img":"PEnX18KgBht6ogdNGHHAXw==","content":"

1999年生。硕士。主要研究方向为自然语言处理、数据挖掘

"}, bioImg=PEnX18KgBht6ogdNGHHAXw==, bioContent=

1999年生。硕士。主要研究方向为自然语言处理、数据挖掘

, aboutCorrespAuthor=null)}, companyList=[AuthorCompany(id=1329419614305497338, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=1, ext=[AuthorCompanyExt(id=1329419614313885947, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1School of Software, Shandong University, Jinan 250101), AuthorCompanyExt(id=1329419614322274556, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1山东大学软件学院 济南 250101)]), AuthorCompany(id=1329419614385189117, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=2, ext=[AuthorCompanyExt(id=1329419614389383422, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614385189117, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=2China Mobile Qilu Innovation Research Institute, Jinan 250102), AuthorCompanyExt(id=1329419614397772031, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614385189117, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=2中国移动通信集团山东有限公司中移齐鲁创新院分公司 济南 250102)])]), Author(id=1329419614783648010, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, orderNo=1, firstName=null, middleName=null, lastName=null, nameCn=null, orcid=null, stid=null, country=null, authorPic=null, dead=0, email=zhoudongao08@nudt.edu.cn, emailSecond=null, emailThird=null, correspondingAuthor=1, authorType=1, ext={EN=AuthorExt(id=1329419614859145484, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614783648010, language=EN, stringName=Dong’ao Zhou, firstName=Dong’ao, middleName=null, lastName=Zhou, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=3, *, address=3Academy of Military Science, Beijing 100080, bio={"content":"

born in 1990. PhD, assistant researcher. His main research interests include artificial intelligence and signal detection

"}, bioImg=null, bioContent=

born in 1990. PhD, assistant researcher. His main research interests include artificial intelligence and signal detection

, aboutCorrespAuthor=null), CN=AuthorExt(id=1329419614922060045, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614783648010, language=CN, stringName=周东傲, firstName=null, middleName=null, lastName=null, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=3, *, address=3中国人民解放军军事科学院 北京 100080, bio={"img":"VhpXexrwzLxereaXqBccsg==","content":"

1990年生。博士,助理研究员。主要研究方向为人工智能、信号检测

"}, bioImg=VhpXexrwzLxereaXqBccsg==, bioContent=

1990年生。博士,助理研究员。主要研究方向为人工智能、信号检测

, aboutCorrespAuthor=null)}, companyList=[AuthorCompany(id=1329419614473269504, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=3, ext=[AuthorCompanyExt(id=1329419614481658113, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614473269504, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=3Academy of Military Science, Beijing 100080), AuthorCompanyExt(id=1329419614490046722, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614473269504, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=3中国人民解放军军事科学院 北京 100080)])]), Author(id=1329419614984974607, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, orderNo=2, firstName=null, middleName=null, lastName=null, nameCn=null, orcid=null, stid=null, country=null, authorPic=null, dead=0, email=null, emailSecond=null, emailThird=null, correspondingAuthor=0, authorType=1, ext={EN=AuthorExt(id=1329419615064666385, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614984974607, language=EN, stringName=Yongshun Gong, firstName=Yongshun, middleName=null, lastName=Gong, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, address=1School of Software, Shandong University, Jinan 250101, bio={"content":"

born in 1990. PhD, professor. His main research interests include data mining and machine learning

"}, bioImg=null, bioContent=

born in 1990. PhD, professor. His main research interests include data mining and machine learning

, aboutCorrespAuthor=null), CN=AuthorExt(id=1329419615123386642, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419614984974607, language=CN, stringName=宫永顺, firstName=null, middleName=null, lastName=null, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, address=1山东大学软件学院 济南 250101, bio={"img":"MQvEkN30J0ZDEzIMZcZiDA==","content":"

1990年生。博士,教授。主要研究方向为数据挖掘、机器学习

"}, bioImg=MQvEkN30J0ZDEzIMZcZiDA==, bioContent=

1990年生。博士,教授。主要研究方向为数据挖掘、机器学习

, aboutCorrespAuthor=null)}, companyList=[AuthorCompany(id=1329419614305497338, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=1, ext=[AuthorCompanyExt(id=1329419614313885947, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1School of Software, Shandong University, Jinan 250101), AuthorCompanyExt(id=1329419614322274556, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1山东大学软件学院 济南 250101)])]), Author(id=1329419615190495508, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, orderNo=3, firstName=null, middleName=null, lastName=null, nameCn=null, orcid=null, stid=null, country=null, authorPic=null, dead=0, email=null, emailSecond=null, emailThird=null, correspondingAuthor=0, authorType=1, ext={EN=AuthorExt(id=1329419615261798678, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419615190495508, language=EN, stringName=Yilong Yin, firstName=Yilong, middleName=null, lastName=Yin, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, address=1School of Software, Shandong University, Jinan 250101, bio={"content":"

born in 1972. PhD, professor. His main research interests include data mining and machine learning

"}, bioImg=null, bioContent=

born in 1972. PhD, professor. His main research interests include data mining and machine learning

, aboutCorrespAuthor=null), CN=AuthorExt(id=1329419615328907543, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, authorId=1329419615190495508, language=CN, stringName=尹义龙, firstName=null, middleName=null, lastName=null, prefix=null, suffix=null, authorComment=null, nameInitials=null, affiliation=null, department=null, xref=1, address=1山东大学软件学院 济南 250101, bio={"img":"KmhdD0sUuGObKb4/nl8Rgw==","content":"

1972年生。博士,教授。主要研究方向为数据挖掘、机器学习

"}, bioImg=KmhdD0sUuGObKb4/nl8Rgw==, bioContent=

1972年生。博士,教授。主要研究方向为数据挖掘、机器学习

, aboutCorrespAuthor=null)}, companyList=[AuthorCompany(id=1329419614305497338, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, xref=1, ext=[AuthorCompanyExt(id=1329419614313885947, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=EN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1School of Software, Shandong University, Jinan 250101), AuthorCompanyExt(id=1329419614322274556, tenantId=1146029695717560320, journalId=1324759914146529478, articleId=1329419612044767459, companyId=1329419614305497338, language=CN, country=null, province=null, city=null, postcode=null, companyName=null, departmentName=null, remark=1山东大学软件学院 济南 250101)])])]
张伟1, 2 , 周东傲3, * , 宫永顺1, 尹义龙1
作者信息
  • 1山东大学软件学院 济南 250101
  • 2中国移动通信集团山东有限公司中移齐鲁创新院分公司 济南 250102
  • 3中国人民解放军军事科学院 北京 100080
通讯作者:
作者简介:

作者贡献声明

张伟提出算法思路,完成实验并撰写论文;周东傲、宫永顺和尹义龙提出指导意见并修改论文。

1999年生。硕士。主要研究方向为自然语言处理、数据挖掘

1990年生。博士,助理研究员。主要研究方向为人工智能、信号检测

1990年生。博士,教授。主要研究方向为数据挖掘、机器学习

1972年生。博士,教授。主要研究方向为数据挖掘、机器学习

Iterative Two-Stage Schema-Enhanced SQL Generation with Large Language Models
Wei Zhang1, 2 , Dong’ao Zhou3, * , Yongshun Gong1, Yilong Yin1
Affiliations
  • 1School of Software, Shandong University, Jinan 250101
  • 2China Mobile Qilu Innovation Research Institute, Jinan 250102
  • 3Academy of Military Science, Beijing 100080
  • born in 1999. Master. His main research interests include natural language processing and data mining

    born in 1990. PhD, assistant researcher. His main research interests include artificial intelligence and signal detection

    born in 1990. PhD, professor. His main research interests include data mining and machine learning

    born in 1972. PhD, professor. His main research interests include data mining and machine learning

出版时间: 2026-05-01 doi: 10.7544/issn1000-1239.202550355
文章导航
收藏切换

随着大数据时代的到来,各种企业和组织在日益增长的业务拓展以及信息需求的推动下积累了海量的数据。这些数据通常以结构化或半结构化的形式存储在对应的关系型数据库中。SQL作为一种结构化的数据库查询语言,长期以来被广泛应用于数据的检索和处理。它为相关专业技术人员提供了一种高效的方式来与数据库进行交互,从而能够更快捷方便地实现对于数据的分析。随着大语言模型(large language models,LLMs)的快速发展,上下文学习(in-context learning,ICL)在文本生成SQL(text-to-SQL)任务中展现出巨大潜力。ICL能够使大语言模型通过利用参考示例生成准确的SQL查询。为了充分利用大语言模型在ICL机制下进行文本生成SQL,提出了一个新的SQL生成流程,该流程包括3个部分:首先,提出了迭代式的模式增强,以强化大语言模型对解决问题相关信息的关注。其次,利用SQL的骨架结构进行语义相似度筛选,从而辅助生成伪SQL(pseudo-SQL)查询。最后设计了一种参考示例选择策略,该策略结合问题与伪SQL骨架之间的相似性,以提高生成SQL查询的准确性。同时,在2个关键阶段中都引入了迭代优化过程,以逐步优化示例选择策略,直至达到稳定状态。在多个大语言模型和数据集上进行了广泛的实验,验证了所提出方法的有效性。

大语言模型  /  文本生成SQL  /  上下文学习  /  数据库管理  /  数据分析

With the advent of the big data era, various enterprises and organizations have accumulated massive amounts of data driven by the growing demands for business expansion and information. This data are typically stored in relational databases in structured or semi-structured formats. SQL, as a structured database query language, has long been widely used for data retrieval and processing. It provides professionals with an efficient way to interact with databases, thereby facilitating quicker and more convenient data sharing and analysis. With the exponential advancement of large language models (LLMs), in-context learning (ICL) has shown significant promise for the text-to-SQL task, where LLMs utilize reference examples to accurately generate SQL queries. To fully harness the potential of LLMs through ICL for text-to-SQL, we propose a new SQL generation pipeline comprising three parts: first, we propose a schema enhancement component to strengthen LLMs’ focus on question-related information. Second, we leverage the inherent structure of SQL to preselect semantically similar, aiding in the generation of initial pseudo-SQL queries. Third, a selection strategy is proposed for selecting reference examples, which considers the similarities between the question and the pseudo-SQL structure to enhance the accuracy of the generated SQL queries. We implement an iterative refinement process in both stages, employing a boosting-like mechanism that progressively improves selection until stabilization is achieved. Extensive experiments across various models and datasets demonstrate the effectiveness of our approach.

large language models  /  text-to-SQL  /  in-context learning  /  database management  /  data analysis
张伟, 周东傲, 宫永顺, 尹义龙. 基于大语言模型的2阶段迭代模式增强SQL生成. 计算机研究与发展, 2026 , 63 (5) : 1261 -1272 . DOI: 10.7544/issn1000-1239.202550355
Wei Zhang, Dong’ao Zhou, Yongshun Gong, Yilong Yin. Iterative Two-Stage Schema-Enhanced SQL Generation with Large Language Models[J]. Journal of Computer Research and Development, 2026 , 63 (5) : 1261 -1272 . DOI: 10.7544/issn1000-1239.202550355
关系型数据库在数据爆炸式增长的时代中对于数据的存储与处理扮演着不可或缺的角色。随着社会信息化进程的不断加快,text-to-SQL任务的重要性日益凸显,其核心目标在于将自然语言问题转换为可执行的SQL查询语句,实现对数据库的高效访问与操作,从而实现数据仓库的高效利用[1]。随着数据量的增长以及数据交互频率的不断增加,传统的数据存储与查询方式在实际应用中已经捉襟见肘。如何在海量数据中快速有效地提取有价值的信息并且保证查询的实时性和准确性已经成为在数据处理分析的时候需要解决的重要问题[2]。SQL作为一种被广泛使用的结构化查询语言,为数据分析领域的技术人员提供了高效的数据库交互方式,从而能更便捷地实现数据的共享与分析,助力各行各业的高效运行与决策支持[3]。
但是对于绝大多数非技术人员来说,编写语法正确且能够满足查询目的的SQL语句仍然存在着比较高的学习门槛。因此文本转化为SQL任务的重要性日益凸显,它能够将自然语言问题准确地转换为可执行的SQL命令[4]。这一技术使得用户能够依据自身需求来轻松访问关系型数据库中的指定数据,使用户无需精通复杂的SQL语法便可以高效地进行数据操作[5]。与此同时,大语言模型的兴起为自然语言处理领域的发展带来了革命性的突破[6]。得益于在大规模数据集上进行了广泛的预训练,大语言模型在语言理解与生成方面展现了卓越的能力[7]。这一发展为文本转化SQL任务的研究开辟了全新的方向。在仅提供数据库模式信息和自然语言问题的情况下,大语言模型生成的SQL语句结果相比传统神经网络能够实现更高的执行正确率[8]。这不仅表明大语言模型的预训练语料和数据中已包含了丰富的文本到SQL任务信息,更凸显了其在文本到SQL应用中的巨大潜力[9]。
尽管大语言模型在文本到SQL任务中展现出强大的能力,但其在实际应用中仍面临诸多挑战。传统的神经网络通常会针对数据库模式链接任务进行专门训练,但大语言模型在预训练阶段可能并未专门针对该任务进行优化[10]。此外,在实际应用中,不同数据库的模式结构信息分布往往差异比较显著,并且通常充斥着各种冗余复杂信息。过多的无关信息可能会干扰大语言模型对于输入数据库信息的理解,导致最后输出错误的SQL语句。因此,仅仅依靠大语言模型从预训练的海量自然语言数据中获得的通用知识来解析未知陌生数据库,往往容易引发理解偏差或输出错误。
大语言模型对不同的上下文示例选择以及关键的思考提示非常敏感,这两者都能显著影响其生成输出的质量[11-13]。直观来讲,一种方法是优化上下文示例的选择和组织,确保它们更具代表性且与特定的文本到SQL任务的上下文相关[14]。其中一个重要的方面是参考示例中自然语言问题的相似性,以及相应SQL骨架的指导作用[15]。此外,在实际应用中,数据库模式信息通常非常复杂且冗余,直接解释和回应自然语言问题时容易出错。因此,在使用大语言模型生成SQL语句时,强调数据库模式中与接收到的自然语言问题真正相关的特定表和列至关重要。
鉴于上述考虑,本文提出了一种新的方法,称为模式增强的迭代式2阶段SQL生成(iterative two-stage schema-enhanced SQL generation,ITS-SQL)。ITS-SQL由3个关键组件组成:模式增强、伪SQL生成和最终SQL生成。首先,我们通过大语言模型由基本的数据库信息生成初步的“粗糙SQL”语句来从数据库模式中筛选与输入自然语言查询语义相关的数据库表和列。随后,考虑到SQL本身具有的较强结构化特性和明确语义,我们设计了一个迭代优化机制,通过逐步调整使参考示例在SQL骨架方面与模型的推理结果更加契合。这种迭代优化过程不仅使大语言模型能够从相似示例中学习有效的生成模式,还显著提升了模型的泛化能力。为进一步增强模型在跨领域场景下的适应性,我们引入了问题文本与SQL骨架关键词之间的相似度评估机制,并基于相似度评分对示例进行优化选择,为大语言模型提供更具针对性的参考示例,从而引导模型输出最终的SQL查询语句。
本文的贡献主要包括3个方面:
1)针对模式增强模块进行了改进,以突出与自然语言问题相关的数据库信息。这种方法避免了传统模式过滤可能导致关键信息丢失的风险,同时增强了大语言模型对关键细节的关注。
2)提出了一种新的样本选择方法,并结合迭代优化过程,选择出更适合作为参考的示例样本。通过这种方法,我们确保了样本选择的稳健性和有效性,从而最大化大语言模型在更复杂的text-to-SQL数据集上的执行正确率。
3)在2个大规模跨领域数据集上进行了广泛的实验。证明了该方法对模型和数据集具有普遍适用性,无论是非开源大语言模型还是开源大语言模型,该方法都能显著提升在不同数据集上的执行正确率,验证了方法的有效性。
随着大语言模型的快速迭代发展,尤其是像GPT[16],Gemini[17],LLaMA[18],DeepSeek[19]系列先进大语言模型的出现,大语言模型已成为自然语言处理领域的重要研究和应用方向之一。大语言模型凭借其广泛的综合知识储备已经在许多NLP任务中展现出了极其强大的语言理解能力[20],同时也因为其强大的生成能力成为了text-to-SQL任务研究中的关键技术。Pourreza等人[21]通过任务分解(task decomposition)的少样本思维链提示引导以及自我纠正辅助大语言模型进行显式的数据库模式链接推理,展示了大语言模型在文本到SQL任务中的强大潜力。Gao等人[22]系统地对现有的基于大语言模型的文本到SQL方法进行了分类和比较,并且重点分析了提示中的问题表示方式和示例组织策略,并且通过搜索具体数据库的实体信息来针对性对自然语言问题和SQL语句进行实体掩盖,从而实现跨知识领域的相似度示例选择。Dong等人[23]通过符号化表结构描述(如分隔指令、上下文和问题)来让模型对与问题相关的多个表进行排序选择,使得模型完成对于数据库模式链接方式的理解,并且通过多路投票机制,生成多个SQL候选并基于执行结果选择最优解,显著提高了生成SQL的鲁棒性。Wang等人[24]提出了一种多代理(multi-agent)协作框架,将文本到SQL任务分解为多个子任务,并且分别由不同的代理负责处理,以提高生成复杂SQL查询的能力。模式链接方面专门微调了用于数据库表和列选择的小规模语言模型作为代理,并且代理之间通过共享信息和协作机制,确保最终生成的SQL查询具备一致性和准确性。Qu等人[10]系统性地对文本到SQL生成中的幻觉(hallucination)问题进行分类,并且通过使用数据分析中Pandas库类比的方式来辅助分析数据库模式关系,优化了大语言模型的潜在模式链接过程。这些方法通常借鉴了基于传统神经网络训练的方式,通过引入额外的中间模式链接(schema linking)阶段,使大语言模型能够将数据库结构映射到自然语言。
模式链接是将自然语言问题转换为SQL过程中的关键环节,其核心目标在于建立自然语言表述与数据库模式元素(如表、列、关系等)之间的语义映射关系。以往的研究普遍采用模式过滤(schema filtering)或模式修剪(schema pruning)技术来优化模式链接过程[21],即通过移除无关的数据库元素来简化模式信息,从而提高模型的表现效果。然而,近期研究表明,对于具备较强上下文理解能力的大语言模型,显式的模式过滤策略可能收效甚微,甚至可能对模型性能产生负面影响[25-26]。这种负面影响主要源于模型在模式过滤过程中可能误判并删除必要的列或表信息,导致生成的SQL查询因关键信息缺失而出现错误。
针对这一问题,本文提出了一种模式增强(schema enhancement)方法:首先,我们直接将完整的数据库模式信息与自然语言问题共同输入模型,使模型能够基于完整的上下文信息生成一个“粗糙SQL(imprecise SQL)”。其次,我们引入基于示例的实体解析机制。通过提供少量示例,引导大语言模型使用思维链方式从生成的“粗糙SQL”中提取出与数据库相关的实体信息,形成数据库增强提示。最后,我们在保留完整数据库结构信息的基础上,将提取的实体信息以增强提示的形式重新注入模型,处理过程如图1所示。
在传统的模式过滤方法中,模型可能会误删关键的数据库表列信息,从而导致后续生成错误的SQL语句。如图2所示,由于语言模型对问题语义及数据库模式的理解不准确,错误地删除了关键字段“MailStreet”,导致最终生成的SQL语句仅返回了“School”列的信息。相比之下,本文提出的模式增强策略能够引导模型基于初步生成的粗糙SQL和完整的数据库模式信息,提取与任务相关的实体。在粗糙SQL中潜在逻辑结构与全局模式信息的共同提示下,模型能够更准确地理解任务目标,并更有效地补全问题中涉及的实体字段,从而提升SQL生成结果的正确性。
在2.1节中,我们仅利用了“粗糙SQL”中的数据库实体信息部分作为数据库表和列的提示信息。在本节中,我们将利用“粗糙SQL”的骨架结构来进行进一步的扩展。对于文本到SQL任务中的上下文示例选择,传统方法通常直接对比输入问题相似度来选择“问题-SQL对”作为参考示例。然而,这种方法存在显著局限性:尽管某些问题在语义上可能非常相似,但由于数据库结构的差异或查询意图的表达差别,其对应的SQL查询语句可能截然不同,如图3所示。
为了解决这一问题,我们提出了一种基于“伪SQL(pseudo SQL)”生成的示例选择方法。在模式增强阶段生成的“粗糙SQL”虽然可能不够精确,但其骨架结构能够有效捕捉问题的核心意图和数据库操作的逻辑框架。
所以在这一步,我们利用生成的“粗糙SQL”来指导示例选择。具体而言,我们将“粗糙SQL”和候选集中的SQL语句均进行SQL语法关键字保留处理,将包含的实体信息均通过使用特殊标记〈unk〉来进行替换从而避免实体信息影响语义相似度计算。然后通过计算处理后的“粗糙SQL”与候选集中SQL语句的语义相似度,选择相似度最高的“问题-SQL对” 作为参考示例,并且通过迭代优化生成该步的“伪SQL”结果。为了确保“伪SQL”生成的稳定性,我们在每次迭代中动态更新示例选择策略,确保所选示例能够逐步逼近最优解。
值得注意的是,“粗糙SQL”主要用来提示大语言模型对应的数据库实体信息以及初步骨架,而“伪SQL”则主要用于最终SQL产生阶段中与问题语义共同选择参考示例来使大语言模型产生最终的结果。
传统方法通常依赖于NLTK的实体识别[27]或从数据库中检索相关信息[22]来屏蔽无关实体数据,从而实现跨领域扩展。然而这些方法存在明显的局限性:首先,由于预训练语料库的覆盖范围有限,使用NLTK等方式在处理未知领域数据时,容易出现识别错误;其次对于大型数据库,检索相关实体信息的计算开销变得不可行,严重影响了方法的实用性。我们摒弃了传统的实体屏蔽策略,转而采用正则表达式匹配从“伪SQL”中提取并保留关键词和符号。
在实现上,我们摒弃了传统的基于n-gram[28]的SQL相似度计算方法,转而采用基于预训练语言模型的通用文本嵌入(general text embedding,GTE)模型[29]来处理SQL语句。这一选择基于2点考虑:首先,SQL语法与自然语言在结构上具有高度相似性,尤其是在操作语义的表达上具有明确且可读性强的特点[30];其次,GTE能够更好地捕捉SQL语句的语义信息,而不仅仅是表面的语法结构。我们通过计算GTE嵌入向量的余弦相似度来量化SQL语句之间的相关性,从而选择最相关的示例对。
在最终SQL产生阶段,为了进一步减轻问题中保留的实体对语义相似性计算的干扰,我们提出了一种基于SQL骨架和问题双重相似性的重叠选择策略。 我们首先根据自然语言问题和在2.2节中产生的“伪SQL”骨架的相似性分别对训练集数据进行排序,生成2个有序集合:$ {O}_{\text{question}} $(基于问题相似性)和$ {O}_{\text{sql}} $(基于SQL骨架相似性)。然后初始化2个空集合$ {C}_{\text{question}} $和$ {C}_{\text{sql}} $,并依次从$ {C}_{\text{question}} $和$ {C}_{\text{sql}} $中按照相似性排名将对应的“问题-SQL对”添加到2个集合中,直到$ {C}_{\text{question}} $和$ {C}_{\text{sql}} $的交集$ {C}_{\text{overlap}} $中的元素数量达到或超过预定义的参考示例数量$ k $(在少样本实验参数设置中指定)。
然而,上述示例选择策略面临一个与“伪SQL”生成过程中类似的问题:我们是否通过选择最合适的样本充分挖掘了模型的少样本学习潜力?为了确保使用该方法能够获得稳定且最优的SQL结果,我们同样迭代优化示例选择过程。在每次迭代中,我们将前一次推理得到的SQL结果作为下一次示例选择的“伪SQL”输入。整个方法流程如图4所示。
为了更好地评估本文所提出的ITS-SQL具体应用的有效性,我们在当前比较流行的2个大型数据集Spider[7]和 BIRD[31]上进行了实验对比与分析。Spider数据集包含10181个问题和5693个独特的复杂SQL查询,分布在200个数据库中。其中140个数据库被划归为训练集,20个数据库作为验证集,40个数据库则构成测试集。BIRD数据集包含超过12751对独特的“问题-SQL对”和95个大型数据库,而且其引入了诸如外部知识、脏数据等新挑战。在数据集划分方面,训练集包含69个数据库,验证集包含11个数据库,测试集包含15个数据库。由于地区的限制,我们仅在BIRD的验证集上进行实验,因为测试集需要提供OpenAI API密钥给BIRD官方数据集才可以测试。
对于开源模型,本文使用vLLM框架加速推理。在文本嵌入模型方面,本文选择了GTE-Large来将自然语言问题和SQL嵌入到1024维向量中。GTE使用了多阶段对比学习方法,首先在大量无监督文本对上进行预训练,然后在多个任务的标注文本三元组上进行微调,从而模型具有较高的泛化能力。
在具体实验中,本文使用了CREATE TABLE语句来表示数据库的模式信息,包括表名、列名、主键、外键等。为了实现不同大语言模型的公平比较,对比实验基准数据均来自于数据集官方网站公示结果以及对应发表论文。
本文统一将所有模型的温度参数值设置为0(即关闭采样随机性,使模型生成结果更具确定性),以消除随机性对实验结果的干扰;同时,将最大生成令牌数设定为512。需要说明的是,若未明确标注示例数量的实验部分,则默认采用 5-shot 设置。
在表1中,我们展示了模型在Spider的验证数据集上,采用不同数量的示例选择方法作为提示示例时的执行正确率。结果证明,我们的示例选择方法在帮助模型生成正确的SQL查询方面,比其他的传统示例选择策略更为有效。几乎所有模型在使用更多示例参考的时候性能都会普遍提高,这显示了在适当范围内提供更多示例能有效提升模型在该任务上的适应能力。其中ITS-SQL的表现始终高于其他策略,值得注意的是,Qwen2.5-Coder-32B-Instruct在 ITS-SQL策略下取得了高达86.8%的执行正确率。
值得指出的是,在众多其他自然语言相关任务表现优异的DeepSeek-V3却并没有在本任务中取得理想的效果。本文推测这可能跟text-to-SQL任务本身的特点以及DeepSeek-V3的MoE(mixture of experts)架构有关。MoE架构通过集成多个“专家”网络来提高模型的表达能力和处理复杂任务的能力。每个“专家”网络通常是一个小型神经网络,专门处理输入数据的一个子集或特定类型的任务。数据库和自然语言问题通常具有很强的跨域性,同时生成的SQL语言又具有很强的结构性,所以在面对此类任务时,MoE架构可能因专家路由机制未能分配到最合适的子网络,导致其SQL生成能力相较于编程语言模型存在劣势。尽管DeepSeek-V3 的总参数量高达671B,但在“专家”网络分配后,其实际激活参数量仅为37B , 从而影响模型表现。
除此之外,本文也使用了Qwen2.5-Coder-32B-Instruct和GPT-4o来与之前基于上下文学习的前沿方法进行了对比。如表2所示,本文提出的方法取得了显著的改进。
我们进行了不同开源模型及GPT-4o执行ITS-SQL方法时针对不同难度查询的实验效果对比。结果表明,采用ITS-SQL方法显著提高了难度级别查询的执行正确性。具体而言,在CodeLlama的结果中,整体执行正确率提升了12.91个百分点,其中简单查询的提升最为显著,提升了16.54个百分点,而困难难度的查询则提升了14.58个百分点。虽然DeepSeek-Coder在基础模型测试中的表现尚佳,但其整体执行正确率仅提升了2.68个百分点。其中中等难度查询的执行正确率相对有较大幅度提高。
可能由于专注于编程方面且发布版本较早,CodeLlama和DeepSeek-Coder未能在模式增强步骤中准确提取并输出表和列信息,这种不准确性可能导致后续SQL生成过程中的偏差。Qwen2.5-Coder尽管初始执行正确率已经高达51.04%,但仍在中等和困难查询上取得了显著进步,执行正确率分别增加了11.82%和10.41%,最终实现了60.17%的整体执行正确率。Llama3的执行正确率整体提升了14.87个百分点,其中简单难度查询的执行正确率增长了15.36个百分点,困难查询的则增长了22.92个百分点,均显示出明显的改进。Qwen2的总平均提升为8.93个百分点,尤其在处理困难难度查询时,执行正确率显著提升了16.66个百分点。最后,GPT-4o在所有查询难度上都取得了出色表现,整体执行正确率提升了15.18个百分点,最终达到了60.23个百分点的执行正确率。具体改进结果如图5所示。
如表3所示,本文将所提出的方法与其他先前基于上下文学习的方法进行了系统性实验对比。我们基于BIRD的验证集部分开展具体执行正确率的对比分析,为了保证对比的全面性,我们选取了表现较好且具有代表性的Qwen2.5-Coder-32B-Instruct和GPT-4o作为基线模型进行实验对比。实验结果表明,当本文所提出的ITS-SQL方法与GPT-4o结合使用时,在BIRD的验证集上取得了60.23%的执行正确率,显著优于所对比的其他基于上下文学习的方法。
值得注意的是,本文方法不仅在非开源语言模型(如GPT-4o)上表现优异,在性能相对较弱的开源模型中也展现出显著优势,充分体现了其模型无关的特性。特别值得关注的是,本文方法在困难难度SQL查询任务上的改进幅度最为显著,显示出解决复杂问题的强大能力。综合实验结果可以得出,ITS-SQL展现出卓越的稳健性、有效性和适应能力,这种优势在不同基准性能水平的模型上均得到稳定体现,充分验证了方法的泛化性。
为系统验证本文方法的有效性,我们针对各部分设计了对应的消融实验,围绕3个核心模块展开评估:模式增强、伪SQL生成和最终SQL生成。如表4和表5所示,我们选用了Spider和BIRD的验证集,并且在所选择的开源大语言模型上完成消融实验。
需说明的是,表中“上限”指在最终SQL生成阶段采用对应真实值来当作伪SQL提取SQL骨架的理想情况,以此来方便展示ITS-SQL应用的上限,但是我们并没有将真实值直接输入模型,而是仅作用于实验阶段的示例筛选过程,因此不存在数据泄露的问题。
为了更具体地展示ITS-SQL的有效性,本文选取了3个案例以说明SQL结果的改进,如图6所示,这3个示例代表了SQL任务中的常见错误:属性理解错误、选择错误的数据表以及数据表连接条件错误。在案例1中,GPT-4o选择了“School”“FreeMeal Count (Ages 5-17)”“Enrollment (Ages 5-17)”“(Free MealCount (Ages 5-17) / Enrollment (Ages 5-17))”作为最终的SQL输出属性结果,出现了与自然语言问题所要查询的属性不一致的情况。这表明在复杂的上下文中,大型语言模型可能会误解用户的查询问题需要并产生错误的检索。然而通过模式增强,ITS-SQL可以引导模型更准确地对正确查询属性赋予更多的注意,使得问题属性能够更加精准地映射到具体的列名上。
在案例2中,GPT-4o在选择查询目标数据表时发生了错误,真实值显示仅从“bond”表中检索便可以获得所需结果,但是GPT-4o错误地选择了多个表并且进行连接操作,导致了查询语句执行速度变慢并且最终返回了错误的查询结果。这个问题揭示了大语言模型在处理涉及一些特定名词数量计算的自然语言查询时,容易对特定量产生误解,从而可能错误地判断了处理计算所需的数据表操作。相比之下,ITS-SQL利用具有相似自然语义的提示,增强了模型对于数值关系的理解,从而实现了更准确的查询选择。
案例3揭示了大型语言模型在SQL生成中的另一个典型问题:数据表连接条件错误。具体而言,在由GPT-4o生成的SQL查询中,存在对“comments”表和“posts”表的错误关联操作——错误地将“comments.CreationDate”字段与“posts.CreationDate”字段进行关联匹配。此类连接错误可能具有多种表现形式,突显了当前大语言模型在全面理解复杂数据库关系模式方面的显著不足。针对这一问题,ITS-SQL 使用了2阶段优化策略:首先,通过优化“伪 SQL”的框架结构提升问题语义表征的准确性;其次借助自身迭代机制有效纠正此类错误。
为了能在难度较大的BIRD数据集上进行更细致的分析,本文对ITS-SQL方法下的GPT-4o在具体不同数据库上的执行正确率变化进行了统计。如表6所示,ITS-SQL在thrombosis_prediction,student_club, european_football_2数据库上相对提升效果最高,执行正确率分别实现了25.54个百分点、22.78个百分点、17.83个百分点的提升。同时本文将每个数据库中的中等和困难难度的查询所占的百分比表示为“困难比”(用于衡量该数据库整体大致复杂度和难度),值得注意的是,查询数量较多(163)且具有最高的“困难比”(69.94%)的thrombosis_prediction数据库取得了最为显著的相对改进(25.54个百分点)。这表明,对于中等到高难度的SQL查询,ITS-SQL能够提供更为显著的效果改进。
在本研究中,我们提出了ITS-SQL,通过模式增强和2阶段生成方法,使大语言模型在SQL组织、表达以及自我迭代修正能力方面表现出更强的能力。在Spider和BIRD这2个大规模跨领域数据集上的实验结果和分析验证了我们方法的有效性和适用性。未来,我们将进一步探索上下文学习在大语言模型中的应用,以低成本构建更具实用价值的SQL生成策略。

参考文献 引证文献
排序方式:
1
Labrinidis A, Jagadish H V. Challenges and opportunities with big data[J]. Proceedings of the VLDB Endowment, 2012, 5(12): 2032−2033
2
潘青峰, 徐辰. 基于查询编译的SQL执行技术研究进展[J]. 计算机研究与发展, 2024, 61(7): 1754−1770
Pan Qingfeng, Xu Chen. Advances in SQL execution techniques based on query compilation[J]. Journal of Computer Research and Development, 2024, 61(7): 1754−1770 (in Chinese)
3
Agarwal S, Mozafari B, Panda A, et al. BlinkDB: Queries with bounded errors and bounded response times on very large data[C]//Proc of the 8th ACM European Conf on Computer Systems. New York: ACM, 2013: 29−42
4
Deng Naihao, Chen Yulong, Zhang Yue. Recent advances in text-to-SQL: A survey of what we have and what we expect[C]//Proc of the 29th Int Conf on Computational Linguistics. Stroudsburg, PA: ACL, 2022: 2166−2187
5
Katsogiannis-Meimarakis G, Koutrika G. A survey on deep learning approaches for text-to-SQL[J]. The VLDB Journal, 2023, 32(4): 905−936
6
Khot T, Trivedi H, Finlayson M, et al. Decomposed prompting: A modular approach for solving complex tasks[J]. arXiv preprint, arXiv: 2210.02406, 2022
7
Chowdhery A, Narang S, Devlin J, et al. Palm: Scaling language modeling with pathways[J]. Journal of Machine Learning Research, 2023, 24(240): 1−113
8
Yu Tao, Zhang Rui, Yang Kai, et al. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-SQL task[C]// Proc of the 27th Conf on Empirical Methods in Natural Language Processing. Stroudsburg, PA: ACL, 2018: 3911−3921
9
Josh A, Steven A, Sandhini A, et al. GPT-4 technical report[J]. arXiv preprint, arXiv: 2303.08774, 2024
10
Qu Ge, Li Jinyang, Li Bowen, et al. Before generation, align it! A novel and effective strategy for mitigating hallucinations in text-to-SQL generation[J]. arXiv preprint, arXiv: 2405.15307, 2024
11
Parciak M, Vandevoort B, Neven F, et al. Schema matching with large language models: An experimental study[J]. arXiv preprint, arXiv: 2307.07306, 2023
12
Dong Qingxiu, Li Lei, Dai Damai, et al. A survey on in-context learning[C]//Proc of the 29th Conf on Empirical Methods in Natural Language Processing. Stroudsburg, PA : ACL, 2024: 1107−1128
13
Liu Jiachang, Shen Dinghan, Zhang Yizhe, et al. What makes good in-context examples for GPT-3? [J]. arXiv preprint, arXiv: 2101.06804, 2021
14
Wang Liang, Yang Nan, Wei Furu. Learning to retrieve in-context examples for large language models[C]//Proc of the 18th Conf of the European Chapter of the Association for Computational Linguistics. Stroudsburg, PA : ACL, 2024: 1752−1767
15
Nguyen T, Wong E. In-context example selection with influences[J]. arXiv preprint, arXiv: 2302.11042, 2023
16
Radford A, Narasimhan K, Salimans T, et al. Improving language understanding by generative pre-training[EB/OL]. 2018[2025-03-02]. https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf
17
Anil R, Borgeaud S, Alayrac J, et al. Gemini: A family of highly capable multimodal models[J]. arXiv preprint, arXiv: 2312.11805, 2025
18
Touvron H, Lavril T, Izacard G, et al. LLaMA: Open and efficient foundation language models[J]. arXiv preprint, arXiv: 2302.13971, 2023
19
Bi Xiao, Chen Deli, Chen Guanting, et al. DeepSeek LLM: Scaling open-source language models with long termism[J]. arXiv preprint, arXiv: 2401.02954, 2024
20
Radford A, Wu J, Child R, et al. Language models are unsupervised multitask learners[EB/OL]. 2019[2024-04-23]. https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf
21
Pourreza M, Rafiei D. DIN-SQL: Decomposed in-context learning of text-to-SQL with self-correction[C]// Proc of the 37th Int Conf on Neural Information Processing Systems. New York: ACM, 2023: 36339−36348
22
Gao Dawei, Wang Haibin, Li Yaliang, et al. Text-to-SQL empowered by large language models: A benchmark evaluation[J]. Proceedings of the VLDB Endowment, 2024, 17(5): 1132−1145
23
Dong Xuemei, Zhang Chao, Ge Yuhang, et al. C3: Zero-shot text-to-SQL with ChatGPT[J]. arXiv preprint, arXiv: 2307.07306, 2023
24
Wang Bing, Ren Changyu, Yang Jian, et al. MAC-SQL: A multi-agent collaborative framework for text-to-SQL[C]//Proc of the 32nd Int Conf on Computational Linguistics. Stroudsburg, PA : ACL, 2025: 540−557
25
Maamari K, Abubaker F, Jaroslawicz D, et al. The death of schema linking? Text-to-SQL in the age of well-reasoned language models[C]//Proc of the 38th Advances in Neural Information Processing Systems. New York: ACM, 2024: 1−10
26
Hasan A C, Özgür U. E-SQL: Direct schema linking via question enrichment in text-to-SQL[J]. arXiv preprint, arXiv: 2409.16751, 2025
27
Li Haoyang, Zhang Jing, Liu Hanbing, et al. Codes: Towards building open-source language models for text-to-sSQL[J]. Proceedings of the ACM on Management of Data, 2024, 2(3): 1−28
28
Peter F B, Vincent P J D, Peter V D, et al. Class-based n-gram models of natural language[J]. Computational Linguistics, 1992, 18(4): 467−480
29
Li Zehan, Zhang Xin, Zhang Yanzhao, et al. Towards general text embeddings with multi-stage contrastive learning[J]. arXiv preprint, arXiv: 2308.03281, 2023
30
Alomari Z, Halimi O E, Sivaprasad K, et al. Comparative studies of six programming languages[J]. arXiv preprint, arXiv: 1504.00693, 2015
31
Li Jinyang, Hui Binyuan, Qu Ge, et al. Can LLM already serve as a database interface? A big bench for large-scale database grounded text-to-SQLs[C]//Proc of the 37th Int Conf on Neural Information Processing Systems. New York: ACM, 2024: 42330−42357
2026年第63卷第5期
84
42
0
引用本文
BibTeX
文章信息
doi: 10.7544/issn1000-1239.202550355
  • 接收时间:2025-05-26
  • 首发时间:2026-11-17
  • 出版时间:2026-05-01
补充材料
相关文章
文章信息
作者
出版历史
  • 收稿日期:2025-05-26
  • 修回日期:2025-12-08
  • 录用日期:2026-01-07
基金
作者信息
    1山东大学软件学院 济南 250101
    2中国移动通信集团山东有限公司中移齐鲁创新院分公司 济南 250102
    3中国人民解放军军事科学院 北京 100080

通讯作者:

参考文献
分享链接
https://castjournals.cast.org.cn/joweb/jsjyjyfz/CN/10.7544/issn1000-1239.202550355
分享至
全文二维码

扫描看全文

引用本文
BibTeX
本文的引用情况
2种不同金属材料的力学参数
科
Family
属数
Number of
genus
种数
Number of
species
占总种数比例
Percentage of
total species (%)
属
Genus
种数
Number of
species
占总种数比例
Percentage of total
species (%)
鹅膏菌科Amanitaceae 2 11 5.26 鹅膏菌属 Amanita 10 4.78
小菇科 Mycenaceae 2 12 5.74 丝盖伞属 Inocybe 5 2.39
多孔菌科 Polyporaceae 8 14 6.70 蜡蘑属 Laccaria 5 2.39
红菇科 Russulaceae 3 23 11.00 小皮伞属 Marasmius 6 2.87
小菇属 Mycena 11 5.26
光柄菇属 Pluteus 5 2.39
红菇属 Russula 17 8.13
栓菌属 Trametes 5 2.39
关闭全屏