Lune

EMNLP Findings2023

ReFSQL: A Retrieval-Augmentation Framework for Text-to-SQL Generation

Kun Zhang, Xiexiong Lin, Yuanzhuo Wang, Xin Zhang, Fei Sun, Jianhe Cen, Hexiang Tan, Xuhui Jiang, Huawei Shen

Abstract

Text-to-SQL is the task that aims at translating natural language questions into SQL queries. Existing methods directly align the natural language with SQL Language and train one encoder-decoder-based model to fit all questions. However, they underestimate the inherent structural characteristics of SQL, as well as the gap between specific structure knowledge and general knowledge. This leads to structure errors in the generated SQL. To address the above challenges, we propose a retrievalargument framework, namely ReFSQL. It contains two parts, structure-enhanced retriever and the generator. Structure-enhanced retriever is designed to identify samples with comparable specific knowledge in an unsupervised way. Subsequently, we incorporate the retrieved samples' SQL into the input, enabling the model to acquire prior knowledge of similar SQL grammar. To further bridge the gap between specific and general knowledge, we present a mahalanobis contrastive learning method, which facilitates the transfer of the sample toward the specific knowledge distribution constructed by the retrieved samples. Experimental results on five datasets verify the effectiveness of our approach in improving the accuracy and robustness of Text-to-SQL generation. Our framework has achieved improved performance when combined with many other backbone models (including the 11B flan-T5) and also achieved state-of-the-art performance when compared to existing methods that employ the fine-tuning approach.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

4 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL cites Relational Graph Attention Network for Aspect-based Sentiment Analysis
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers4

  1. Tree-of-Reasoning Question Decomposition for Complex Question Answering with Large Language ModelsKun Zhang, Jiali Zeng, Fandong Meng, Yuanzhuo Wang et al.AAAI 2024 · 14 citations
  2. SEFRQO: A Self-Evolving Fine-Tuned RAG-Based Query OptimizerHanwen Liu, Qihan Zhang, Ryan Marcus, Ibrahim SabekSIGMOD 2026 · 2 citations
  3. Consistent Autoformalization for Constructing Mathematical LibrariesLan Zhang, Xin Quan, André FreitasEMNLP 2024 · 2 citations
  4. DCG-SQL: Enhancing In-Context Learning for Text-to-SQL with Deep Contextual Schema Link GraphJihyung Lee, Jin-Seop Lee, Jaehoon Lee, YunSeok Choi et al.ACL 2025

Builds on19

  1. A Simple Framework for Contrastive Learning of Visual RepresentationsTing Chen, Simon Kornblith, Mohammad Norouzi, Geoffrey E. HintonICML 2020 · 24,064 citations
  2. Improving Language Models by Retrieving from Trillions of TokensSebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai et al.ICML 2022 · 1,629 citations
  3. Relational Graph Attention Network for Aspect-based Sentiment AnalysisKai Wang, Weizhou Shen, Yunyi Yang, Xiaojun Quan et al.ACL 2020 · 614 citations
  4. RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQLHaoyang Li, Jing Zhang, Cuiping Li, Hong ChenAAAI 2023 · 343 citations
  5. UnifiedSKG: Unifying and Multi-Tasking Structured Knowledge Grounding with Text-to-Text Language ModelsTianbao Xie, Chen Henry Wu, Peng Shi, Ruiqi Zhong et al.EMNLP 2022 · 222 citations

Related papers

  1. SchemaRAG: A Schema-aware Retrieval-Augmented Generation Framework for Text-to-SQLDi Wu, Zetong Tang, Yi He, Xin LuoSIGMOD 2026 · 9 citations
  2. SAFE-SQL: Self-Augmented In-Context Learning with Fine-grained Example Selection for Text-to-SQLJimin Lee, Ingeol Baek, Byeongjeong Kim, Hyunkyung Bae et al.EMNLP 2025 · 1 citation
  3. AID-SQL: Adaptive In-Context Learning of Text-to-SQL with Difficulty-Aware Instruction and Retrieval-Augmented GenerationXiuwen Li, Qifeng Cai, Yang Shu, Chenjuan Guo et al.ICDE 2025 · 9 citations
  4. G³R: A Graph-Guided Generate-and-Rerank Framework for Complex and Cross-domain Text-to-SQL GenerationYanzheng Xiang, Qian-Wen Zhang, Xu Zhang, Zejie Liu et al.ACL Findings 2023 · 3 citations
  5. Text2sql-Flow: a Robust Sql-Aware Data Augmentation Framework for Text-To-SqlQifeng Cai, Hao Liang, Chang Xu, Tao Xie et al.ICDE 2026 · 1 citation
Dusk over the sea between two cliffs drawn in fine vertical lines