Table of Contents
Fetching ...

RSL-SQL: Robust Schema Linking in Text-to-SQL Generation

Zhenbiao Cao, Yuanlei Zheng, Zhihao Fan, Xiaojin Zhang, Wei Chen, Xiang Bai

TL;DR

<3-5 sentence high-level summary>RSL-SQL addresses the risks of schema linking in Text-to-SQL by jointly maximizing beneficial recall and minimizing information loss. It introduces a four-step framework—bidirectional schema linking, contextual information augmentation, binary selection, and multi-turn self-correction—evaluated on BIRD and Spider, achieving state-of-the-art open-source results and strong cost-efficiency with DeepSeek. The approach demonstrates that high recall can be maintained without excessive prompt size, and that context-augmented, hedge-based generation coupled with iterative refinement yields robust SQL queries across complex schemas. These findings have practical implications for cost-effective, reliable Text-to-SQL systems in real-world databases.

Abstract

Text-to-SQL generation aims to translate natural language questions into SQL statements. In Text-to-SQL based on large language models, schema linking is a widely adopted strategy to streamline the input for LLMs by selecting only relevant schema elements, therefore reducing noise and computational overhead. However, schema linking faces risks that require caution, including the potential omission of necessary elements and disruption of database structural integrity. To address these challenges, we propose a novel framework called RSL-SQL that combines bidirectional schema linking, contextual information augmentation, binary selection strategy, and multi-turn self-correction. We improve the recall of pattern linking using forward and backward pruning methods, achieving a strict recall of 94% while reducing the number of input columns by 83%. Furthermore, it hedges the risk by voting between a full mode and a simplified mode enhanced with contextual information. Experiments on the BIRD and Spider benchmarks demonstrate that our approach achieves SOTA execution accuracy among open-source solutions, with 67.2% on BIRD and 87.9% on Spider using GPT-4o. Furthermore, our approach outperforms a series of GPT-4 based Text-to-SQL systems when adopting DeepSeek (much cheaper) with same intact prompts. Extensive analysis and ablation studies confirm the effectiveness of each component in our framework. The codes are available at https://github.com/Laqcce-cao/RSL-SQL.

RSL-SQL: Robust Schema Linking in Text-to-SQL Generation

TL;DR

<3-5 sentence high-level summary>RSL-SQL addresses the risks of schema linking in Text-to-SQL by jointly maximizing beneficial recall and minimizing information loss. It introduces a four-step framework—bidirectional schema linking, contextual information augmentation, binary selection, and multi-turn self-correction—evaluated on BIRD and Spider, achieving state-of-the-art open-source results and strong cost-efficiency with DeepSeek. The approach demonstrates that high recall can be maintained without excessive prompt size, and that context-augmented, hedge-based generation coupled with iterative refinement yields robust SQL queries across complex schemas. These findings have practical implications for cost-effective, reliable Text-to-SQL systems in real-world databases.

Abstract

Text-to-SQL generation aims to translate natural language questions into SQL statements. In Text-to-SQL based on large language models, schema linking is a widely adopted strategy to streamline the input for LLMs by selecting only relevant schema elements, therefore reducing noise and computational overhead. However, schema linking faces risks that require caution, including the potential omission of necessary elements and disruption of database structural integrity. To address these challenges, we propose a novel framework called RSL-SQL that combines bidirectional schema linking, contextual information augmentation, binary selection strategy, and multi-turn self-correction. We improve the recall of pattern linking using forward and backward pruning methods, achieving a strict recall of 94% while reducing the number of input columns by 83%. Furthermore, it hedges the risk by voting between a full mode and a simplified mode enhanced with contextual information. Experiments on the BIRD and Spider benchmarks demonstrate that our approach achieves SOTA execution accuracy among open-source solutions, with 67.2% on BIRD and 87.9% on Spider using GPT-4o. Furthermore, our approach outperforms a series of GPT-4 based Text-to-SQL systems when adopting DeepSeek (much cheaper) with same intact prompts. Extensive analysis and ablation studies confirm the effectiveness of each component in our framework. The codes are available at https://github.com/Laqcce-cao/RSL-SQL.

Paper Structure

This paper contains 47 sections, 6 equations, 9 figures, 7 tables, 1 algorithm.

Figures (9)

  • Figure 1: The framework consists of four main components: (1) Preliminary SQL Generation, (2) SQL Generation with Contextual Information Augmentation, (3) Binary Selection Strategy, and (4) Multi-Turn Self-Correction.
  • Figure 2: Organization of Elements in the Prompt.
  • Figure 3: Framework of Bidirectional Schema Linking. $L_\text{fwd}$ and $L_\text{bwd}$ refer to the results of forward schema linking and backward schema linking respectively.
  • Figure 4: An example of contextual information augmentation.
  • Figure 5: An example of binary selection strategy.
  • ...and 4 more figures