KADP-SQL: Knowledge-Augmented Generation and Dual-Path Validation in Text-to-SQL

Authors

DOI:

https://doi.org/10.4108/eetsis.10499

Keywords:

LLM, Text-to-SQL, Knowledge-Augmented Generation, Dual-Path Validation

Abstract

The widespread application of Large Language Models (LLMs) has significantly advanced the development of the Text-to-SQL task, which aims to translate natural language questions posed by users into executable structured query statements. This allows non-expert users to efficiently access databases. However, existing models still struggle to generate correct SQL statements in the absence of sufficient knowledge, particularly under complex query scenarios, where they are prone to syntactic errors and semantic deviations. Moreover, most current approaches rely solely on execution feedback for SQL correction via a single path, making it difficult to detect semantic errors. To address these challenges, we propose KADP-SQL, which divides the Text-to-SQL task into two main modules: Knowledge-Augmented Generation and Dual-Path Validation. This framework structurally represents manually annotated evidence and incorporates web-based external knowledge to enhance SQL generation. Additionally, we introduce a dual-path SQL validation method to detect and correct errors in generated SQL queries. Through extensive experiments conducted on multiple closed-source and open-source LLMs, our proposed KADP-SQL achieves an execution accuracy of 70.53% on the BIRD development set and 88.22% on the Spider test set. These results demonstrate the effectiveness and adaptability of the proposed method.

References

[1] Cai, R., Xu, B., Zhang, Z., Yang, X., Li, Z. and Liang, Z. (2018) An encoder-decoder framework translating natural language to database queries. In Lang, J. [ed.] Proceedings of the Twenty-Seventh International Joint Conference on Artificial Intelligence (Stockholm, Sweden: AAAI Press): 3977–3983. doi:10.24963/IJCAI.2018/553.

[2] Gao, D., Wang, H., Li, Y., Sun, X., Qian, Y., Ding, B. and Zhou, J. (2024) Text-to-sql empowered by large language models: A benchmark evaluation. Proc. VLDB Endow. 17(5): 1132–1145. doi:10.14778/3641204.3641221.

[3] Rajkumar, N., Li, R. and Bahdanau, D. (2022) Evaluating the text-to-sql capabilities of large language models. CoRR abs/2204.00498. doi:10.48550/ARXIV.2204.00498.

[4] Li, J., Hui, B., Qu, G., Yang, J., Li, B., Li, B., Wang, B. et al. (2023) Can llm already serve as a database interface? a big bench for large-scale database grounded text-to-sqls. In Proceedings of the 37th International Conference on Neural Information Processing Systems, NIPS ’23 (Red Hook, NY, USA: Curran Associates Inc.).

[5] Dou, L., Gao, Y., Liu, X., Pan, M., Wang, D., Che, W., Zhan, D. et al. (2022) Towards knowledge-intensive text-to-SQL semantic parsing with formulaic knowledge. In Goldberg, Y., Kozareva, Z. and Zhang, Y. [eds.] Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing (Abu Dhabi, United Arab Emirates: Association for Computational Linguistics): 5240–5253. doi:10.18653/v1/2022.emnlp-main.350.

[6] Hong, Z., Yuan, Z., Chen, H., Zhang, Q., Huang, F. and Huang, X. (2024) Knowledge-to-SQL: Enhancing SQL generation with data expert LLM. In Ku, L.W., Martins, A. and Srikumar, V. [eds.] Findings of the Association for Computational Linguistics: ACL 2024 (Bangkok, Thailand: Association for Computational Linguistics): 10997–11008. doi:10.18653/v1/2024.findings-acl.653.

[7] Baek, J., Samulowitz, H., Hassanzadeh, O., Subramanian, D., Shirai, S., Gliozzo, A. and Bhattacharjya, D. (2025) Knowledge base construction for knowledgeaugmented text-to-SQL. In Che,W., Nabende, J., Shutova, E. and Pilehvar, M.T. [eds.] Findings of the Association for Computational Linguistics: ACL 2025 (Vienna, Austria: Association for Computational Linguistics): 26569– 26583.

[8] Huang, L., Yu,W., Ma,W., Zhong,W., Feng, Z.,Wang, H., Chen, Q. et al. (2025) A survey on hallucination in large language models: Principles, taxonomy, challenges, and open questions. ACM Trans. Inf. Syst. 43(2): 42:1–42:55. doi:10.1145/3703155.

[9] Yun, J. and Lee, S. (2025) SEED: enhancing textto- sql performance and practical usability through automatic evidence generation. CoRR abs/2506.07423. doi:10.48550/ARXIV.2506.07423.

[10] Talaei, S., Pourreza, M., Chang, Y., Mirhoseini, A. and Saberi, A. (2024) CHESS: contextual harnessing for efficient SQL synthesis. CoRR abs/2405.16755. doi:10.48550/ARXIV.2405.16755.

[11] Lee, D., Park, C., Kim, J. and Park, H. (2025) MCSSQL: Leveraging multiple prompts and multiple-choice selection for text-to-SQL generation. In Rambow, O., Wanner, L., Apidianaki, M., Al-Khalifa, H., Eugenio, B.D. and Schockaert, S. [eds.] Proceedings of the 31st International Conference on Computational Linguistics (Abu Dhabi, UAE: Association for Computational Linguistics): 337–353.

[12] Wang, B., Ren, C., Yang, J., Liang, X., Bai, J., Chai, L., Yan, Z. et al. (2025) MAC-SQL: A multi-agent collaborative framework for text-to-SQL. In Rambow, O., Wanner, L., Apidianaki, M., Al-Khalifa, H., Eugenio, B.D. and Schockaert, S. [eds.] Proceedings of the 31st International Conference on Computational Linguistics (Abu Dhabi, UAE: Association for Computational Linguistics): 540–557.

[13] Yu, T., Zhang, R., Yang, K., Yasunaga, M., Wang, D., Li, Z., Ma, J. et al. (2018) Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-SQL task. In Riloff, E., Chiang, D., Hockenmaier, J. and Tsujii, J. [eds.] Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing (Brussels, Belgium: Association for Computational Linguistics): 3911–3921. doi:10.18653/v1/D18-1425.

[14] Floratou, A., Psallidas, F., Zhao, F., Deep, S., Hagleither, G., Tan,W., Cahoon, J. et al. (2024) NL2SQL is a solved problem... not! In 14th Conference on Innovative Data Systems Research, CIDR 2024, January 14-17, 2024 (Chaminade, HI, USA: www.cidrdb.org).

[15] Pourreza, M. and Rafiei, D. (2023) DIN-SQL: decomposed in-context learning of text-to-sql with selfcorrection. In Oh, A., Naumann, T., Globerson, A., Saenko, K., Hardt, M. and Levine, S. [eds.] Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems 2023, NeurIPS 2023, New Orleans, LA, USA, December 10 - 16, 2023.

[16] Xie, X., Xu, G., Zhao, L. and Guo, R. (2025) Opensearchsql: Enhancing text-to-sql with dynamic few-shot and consistency alignment. Proc. ACM Manag. Data 3(3): 194:1–194:24. doi:10.1145/3725331.

[17] Gao, Y., Liu, Y., Li, X., Shi, X., Zhu, Y., Wang, Y., Li, S. et al. (2024) Xiyan-sql: A multi-generator ensemble framework for text-to-sql. CoRR abs/2411.08599. doi:10.48550/ARXIV.2411.08599.

[18] Pourreza, M., Li, H., Sun, R., Chung, Y., Talaei, S., Kakkar, G.T., Gan, Y. et al. (2025) CHASE-SQL: multipath reasoning and preference optimized candidate selection in text-to-sql. In The Thirteenth International Conference on Learning Representations, ICLR 2025, April 24-28, 2025 (Singapore: OpenReview.net).

[19] Sheng, L. and Xu, S. (2025) CSC-SQL: corrective selfconsistency in text-to-sql via reinforcement learning. CoRR abs/2505.13271. doi:10.48550/ARXIV.2505.13271.

[20] Zhang, C., Mao, Y., Fan, Y., Mi, Y., Gao, Y., Chen, L., Lou, D. et al. (2024) Finsql: Model-agnostic llmsbased text-to-sql framework for financial analysis. In Barcelo, P., Sanchez-Pi, N., Meliou, A. and Sudarshan, S. [eds.] Companion of the 2024 International Conference on Management of Data, SIGMOD/PODS 2024, June 9-15, 2024 (Santiago, Chile: ACM): 93–105. doi:10.1145/3626246.3653375.

[21] Li, Z., Wang, X., Zhao, J., Yang, S., Du, G., Hu, X., Zhang, B. et al. (2024) PET-SQL: A prompt-enhanced two-stage text-to-sql framework with cross-consistency. CoRR abs/2403.09732. doi:10.48550/ARXIV.2403.09732.

[22] Dong, X., Zhang, C., Ge, Y., Mao, Y., Gao, Y., Chen, L., Lin, J. et al. (2023) C3: zero-shot text-to-sql with chatgpt. CoRR abs/2307.07306. doi:10.48550/ARXIV.2307.07306.

[23] Liu, A., Hu, X., Wen, L. and Yu, P.S. (2023) A comprehensive evaluation of chatgpt’s zeroshot text-to-sql capability. CoRR abs/2303.13547. doi:10.48550/ARXIV.2303.13547.

[24] Wei, J., Bosma, M., Zhao, V.Y., Guu, K., Yu, A.W., Lester, B., Du, N. et al. (2022) Finetuned language models are zero-shot learners. In The Tenth International Conference on Learning Representations, ICLR 2022 (Virtual Event: OpenReview.net).

[25] Liu, X. and Tan, Z. (2023) Divide and prompt: Chain of thought prompting for text-to-sql. CoRR abs/2304.11556. doi:10.48550/ARXIV.2304.11556.

[26] Wei, J., Wang, X., Schuurmans, D., Bosma, M., Ichter, B., Xia, F., Chi, E.H. et al. (2022) Chain-of-thought prompting elicits reasoning in large language models. In Koyejo, S., Mohamed, S., Agarwal, A., Belgrave, D., Cho, K. and Oh, A. [eds.] Advances in Neural Information Processing Systems 35: Annual Conference on Neural Information Processing Systems 2022, NeurIPS 2022, New Orleans, LA, USA, November 28 - December 9, 2022.

[27] Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Kuttler, H. et al. (2020) Retrievalaugmented generation for knowledge-intensive NLP tasks. In Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M. and Lin, H. [eds.] Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual.

[28] Tai, C.Y., Chen, Z., Zhang, T., Deng, X. and Sun, H. (2023) Exploring chain of thought style prompting for text-to-SQL. In Bouamor, H., Pino, J. and Bali, K. [eds.] Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing (Singapore: Association for Computational Linguistics): 5376–5393. doi:10.18653/v1/2023.emnlp-main.327.

[29] Chang, S. and Fosler-Lussier, E. (2023) How to prompt llms for text-to-sql: A study in zero-shot, single-domain, and cross-domain settings. CoRR abs/2305.11853. doi:10.48550/ARXIV.2305.11853.

[30] Zhang, H., Cao, R., Chen, L., Xu, H. and Yu, K. (2023) ACT-SQL: In-context learning for text-to-SQL with automatically-generated chain-of-thought. In Bouamor, H., Pino, J. and Bali, K. [eds.] Findings of the Association for Computational Linguistics: EMNLP 2023 (Singapore: Association for Computational Linguistics): 3501–3532. doi:10.18653/v1/2023.findings-emnlp.227.

[31] Tang, Z., Ma, Q. and Wu, D. (2025) Auto prompt sql: a resource-efficient architecture for text-to-sql translation in constrained environments. CoRR abs/2506.03598. doi:10.48550/ARXIV.2506.03598.

[32] Sun, R., Arik, S.O., Muzio, A., Miculicich, L., Gundabathula, S.K., Yin, P., Dai, H. et al. (2024) Sql-palm: Improved large language model adaptation for text-to-sql. Trans. Mach. Learn. Res. 2024.

[33] Zhou, D., Scharli, N., Hou, L., Wei, J., Scales, N., Wang, X., Schuurmans, D. et al. (2023) Least-to-most prompting enables complex reasoning in large language models. In The Eleventh International Conference on Learning Representations, ICLR 2023, May 1-5, 2023 (Kigali, Rwanda: OpenReview.net).

[34] Qu, G., Li, J., Li, B., Qin, B., Huo, N., Ma, C. and Cheng, R. (2024) Before generation, align it! A novel and effective strategy for mitigating hallucinations in text-to-sql generation. In Ku, L., Martins, A. and Srikumar, V. [eds.] Findings of the Association for Computational Linguistics, ACL 2024, Bangkok, Thailand and virtual meeting, August 11-16, 2024 (Association for Computational Linguistics): 5456–5471. doi:10.18653/V1/2024.FINDINGS-ACL.324, URL https: //doi.org/10.18653/v1/2024.findings-acl.324.

[35] Cao, Z., Zheng, Y., Fan, Z., Zhang, X., Chen, W. and Bai, X. (2024) RSL-SQL: robust schema linking in text-to-sql generation. CoRR abs/2411.00073. doi:10.48550/ARXIV.2411.00073.

[36] Liu, G., Tan, Y., Zhong, R., Xie, Y., Zhao, L., Wang, Q., Hu, B. et al. (2025) Solid-sql: Enhanced schemalinking based in-context learning for robust text-tosql. In Rambow, O., Wanner, L., Apidianaki, M., Al- Khalifa, H., Eugenio, B.D. and Schockaert, S. [eds.] Proceedings of the 31st International Conference on Computational Linguistics, COLING 2025, Abu Dhabi, UAE, January 19-24, 2025 (Association for Computational Linguistics): 9793–9803. URL https://aclanthology. org/2025.coling-main.654/.

[37] Safdarian, A., Mohammadi, M., Jahanbakhsh, E., Naderi, M.S. and Faili, H. (2025) Schemagraphsql: Efficient schema linking with pathfinding graph algorithms for text-to-sql on large-scale databases. CoRR abs/2505.18363. doi:10.48550/ARXIV.2505.18363, URL https://doi.org/10.48550/arXiv.2505.18363. 2505. 18363.

[38] Cao, R., Chen, L., Chen, Z., Zhao, Y., Zhu, S. and Yu, K. (2021) LGESQL: line graph enhanced text-tosql model with mixed local and non-local relations. In Zong, C., Xia, F., Li, W. and Navigli, R. [eds.] Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, ACL/IJCNLP 2021, (Volume 1: Long Papers), Virtual Event, August 1-6, 2021 (Association for Computational Linguistics): 2541–2555. doi:10.18653/V1/2021.ACL-LONG.198, URL https://doi.org/10.18653/v1/2021.acl-long.198.

[39] Wang, P., Sun, B., Dong, X., Dai, Y., Yuan, H., Chu, M., Gao, Y. et al. (2025) Agentar-scale-sql: Advancing text-to-sql through orchestrated test-time scaling. CoRR abs/2509.24403. doi:10.48550/ARXIV.2509.24403, URL https://doi.org/10.48550/arXiv.2509.24403. 2509. 24403.

[40] Li, X., You, J., Li, H., Peng, J., Chen, X. and Guo, Z. (2025) CM-SQL: A cross-model consistency framework for text-to-sql. Neurocomputing 658: 131708. doi:10.1016/J.NEUCOM.2025.131708, URL https://doi.org/10.1016/j.neucom.2025.131708.

[41] Ma, X., Tian, X., Wu, L., Wang, X., Tang, X. and Wang, J. (2024) Enhancing text-to-sql capabilities of large language models via domain database knowledge injection. In Endriss, U., Melo, F.S., Bach, K., Diz, A.J.B., Alonso-Moral, J.M., Barro, S. and Heintz, F. [eds.] ECAI2024 - 27th European Conference on Artificial Intelligence, 19-24 October 2024, Santiago de Compostela, Spain - Including 13th Conference on Prestigious Applications of Intelligent Systems (PAIS 2024) (IOS Press), Frontiers in Artificial Intelligence and Applications 392: 3859– 3866. doi:10.3233/FAIA240949, URL https://doi.org/ 10.3233/FAIA240949.

[42] Zhan, Z., E, H. and Song, M. (2025) Leveraging large language model for enhanced text-tosql parsing. IEEE Access 13: 30497–30504. doi:10.1109/ACCESS.2025.3540072, URL https: //doi.org/10.1109/ACCESS.2025.3540072.

[43] Zhong, V., Xiong, C. and Socher, R. (2017) Seq2sql: Generating structured queries from natural language using reinforcement learning. CoRR abs/1709.00103. URL http://arxiv.org/abs/1709.00103. 1709.00103.

[44] Chu, Z., Wang, Z. and Qin, Q. (2024) Leveraging prior experience: An expandable auxiliary knowledge base for text-to-sql. CoRR abs/2411.13244. doi:10.48550/ARXIV.2411.13244, URL https://doi. org/10.48550/arXiv.2411.13244. 2411.13244.

[45] Li, C., Shao, Y. and Liu, Z. (2024) SEA-SQL: semanticenhanced text-to-sql with adaptive refinement. CoRR abs/2408.04919. doi:10.48550/ARXIV.2408.04919.

[46] Cen, J., Liu, J., Li, Z. and Wang, J. (2025) Sqlfixagent: Towards semantic-accurate text-to-sql parsing via consistency-enhanced multi-agent collaboration. In Walsh, T., Shah, J. and Kolter, Z. [eds.] AAAI- 25, Sponsored by the Association for the Advancement of Artificial Intelligence, February 25 - March 4, 2025 (Philadelphia, PA, USA: AAAI Press): 49–57. doi:10.1609/AAAI.V39I1.31979.

[47] Zhang, B., Ye, Y., Du, G., Hu, X., Li, Z., Yang, S., Liu, C.H. et al. (2024) Benchmarking the text-to-sql capability of large language models: A comprehensive evaluation. CoRR abs/2403.02951. doi:10.48550/ARXIV.2403.02951.

[48] Li, H., Wu, S., Zhang, X., Huang, X., Zhang, J., Jiang, F., Wang, S. et al. (2025) Omnisql: Synthesizing highquality text-to-sql data at scale. CoRR abs/2503.02240. doi:10.48550/ARXIV.2503.02240.

[49] Maamari, K., Abubaker, F., Jaroslawicz, D. and Mhedhbi, A. (2024) The death of schema linking? text-to-sql in the age of well-reasoned language models. CoRR abs/2408.07702. doi:10.48550/ARXIV.2408.07702.

[50] Caferoglu, H.A. and Ulusoy, O. (2024) E-SQL: direct schema linking via question enrichment in text-to-sql. CoRR abs/2409.16751. doi:10.48550/ARXIV.2409.16751.

Downloads

Published

02-02-2026

How to Cite

1.
Peng J, You J, Li X, Ding J, Jia L. KADP-SQL: Knowledge-Augmented Generation and Dual-Path Validation in Text-to-SQL. EAI Endorsed Scal Inf Syst [Internet]. 2026 Feb. 2 [cited 2026 Feb. 15];12(7). Available from: https://publications.eai.eu/index.php/sis/article/view/10499