close
Skip to main content

MR-SQL: Multi-level Retrieval Enhances Inference for LLM in Text-to-SQL

  • Conference paper
  • First Online:
Database Systems for Advanced Applications (DASFAA 2025)

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+
from $39.99 /Month
  • Starting from 10 chapters or articles per month
  • Access and download chapters and articles from more than 300k books and 2,500 journals
  • Cancel anytime
View plans

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 69.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 89.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Free shipping worldwide - view details

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. Bai, J., et al.: Qwen technical report. arXiv preprint arXiv:2309.16609 abs/2309.16609 (2023). https://arxiv.org/abs/2309.16609

  2. Chai, L., et al.: Mceval: massively multilingual code evaluation. arXiv preprint arXiv:2406.07436 (2024)

  3. 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)

    Google Scholar 

  4. Dong, Q., et al.: A survey for in-context learning. CoRR abs/2301.00234 (2023)

    Google Scholar 

  5. Dong, X., et al.: C3: zero-shot text-to-sql with ChatGPT. CoRR abs/2307.07306 (2023)

    Google Scholar 

  6. Gao, D., et al.: Text-to-sql empowered by large language models: a benchmark evaluation. Proc. VLDB Endow. 17(5), 1132–1145 (2024)

    Article  Google Scholar 

  7. 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)

    Google Scholar 

  8. He, P., Mao, Y., Chakrabarti, K., Chen, W.: X-SQL: reinforce schema representation with context. CoRR abs/1908.08113 (2019)

    Google Scholar 

  9. Hui, B., et al.: S\({^2}\)sql: injecting syntax to question-schema interaction graph encoder for text-to-SQL parsers. In: ACL 2022, (2022)

    Google Scholar 

  10. 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)

    Google Scholar 

  11. 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)

    Google Scholar 

  12. Li, J., et al.: Graphix-t5: mixing pre-trained transformers with graph-aware layers for text-to-sql parsing. In: EAAI 2023 (2023)

    Google Scholar 

  13. 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)

    Google Scholar 

  14. Li, X., et al.: Tele-FLM technical report. CoRR abs/2404.16645 (2024)

    Google Scholar 

  15. 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)

    Google Scholar 

  16. 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)

    Google Scholar 

  17. OpenAI: GPT-4 technical report. arXiv preprint arXiv:2303.08774 (2023). https://arxiv.org/abs/2303.08774

  18. 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)

    Google Scholar 

  19. Qin, B., et al: A survey on text-to-sql parsing: cncepts, methods, and future directions. CoRR abs/2208.13629 (2022)

    Google Scholar 

  20. Rozière, B., et al.: Code llama: oen foundation models for code. arXiv preprint arXiv:2308.12950 (2023).https://arxiv.org/abs/2308.12950

  21. Shao, J., Li, X.: AI flow at the network edge. IEEE Network, pp. 1–1 (2025). https://doi.org/10.1109/MNET.2025.3541208

  22. Sun, R., et al.: SQL-palm: improved large language model adaptation for text-to-sql. CoRR abs/2306.00739 (2023)

    Google Scholar 

  23. Sun, T., et al.: Unicoder: scaling code large language model via universal code. arXiv preprint arXiv:2406.16441 (2024)

  24. Tai, C., Chen, Z., Zhang, T., Deng, X., Sun, H.: Exploring chain of thought style prompting for text-to-sql. In: EMNLP 2023 (2023)

    Google Scholar 

  25. 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)

    Google Scholar 

  26. Wang, B., et al.: MAC-SQL: A multi-agent collaborative framework for text-to-SQL. CoRR abs/2312.11242 (2023)

    Google Scholar 

  27. 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)

    Google Scholar 

  28. Wang, Z., et al.: Telechat technical report. CoRR abs/2401.03804 (2024)

    Google Scholar 

  29. Wei, J., et al.: Chain-of-thought prompting elicits reasoning in large language models. In: NeurIPS 2022 (2022)

    Google Scholar 

  30. 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)

    Google Scholar 

  31. 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)

    Google Scholar 

  32. 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)

    Google Scholar 

  33. Zhou, D., et al.: Least-to-most prompting enables complex reasoning in large language models. In: ICLR 2023. OpenReview.net (2023)

    Google Scholar 

Download references

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

Authors

Corresponding authors

Correspondence to Zhoujun Li or Shuangyong Song.

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2026 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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

Keywords

Publish with us

Policies and ethics

Profiles

  1. Jian Yang