You need to agree to share your contact information to access this model
This repository is publicly accessible, but you have to accept the conditions to access its files and content.
This checkpoint is an intermediate research artifact from an active TKDE extension of FINER-SQL (chained execution-feedback RL). Access is manual approval only while the paper is under development.
Log in or Sign Up to review the conditions and access this model content.
chained-sql-0.5b-sft-4teacher
Status: research checkpoint (gated, manual approval). This is the SFT-only baseline for an agentic generate → execute → self-verify → regenerate Text-to-SQL policy, released as an intermediate artifact of the FINER-SQL TKDE extension (chained execution-feedback RL). It is the starting policy for a subsequent GRPO stage and is not the final model — do not compare its numbers to FINER-SQL-0.5B's published post-GRPO results.
Supersedes
thanhdath/chained-sql-0.5b-sft-v2, which was trained on the wrong dataset (only 2 of the intended 4 teacher models). This checkpoint is trained on the correct, full 4-teacher dataset.
Model details
- Base model:
Qwen/Qwen2.5-Coder-0.5B-Instruct - Architecture: Qwen2ForCausalLM, 0.5B params, bf16
- Training paradigm: 2-epoch multi-turn agentic supervised fine-tuning. Each training
trajectory is a multi-turn conversation: per turn, the assistant emits
<think>…</think>\n<sql>…</sql>; the SQL is executed against the target database and the result (or error) is fed back as an<observation>…</observation>user turn; the model self-verifies and regenerates if needed. A trajectory confirms (terminates) when the assistant repeats an identical SQL query across consecutive turns, up to a budget of 5 turns. - Loss masking: assistant-only loss. Prompt tokens and
<observation>execution-feedback tokens are masked out of the loss; only the assistant's generated content (including the<|im_end|>turn terminator) contributes to the gradient. Verified at 100% token-level agreement against an independent offset-mapping oracle (spot-checked across 200/200 rows, including tag-less and max-turn edge cases; 0 observation-token leaks into the trainable mask). - Dataset:
thanhdath/chained-sql-multidialect— all 75,858 agentic trajectories, distilled from 4 teacher models:gpt-oss-120b(19,038),deepseek-v4-flash(18,793),glm-4.7-flash(18,976),qwen3.5-35b-a3b(19,061). Used fully unfiltered by design (no confirmation-status, tag-presence, or correctness filtering) — only 2 of 75,858 rows (those exceeding the 32,768-token training context) were excluded, mechanically, by the trainer's--max_lengthcutoff. - Trainer:
trl-llm-trainingfork'sscripts/sft.py(this repo's vendored copy lives attrl_llm_training/in the source repo), run with:max_length = 32768- effective batch size 64 (per-device batch 8 × gradient accumulation 8)
- learning rate 1e-5, cosine schedule
- precision bf16
- hardware: single A100 (ICT Griffith cluster, gn061)
- Final training metrics:
train_loss = 0.8640, mean token accuracy = 0.8633 (assistant tokens only) — 344M trained tokens, 2 epochs. This is a substantial improvement over the (wrong-dataset) v2 run's 0.773 token accuracy.
Evaluation — BIRD dev, agentic protocol (SFT-only baseline)
Greedy decoding (temperature 0, n=1), up to 5 turns of generate→execute→self-verify per sample, full official BIRD dev set (1,534 samples).
| Metric | Value |
|---|---|
| EX overall | 12.84% |
| EX — simple | 17.73% |
| EX — moderate | 6.25% |
| EX — challenging | 2.76% |
| Convergence rate (same SQL twice, executable) | 57.8% |
| Exec-ok rate | 60.2% |
| Format violation rate | 16.2% |
| Avg. turns used | 3.35 |
This is a greedy, single-sample, SFT-only number and is not directly comparable to FINER-SQL-0.5B's reported 50.85 EX, which uses post-GRPO policy + n=30 majority voting. It is the pre-GRPO baseline this checkpoint is meant to establish. Relative to the (wrong-dataset) v2 checkpoint, this run improves convergence (57.8% vs 41.7%) and exec-ok rate (60.2% vs 45.2%) substantially, though overall EX is roughly comparable (12.84% vs 12.65%) — the follow-on GRPO stage (execution + format + convergence rewards) is what's expected to move EX materially.
Evaluation artifacts are included under
eval/bird_dev_sft_4t_full/ in this repo: summary.json (metrics
above) and results.jsonl (per-sample predictions/outcomes), plus the official BIRD submission
file predict_dev.json. The full per-turn conversation trajectories (trajectories.jsonl,
~22MB) were not uploaded here for size; they are kept locally at
campaigns/chained_05b_tkde/eval_results/sft_4t_full_bird_dev/trajectories.jsonl in the source
repo.
Usage
The model expects a multi-turn agentic interaction: assistant emits <think>…</think> then
<sql>…</sql>, the caller executes the SQL and appends the result as an <observation>…</observation>
user turn, and the loop repeats until the assistant's SQL converges (repeats identically across
turns) or the turn budget is hit.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "thanhdath/chained-sql-0.5b-sft-4teacher"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="bfloat16", device_map="auto")
messages = [
{"role": "system", "content": SYSTEM_PROMPT}, # dialect + schema + <think>/<sql> protocol rules
{"role": "user", "content": QUESTION_WITH_SCHEMA},
]
MAX_TURNS = 5
prev_sql = None
final_sql = None
for turn in range(MAX_TURNS):
prompt = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
reply = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
messages.append({"role": "assistant", "content": reply})
sql = extract_sql(reply) # parse the <sql>...</sql> block
if sql == prev_sql: # convergence: model re-affirmed the same query
final_sql = sql
break
prev_sql = sql
exec_result_or_error = execute_sql(sql) # run against the target DB
observation = f"<observation>{format_result(exec_result_or_error)}</observation>"
messages.append({"role": "user", "content": observation})
final_sql = sql
print(final_sql)
The tokenizer's chat_template.jinja (included in this repo) contains {% generation %}
markers used at training time to compute the assistant-only loss mask; they are inert for
plain inference (apply_chat_template(..., tokenize=False, add_generation_prompt=True) works
as shown above).
Intended use & limitations
- Research artifact for the FINER-SQL TKDE extension studying chained execution-feedback RL for small (0.5B) Text-to-SQL policies. Not tuned for production use.
- SFT-only: has not yet received the GRPO execution/format/convergence reward stage.
- Trained on a fully unfiltered dataset by design — includes trajectories that never converged, had format violations, or ended incorrect. This is intentional: filtering is left to the downstream GRPO reward stage rather than the SFT data curation step.
- Repo is gated with manual approval — this is an intentional access-control choice for an in-progress research checkpoint, not a claim of restricted licensing (weights are Apache-2.0, inherited from the base model).
- Downloads last month
- -
Model tree for thanhdath/chained-sql-0.5b-sft-4teacher
Base model
Qwen/Qwen2.5-0.5B