Gar: A Generate-and-Rank Approach for Natural Language to SQL Translation
Yuankai Fan, Zhenying He, Tonghui Ren, Dianjun Guo, Lin Chen, Ruisi Zhu, Guanduo Chen, Yinan Jing, Kai Zhang, X. Sean Wang
Abstract
A Natural Language (NL) Interface to Databases (NLIDB) aims to help end-users access databases. State-of-the-art approaches primarily construct language translation models to convert NL queries to SQL queries. While these models exhibit good performance on NLIDB benchmarks, the translation accuracy seems to have stalled at between 70%-75%, and most erroneous translations happen with complex queries that require an understanding of the structure and semantics specific to a database. This paper proposes a Generate-And-Rank approach called Gar. Gar assumes that a set of sample SQL queries is given to represent the possible user-intended queries to the database. In order to provide a broad coverage, akin to avoiding over-fitting, Gar extracts the basic components from the sample set to form the basic building blocks to generate a set of generalized SQL queries. By leveraging a simple rule-based SQL to NL technique, a less natural NL expression called a dialect expression for each sample and generalized SQL query is obtained. Finally, a learning-to-rank method is used for a given NL query to retrieve the best dialect expression and hence the resulting SQL query. Extensive experiments are performed to study Gar in comparison with other approaches. The results show that Gar achieves better performance on the NLIDB benchmarks, including in particular a 78.5% translation accuracy on the popular Spider benchmark, outperforming the best reported accuracy in the literature. An extension to Gar, called Gar-j, is further introduced to aid the translation by annotating join semantics in the sample queries. The experimental results show that Gar-j can further improve translation accuracy on queries with joins. Code for Gar can be found at https://github.com/Kaimary/GAR.
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.
5 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- PURPLE: Making a Large Language Model a Better SQL Writer cites Natural SQL: Making SQL Easier to Infer from Natural Language Specifications
- PURPLE: Making a Large Language Model a Better SQL Writer cites Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
- PURPLE: Making a Large Language Model a Better SQL Writer cites Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation
- GraPPa: Grammar-Augmented Pre-Training for Table Semantic Parsing cites Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
- Learning Contextual Representations for Semantic Parsing with Generation-Augmented Pre-Training cites GraPPa: Grammar-Augmented Pre-Training for Table Semantic Parsing
- Natural SQL: Making SQL Easier to Infer from Natural Language Specifications cites Learning Contextual Representations for Semantic Parsing with Generation-Augmented Pre-Training
- Natural SQL: Making SQL Easier to Infer from Natural Language Specifications cites Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
- Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing cites Exploring Unexplored Generalization Challenges for Cross-Database Semantic Parsing
- The Power of Constraints in Natural Language to SQL Translation cites PURPLE: Making a Large Language Model a Better SQL Writer
- The Power of Constraints in Natural Language to SQL Translation cites Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
- The Power of Constraints in Natural Language to SQL Translation cites Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation
- The Power of Constraints in Natural Language to SQL Translation cites Grounding Natural Language to SQL Translation with Data-Based Self-Explanations
- Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation cites GraPPa: Grammar-Augmented Pre-Training for Table Semantic Parsing
- Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation cites Learning Contextual Representations for Semantic Parsing with Generation-Augmented Pre-Training
- Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation cites Natural SQL: Making SQL Easier to Infer from Natural Language Specifications
- Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation cites Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
- Grounding Natural Language to SQL Translation with Data-Based Self-Explanations cites PURPLE: Making a Large Language Model a Better SQL Writer
- Grounding Natural Language to SQL Translation with Data-Based Self-Explanations cites GraPPa: Grammar-Augmented Pre-Training for Table Semantic Parsing
- Grounding Natural Language to SQL Translation with Data-Based Self-Explanations cites Natural SQL: Making SQL Easier to Infer from Natural Language Specifications
- Grounding Natural Language to SQL Translation with Data-Based Self-Explanations cites Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
Cited by top-tier papers5
- PURPLE: Making a Large Language Model a Better SQL WriterTonghui Ren, Yuankai Fan, Zhenying He, Ren Huang et al.ICDE 2024 · 49 citations
- Metasql: A Generate-Then-Rank Framework for Natural Language to SQL TranslationYuankai Fan, Zhenying He, Tonghui Ren, Can Huang et al.ICDE 2024 · 23 citations
- Grounding Natural Language to SQL Translation with Data-Based Self-ExplanationsYuankai Fan, Tonghui Ren, Can Huang, Zhenying He et al.ICDE 2025 · 7 citations
- The Power of Constraints in Natural Language to SQL TranslationTonghui Ren, Chen Ke, Yuankai Fan, Yinan Jing et al.VLDB 2025 · 4 citations
- HCT-QA: A Benchmark for Question Answering on Human-Centric TablesMohammad Shahmeer Ahmad, Zan Ahmad Naeem, Michaël Aupetit, Ahmed K. Elmagarmid et al.ICDE 2026
Builds on10
- Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic ParsingXi Victoria Lin, Richard Socher, Caiming XiongEMNLP Findings 2020 · 186 citations
- Learning Contextual Representations for Semantic Parsing with Generation-Augmented Pre-TrainingPeng Shi, Patrick Ng, Zhiguo Wang, Henghui Zhu et al.AAAI 2021 · 124 citations
- Natural SQL: Making SQL Easier to Infer from Natural Language SpecificationsYujian Gan, Xinyun Chen, Jinxia Xie, Matthew Purver et al.EMNLP Findings 2021 · 88 citations
- Exploring Unexplored Generalization Challenges for Cross-Database Semantic ParsingAlane Suhr, Ming-Wei Chang, Peter Shaw, Kenton LeeACL 2020 · 76 citations
- GraPPa: Grammar-Augmented Pre-Training for Table Semantic ParsingTao Yu, Chien-Sheng Wu, Xi Victoria Lin, Bailin Wang et al.ICLR 2021 · 59 citations
Related papers
- ScienceBenchmark: A Complex Real-World Benchmark for Evaluating Natural Language to SQL SystemsYi Zhang, Jan Deriu, George Katsogiannis-Meimarakis, Catherine Kosten et al.VLDB 2024 · 65 citations
- MT-Teql: Evaluating and Augmenting Neural NLIDB on Real-world Linguistic and Schema VariationsPingchuan Ma, Shuai WangVLDB 2022 · 38 citations
- Dial: A Knowledge-Grounded Dialect-Specific NL2SQL SystemXiang Zhang, Le Zhou, Hongming Xu, Wei Zhou et al.VLDB 2026 · 2 citations
- A Natural Language Interface for Database: Achieving Transfer-learnability Using Adversarial Method for Question UnderstandingWenlu Wang, Yingtao Tian, Haixun Wang, Wei-Shinn KuICDE 2020 · 14 citations
- DBPal: A Fully Pluggable NL2SQL Training PipelineNathaniel Weir, Prasetya Ajie Utama, Alex Galakatos, Andrew Crotty et al.SIGMOD 2020 · 36 citations
