Abstract
Large language models (LLMs) with in-context learning (ICL) have notably boosted the performance in text-to-SQL, with prior efforts concentrating on exclusive SQL prompts to enhance reasoning ability. However, it is still challenging to further enhance the operational efficiency and inference performance of LLMs. To tackle this challenge, we propose MR-SQL, a multi-level retrieval-based LLM framework consists of three specially designed retrievers. The retrievers collaborate to retrieve valuable information for the target question, which not only reduce schema size and minimize the interference noise, but also enhance the reasoning capability of LLMs through more similar Chains of Thought (CoT). Concretely, Table-Retriever and Column-Retriever retrieve concise tables and columns from original large databases with redundant schema information. Example-Retriever select similar few-shot examples for more targeted CoT. Experiment results indicate that MR-SQL increases the execution accuracy on the BIRD and Spider validation sets by +2.54% and +1.15% respectively.
Z. Wu and Z. Li—Equal contribution.
Work done during Z. Wu’s internship at TeleAI.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
Bai, J., et al.: Qwen technical report. arXiv preprint arXiv:2309.16609 abs/2309.16609 (2023). https://arxiv.org/abs/2309.16609
Chai, L., et al.: Mceval: massively multilingual code evaluation. arXiv preprint arXiv:2406.07436 (2024)
Chang, S., Fosler-Lussier, E.: How to prompt LLMs for text-to-sql: a study in zero-shot, single-domain, and cross-domain settings. CoRR abs/2305.11853 (2023)
Dong, Q., et al.: A survey for in-context learning. CoRR abs/2301.00234 (2023)
Dong, X., et al.: C3: zero-shot text-to-sql with ChatGPT. CoRR abs/2307.07306 (2023)
Gao, D., et al.: Text-to-sql empowered by large language models: a benchmark evaluation. Proc. VLDB Endow. 17(5), 1132–1145 (2024)
Guo, J., et al.: Towards complex text-to-SQL in cross-domain database with intermediate representation. In: Korhonen, A., Traum, D.R., Màrquez, L. (eds.) ACL 2019. ACL (2019)
He, P., Mao, Y., Chakrabarti, K., Chen, W.: X-SQL: reinforce schema representation with context. CoRR abs/1908.08113 (2019)
Hui, B., et al.: S\({^2}\)sql: injecting syntax to question-schema interaction graph encoder for text-to-SQL parsers. In: ACL 2022, (2022)
Khattab, O., Zaharia, M.: Colbert: efficient and effective passage search via contextualized late interaction over BERT. In: Huang, J.X., et al(eds.) SIGIR 2020. ACM (2020)
Li, H., Zhang, J., Li, C., Chen, H.: RESDSQL: decoupling schema linking and skeleton parsing for text-to-sql. In: Williams, B., Chen, Y., Neville, J. (eds.) Thirty-Seventh AAAI Conference on Artificial Intelligence, AAAI (2023)
Li, J., et al.: Graphix-t5: mixing pre-trained transformers with graph-aware layers for text-to-sql parsing. In: EAAI 2023 (2023)
Li, J., et al.: Can LLM already serve as a database interface? A big bench for large-scale database grounded text-to-sqls. In: NeurIPS 2023 (2023)
Li, X., et al.: Tele-FLM technical report. CoRR abs/2404.16645 (2024)
Li, Z., et al.: Scalable database-driven KGS can help text-to-SQLl. In: Proceedings of the ISWC 2024 Posters, Demos and Industry Tracks: (2024)
Liu, S., Peng, C., Wang, C., Chen, X., Song, S.: icsberts: optimizing pre-trained language models in intelligent customer service. In: INNS DLIA@IJCNN (2023)
OpenAI: GPT-4 technical report. arXiv preprint arXiv:2303.08774 (2023). https://arxiv.org/abs/2303.08774
Pourreza, M., Rafiei, D.: DIN-SQL: decomposed in-context learning of text-to-sql with self-correction. In: Oh, A., Naumann, T., Globerson, A., Saenko, K., Hardt, M., Levine, S. (eds.) NeurIPS 2023 (2023)
Qin, B., et al: A survey on text-to-sql parsing: cncepts, methods, and future directions. CoRR abs/2208.13629 (2022)
Rozière, B., et al.: Code llama: oen foundation models for code. arXiv preprint arXiv:2308.12950 (2023).https://arxiv.org/abs/2308.12950
Shao, J., Li, X.: AI flow at the network edge. IEEE Network, pp. 1–1 (2025). https://doi.org/10.1109/MNET.2025.3541208
Sun, R., et al.: SQL-palm: improved large language model adaptation for text-to-sql. CoRR abs/2306.00739 (2023)
Sun, T., et al.: Unicoder: scaling code large language model via universal code. arXiv preprint arXiv:2406.16441 (2024)
Tai, C., Chen, Z., Zhang, T., Deng, X., Sun, H.: Exploring chain of thought style prompting for text-to-sql. In: EMNLP 2023 (2023)
Wang, B., Shin, R., Liu, X., Polozov, O., Richardson, M.: RAT-SQL: relation-aware schema encoding and linking for text-to-sql parsers. In: ACL 2020 (2020)
Wang, B., et al.: MAC-SQL: A multi-agent collaborative framework for text-to-SQL. CoRR abs/2312.11242 (2023)
Wang, Z., et al.: Telechat: an open-source billingual large language model. In: Proceedings of the 10th SIGHAN Workshop on Chinese Language Processing (SIGHAN-10), pp. 10–20 (2024)
Wang, Z., et al.: Telechat technical report. CoRR abs/2401.03804 (2024)
Wei, J., et al.: Chain-of-thought prompting elicits reasoning in large language models. In: NeurIPS 2022 (2022)
Wu, H., Chen, Y., Liu, L., Chen, T., Wang, K., Lin, L.: Sqlnet: scale-modulated query and localization network for few-shot class-agnostic counting. CoRR abs/2311.10011 (2023)
Yu, T., et al.: Spider: a large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-SQL task. In: EMNLP 2018. ACL (2018)
Zheng, Y., Wang, H., Dong, B., Wang, X., Li, C.: HIE-SQL: history information enhanced network for context-dependent text-to-sql semantic parsing. In: Findings of the Association for Computational Linguistics: ACL 2022, (2022)
Zhou, D., et al.: Least-to-most prompting enables complex reasoning in large language models. In: ICLR 2023. OpenReview.net (2023)
Acknowledgments
This work was partially supported by the National Natural Science Foundation of China (Grant Nos. 62276017, 62406033, U1636211, 61672081), and the State Key Laboratory of Complex& Critical Software Environment (Grant No. SKLCCSE-2024ZX-18).
Author information
Authors and Affiliations
Corresponding authors
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2026 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.
About this paper
Cite this paper
Wu, Z. et al. (2026). MR-SQL: Multi-level Retrieval Enhances Inference for LLM in Text-to-SQL. In: Zhu, F., et al. Database Systems for Advanced Applications. DASFAA 2025. Lecture Notes in Computer Science, vol 15987. Springer, Singapore. https://doi.org/10.1007/978-981-95-3830-0_27
Download citation
DOI: https://doi.org/10.1007/978-981-95-3830-0_27
Published:
Publisher Name: Springer, Singapore
Print ISBN: 978-981-95-3829-4
Online ISBN: 978-981-95-3830-0
eBook Packages: Computer ScienceComputer Science (R0)Springer Nature Proceedings Computer Science
