{"id":9478,"date":"2025-11-11T16:33:16","date_gmt":"2025-11-11T08:33:16","guid":{"rendered":"\/?p=9478"},"modified":"2025-11-11T16:33:16","modified_gmt":"2025-11-11T08:33:16","slug":"text2sql-nl2sql%ef%bc%88%e4%ba%8c%ef%bc%89%e5%ae%9e%e7%8e%b0%ef%bc%9a%e7%ab%99%e5%9c%a8-llm-%e8%82%a9%e8%86%80%e4%b8%8a","status":"publish","type":"post","link":"\/?p=9478","title":{"rendered":"Text2SQL \/ NL2SQL\uff08\u4e8c\uff09\u5b9e\u73b0\uff1a\u7ad9\u5728 LLM \u80a9\u8180\u4e0a"},"content":{"rendered":"<p>\u8bdd\u5206\u4e24\u5934\uff0c\u524d\u6587\u5199\u4e86 Text2SQL \u7684\u6838\u5fc3\u5e94\u7528\u65b9\u5f0f\u548c\u4e1a\u5185\u516c\u8ba4\u7684\u6570\u636e\u96c6:<\/p>\n<p><a href=\"https:\/\/mp.weixin.qq.com\/s?__biz=MzU4NjY4MzA4Ng==&amp;mid=2247483790&amp;idx=1&amp;sn=a6260de4910a9495531552c7c22e20e1&amp;scene=21#wechat_redirect\">Text2SQL \/ NL2SQL\uff08\u4e00\uff09\u6570\u636e\u96c6\uff1a\u81ea\u7136\u8bed\u8a00\u4e0e\u6570\u636e\u5e93\u7684\u201c\u7ffb\u8bd1\u6865\u6881\u201d<\/a><\/p>\n<p>\u63a5\u4e0b\u6765\u5206\u4eab\u5728\u6570\u636e\u96c6\u4e0a\u8fdb\u884c\u63a2\u7d22\u7684\u5b9e\u73b0\u65b9\u6cd5\u4ecb\u7ecd\uff0c\u7b14\u8005\u624d\u758f\uff0c\u4ed3\u4fc3\u6210\u6587\uff0c\u6709\u9519\u6f0f\u656c\u8bf7\u8bfb\u8005\u7559\u8a00\u6307\u51fa\uff0c\u5341\u5206\u611f\u6fc0\uff01<\/p>\n<p><strong>\ud83c\udfaf\u5b9e\u73b0\u65b9\u6cd5\u53d1\u5c55\u7b80\u4ecb<\/strong><\/p>\n<p>\u8ddf AI \u53d1\u5c55\u7c7b\u4f3c\uff0cText-to-SQL \u7684\u7814\u7a76\u7531\u6765\u5df2\u4e45\uff0c\u53ef\u4ee5\u8ffd\u6eaf\u5230\u4e0a\u4e16\u7eaa60\u5e74\u4ee3\uff0c\u7ecf\u5386\u8fc7\u8d77\u8d77\u4f0f\u4f0f\uff0c\u672c\u6587\u8df3\u8fc7\u201c\u53e4\u8001\u201d\u7684\u5386\u53f2\uff0c\u76f4\u63a5\u4ece\u6700\u8fd1\u7684\u70ed\u70b9\u65b9\u6cd5\u8bb2\u8d77\uff0c\u4e0b\u9762\u662f\u4e00\u4e2a\u53d1\u5c55\u7b80\u56fe\uff1a<\/p>\n<p><strong><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251111163212442.png\" alt=\"\u56fe\u7247\" \/><\/strong><\/p>\n<p>2015 \u5e74\u4ee5\u6765\u8be5\u8bdd\u9898\u7814\u7a76\u518d\u5ea6\u70ed\u95e8\u8d77\u6765\uff0c\u6700\u521d\u662f\u7b80\u5355\u7684\u89e3\u6790\u6811\u548c\u57fa\u4e8e\u89c4\u5219\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u5feb\u8fdb\u5230 2019 \u5e74\uff0c\u7ee7\u957f\u77ed\u65f6\u8bb0\u5fc6\u7f51\u7edc\uff08LSTMs\uff09\u540e\uff0cTransformer \u5927\u53d7\u6b22\u8fce\uff0cEncoder-decoder-based \u7684\u65b9\u6cd5\u5982 SQL sketch \u4e5f\u5907\u53d7\u5173\u6ce8\u3002<\/p>\n<p>2021 \u5e74\uff0c\u5728 Text-to-SQL \u8bed\u6599\u5e93\u4e0a\u5bf9 BERT\u3001RoBERTa \u8fd9\u7c7b\u73b0\u6210\u7684\u9884\u8bad\u7ec3\u8bed\u8a00\u6a21\u578b\u8fdb\u884c<strong>\u5fae\u8c03<\/strong>\u53d8\u5f97\u6d41\u884c\u3002<\/p>\n<p>\u968f\u7740\u50cf ChatGPT\uff08\u95ed\u6e90\uff09\u548c Llama 2\/3\uff08\u5f00\u6e90\uff09\u3001DeepSeek\uff08\u5f00\u6e90\uff09\u3001Claude\uff08\u95ed\u6e90\uff09\u7b49\u5927\u8bed\u8a00\u6a21\u578b\uff08LLMs\uff09\u7684\u5174\u8d77\uff0c\u57fa\u4e8e LLM \u5728 Text-to-SQL \u8bed\u6599\u5e93\u7684\u5e94\u7528\u51e0\u4e4e\u6210\u4e86\u89e3\u51b3\u8be5\u95ee\u9898\u7684\u5b9e\u9645\u6807\u51c6\uff0c\u65b9\u6cd5\u6709<strong>\u5fae\u8c03\u3001RAG\u3001Agent ...<\/strong><\/p>\n<p><strong>\ud83c\udfaf\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u770b\u770b\u4e1a\u5185\u6700\u65b0\u6210\u679c<\/strong><\/p>\n<p>\u6839\u636e Spider 2 \u7684\u699c\u5355\uff0c\u94fe\u63a5\uff1a<a href=\"https:\/\/spider2-sql.github.io\/\">https:\/\/spider2-sql.github.io\/<\/a><\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251111163212551.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<p><strong>\u699c\u5355\u524d\u5341\uff0c\u5747\u662f\u5728\u5927\u6a21\u578b\u7684\u57fa\u7840\u4e0a\u505a\u7684\u5de5\u4f5c<\/strong>\u3002<\/p>\n<p>\u67092\u4e2a\u4e2d\u56fd\u5927\u6a21\u578b\u8fdb\u5165\u4e86\u699c\u5355\uff1aDeepSeek-V3 \u548c Qwen2.5-Coder-32B-Instruct<\/p>\n<p>\u987a\u9053\u4e00\u63d0\uff0c\u4ece 2025.1 \u7684\u6700\u65b0\u7ed3\u679c\u6765\u770b\uff0c<strong>\u6700\u597d\u5206\u503c\u4e5f\u53ea\u670931.26<\/strong>\uff0c\u4e00\u65b9\u9762\u8bf4\u660e Spider 2 \u6570\u636e\u96c6\u96be\u5ea6\u548c\u9886\u5148\u6027\uff0c\u800c\u4e14\u5e76\u6ca1\u6709\u88ab LLM \u62df\u5408\uff0c\u53e6\u4e00\u65b9\u9762\u4e5f\u8bf4\u660e AI \u5728 Spider 2 \u4efb\u52a1\u4e0a\u4ecd\u9762\u4e34\u7740\u5f88\u591a\u6311\u6218\u3002<\/p>\n<blockquote>\n<p>Notably, even the advanced LLMs-o1-preview solve only 17.1% of Spider 2.0 tasks. For widely-used models like GPT-4o, the success rate is only 10.1% on Spider 2.0 tasks, compared to 86.6% on Spider 1.0, underscoring the substantial challenges posed by Spider 2.0.<\/p>\n<p><a href=\"https:\/\/spider2-sql.github.io\/\">https:\/\/spider2-sql.github.io\/<\/a><\/p>\n<\/blockquote>\n<p><strong>\ud83c\udfaf\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u770b\u770b\u699c\u5355 TOP1\uff1aReFoRCE + o1-preview<\/strong><\/p>\n<p>\u4e0b\u9762\u5206\u4eab\u4e0b Spider 2 \u6392\u884c\u7b2c\u4e00\u7684 ReFoRCE + o1-preview\uff0c\u6587\u7ae0\u94fe\u63a5\uff1a<a href=\"https:\/\/arxiv.org\/abs\/2502.00675\">https:\/\/arxiv.org\/abs\/2502.00675<\/a><\/p>\n<p>ReFoRCE\uff0c\u5373\u4e3a Self-<strong>Re<\/strong>finement Agent with <strong>Fo<\/strong>rmat <strong>R<\/strong>estriction and <strong>C<\/strong>olumn <strong>E<\/strong>xploration (ReFoRCE) workflow.<\/p>\n<p>\u4f7f\u7528 chatGPT o1-preview \u5927\u6a21\u578b<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251111163212918.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<ol>\n<li>\n<p><strong>ReFoRCE \u521b\u65b0\u70b9\u5982\u4e0b\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p>\u8868\u4fe1\u606f\u538b\u7f29\uff1a<\/p>\n<p>\u9488\u5bf9\u5927\u6570\u636e\u5e93\u957f\u4e0a\u4e0b\u6587\u95ee\u9898\uff0c\u91c7\u7528\u57fa\u4e8e\u6a21\u5f0f\u5339\u914d\u7684\u65b9\u6cd5\uff0c\u5408\u5e76\u76f8\u4f3c\u524d\u7f00\u6216\u540e\u7f00\u7684\u8868\uff0c\u4e3a\u6a21\u578b\u51cf\u8d1f\u3002<strong>\u51cf\u5c11 token \u6570\uff0c\u7701\u6210\u672c\uff0c\u540c\u65f6\u964d\u4f4e LLM \u5e7b\u89c9<\/strong>\u3002<\/p>\n<\/li>\n<li>\n<p>\u9884\u671f\u7b54\u6848\u683c\u5f0f\u9650\u5236\uff1a<\/p>\n<p>\u5728\u4efb\u52a1\u5f00\u59cb\u65f6\u751f\u6210\u9884\u671f\u7b54\u6848\u683c\u5f0f\uff0c\u5e76\u5728\u81ea\u6211\u4f18\u5316\u8fc7\u7a0b\u4e2d\u5f3a\u5316\uff0c\u8981\u6c42\u6a21\u578b\u4e25\u683c\u9075\u5faa CSV \u683c\u5f0f\u8f93\u51fa\uff0c\u660e\u786e\u5404\u5217\u5c5e\u6027\uff0c\u786e\u4fdd\u7b54\u6848\u6e05\u6670\u51c6\u786e\u3002<\/p>\n<\/li>\n<li>\n<p>\u6f5c\u5728\u6709\u7528\u5217\u63a2\u7d22\uff1a<\/p>\n<p>\u8bbe\u8ba1\u7cfb\u7edf\u65b9\u6cd5\uff0c\u4ece\u7b80\u5355\u5230\u590d\u6742\u751f\u6210 SQL \u67e5\u8be2\uff0c\u9010\u6b65\u7406\u89e3\u6570\u636e\u5e93\u7ed3\u6784\u3002\u4f7f\u7528\u989d\u5916\u7684 LLM \u804a\u5929\u4f1a\u8bdd\u786e\u5b9a\u76f8\u5173\u8868\u548c\u5217\uff0c\u6267\u884c\u67e5\u8be2\u83b7\u53d6\u7ed3\u679c\uff0c\u5e76\u901a\u8fc7\u7b97\u6cd5\u52a8\u6001\u7ea0\u9519\u3002<\/p>\n<\/li>\n<li>\n<p>\u81ea\u6211\u4f18\u5316\u5de5\u4f5c\u6d41\u7a0b\uff1a<\/p>\n<p>\u8f93\u5165\u5904\u7406\u540e\u7684\u4fe1\u606f\u5230\u6a21\u578b\u8fdb\u884c\u81ea\u6211\u4f18\u5316\uff0c\u901a\u8fc7<strong>\u6267\u884c\u53cd\u9988\u4fee\u6b63\u9519\u8bef<\/strong>\uff0c\u8fbe\u5230\u81ea\u6d3d\u6027\u6216\u6ee1\u8db3\u7ec8\u6b62\u6761\u4ef6\u65f6\u8f93\u51fa\u6700\u7ec8\u7ed3\u679c\u3002\u5bf9\u590d\u6742\u67e5\u8be2\uff0c\u5229\u7528 CTE \u8fdb\u884c\u5206\u6b65\u7ec6\u5316\u3002<\/p>\n<\/li>\n<li>\n<p>\u5e76\u884c\u5316\uff1a<\/p>\n<p>\u542f\u52a8<strong>\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u6267\u884c\u6574\u4e2a\u5de5\u4f5c\u6d41\u7a0b\uff0c\u901a\u8fc7\u6295\u7968\u673a\u5236<\/strong>\u786e\u5b9a\u6700\u53ef\u80fd\u6b63\u786e\u7684\u7ed3\u679c\uff0c\u63d0\u9ad8\u7ed3\u679c\u7684\u53ef\u4fe1\u5ea6\u548c\u51c6\u786e\u6027\uff0c\u8fd8\u652f\u6301\u4e0d\u540c\u793a\u4f8b\u7684\u5e76\u884c\u5904\u7406\uff0c\u52a0\u901f\u6574\u4f53\u8fc7\u7a0b\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8be5\u65b9\u6848\u6709\u5982\u4e0b\u4f18\u70b9\uff1a<\/p>\n<ul>\n<li>\n<p>\u590d\u6742\u6570\u636e\u96c6\u8868\u73b0\u597d\uff1a<\/p>\n<p>\u5728 Spider 2.0-Snow \u548c Spider 2.0-Lite \u6570\u636e\u96c6\u4e0a\uff0cReFoRCE \u7684\u6267\u884c\u51c6\u786e\u7387\u5206\u522b\u8fbe\u5230 31.26 \u548c 30.35\uff0c\u663e\u8457\u8d85\u8d8a\u5176\u4ed6\u65b9\u6cd5\uff0c\u5982 Spider-Agent \u5728\u76f8\u540c\u6570\u636e\u96c6\u4e0a\u5f97\u5206\u4ec5\u7ea6 23\u3002<\/p>\n<\/li>\n<li>\n<p>\u591a\u6570\u636e\u5e93\u9002\u5e94\u6027\u5f3a\uff1a<\/p>\n<p>\u80fd\u652f\u6301\u591a\u79cd SQL dialect\uff0c\u5728\u8de8\u6570\u636e\u5e93\u4efb\u52a1 Spider 2.0-Lite \u4e2d\u8868\u73b0\u51fa\u826f\u597d\u7684\u9002\u5e94\u6027\uff0c\u5c3d\u7ba1\u63d0\u793a\u4e3b\u8981\u9488\u5bf9 Snowflake dialect\uff0c\u4f46\u4ecd\u80fd\u6709\u6548\u5904\u7406\u5176\u4ed6\u65b9\u8a00\u7684\u60c5\u51b5\u3002<\/p>\n<\/li>\n<li>\n<p>\u590d\u6742\u60c5\u51b5\u5904\u7406\u80fd\u529b\u4f18\uff1a<\/p>\n<p>\u6709\u6548\u5904\u7406\u5d4c\u5957\u5217\u548c\u590d\u6742\u6570\u636e\u7c7b\u578b\uff0c\u5728\u5904\u7406\u590d\u6742\u6570\u636e\u5e93\u7ed3\u6784\u548c\u67e5\u8be2\u8981\u6c42\u65f6\u66f4\u5177\u4f18\u52bf\uff0c\u89e3\u51b3\u4e86\u73b0\u6709\u65b9\u6cd5\u5728\u8fd9\u4e9b\u65b9\u9762\u7684\u4e0d\u8db3\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\ud83c\udfaf\u603b\u7ed3\u4e00\u4e0b\uff1a\u5927\u6a21\u578b\u65f6\u4ee3 Text-to-SQL \u7279\u70b9<\/strong><\/p>\n<p>\u968f\u7740\u57fa\u4e8e LLM \u6280\u672f\u7684\u53d1\u5c55\uff0cRAG \/ Agent \u7b49\u65b9\u6cd5\u4e5f\u5e7f\u6cdb\u5e94\u7528\u4e8e Text-to-SQL \u9886\u57df\uff0c\u5927\u6a21\u578b\u65f6\u4ee3\u53d1\u5c55\u51fa\u5982\u4e0b\u7279\u70b9\uff1a<\/p>\n<ul>\n<li><strong>\u5e73\u53f0\u5316<\/strong><\/li>\n<\/ul>\n<p>\u63d0\u9ad8\u517c\u5bb9\u6027\uff0c\u4fbf\u4e8e\u63a5\u5165\u5176\u4ed6\u4ea7\u54c1\uff0c\u751f\u4ea7\u73af\u5883\u4e0b\uff0c\u4e0d\u540c\u4ea7\u54c1 schema \u5b9a\u4e49\u4e0d\u4e00\u6837\uff0c\u751a\u81f3\u7528\u7684\u6570\u636e\u5e93\u90fd\u4e0d\u4e00\u6837\uff0c\u6bd4\u5982\uff1amysql \/ postgressql \/ nosql ...\uff0c\u5c31\u8981\u6c42\u5177\u6709\u5e73\u53f0\u7684\u517c\u5bb9\u7279\u70b9\u3002\u57cb\u4e2a\u4f0f\u7b14\uff0c\u5b9e\u9645\u4ea7\u4e1a\u754c\u4f1a\u5f15\u5165\u4e13\u95e8\u7684\u6570\u636e\u4ea7\u54c1\uff0c<strong>\u6570\u636e\u4ea7\u54c1<\/strong>\u8d1f\u8d23\u63a5\u5165\u4e0d\u540c\u6e90\u7684\u5b9e\u9645\u6570\u636e\u8868\uff0c\u91c7\u7528 <strong>Text-to-GraphQL \/ NL-to-GraphQL<\/strong> \u6765\u8c03\u7528\u6570\u636e\u6e56\u7684\u6570\u636e\uff0c\u6709\u5174\u8da3\u53ef\u4ee5\u7559\u8a00\u8bc4\u8bba\u533a\uff0c\u5b89\u6392\u4e00\u671f\u4e13\u95e8\u5185\u5bb9\u3002<\/p>\n<ul>\n<li>\n<p><strong>\u63d2\u4ef6\u5316<\/strong><\/p>\n<\/li>\n<li>\n<p>\u63d0\u9ad8\u6269\u5c55\u6027\uff0c\u4fbf\u4e8e\u529f\u80fd\u6269\u5c55\uff0c\u5982\uff1a<\/p>\n<\/li>\n<li>\n<p>\u63d0\u4f9b<strong>\u8bb0\u5fc6\u529f\u80fd<\/strong>\uff0c\u7f13\u5b58\u7528\u6237\u95ee\u9898\uff0c\u63d0\u9ad8\u54cd\u5e94\u901f\u5ea6\u548c\u4f18\u5316\u7cbe\u5ea6\uff1b<\/p>\n<\/li>\n<li>\n<p>\u63d0\u4f9b <strong>tools \u8c03\u7528\u529f\u80fd<\/strong>\uff0c\u7528\u4e8e\u8fd4\u56de\u6570\u636e\u7684\u540e\u5904\u7406\uff08LLM\u7684\u6570\u636e\u8ba1\u7b97\u80fd\u529b\uff0c\u4e00\u76f4\u662f\u9650\u5236\u4ea7\u4e1a\u8bd5\u7528\u7684\u77ed\u677f\uff09\uff1b<\/p>\n<\/li>\n<li>\n<p>\u63d0\u4f9b<strong>\u7ed3\u679c\u6e32\u67d3<\/strong>\u529f\u80fd\uff0c\u751f\u6210\u8868\u683c\uff0c\u56fe\u7247\uff0c\u62a5\u544a<\/p>\n<\/li>\n<li>\n<p><strong>\u81ea\u6211\u8fdb\u5316<\/strong><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u8bc4\u6d4b -&gt; \u53cd\u9988 -&gt; \u4f18\u5316<\/strong>\uff0c\u5f62\u6210\u95ed\u73af\uff0c\u4e0d\u65ad\u81ea\u52a8\u63d0\u9ad8\u51c6\u786e\u6027<\/p>\n<ul>\n<li><strong>\u6210\u672c\u63a7\u5236<\/strong><\/li>\n<\/ul>\n<p>\u5927\u6a21\u578b\u8c03\u7528\u6309\u7167 token \u6570\u91cf\u7b97\u94b1\uff0c\u672c\u5730\u90e8\u7f72\u4e5f\u9700\u8981\u5360\u7528\u7b97\u529b\u8d44\u6e90\uff0c\u56e0\u6b64\u5982\u4f55\u4f18\u5316 prompt template\uff0c\u964d\u4f4e\u6210\u672c\uff0c\u4e5f\u662f\u5fc5\u987b\u8003\u8651\u7684\u56e0\u7d20<\/p>\n<blockquote>\n<p><a href=\"https:\/\/spider2-sql.github.io\/\">https:\/\/spider2-sql.github.io\/<\/a><\/p>\n<p><a href=\"https:\/\/arxiv.org\/abs\/2502.00675\">https:\/\/arxiv.org\/abs\/2502.00675<\/a><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u8bdd\u5206\u4e24\u5934\uff0c\u524d\u6587\u5199\u4e86 Text2SQL \u7684\u6838\u5fc3\u5e94\u7528\u65b9\u5f0f\u548c\u4e1a\u5185\u516c\u8ba4\u7684\u6570\u636e\u96c6: Text2SQL \/ NL2SQL\uff08\u4e00\uff09\u6570\u636e\u96c6\uff1a\u81ea\u7136\u8bed\u8a00\u4e0e\u6570\u636e   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[288],"tags":[],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9478"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9478"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9478\/revisions"}],"predecessor-version":[{"id":9479,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9478\/revisions\/9479"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9478"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}