--- license: cc-by-nc-4.0 language: [en] tags: [text-to-sql, reward-modeling, grpo, counterfactual, sqlite, lexsi-hackathon] pretty_name: Counterfactual-DB rewards for SQL agents --- # Counterfactual-DB rewards for SQL agents: data, results and rollout logs **Lexsi Labs AI Safety & Alignment Hackathon, Track 3 (PS #6 data and database agents + #9 reward design and reward-hacking defences), team Teen_khapeetars:** Shreshth Rai (lead, [@hi-phi-r25i](https://huggingface.co/hi-phi-r25i)), Rishii Kumar Singh ([@LogicPalette](https://huggingface.co/LogicPalette)), Aksh Aggarwal ([@AkshAgg](https://huggingface.co/AkshAgg)). Collections: [models](https://huggingface.co/collections/sqlcf-lexsi/counterfactual-db-rewards-for-a-small-sql-agent-6af174f77dbae0bf0a54c3c4), [data](https://huggingface.co/collections/sqlcf-lexsi/counterfactual-sql-data-rollouts-and-traces-6af479430243b7731f85d144) · [Demo](https://huggingface.co/spaces/sqlcf-lexsi/counterfactual-sql-demo) · [Data](https://huggingface.co/datasets/sqlcf-lexsi/counterfactual-sql-data) · Adapters: [SFT](https://huggingface.co/sqlcf-lexsi/tiny-aya-global-sqlcf-sft), [GRPO-B](https://huggingface.co/sqlcf-lexsi/tiny-aya-global-sqlcf-grpo-b), [GRPO-C](https://huggingface.co/sqlcf-lexsi/tiny-aya-global-sqlcf-grpo-c) · [Code](https://github.com/RishiiGamer2201/sexsi_hack) · [Write-up](https://github.com/RishiiGamer2201/sexsi_hack/blob/main/ARTICLE.md) Every number in the write-up is re-derived from these files by `python verify_all.py` in the code repo. ```python import tarfile from huggingface_hub import snapshot_download d = snapshot_download("sqlcf-lexsi/counterfactual-sql-data", repo_type="dataset") for split in ("audit", "train", "test"): tarfile.open(f"{d}/{split}/dbs.tar.gz").extractall(f"{d}/{split}") # SQLite DBs next to items.jsonl ``` | Path | What | |---|---| | `{audit,train,test}/items.jsonl` | Questions, gold SQL, per-item DB paths and gold results on the original + counterfactual DBs | | `{audit,train,test}/dbs.tar.gz` | The SQLite DBs (original and counterfactual copies); extract in place | | `train/grpo_items.jsonl` | GRPO prompts (SFT pass rate in (0,1); 3 templates held out of SFT) | | `sft.jsonl`, `sft_all_templates.jsonl` | Scripted oracle trajectories for the SFT warm start | | `results/e0_*.json`, `results/e1_*.json`, `figure*.png` | Reward audit (FP/FN per reward) and blind rate vs DB size | | `results/traj_.jsonl` | Test trajectories: base, sft, sft_ho, GRPO B, GRPO C, Command A, sft_distil (E9), dpo_std / dpo_cf (E10) | | `results/e4_eval.json` | Verified / single-DB accuracy, silent error, smuggling, pass^k, McNemar, bootstrap | | `results/a2_spider_lucky.json` | E6: Spider-dev lucky passes of 8 published systems (question indices only; predictions from bossben/ESMp, DBs from Zhong et al. 2020) | | `results/a3_skyrl_audit.json` | E7: SkyRL-SQL reward audit on the E0 candidates | | `results/a4_selfconsistency.json` | E8: gold-free majority vote and shaky-answer flag on the test trajectories | | `results/teacher_command_a.jsonl`, `results/d1_teacher_filter.json` | E9: Command A plan + SQL on the 353 SFT train items; lucky answers a single-DB filter would keep | | `sft_distil.jsonl` | E9: the SFT trajectories with the 211 counterfactual-verified teacher endings swapped in (`traj_sft_distil` is the resulting model) | | `runs/traj_sft_ho_grpoprompts.jsonl` | sft_ho's 2670 rollouts on the 445 GRPO prompts (G = 6, T = 1.0): the source of the E10 DPO pairs, replayed by E11 and E12 | | `dpo_std.jsonl`, `dpo_cf.jsonl`, `results/dpo_pairs.json` | E10: DPO pairs from those rollouts, single-DB vs counterfactual labels (`traj_dpo_` are the resulting models) | | `results/e11_partial_credit.json` | E11: partial-credit rewards audited like E0 and replayed on the GRPO rollouts | | `results/e12_period_copies.json` | E12: period-edge copies vs date-filter bugs, and replayed on real answers (the copies are in `/dbs/*/period/`) | | `runs/grpo__rewards.jsonl` | Every GRPO rollout: final SQL, reward, per-DB pass vector | | `runs/grpo_/` | `lexsi_provenance.json`, training config and stats | Synthetic e-commerce data from a seeded generator; no personal data. Rollouts contain outputs of Tiny Aya Global (CC-BY-NC-4.0) and Cohere Command A, hence the non-commercial licence.