In-Context Reinforcement Learning with Retrieval-Augmented Generation for Text-to-SQL

Rishit Toteja, Arindam Sarkar, Prakash Mandayam Comar


Abstract
Text-to-SQL simplifies database interactions by enabling non-experts to convert their natural language (NL) questions to Structured Query Language (SQL) queries. With advancements in Large Language Models (LLM), in-context learning (ICL) has emerged as a popular choice for building Text-to-SQL systems. Real world, industry-scale databases, often comprise thousands of tables and hundreds of columns, and makes passing the entire schema as context to an LLM infeasibly expensive. This requisites access to the correct database and the set of tables. Recently Retrieval Augmented Generation (RAG) based methods have been proposed for retrieving relevant subset of databases and tables for a given query. However, we observe that the existing methods of synthetic query generation can generate predominantly simple queries which might not be sufficiently representative of complex, real world queries, thus, negatively affecting the quality of the generated SQL. To address this, we propose an innovative in-context reinforcement learning (ICRL) based framework which refines the question generation process by enhancing the model’s ability to produce intricate queries that practitioners may pose during inference. In contrast to the existing approaches, our framework ensures the generation of synthetic SQL queries which are diverse and complex. We demonstrate the effectiveness of our approach via multiple experiments comparing against the representative state-of-the-art models on public benchmark datasets and observe substantial improvements in performance and scalability. Our method achieves 15-20% higher recall in database/table retrieval task compared to the existing state-of-the-art models for schema identification and upto 2% higher execution accuracy for SQL generation.
Anthology ID:
2025.coling-main.692
Volume:
Proceedings of the 31st International Conference on Computational Linguistics
Month:
January
Year:
2025
Address:
Abu Dhabi, UAE
Editors:
Owen Rambow, Leo Wanner, Marianna Apidianaki, Hend Al-Khalifa, Barbara Di Eugenio, Steven Schockaert
Venue:
COLING
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
10390–10397
Language:
URL:
https://aclanthology.org/2025.coling-main.692/
DOI:
Bibkey:
Cite (ACL):
Rishit Toteja, Arindam Sarkar, and Prakash Mandayam Comar. 2025. In-Context Reinforcement Learning with Retrieval-Augmented Generation for Text-to-SQL. In Proceedings of the 31st International Conference on Computational Linguistics, pages 10390–10397, Abu Dhabi, UAE. Association for Computational Linguistics.
Cite (Informal):
In-Context Reinforcement Learning with Retrieval-Augmented Generation for Text-to-SQL (Toteja et al., COLING 2025)
Copy Citation:
PDF:
https://aclanthology.org/2025.coling-main.692.pdf