Lune

ICDE2024Top-tier venue

Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation

Yuankai Fan, Zhenying He, Tonghui Ren, Can Huang, Yinan Jing, Kai Zhang, X. Sean Wang

Abstract

The Natural Language Interface to Databases (NLIDB) empowers non-technical users with database access through intuitive natural language (NL) interactions. Advanced approaches, utilizing neural sequence-to-sequence models or large-scale language models, typically employ auto-regressive decoding to generate unique SQL queries sequentially. While these translation models have greatly improved the overall translation accuracy, surpassing 70% on NLIDB benchmarks, the use of auto-regressive decoding to generate single SQL queries may result in sub-optimal outputs, potentially leading to erroneous translations. In this paper, we propose Metasql, a unified generate-then-rank framework that can be flexibly incorporated with existing NLIDBs to consistently improve their translation accuracy. Metasql introduces query metadata to control the generation of better SQL query candidates and uses learning-to-rank algorithms to retrieve globally optimized queries. Specifically, Metasql first breaks down the meaning of the given NL query into a set of possible query metadata, representing the basic concepts of the semantics. These metadata are then used as language constraints to steer the underlying translation model toward generating a set of candidate SQL queries. Finally, Metasql ranks the candidates to identify the best matching one for the given NL query. Extensive experiments are performed to study Metasql on two public NLIDB benchmarks. The results show that the performance of the translation models can be effectively improved using Metasql. In particular, applying Metasql to the published Lgesql model obtains a translation accuracy of 77.4 % on the validation set and 72.3 % on the test set of the Spider benchmark, outperforming the baseline by 2.3% and 0.3%, respectively. Moreover, applying Metasql to GpT-4 achieves translation accuracies of 68.6%, 42.0%, and 17.6 % on the three real-world complex scientific databases of Sciencebenchmark, respectively. The code for Metasql is available at https://github.com/Kaimary/MetaSQL.

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.

7 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 Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
  • Text2VectorSQL: Towards a Unified Interface for Vector Search and SQL Queries cites RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
  • Text2VectorSQL: Towards a Unified Interface for Vector Search and SQL Queries cites DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction
  • PURPLE: Making a Large Language Model a Better SQL Writer cites RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
  • PURPLE: Making a Large Language Model a Better SQL Writer cites DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction
  • 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 Language Models are Few-Shot Learners
  • DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction cites Language Models are Few-Shot Learners
  • Reliable Text-to-SQL with Adaptive Abstention cites RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
  • Reliable Text-to-SQL with Adaptive Abstention cites DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction
  • Reliable Text-to-SQL with Adaptive Abstention cites Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
  • Reliable Text-to-SQL with Adaptive Abstention cites Language Models are Few-Shot Learners
  • LearNAT: Learning NL2SQL with AST-guided Task Decomposition for Large Language Models cites RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
  • LearNAT: Learning NL2SQL with AST-guided Task Decomposition for Large Language Models cites DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction
  • The Power of Constraints in Natural Language to SQL Translation cites RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
  • 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 DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction
  • The Power of Constraints in Natural Language to SQL Translation cites Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers7

  1. PURPLE: Making a Large Language Model a Better SQL WriterTonghui Ren, Yuankai Fan, Zhenying He, Ren Huang et al.ICDE 2024 · 49 citations
  2. Reliable Text-to-SQL with Adaptive AbstentionKaiwen Chen, Yueting Chen, Nick Koudas, Xiaohui YuSIGMOD 2025 · 9 citations
  3. LearNAT: Learning NL2SQL with AST-guided Task Decomposition for Large Language ModelsWeibin Liao, Xin Gao, Tianyu Jia, Rihong Qiu et al.ICLR 2026 · 9 citations
  4. The Power of Constraints in Natural Language to SQL TranslationTonghui Ren, Chen Ke, Yuankai Fan, Yinan Jing et al.VLDB 2025 · 4 citations
  5. Text2VectorSQL: Towards a Unified Interface for Vector Search and SQL QueriesZhengren Wang, Dongwen Yao, Bozhou Li, Dongsheng Ma et al.ICDE 2026 · 1 citation

Builds on19

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Approximate Nearest Neighbor Negative Contrastive Learning for Dense Text RetrievalLee Xiong, Chenyan Xiong, Ye Li, Kwok-Fung Tang et al.ICLR 2021 · 1,547 citations
  3. DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-CorrectionMohammadreza Pourreza, Davood RafieiNeurIPS 2023 · 909 citations
  4. RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQLHaoyang Li, Jing Zhang, Cuiping Li, Hong ChenAAAI 2023 · 343 citations
  5. Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic ParsingXi Victoria Lin, Richard Socher, Caiming XiongEMNLP Findings 2020 · 186 citations

Related papers

  1. Gar: A Generate-and-Rank Approach for Natural Language to SQL TranslationYuankai Fan, Zhenying He, Tonghui Ren, Dianjun Guo et al.ICDE 2023 · 12 citations
  2. MT-Teql: Evaluating and Augmenting Neural NLIDB on Real-world Linguistic and Schema VariationsPingchuan Ma, Shuai WangVLDB 2022 · 38 citations
  3. 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
  4. Grounding Natural Language to SQL Translation with Data-Based Self-ExplanationsYuankai Fan, Tonghui Ren, Can Huang, Zhenying He et al.ICDE 2025 · 7 citations
  5. NL2SQLBench: A Modular Benchmarking Framework for LLM-Enabled NL2SQL SolutionsShizheng Hou, Wenqi Pei, Nuo Chen, Quang-Trung Ta et al.VLDB 2026 · 1 citation
Dusk over the sea between two cliffs drawn in fine vertical lines