{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/act-sql-in-context-learning-for-text-to-sql","title":"ACT-SQL: In-Context Learning for Text-to-SQL with Automatically-Generated Chain-of-Thought","arxiv_id":"2310.17342","date":"2023-10-26","proceeding":null,"authors":["Hanchong Zhang","Ruisheng Cao","Lu Chen","Hongshen Xu","Kai Yu"],"abstract":"Recently Large Language Models (LLMs) have been proven to have strong abilities in various domains and tasks. We study the problem of prompt designing in the text-to-SQL task and attempt to improve the LLMs' reasoning ability when generating SQL queries. Besides the trivial few-shot in-context learning setting, we design our chain-of-thought (CoT) prompt with a similar method to schema linking. We provide a method named ACT-SQL to automatically generate auto-CoT exemplars and thus the whole process doesn't need manual labeling. Our approach is cost-saving since we only use the LLMs' API call once when generating one SQL query. Furthermore, we extend our in-context learning method to the multi-turn text-to-SQL task. The experiment results show that the LLMs' performance can benefit from our ACT-SQL approach. Our approach achieves SOTA performance on the Spider dev set among existing in-context learning approaches.","url_abs":"https://arxiv.org/abs/2310.17342v1","url_pdf":"https://arxiv.org/pdf/2310.17342v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"act-sql-in-context-learning-for-text-to-sql","repo_url":"https://github.com/x-lance/text2sql-gpt","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}}],"tasks":[{"task_slug":"in-context-learning","task_name":"In-Context Learning"},{"task_slug":"text-to-sql","task_name":"Text to SQL"},{"task_slug":"text-to-sql","task_name":"Text-To-SQL"}],"methods":[{"method_slug":"set","method_name":"SET"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2310.17342","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2310.17342"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/x-lance/text2sql-gpt","reach":{"status":"ok"}}],"summary":{"ran_violates":3,"ran":7,"unverified":2},"by_repo_kind":{"official":{"samples":12,"ran":10,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":12,"samples":[{"code_sha256_prefix":"8231e3fdffa9c8ee","entry":"condition_has_like","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/evaluation.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/evaluation.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8231e3fdffa9c8ee"}},{"code_sha256_prefix":"f2d76234528d3b57","entry":"condition_has_or","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/evaluation.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/evaluation.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f2d76234528d3b57"}},{"code_sha256_prefix":"954c76e256cc7220","entry":"condition_has_sql","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/evaluation.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/evaluation.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"954c76e256cc7220"}},{"code_sha256_prefix":"0992d2a47ae733fa","entry":"get_schema","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/process_sql.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/process_sql.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0992d2a47ae733fa"}},{"code_sha256_prefix":"c4dcaf29b663a364","entry":"get_schema_from_json","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/process_sql.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/process_sql.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c4dcaf29b663a364"}},{"code_sha256_prefix":"2178b95c919ae420","entry":"join_tokens","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/parse.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/parse.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2178b95c919ae420"}},{"code_sha256_prefix":"f23d6ff3772963bc","entry":"permute_tuple","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/exec_eval.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/exec_eval.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f23d6ff3772963bc"}},{"code_sha256_prefix":"58e472cff9780d63","entry":"postprocess","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/parse.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/parse.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"58e472cff9780d63"}},{"code_sha256_prefix":"a40510ba6a37f798","entry":"quick_rej","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/exec_eval.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/exec_eval.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a40510ba6a37f798"}},{"code_sha256_prefix":"afc8ef89576ef2aa","entry":"unorder_row","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/exec_eval.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/exec_eval.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"afc8ef89576ef2aa"}},{"code_sha256_prefix":"83512c75d8835ed6","entry":"get_response","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"util/gpt.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/util/gpt.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"83512c75d8835ed6"}},{"code_sha256_prefix":"a906f5de1f5971b0","entry":"tokenize","repo":"x-lance/text2sql-gpt","repo_kind":"official","path":"eval/process_sql.py","file_url":"https://github.com/x-lance/text2sql-gpt/blob/HEAD/eval/process_sql.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a906f5de1f5971b0"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}