File size: 7,651 Bytes
8377cfd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca1b742
8377cfd
ca1b742
 
 
 
8377cfd
ca1b742
 
 
 
 
 
3174d9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8377cfd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# 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: <rows>` 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)