Computer Science ›› 2026, Vol. 53 ›› Issue (6A): 250900107-7.doi: 10.11896/jsjkx.250900107

• Artificial Intelligence • Previous Articles     Next Articles

Study on Text-to-SQL Approach Integrating Chain-of-Thought Reasoning with Retrieval Augmentation

XU Yafei1, LIU Chuanyou2, LIU Shaohua1   

  1. 1 Naval University of Engineering,Wuhan 430000,China
    2 Guangzhou Cash Concentration and Payment Management Center,Guangzhou 510000,China
  • Online:2026-06-16 Published:2026-06-12
  • About author:XU Yafei,born in 1990,postgraduate.His main research interests include financial informatization and artificial intelligence.

Abstract: Text-to-SQL technology enables the automatic conversion of natural language into SQL,significantly lowering the barrier for non-experts to interact with databases.However,in vertical domains such as finance,it still faces two major challenges:complex query intents and ambiguous expressions.To address these,this paper proposes a collaborative framework that integrates Chain-of-Thought reasoning with retrieval augmentation.Firstly,it designs an iterative distillation algorithm that leverages a compact 3-billion-parameter model to automatically generate and verify over 20 000 high-quality Chain-of-Thought seed examples with detailed reasoning steps on the Spider,BIRD,and BookSQL datasets,effectively compensating for the limitations of small models in complex reasoning tasks.Secondly,it introduces an innovative dual-vector retrieval mechanism based on “question ske-letons” and “SQL skeletons” to eliminate interference from table and column names,dynamically incorporating historically similar queries and implicit semantics as examples within prompts,thereby achieving precise alignment of ambiguous domain-specific expressions.Experimental results demonstrate that Qwen2.5-Coder,with only 3 billion parameters,attains 86.5% execution accuracy on Spider-dev—comparable to powerful models such as GPT-4,achieves 59.6% on the more challenging BIRD-dev,outperforming many larger models,and reaches 81.2% on a proprietary financial dataset,exceeding existing methods by over 1 percentage point.This approach delivers high-precision SQL generation for complex and ambiguous natural language queries at low cost and with a relatively small model size.

Key words: Financial information systems, Artificial intelligence, Natural language processing, Text-to-SQL, Large-scale language models

CLC Number: 

  • TP391
[1] LIU X Y,SHEN S Y,LI B Y,et al.A Survey of NL2SQL with Large Language Models:Where are we,and where are we going?[J].arXiv:2408.05109,2024.
[2] GEORGE K,GEORGIA K.A survey on deep learning approaches for text-to-SQL[J].The VLDB Journal,2023,32(4):905-936.
[3] JOSH A,ADLER S,AGARWAL S,et al.Gpt-4 technical report [J].arXiv:2303.08774,2023.
[4] HUGO T,LAVRIL T,LZACARD G,et al.Llama:Open and efficient foundation language models [J].arXiv:2302.13971,2023.
[5] GAN,Y J,CHEN X Y,XIE J X,et al.Natural SQL:Making SQL easier to infer from natural language specifications [C]//Findings of the Association for Computational Linguistics.2021:2030-2042.
[6] TORSTEN S,NATHAN S,DZMITRY B.PICARD:Parsing incrementally for constrained auto-regressive decoding from language models [C]//Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing.2021:0895-9901.
[7] ILYA S,ORIOL V,QUOC V L.Sequence to sequence learning with neural networks [C]//Advances in Neural Information Processing.2014:1-9.
[8] DONG Q X,LI L,DAI D M,et al.A survey on in-context lear-ning[C]//Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing.2024:1107-1128.
[9] WANG B,REN C Y,YANG J,et al.Mac-sql:A multi-agent collaborative framework for text-to-sql [C]//Proceedings of the 31st International Conference on Computational Linguistics.2025:540-557.
[10] POURREZA M,DAVOOD R.Din-sql:Decomposed in-contextlearning of text-to-sql with self-correction [C]//Advances in Neural Information Processing Systems.2023:36339-36348.
[11] JACOB D,CHANG M W,LEE K,et al.Bert:Pre-training of deep bidirectional transformers for language understanding [C]//Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics:Human Language Technologies.2019:4171-4186.
[12] TAO Y,ZHANG R,YANG K,et al.Spider:A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task [C]//2018 Conference on Empirical Methods in Natural Language Processing.EMNLP,2018:3911-3921.
[13] WANG B,SHIN R,LIU X D,et al.Rat-sql:Relation-awareschema encoding and linking for text-to-sql parsers [C]//Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics.2020:7567-7578.
[14] FRANCO S,GORI M,TSOI A C,et al.The graph neural network model [J].IEEE Transactions on Neural Networks,2008,20(1):61-80.
[15] LI H Y,ZHANG J,LIU H B,et al.Codes:Towards buildingopen-source language models for text-to-sql [C]//Proceedings of the ACM on Management of Data.2024:1-28.
[16] LI R,LOUBNA B A,ZI Y T,et al.Starcoder:may the source be with you![J].arXiv:2305.06161,2023.
[17] GAO D W,WANG H B,LI Y L,et al.Text-to-sql empowered by large language models:A benchmark evaluation [C]//Proceedings of the VLDB Endowment.2024:1132-1145.
[18] DONG X M,ZHANG C,GE Y H,et al.C3:Zero-shot text-to-sql with chatgpt[J].arXiv:2307.07306,2023.
[19] CUI Y M,CHE W X,LIU T,et al.Pre-training with wholeword masking for chinesebert[J].IEEE/ACM Transactions on Audio,Speech,and Language Processing,2021(29):3504-3514.
[20] GAN Y J,CHEN X Y,HUANG Q P,et al.Towards robustness of text-to-SQL models against synonym substitution[J].arXiv:2106.01065,2021.
[21] DENG X,AHMED H A,CHRISTOPHER M,et al,Structure-grounded pretraining for text-to-sql[J].arXiv:2010.12773,2020.
[22] GAO D W,WANG H B,LI Y L,et al.Text-to-sql empowered by large language models:A benchmark evaluation[J].arXiv:2308.15363,2023.
[23] WEI J,WANG X Z,DALE S,et al.Chain-of-thought prompting elicits reasoning in large language models[C]//Advances in Neural Information Processing Systems.2022:24824-24837.
[24] KUMAR R,AMAR R D,SHRUTENDRA H,et al.Booksql:A large scale text-to-sql dataset for accounting domain[J].arXiv:2406.07860,2024.
[25] LI H Y,WU S,ZHANG X K,et al.Omnisql:Synthesizing high-quality text-to-sql data at scale[J].arXiv:2503.02240,2025.
[26] POURREZA M,DAVOOD R.Dts-sql:Decomposed text-to-sql with small large language models[J].arXiv:2402.01117,2024.
[27] YANG J X,HUI B Y,YANG M,et al.Synthesizing text-to-SQL data from weak and strong LLMs[C]//Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics.2024:7864-7875.
[1] MENG Lin. Software System Architecture of New Intelligent Hardware [J]. Computer Science, 2026, 53(6A): 250600017-12.
[2] LI Xiao, LI Xinyi. Criminal Law Adaptation for Digital Civilization:Paths Regulation and System Construction of Artificial Intelligence Crime [J]. Computer Science, 2026, 53(6A): 251000061-9.
[3] PAN Weiying, LI Yutong, MA Miao. Intelligent Analysis and Understanding Research Progress on Teachers’ Classroom Behavior [J]. Computer Science, 2026, 53(5): 41-49.
[4] SHEN Ao, ZHOU Qingkai, XIA Tian, GAO Ruiling. Span-based Aspect Sentiment Triplet Extraction Based on Multi-view Graph Neural Networks [J]. Computer Science, 2026, 53(5): 319-327.
[5] XU Shenjian. Cross-model Collaborative Unsupervised Representation Method for Legal Texts [J]. Computer Science, 2026, 53(4): 356-365.
[6] WU Qiaorui, LUO Li, ZHAO Cairong. LLM-augmented Training Framework with Cycle-Consistency Constraints [J]. Computer Science, 2026, 53(4): 377-383.
[7] CHEN Han, XU Zefeng, JIANG Jiu, FAN Fan, ZHANG Junjian, HE Chu, WANG Wenwei. Large Language Model and Deep Network Based Cognitive Assessment Automatic Diagnosis [J]. Computer Science, 2026, 53(3): 41-51.
[8] QIAN Qing, CHEN Huicheng, CUI Yunhe, TANG Ruixue, FU Jinmei. Joint Entity and Relation Extraction Method with Multi-scale Collaborative Aggregation and Axial-semantic Guidance [J]. Computer Science, 2026, 53(3): 97-106.
[9] WU Xianjie, LI Tongliang, LI Zhoujun. Survey of Table Question Answering Research [J]. Computer Science, 2026, 53(3): 295-306.
[10] SUN Mingxu, LIANG Gang, WU Yifei, HU Haixin. Chinese Hate Speech Detection Incorporating Hate Object Features and Variant Word Restoration Mechanism [J]. Computer Science, 2026, 53(2): 289-299.
[11] GUO Luxiang, WANG Yueyu, LI Qianyue, LI Shasha, LIU Xiaodong, JI Bin, YU Jie. Comprehensive Survey of LLM-based Agent Operating Systems [J]. Computer Science, 2026, 53(1): 1-11.
[12] WEN Zerui, JIANG Tian, HUANG Zijian, CUI Xiaohui. Section Sparse Attack:A More Powerful Sparse Attack Method [J]. Computer Science, 2026, 53(1): 323-330.
[13] LYU Zhenghao, XIAN Hequn. Deep Learning Model Protection Method Based on Robust Partitioned Watermarking [J]. Computer Science, 2026, 53(1): 423-429.
[14] CHENG Zhangtao, HUANG Haoran, XUE He, LIU Leyuan, ZHONG Ting, ZHOU Fan. Event Causality Identification Model Based on Prompt Learning and Hypergraph [J]. Computer Science, 2025, 52(9): 303-312.
[15] LIU Le, XIAO Rong, YANG Xiao. Application of Decoupled Knowledge Distillation Method in Document-level RelationExtraction [J]. Computer Science, 2025, 52(8): 277-287.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!