NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Multi-Turn Interactions for Text-to-SQL with Large Language Models

Guanming Xiong, Junwei Bao, Hongfei Jiang, Yang Song, Wen Zhao

TL;DR

This paper introduces Interactive-T2S, a novel framework that uses Large Language Models (LLMs) to generate SQL queries through multi-turn interactions with databases. It addresses inefficiencies and scalability issues in existing LLM-based text-to-SQL methods, particularly with wide tables, by employing a set of four general tools and a step-by-step reasoning process. The framework achieves state-of-the-art results on challenging benchmarks like BIRD without relying on external knowledge.

What Problem Does This Paper Address?

Text-to-SQL, the task of converting natural language questions into executable SQL queries, is crucial for enabling non-experts to interact with databases. While Large Language Models (LLMs) have shown great promise in this area, current LLM-based approaches face several challenges:

  • Inefficiency with Wide Tables: Existing methods often struggle to handle tables with many columns, as they require inputting the entire schema, consuming significant LLM context windows and increasing costs.
  • Lack of Interpretability: Some interaction-based methods generate SQL queries in a coarse-grained manner, lacking a clear, step-by-step interpretable process.
  • Universally Applicable Interaction Design: Current interaction designs are not always universally applicable or may introduce unnecessary complexity.
  • Resource Scarcity for Data Annotation: Creating large, annotated datasets for text-to-SQL is costly and time-consuming, making it difficult to develop robust models, especially in low-resource settings.

This paper aims to address these limitations by proposing an interactive framework that leverages LLMs' reasoning capabilities through a conversational process with databases.

Methods

The core of the proposed solution is the Interactive-T2S framework, which conceptualizes the LLM as an agent interacting with a database environment. This framework operates under a "thought-action" paradigm, where the LLM first thinks and then acts. The key components are:

  • Unified Interaction Logic: A conversational process where the LLM generates an action based on the prompt and historical interactions. This process involves intermediate "thought" steps before taking an "action."
  • Four General Tools: To facilitate proactive and efficient information retrieval, the framework includes four tools:
  • SearchColumn(semantic): Helps LLMs identify the most relevant columns by ranking them based on their semantic similarity to the query. It also returns column statistics.
  • SearchValue(value, table=None, column=None): Efficiently locates specific cell values within the database, with options to narrow down the search to a particular table or column.
  • FindShortestPath(start, end): Addresses the challenge of multi-table joins by efficiently identifying the shortest path between columns based on foreign key relationships. This models the database schema as a graph, reducing the LLM's burden.
  • ExecuteSQL(sql): Allows for the direct execution of SQL queries, providing a mechanism for verification and refinement.
  • Few-Shot Learning with Exemplars: The framework utilizes a few-shot learning strategy, providing only two detailed exemplars with complete interactive processes to guide the LLM. This addresses the resource scarcity issue.

Datasets

The paper evaluates its approach on several established text-to-SQL datasets:

  • Spider: A widely used cross-domain benchmark.
  • Spider-DK: Challenges parsers with domain knowledge reasoning and real-world question paraphrases.
  • Spider-Syn: Introduces synonyms for schema tokens to test robustness against string matching.
  • Spider-Realistic: Modifies questions to omit explicit column names, testing text-table alignment.
  • BIRD: Known for its complexity and intricate instructions over large databases. The paper uses both settings: with and without external knowledge (oracle knowledge).
  • BIRD-Financial Corrected (FinC): Addresses noise in the BIRD benchmark with revised financial domain data.
  • BIRD Mini-Dev: Offers high-quality text-SQL pairs derived from community feedback.
  • Spider 2.0-lite: A subset of the Spider 2.0 benchmark, used to evaluate performance on SQLite and Snowflake databases.

Key Insights and Ideas

  • Interactive LLM as an Agent: Framing the LLM as an agent interacting with a database environment through a structured dialogue is a powerful paradigm for complex tasks like text-to-SQL.
  • Tool-Assisted Reasoning: The four general-purpose tools (SearchColumn, SearchValue, FindShortestPath, ExecuteSQL) are crucial for breaking down the complex text-to-SQL problem into manageable steps, allowing the LLM to focus on reasoning rather than low-level database operations.
  • Scalability through Graph-based Joins: The FindShortestPath tool is a significant innovation for handling multi-table joins. By abstracting the schema into a graph, it decouples the join complexity from the LLM's direct reasoning, making the system more scalable.
  • Effectiveness of Minimal Exemplars: The framework demonstrates that even with just two carefully crafted exemplars, LLMs can achieve state-of-the-art performance, highlighting the power of well-designed interaction logic and tools.
  • Cell Value Localization is Key: The analysis of cell value localization difficulty (CVR and CVCR metrics) underscores the importance of tools like SearchValue for handling real-world database queries, especially in more complex datasets like BIRD.

Key Results

  • State-of-the-Art Performance: The Interactive-T2S framework achieves state-of-the-art results on the BIRD leaderboard without oracle knowledge.
  • Competitive on Spider Variants: The method shows competitive performance across various Spider datasets, outperforming some selection-based methods, particularly on more challenging variants like Spider-DK.
  • Efficiency Gains: The framework significantly reduces prompt token consumption compared to methods like DIN-SQL, requiring approximately 36% and 22% of the tokens for Spider-Dev and BIRD-Dev, respectively.
  • Impact of FindShortestPath: The FindShortestPath tool demonstrates a notable improvement in performance, especially in scenarios involving joins across multiple tables.
  • Robustness to Data Issues: The error analysis reveals that while mismatches related to "Golden Wrong" and "Ambiguous" references exist, the framework's interactive nature and tool usage help mitigate fundamental SQL generation errors.

Limitations and Future Work

  • Ambiguity in Golden References: The paper notes that the presence of multiple valid SQL queries for a single question (ambiguity) and discrepancies in golden SQL references can pose challenges.
  • LLM Reasoning Limitations: While the framework is designed to assist LLMs, fundamental reasoning limitations in LLMs can still lead to errors, particularly in complex SQL structures.
  • Future Work: The authors suggest exploring more sophisticated LLM reasoning capabilities and further refining the interaction logic and tool design to handle even more complex database interactions and queries. They also mention the potential for applying this framework to other structured data tasks.

Summary updated

BibTeX
@inproceedings{xiong2025multi,
  author = {Guanming Xiong and Junwei Bao and Hongfei Jiang and Yang Song and Wen Zhao},
  title = {{Multi-Turn Interactions for Text-to-SQL with Large Language Models}},
  booktitle = {ACM International Conference on Information and Knowledge Management},
  year = {2025},
  doi = {10.1145/3746252.3761052},
}
Figure