Papers › Metasql: A Generate-then-Rank Framework for Natural Language to SQL Translation

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

27 Feb 2024arXiv:2402.17144archive 2025-07-28

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

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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2402.17144")

Code

Syntology Ran 9 of 12 code samples harvested from 1 repository linked to this paper; 3 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 8 ran with no contract checked.

By repository: official repository: 12 samples from 1 repository, 9 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Kaimary/MetaSQL officialmentioned in papermentioned on GitHubpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

12 samples harvested; 9 ran; 0 honoured the contract we drafted; 3 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · our draft was wrong
8ran
3unverified

Licence: 0 of the 12 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from Kaimary/MetaSQL. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

candidates_sqlization Kaimary/MetaSQL/allenmodels/dataset_readers/listwise_pair_reader_ratsql.py official repository ran Apache-2.0 (permissive) · 00436a8a2dd58cad · report
clamp Kaimary/MetaSQL/allenmodels/dataset_readers/enc_preproc.py official repository ran fingerprinted Apache-2.0 (permissive) · 6bef2da47f1a8400 · report
clones Kaimary/MetaSQL/allenmodels/modules/transformer.py official repository ran Apache-2.0 (permissive) · ac13caa2ecfa34fe · report
creating_schema Kaimary/MetaSQL/openai_generate_with_meta.py official repository ran Apache-2.0 (permissive) · 5ef8c55289697887 · report
load_schema Kaimary/MetaSQL/allenmodels/dataset_readers/listwise_pair_reader_ratsql.py official repository ran Apache-2.0 (permissive) · d3104f05227a678b · report
relative_attention_values Kaimary/MetaSQL/allenmodels/modules/transformer.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · b1447ba09556aed5 · report
table_text_encoding Kaimary/MetaSQL/allenmodels/dataset_readers/multi_label_classifier_reader.py official repository ran Apache-2.0 (permissive) · 177a4d3341a6623f · report
to_dict_with_sorted_values Kaimary/MetaSQL/allenmodels/dataset_readers/enc_preproc.py official repository ran Apache-2.0 (permissive) · ba31bb11956f3909 · report
tree_reduce Kaimary/MetaSQL/allenmodels/dataset_readers/listwise_pair_reader_ratsql.py official repository ran fingerprinted Apache-2.0 (permissive) · 3be1fa204837231a · report
find_foreign_keys_MYSQL_like Kaimary/MetaSQL/openai_generate_with_meta.py official repository unverified Apache-2.0 (permissive) · aebf06ad16efc68b · report
find_primary_keys_MYSQL_like Kaimary/MetaSQL/openai_generate_with_meta.py official repository unverified Apache-2.0 (permissive) · 9693d8bfedca49c8 · report
relative_attention_logits Kaimary/MetaSQL/allenmodels/modules/transformer.py official repository unverified Apache-2.0 (permissive) · ccc72a1f79c00ef3 · report

Tasks

Learning-To-RankTranslation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

SET

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections