SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2506.00391 · ACL · 2025

SHARE: An SLM-based Hierarchical Action CorREction Assistant for Text-to-SQL

Jinyang Li, Ge Qu, Bowen Qin, Nan Huo, Chenhao Ma, Reynold Cheng, Xiaolong Li

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 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; 0 honoured the contract we drafted, 0 violated it and 9 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-24; 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/2506.00391.json · badge: /api/ran/2506.00391.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
quge2023/SHARE canonical (classifier label)
classifier basis not recorded on the link
9 ran · 2 no recorded run
FunctionStatusWhere it lives
api_request Ran
ran on a synthesized input
quge2023/SHARE/src/call_models/call_apis.py
code served (permissive licence) · get_code("89514e47407d67c9")
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 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.

import torch
import torch.nn as nn
from unittest.mock import Mock, MagicMock

torch.manual_seed(0)

# Create mock message objects
mock_message = Mock()
mock_message.content = "This is a test response from the LLM."

# Create mock usage object
mock_usage = Mock()
mock_usage.completion_tokens = 42
mock_usage.prompt_tokens = 10
mock_usage.total_tokens = 52

# Create mock choice object
mock_choice = Mock()
mock_choice.message = mock_message

# Create mock completion object
mock_completion = Mock()
mock_completion.choices = [mock_choice]
mock_completion.usage = mock_usage

# Create mock client with chat.completions.create method
mock_client = Mock()
mock_client.chat = Mock()
mock_client.chat.completions = Mock()
mock_client.chat.completions.create = Mock(return_value=mock_completion)

# Define messages as list of dicts
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello, how are you?"}
]

# Define engine as a string (model name)
engine = "gpt-4"

# Define client as the mock client
client = mock_client

# Define backend as a string
backend = "openai"

# Construct ARGS dict with all parameters
ARGS = {
    "messages": messages,
    "engine": engine,
    "client": client,
    "backend": backend,
    "temperature": 0.7,
    "max_tokens": 256,
    "top_p": 0.95,
    "frequency_penalty": 0.0,
    "presence_penalty": 0.0,
    "stop": None
}
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 1, 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
filter_output Ran
ran on a synthesized input
quge2023/SHARE/src/call_models/vllm_infer.py
code served (permissive licence) · get_code("6d74f1fb350a4cad")
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 str. 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

torch.manual_seed(0)

ARGS = {
    "response": "Hello world"
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
generate_schema Ran
ran on a synthesized input
quge2023/SHARE/src/train/prepare_data_for_sam.py
code served (permissive licence) · get_code("68b84e33a25b0012")
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.

# Setup code for generate_schema function

# Analyze the function: generate_schema takes table_json parameter
# which is iterated over. Each element (db_info) needs:
#   - 'db_id' key
#   - 'table_names_original' key with a list of table names
#   - 'column_names_original' key with a list of tuples (table_idx, column_name)

# Build minimal test data
table_json = [
    {
        'db_id': 'database_1',
        'table_names_original': ['users', 'orders'],
        'column_names_original': [
            (-1, 'id'),  # Special entry with -1 index (skipped by [1:])
            (0, 'user_id'),
            (0, 'user name'),  # Has space to test backtick logic
            (1, 'order_id'),
            (1, 'user_id'),
        ]
    },
    {
        'db_id': 'database_2',
        'table_names_original': ['products', 'inventory'],
        'column_names_original': [
            (-1, 'id'),
            (0, 'product_id'),
            (0, 'product name'),  # Has space
            (1, 'inventory_count'),
            (1, 'location'),
        ]
    }
]

ARGS = {
    'table_json': table_json
}
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
generate_schema_for_db Ran
ran on a synthesized input
quge2023/SHARE/src/train/prepare_data_for_sam.py
code served (permissive licence) · get_code("3cd8e595be361fb6")
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 str. 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.

# Analyze the function to understand what db_info needs to contain
# The function expects:
# - db_info['table_names_original']: list of table names
# - db_info['column_names_original']: list of tuples (table_index, column_name)
#   where the first element is skipped (index [1:])

db_info = {
    'table_names_original': ['users', 'orders', 'products'],
    'column_names_original': [
        (0, 'dummy'),  # This gets skipped due to [1:]
        (0, 'user_id'),
        (0, 'user name'),  # Has space to test backtick logic
        (1, 'order_id'),
        (1, 'order date'),  # Has space to test backtick logic
        (2, 'product_id'),
        (2, 'product_name'),
    ]
}

ARGS = {
    'db_info': db_info
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
get_abs_path Ran
ran on a synthesized input
quge2023/SHARE/src/utils.py
code served (permissive licence) · get_code("f83563c8d3afa0ce")
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 str. 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 os
import tempfile

# Create temporary directories for testing
base_dir = tempfile.gettempdir()
sub_path_1 = "subdir/nested"
sub_path_2 = ""

# Test case 1: with sub_path
ARGS = {
    "base_dir": base_dir,
    "sub_path": sub_path_1
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
load_jsonl Ran
ran on a synthesized input
quge2023/SHARE/src/utils.py
code served (permissive licence) · get_code("32da31b37eea7836")
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.

import json
import tempfile
import os

# Create a temporary JSONL file with test data
temp_dir = tempfile.mkdtemp()
file_path = os.path.join(temp_dir, "test_data.jsonl")

# Write test data to JSONL file
test_data = [
    {"id": 1, "text": "hello world"},
    {"id": 2, "text": "foo bar"},
    {"id": 3, "value": 42}
]

with open(file_path, 'w', encoding='utf-8') as f:
    for item in test_data:
        f.write(json.dumps(item) + '\n')

ARGS = {
    "file_path": file_path
}
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
process_batch_data Ran
ran on a synthesized input
quge2023/SHARE/src/call_models/vllm_infer.py
code served (permissive licence) · get_code("709be4079ef13a12")
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.

import torch
import sys

torch.manual_seed(0)

# Construct a simple data_list with numeric items
data_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# batch_size parameter
batch_size = 3

ARGS = {
    "data_list": data_list,
    "batch_size": batch_size,
}
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 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
re_keywords Ran
ran on a synthesized input
quge2023/SHARE/src/utils.py
code served (permissive licence) · get_code("99d7384fefccf53d")
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 str. 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 re

def re_keywords(input, keyword):
    match = re.search(f'```{keyword}(.*?)```', input, re.DOTALL)
    tmp = match.group(1).strip() if match else None
    if not tmp:
        tmp = ''
    return tmp

# Setup code
ARGS = {
    'input': '```python\nprint("hello world")\n```',
    'keyword': 'python'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
read_sqls Ran
ran on a synthesized input
quge2023/SHARE/src/train/prepare_data_for_lom.py
code served (permissive licence) · get_code("98f9a5dde4818279")
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 os
import tempfile

# Create temporary directory structure for databases
temp_dir = tempfile.mkdtemp()
db_dir = os.path.join(temp_dir, "databases")
os.makedirs(db_dir, exist_ok=True)

# Create a sample database directory and file
db_id_1 = "db_1"
db_path_1 = os.path.join(db_dir, db_id_1)
os.makedirs(db_path_1, exist_ok=True)
with open(os.path.join(db_path_1, f"{db_id_1}.sqlite"), "w") as f:
    f.write("dummy")

db_id_2 = "db_2"
db_path_2 = os.path.join(db_dir, db_id_2)
os.makedirs(db_path_2, exist_ok=True)
with open(os.path.join(db_path_2, f"{db_id_2}.sqlite"), "w") as f:
    f.write("dummy")

# Construct data_json
data_json = {
    0: {
        "SQL": "SELECT * FROM table1 WHERE id = 1",
        "db_id": db_id_1
    },
    1: {
        "SQL": "SELECT COUNT(*) FROM table2",
        "db_id": db_id_2
    }
}

# Construct baseline_sql_json
baseline_sql_json = {
    "0": "SELECT * FROM table1",
    "1": "SELECT * FROM table2"
}

ARGS = {
    "data_json": data_json,
    "baseline_sql_json": baseline_sql_json,
    "db_dir": db_dir
}
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 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
api_infer Not yet run
unverified (harvested, no recorded run)
quge2023/SHARE/src/call_models/call_apis.py
code served (permissive licence) · get_code("490e585f3dbab236")
How it ran

no invocation recorded.

api_infer_single Not yet run
unverified (harvested, no recorded run)
quge2023/SHARE/src/call_models/call_apis.py
code served (permissive licence) · get_code("ce4fe4c4ff578829")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 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.

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-24.

Repositories linked to this paper

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

Abstract

Current self-correction approaches in text-to-SQL face two critical limitations: 1) Conventional self-correction methods rely on recursive self-calls of LLMs, resulting in multiplicative computational overhead, and 2) LLMs struggle to implement effective error detection and correction for declarative SQL queries, as they fail to demonstrate the underlying reasoning path. In this work, we propose SHARE, an SLM-based Hierarchical Action corREction assistant that enables LLMs to perform more precise error localization and efficient correction. SHARE orchestrates three specialized Small Language Models (SLMs) in a sequential pipeline, where it first transforms declarative SQL queries into stepwise action trajectories that reveal underlying reasoning, followed by a two-phase granular refinement. We further propose a novel hierarchical self-evolution strategy for data-efficient training. Experimental results demonstrate that SHARE effectively enhances self-correction capabilities while proving robust across various LLMs. Furthermore, our comprehensive analysis shows that SHARE maintains strong performance even in low-resource training settings, which is particularly valuable for text-to-SQL applications with data privacy constraints. For reproducibility, we release our code at https: //github.com/quge2023/SHARE.

For agents

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

get_harvested_code_for_paper("2506.00391")
get_code_for_paper("2506.00391")
have("2506.00391")

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

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

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

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

Connect an agent — have() is free.