SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.17144 · 2024

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

arXiv · PDF · Open in the Atlas

Code that ran

9 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 8 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2402.17144.json · badge: /api/ran/2402.17144.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Kaimary/MetaSQL canonical (classifier label)
classifier basis: census
9 ran · 3 no recorded run
FunctionStatusWhere it lives
candidates_sqlization Ran
ran; our contract draft was wrong, not the code
Kaimary/MetaSQL/allenmodels/dataset_readers/listwise_pair_reader_ratsql.py
code served (permissive licence) · get_code("00436a8a2dd58cad")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for candidates_sqlization function

ARGS = {
    'candidates': [
        ['select', 'from', 'Product', 'eq', 'id', '.', 'name', 'And', 'price'],
        ['from', 'Product', 'where', 'eq', 'status', '.', 'active'],
        ['Selection', 'from', 'Product', 'eq', 'category', '.', 'electronics'],
    ],
    'token_mapping': {
        'select': 'SELECT',
        'from': 'FROM',
        'Product': 'products',
        'eq': '=',
        'where': 'WHERE',
        'And': 'AND',
        'id': 'product_id',
        'name': 'product_name',
        'price': 'product_price',
        'status': 'product_status',
        'active': '1',
        'category': 'product_category',
        'electronics': 'ELECTRONICS',
        'Selection': '',
    }
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
clamp Ran
ran, honoured the contract we drafted
Kaimary/MetaSQL/allenmodels/dataset_readers/enc_preproc.py
code served (permissive licence) · get_code("6bef2da47f1a8400")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    "value": 5.7,
    "abs_max": 3.0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
clones Ran
ran; our contract draft was wrong, not the code
Kaimary/MetaSQL/allenmodels/modules/transformer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from dmirlab-group/sadga, is pointer only (licence: NONE) · get_code("ac13caa2ecfa34fe")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from dmirlab-group/sadga, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

creating_schema Ran
ran; our contract draft was wrong, not the code
Kaimary/MetaSQL/openai_generate_with_meta.py
code served (permissive licence) · get_code("5ef8c55289697887")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import json
import io

# Create a valid dataset JSON structure that matches what the function expects
dataset_dict = {
    "db_id": ["database1"],
    "table_names_original": [["users", "orders"]],
    "column_names_original": [[[-1, ""], [0, "user_id"], [0, "name"], [1, "order_id"], [1, "user_id"]]],
    "column_types": [["text", "int", "text", "int", "int"]],
    "primary_keys": [[1, 3]],  # user_id is primary key in users, order_id is primary key in orders
    "foreign_keys": [[[4, 1]]],  # user_id in orders references user_id in users
    "column_names": [["*", "user_id", "name", "order_id", "user_id"]],
    "table_names": [["users", "orders"]]
}

# Convert dict to JSON string
dataset_json_str = json.dumps(dataset_dict)

# Create a file-like object that pandas can read from
DATASET_JSON = io.StringIO(dataset_json_str)

ARGS = {
    "DATASET_JSON": DATASET_JSON
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_schema Ran
ran; our contract draft was wrong, not the code
Kaimary/MetaSQL/allenmodels/dataset_readers/listwise_pair_reader_ratsql.py
code served (permissive licence) · get_code("d3104f05227a678b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary tables.json file with valid schema structure
temp_dir = tempfile.mkdtemp()
tables_file = os.path.join(temp_dir, "tables.json")

schema_data = [
    {
        "db_id": "database1",
        "table_names_original": ["users", "orders"],
        "table_names": ["Users", "Orders"],
        "column_names_original": [[-1, "*"], [0, "user_id"], [0, "name"], [1, "order_id"], [1, "user_id"], [1, "amount"]],
        "column_types": ["text", "number", "text", "number", "number", "number"],
        "primary_keys": [2, 4],
        "foreign_keys": [[5, 2]]
    },
    {
        "db_id": "database2",
        "table_names_original": ["products"],
        "table_names": ["Products"],
        "column_names_original": [[-1, "*"], [0, "product_id"], [0, "name"], [0, "price"]],
        "column_types": ["text", "number", "text", "number"],
        "primary_keys": [2],
        "foreign_keys": []
    }
]

with open(tables_file, 'w') as f:
    json.dump(schema_data, f)

ARGS = {
    "tables_file": tables_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
relative_attention_values Ran
ran; our contract draft was wrong, not the code
Kaimary/MetaSQL/allenmodels/modules/transformer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from DMIRLAB-Group/SADGA, is pointer only (licence: NONE) · get_code("b1447ba09556aed5")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from DMIRLAB-Group/SADGA, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

table_text_encoding Ran
ran; our contract draft was wrong, not the code
Kaimary/MetaSQL/allenmodels/dataset_readers/multi_label_classifier_reader.py
code served (permissive licence) · get_code("177a4d3341a6623f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    "entity_text_list": [
        "column:value",
        "column:value",
        "row",
        "another_row"
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
to_dict_with_sorted_values Ran
ran; our contract draft was wrong, not the code
Kaimary/MetaSQL/allenmodels/dataset_readers/enc_preproc.py
code served (permissive licence) · get_code("ba31bb11956f3909")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function takes a dict d and an optional key parameter
# It iterates over items in d and sorts each value v using sorted()
# The key parameter is passed to sorted()

# Create a dict where values are lists that can be sorted
d = {
    'list_1': [3, 1, 4, 1, 5],
    'list_2': ['zebra', 'apple', 'banana'],
    'list_3': [2.5, 1.1, 3.7],
}

# Create a key function for sorting (e.g., sort by absolute value)
key_fn = lambda x: abs(x) if isinstance(x, (int, float)) else x

ARGS = {
    'd': d,
    'key': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
tree_reduce Ran
ran; our contract draft was wrong, not the code
Kaimary/MetaSQL/allenmodels/dataset_readers/listwise_pair_reader_ratsql.py
code served (permissive licence) · get_code("3be1fa204837231a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for tree_reduce function

ARGS = {
    'tree': [
        'min',
        'column1',
        'Selection',
        'table1',
        'Project',
        'avg',
        'column2'
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_foreign_keys_MYSQL_like Not yet run
unverified (harvested, no recorded run)
Kaimary/MetaSQL/openai_generate_with_meta.py
code served (permissive licence) · get_code("aebf06ad16efc68b")
How it ran

no invocation recorded.

find_primary_keys_MYSQL_like Not yet run
unverified (harvested, no recorded run)
Kaimary/MetaSQL/openai_generate_with_meta.py
code served (permissive licence) · get_code("9693d8bfedca49c8")
How it ran

no invocation recorded.

relative_attention_logits Not yet run
unverified (harvested, no recorded run)
Kaimary/MetaSQL/allenmodels/modules/transformer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from DMIRLAB-Group/SADGA, is pointer only (licence: NONE) · get_code("ccc72a1f79c00ef3")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from DMIRLAB-Group/SADGA, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
clones 3 other papers
3 dated earlier
1911.04942 (2019-11)
RAT-SQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parsers
2111.00653 (2021-11)
SADGA: Structure-Aware Dual Graph Aggregation Network for Text-to-SQL
2306.14256 (2023-06)
A Multilingual Translator to SQL with Database Schema Pruning to Improve Self-Attention
relative_attention_logits 3 other papers
3 dated earlier
1911.04942 (2019-11)
RAT-SQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parsers
2111.00653 (2021-11)
SADGA: Structure-Aware Dual Graph Aggregation Network for Text-to-SQL
2306.14256 (2023-06)
A Multilingual Translator to SQL with Database Schema Pruning to Improve Self-Attention
relative_attention_values 3 other papers
3 dated earlier
1911.04942 (2019-11)
RAT-SQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parsers
2111.00653 (2021-11)
SADGA: Structure-Aware Dual Graph Aggregation Network for Text-to-SQL
2306.14256 (2023-06)
A Multilingual Translator to SQL with Database Schema Pruning to Improve Self-Attention

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2402.17144")
get_code_for_paper("2402.17144")
have("2402.17144")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2402.17144.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2402.17144.svg)](https://syntology.ai/paper/2402.17144)

Connect an agent — have() is free.