# MATS-SQL Bundle — Progress Snapshot **Bundle**: `thanhdath/mats-sql-bundle` (HuggingFace) **Snapshot date**: 2026-05-13 --- ## Original Task Multi-agent Text2SQL pipeline reaching **pass@8 ≥ 67%** (BIRD-dev, EX). Hard constraints from project owner: - Planner ≤ 3B params - Selection ≤ 3B params - Validator(s) and Fixer ≤ 1B params each (prefer 0.5B) - Max ORPO iter-2 (no iter-3+) - **No commercial APIs (no GPT teacher)** — collaborative training must be structurally necessary - V+F (validators + fixer) must **not hurt** final accuracy and **should contribute** to acc increase - Results tables must include per-agent parameter counts - Two specialized validators per paper §Combined Validator: **v_s (selection)** and **v_c (condition)** --- ## Current Progress (latest) ### Best result so far (BIRD-dev, K=8) | Config | N | pass@8 (recall, oracle) | Trained selector (real, no leak) | Notes | |---|---|---|---|---| | 1-stage iter-2 uniform-temp | 1524 | 64.96% | — | leak-pre-patch number was 64.96 | | 1-stage iter-2 mixed-temp (0.5/0.7/0.9/1.1) | 1525 | **65.38%** | — | best recall | | 3-stage iter-2 + 0.6B v_s/v_c + ORPO fixer iter-1 | 1525 | 65.05% | — | V+F neutral (0 rescues) | | 3-stage iter-2 + 0.5B v_s + 0.6B v_c + 0.5B **replanner**-fixer iter-2 | 1525 | 65.11% | **54.30%** | leak-free selector measurement; **fixer iter-2 +0.06pp vs iter-1** | **Critical finding (2026-05-13):** `compute_bestofn_with_selector.py` had `exec_response = "OK" if is_planner_correct else "Error / no rows"` — passed the gold-graded label to the selector → trivially matched oracle. **Patched** to use actual SQL execution result. Real trained-selector accuracy is **54.30%, NOT 65%**. Selector → oracle gap = 10.81pp. ### Two headline gaps to close (target = headline EX ≥ 67%) | Gap | Current | Target | Gap | Lever | |---|---|---|---|---| | **Oracle pass@8** (recall) | 65.38% (mixed-temp) | ≥70% | +4.6pp | More diverse sampling / better fixer rescues | | **Selector → oracle** | 57.25 / 65.38 = 87.6% | ≥95% | +8.13pp | Selector v3 (more data / different arch) | ### Selector v2 results (2026-05-13 — row preview added to prompt) Retrained 3B selector with `OK. Rows preview: ` instead of bare `OK`. Closes ~3-4pp of the ~11pp gap. | Config (BIRD-dev K=8 iter-2 planner) | Oracle | Selector v1 (no rows) | **Selector v2 (rows)** | v2 gain | |---|---|---|---|---| | 1-stage uniform-temp | 64.96% | 53.94% | 56.43% | +2.49pp | | **1-stage mixed-temp** | **65.38%** | 53.64% | **57.25%** ← headline | +3.61pp | | 2-stage + ORPO fixer-iter1 | 63.04% | 52.72% | 56.02% | +3.30pp | | 3-stage + 0.6B V/V + ORPO fixer-iter1 | 65.05% | 53.11% | 56.98% | +3.87pp | | 3-stage + 0.5B V/V + 0.5B replanner-fixer | 65.11% | 53.51% | 56.66% | +3.15pp | **Headline pass@8 post-selector = 57.25%** (1-stage mixed-temp + v2 selector). Still −9.75pp from 67%. ### Per-model status | Agent | Model | Params | Status | |---|---|---|---| | Planner | Qwen2.5-Coder-3B-Instruct + ORPO iter-2 (collab) | 3B | trained ✓ | | Selector | Qwen2.5-Coder-3B-Instruct + SFT (YES/NO binary) | 3B | trained ✓ | | Validator-Selection (v_s) | Qwen2.5-Coder-0.5B-Instruct + SFT v3 | 0.5B | trained ✓ | | Validator-Condition (v_c) | Qwen3-0.6B-Instruct + SFT v3 | 0.6B | trained ✓ (0.5B variant truncated, retrain pending) | | Fixer (re-planner) | Qwen2.5-Coder-0.5B + ORPO iter-2 (replanner data) | 0.5B | trained ✓ | ### V+F contribution diagnostic (mixed-temp iter-2 K=8, 1525 q) - Validators critique 91.6% of trajectories; old fixer ignored 98.6% → 0 rescues at pass@8 - Replanner fixer (iter-2) currently flipping ~40% of trajectories (winloss=605 at 1360/1534) — net effect being measured ### Key findings - ORPO planner: SFT 64.11% → iter-1 64.26% → iter-2 64.96% (+0.70pp, diminishing returns) - Mixed-temp sampling adds +0.42pp over uniform-temp at K=8 - v3 validator data rebalanced from 8% all-OK (over-critique) to 34.5%/61% all-OK - Fixer dataset re-built as "re-planner" objective (1833 pairs): given a failed planner trajectory, produce a correct alternative from same question's K=4 trajectories - pass@8 (true recall) is the *upper bound* for trained-selector accuracy; need recall ≥70% to land headline ≥67% after selector picks --- ## What's Next (in priority order) 1. **Phase4 K=8 3-stage eval finishes** (currently 89% done, ETA 30 min) → get pass@8 with replanner-fixer. 2. **Apply patched (leak-free) selector** to all K=8 JSONLs → get true selector accuracy (not oracle). 3. **If pass@8 selector ≥67%: DONE.** Write results table with per-agent sizes. 4. **If pass@8 selector <67%:** - Re-mine fixer ORPO data on **iter-2 planner** BIRD-train rollouts (current data was from iter-1 planner → distribution shift). - Re-train fixer ORPO iter-2 on fresh data. - Consider planner sampling tricks: wider mixed-temp (0.3-1.3), nucleus variation. 5. **Make V+F contribute (currently neutral):** the 0.5B replanner fixer's `winloss` is now high (~40%) — need to check if those flips are net+ or net-. If net-, gate fixer to only run on `planner_exec_ok=False` cases. --- ## Repo contents ``` mats-sql-bundle/ ├── PROGRESS.md # this file ├── models/ │ ├── planner-iter2-collab-3B/ # 3B ORPO iter-2 planner │ ├── selector-3B-sft/ # 3B trained selector │ ├── validator-selection-0.5B-v3/ # v_s SFT │ ├── validator-condition-0.6B-v3/ # v_c SFT │ └── fixer-replanner-0.5B-iter2-orpo/ # ORPO iter-2 re-planner fixer ├── data/ │ ├── sft-validator-selection-v3/ # SFT data for v_s │ ├── sft-validator-condition-v3/ # SFT data for v_c │ ├── hf_fixer_replanner/ # ORPO data for fixer iter-2 │ └── hf_planner_collaborative_iter2/ # ORPO data for planner iter-2 ├── recipes/ │ ├── orpo-planner-collab-iter2.yaml │ ├── orpo-fixer-replanner-0.5b-iter2.yaml │ ├── validator-selection-fft-0.5b-v3.yaml │ └── validator-condition-fft-0.5b-v3.yaml └── scripts/ ├── run_pipeline_rollouts.py # rollout / 3-stage runner ├── compute_bestofn_with_selector.py # selector apply (patched) ├── compute_bestofn_metrics.py # oracle/greedy metrics ├── build_validator_2agents_v3.py # v_s/v_c data builder └── build_fixer_replanner_iter2.py # fixer re-planner data builder ``` ## How to continue from this bundle ```bash # 1. Clone the bundle (~16 GB) git clone https://huggingface.co/datasets/thanhdath/mats-sql-bundle cd mats-sql-bundle # 2. Symlink to alignment-handbook layout ln -s $(pwd)/models /path/to/alignment-handbook/output ln -s $(pwd)/data /path/to/mats-sql-tist/data/llm_alignment_imported # 3. Continue from where we left off: BIRD-dev K=8 3-stage with iter-2 planner + 0.5B agents bash scripts/run_pipeline_rollouts.py --K 8 --mixed_temp "0.5,0.7,0.9,1.1" ... # 4. To do iter-3 (if needed), re-mine fixer data on iter-2 planner BIRD-train rollouts first. ``` --- **Maintainer**: thanhdath@gmail.com / thanhdath97@gmail.com **Source repo**: /home/datht/mats-sql-tist (private dev machine)