thanhdath commited on
Commit
06d06ae
·
verified ·
1 Parent(s): eafac5d

docs: handoff for COLLAB > INDEP task

Browse files
Files changed (1) hide show
  1. HANDOFF_COLLAB_TASK.md +275 -0
HANDOFF_COLLAB_TASK.md ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Handoff: Make COLLAB > INDEP at end-to-end EX (target ≥1pp, stretch ≥2pp)
2
+
3
+ ## The problem in one line
4
+
5
+ Our paper-format ORPO **validator-internal reward-accuracy** strongly favors COLLAB over INDEP
6
+ (+10pp on val-sel, +17.7pp on val-cond), but **end-to-end selector EX is identical** (COLLAB 59.97% vs INDEP 60.31% — INDEP is actually 0.34pp ahead). The collab training signal isn't translating to pipeline gains.
7
+
8
+ **Your goal**: lift the COLLAB pipeline's selector EX so that it **beats INDEP by ≥1pp** (stretch goal: ≥2pp gap) on full BIRD-dev (1524 questions).
9
+
10
+ This must show in the **pipeline metric the paper cares about** (`compute_bestofn_with_selector.py` trained selector EX), not just the validator-internal `eval_rewards/accuracies`.
11
+
12
+ ---
13
+
14
+ ## 1. Current ground truth (full BIRD-dev, 1524 questions)
15
+
16
+ | Config | planner@1 (T=0) | pipeline@1 (T=0) | oracle pass@8 | **trained selector EX** |
17
+ |---|---|---|---|---|
18
+ | PLANNER-only | **51.54%** | 51.54% | 70.80% | — |
19
+ | SFT-VF (paper validators, no ORPO) | 51.48% | 52.20% | 71.65% | **59.91%** |
20
+ | **ORPO iter1 COLLAB** | 51.08% | 51.81% | 71.19% | **59.97%** |
21
+ | **ORPO iter1 INDEP** | 51.74% | 52.59% | 71.95% | **60.31%** |
22
+
23
+ Validator-internal reward accuracies (test_dpo split, what ORPO optimizes):
24
+
25
+ | Validator | eval_loss | eval_rewards/accuracies |
26
+ |---|---|---|
27
+ | **val-sel COLLAB** | 0.174 | **69.7%** |
28
+ | val-sel INDEP | 0.210 | 59.7% |
29
+ | **val-cond COLLAB** | 0.148 | **89.7%** |
30
+ | val-cond INDEP | 0.163 | 72.0% |
31
+
32
+ **Reading the gap**: COLLAB's chosen/rejected discrimination training succeeded, but at inference the chosen "correct" critiques don't lead to materially different fixer outputs (or different pipeline EX) than INDEP's.
33
+
34
+ ---
35
+
36
+ ## 2. Why collab SHOULD be better than indep (paper Alg. 2 intuition)
37
+
38
+ | Mode | What "chosen" means | What signal it carries |
39
+ |---|---|---|
40
+ | **INDEP** | critique whose `Conclude:` matches a HEURISTIC over planner-vs-gold correctness | Local: was the critique text consistent with whether planner was correct? Surface-level. |
41
+ | **COLLAB** | critique that, when fed to the fixer, produces a correct final SQL | End-to-end: did this critique HELP the downstream fixer produce correct SQL? |
42
+
43
+ If the fixer **actually uses critique content**, COLLAB's signal carries downstream-aware information INDEP doesn't have. If the fixer **ignores critique**, COLLAB signal collapses to noise + the fixer's intrinsic correctness, and INDEP wins on cleaner labels.
44
+
45
+ ---
46
+
47
+ ## 3. Diagnosis: why our collab signal is currently weak
48
+
49
+ Three structural issues identified in this session — partially mitigated, not fixed:
50
+
51
+ ### 3.1 The fixer was trained on a FIXED critique template
52
+
53
+ [`build_orpo_data.py:245`](https://huggingface.co/datasets/thanhdath/mats-sql-bundle/blob/main/scripts/build_orpo_data.py) (in the snapshot uploaded to `thanhdath/mats-sql-bundle/scripts/`):
54
+
55
+ ```python
56
+ val_critique = "<select>\nSELECT.\nINCORRECT\n</select>\n\n<condition>\nCONDITION.\nINCORRECT\n</condition>"
57
+ ```
58
+
59
+ Every fixer SFT example uses this **identical** critique. The fixer never learned to condition its output on critique content. At collab data-gen time we feed K=4 *diverse* critiques per question, but the fixer's output is largely invariant to the critique — so chosen vs rejected critiques produce near-identical fixer SQLs → ORPO sees a low-information signal.
60
+
61
+ **Evidence**: collab pair-formation rate is 0.33 pairs/question (650 pairs from 2000 q) vs independent's 1.78 pairs/question (3565 pairs from 2000 q). The fixer judging step is collapsing — most critiques bucket identically.
62
+
63
+ ### 3.2 Data-gen flow ≠ inference flow
64
+
65
+ At collab data-gen, the fixer runs for EVERY critique regardless of what the critique says. At inference, the fixer is gated by `planner_exec_ok=False`. This mismatch means the collab training distribution doesn't reflect how the validator actually contributes at inference (where it primarily votes "this candidate is good / bad" rather than steering a per-call fixer rewrite).
66
+
67
+ We added a `collab_v2` mode in `build_orpo_data.py` (`--mode collab_v2`) that simulates inference: critique-says-`Conclude:correct` → keep planner SQL; else → run fixer; chosen/rejected by end-to-end correctness. **It hasn't been used to retrain validators yet** — that's the obvious next experiment.
68
+
69
+ ### 3.3 Small K + small dataset
70
+
71
+ `build_orpo_data.py` uses K=4 critiques per question in our runs. With paper-format validators that are already fairly calibrated, 4 critiques often land in the same bucket → 0 pairs for that question. Net pair yield is low for COLLAB.
72
+
73
+ ---
74
+
75
+ ## 4. Concrete experiments to flip the gap (ranked by ROI)
76
+
77
+ ### E1. **Train a CRITIQUE-AWARE fixer** ⭐ highest ROI
78
+
79
+ The biggest single thing keeping COLLAB ≈ INDEP. Rebuild the fixer SFT data so each example has a DIFFERENT critique:
80
+
81
+ ```
82
+ For each BIRD-train question with planner_exec_ok=False:
83
+ Generate K=4 validator critiques (val-sel + val-cond, paper-format)
84
+ For each critique:
85
+ Run fixer at T=1.0, get fix_sql
86
+ Score correctness
87
+ Form (critique, fix) pairs:
88
+ chosen = (good_critique, correct_fix)
89
+ rejected = (bad_critique, wrong_fix)
90
+ Save with critique embedded in the prompt.
91
+ ```
92
+
93
+ Then ORPO-train the fixer on this data. Now the fixer LEARNS to use critique content.
94
+
95
+ When the fixer becomes critique-aware, **collab's "fixer-judged chosen/rejected" signal becomes informative** (different critiques → different fix outputs → different correctness labels), so retraining COLLAB validators on iter2 data will discriminate better than INDEP.
96
+
97
+ Builder skeleton lives in [`scripts/build_orpo_data.py:build_fixer_data`](models/fixer-1B-orpo-iter1) — currently uses the fixed critique. Replace `val_critique = "<select>...INCORRECT..."` with per-row diverse critiques sampled from the SFT validators.
98
+
99
+ ### E2. **Train iter2 COLLAB validators with the new fixer + `collab_v2` mode** ⭐ high ROI
100
+
101
+ Once E1 produces a critique-aware fixer (call it `fixer-1B-orpo-iter2`):
102
+
103
+ ```bash
104
+ python scripts/build_orpo_data.py --agent validator_sel --mode collab_v2 \
105
+ --planner_host ... --validator_host <SFT-paper> --fixer_host <fixer-iter2> \
106
+ --K 8 --temperature 1.0 --max_questions 2000 \
107
+ --out data/hf_orpo_val_sel_paper_iter2_collab
108
+ ```
109
+
110
+ Note: **K=8 instead of K=4** for more pair-yield diversity. **`collab_v2`** for inference-aligned chosen/rejected.
111
+
112
+ Then ORPO iter2 on top of iter1 COLLAB. Expected gain: each ORPO iter typically lifts 0.3-0.8pp at pipeline level; with a working collab signal, iter2 should move COLLAB above INDEP.
113
+
114
+ ### E3. **Joint K-rollout training (paper Alg. 2 in true form)**
115
+
116
+ The paper's joint training uses ONE rollout pool for ALL agents. We currently:
117
+
118
+ - Generate per-agent ORPO datasets independently (planner pool, val-sel pool, val-cond pool, fixer pool)
119
+ - Train each agent on its own pool
120
+
121
+ True Alg. 2: for each BIRD-train question, do K=8 FULL pipeline rollouts (planner→val-sel→val-cond→fixer→final SQL). Each rollout produces decisions at each agent. Then:
122
+
123
+ - planner chosen/rejected = the rollouts whose FINAL SQL was correct (vs not)
124
+ - val-sel chosen/rejected = the critiques that came from rollouts whose final was correct
125
+ - val-cond chosen/rejected = same
126
+ - fixer chosen/rejected = same
127
+
128
+ This couples the agents — each one is rewarded for decisions that helped the END-TO-END outcome. This is what COLLAB is supposed to be in the paper but our current `--mode collab` only does step-2 (fixer judges critique) not step-1 (final-outcome judges everything).
129
+
130
+ Build script doesn't exist; would need writing.
131
+
132
+ ### E4. **Verify the fixer is gated correctly at inference**
133
+
134
+ [`scripts/run_pipeline_rollouts.py`](models/) wraps paper-format critique inside `<select>/<condition>` tags before sending to the fixer (since fixer was trained with wrapper tags). Inspect 5-10 fixer prompts in a `paper_COLLAB_par_passAt8_bird_dev.jsonl` row to confirm:
135
+ 1. Critique content is reaching the fixer
136
+ 2. Fixer's output actually responds to critique content (i.e., `fixed_sql != planner_sql` when critique says "INCORRECT")
137
+
138
+ If the fixer is ignoring critique content, E1 (critique-aware retraining) is mandatory.
139
+
140
+ ### E5. **Tighten the comparison statistic**
141
+
142
+ Selector EX over n=1524 has ~1.2pp standard error at 60% — our COLLAB-INDEP gap of 0.34pp is well within noise. To call a ≥1pp gap "real":
143
+ - Report bootstrap CI over rollouts (resample questions with replacement, 1000 iters)
144
+ - Or report the gap on a fixed selector + fixed K=8 rollouts so the only variable is which validator was used
145
+
146
+ If the next iter shows COLLAB +1.2pp over INDEP, bootstrap will say whether it's statistically real or sampling.
147
+
148
+ ---
149
+
150
+ ## 5. Resources (all on `thanhdath/mats-sql-bundle` HF dataset + local)
151
+
152
+ ### Pre-trained ckpts (already on HF, can re-download or use directly)
153
+
154
+ ```
155
+ hf:thanhdath/mats-sql-bundle:models/planner-3B-sft/
156
+ hf:thanhdath/mats-sql-bundle:models/planner-3B-orpo-iter1/
157
+ hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-sft-paper/
158
+ hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-orpo-iter1-collab-paper/
159
+ hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-orpo-iter1-indep-paper/
160
+ hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-sft-paper/
161
+ hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-orpo-iter1-collab-paper/
162
+ hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-orpo-iter1-indep-paper/
163
+ hf:thanhdath/mats-sql-bundle:models/fixer-1B-sft/ ← E1 retrains THIS
164
+ hf:thanhdath/mats-sql-bundle:models/fixer-1B-orpo-iter1/ ← E1's alt input
165
+ hf:thanhdath/mats-sql-bundle:models/selector-3B-sft/ ← keep frozen for fair compare
166
+ ```
167
+
168
+ Local copies on weka (if you have the same compute):
169
+
170
+ ```
171
+ /weka/s225250685/mats-tist/alignment-handbook/output/<same names>
172
+ ```
173
+
174
+ ### Pre-built ORPO iter1 paper datasets
175
+
176
+ ```
177
+ data/hf_orpo_val_sel_paper_iter1_collab 617 train + 33 test pairs
178
+ data/hf_orpo_val_sel_paper_iter1_indep 3386 train + 179 test pairs
179
+ data/hf_orpo_val_cond_paper_iter1_collab 545 train + 29 test pairs
180
+ data/hf_orpo_val_cond_paper_iter1_indep 1553 train + 82 test pairs
181
+ ```
182
+
183
+ ### Scripts
184
+
185
+ ```
186
+ scripts/build_orpo_data.py # has --mode {collab, collab_v2, independent}
187
+ scripts/run_pipeline_rollouts.py # K=8 pipeline eval; emits *_passAt8_bird_dev.jsonl
188
+ scripts/compute_bestofn_with_selector.py # runs trained selector, reports EX
189
+ scripts/gen_validator_sft_qwen72b.py # Qwen-72B teacher for paper-format SFT (already ran)
190
+ scripts/train_sft_completion_only.py # SFT trainer
191
+ ```
192
+
193
+ ### ORPO recipes
194
+
195
+ ```
196
+ recipes/iter1-paper/orpo-val-sel-collab-paper.yaml
197
+ recipes/iter1-paper/orpo-val-sel-indep-paper.yaml
198
+ recipes/iter1-paper/orpo-val-cond-collab-paper.yaml
199
+ recipes/iter1-paper/orpo-val-cond-indep-paper.yaml
200
+ ```
201
+
202
+ For an iter2, copy + change `model_name_or_path` to the iter1 ORPO ckpt, point `dataset_mixer` at the new iter2 dataset, output to `orpo-val-*-iter2-paper`.
203
+
204
+ ### Reference rollouts (use these to eval without re-running the GPU pipeline)
205
+
206
+ ```
207
+ eval_results/paper_SFT_VF_passAt8_bird_dev.jsonl # K=8 SFT validators
208
+ eval_results/paper_COLLAB_par_passAt8_bird_dev.jsonl # K=8 ORPO COLLAB
209
+ eval_results/paper_INDEP_par_passAt8_bird_dev.jsonl # K=8 ORPO INDEP
210
+ eval_results/paper_greedy_*_passAt1_bird_dev.jsonl # 4 greedy configs
211
+ ```
212
+
213
+ ---
214
+
215
+ ## 6. Definition of done
216
+
217
+ A single command must produce a **passing** run:
218
+
219
+ ```bash
220
+ python scripts/compute_bestofn_with_selector.py \
221
+ eval_results/paper_COLLAB_iter2_passAt8_bird_dev.jsonl \
222
+ paper_COLLAB_iter2_selectorEX \
223
+ --selector_host http://localhost:8103 --row_preview
224
+ # Print: trained selector ≥ INDEP_iter2 + 1.0pp
225
+ ```
226
+
227
+ Required to ship:
228
+
229
+ 1. **K=8 BIRD-dev rollouts** for both new configs:
230
+ - `paper_COLLAB_iter2_passAt8_bird_dev.jsonl` (new agents)
231
+ - `paper_INDEP_iter2_passAt8_bird_dev.jsonl` (matched control)
232
+ 2. **Selector EX from `compute_bestofn_with_selector.py`** on both.
233
+ 3. **A bootstrap 95% CI** showing the COLLAB − INDEP gap is positive with lower bound ≥ 1pp.
234
+ 4. **Updated `thanhdath/mats-sql-bundle` README** with the new numbers.
235
+ 5. **The new iter2 ckpts pushed to HF** under `models/*-iter2-*-paper`.
236
+
237
+ ---
238
+
239
+ ## 7. Constraints (don't violate)
240
+
241
+ - **K = 8 is fixed** at inference rollout. Don't compare with K=16 etc.
242
+ - **Temperature = 1.0** for the K=8 rollouts.
243
+ - **Same selector for both configs** — use `selector-3B-sft` from the bundle, do NOT retrain the selector while making this comparison (otherwise you're conflating two changes).
244
+ - **Same planner and same fixer family across COLLAB vs INDEP at eval** — only the validators change (this is what isolates the COLLAB vs INDEP effect). If E1 retrains the fixer, evaluate COLLAB and INDEP both with the NEW fixer.
245
+ - **β = 0.1** for ORPO unless you have a specific reason to vary; β ≥ 0.5 collapsed val-sel in our runs.
246
+ - SLURM job name must be `vl` (lowercase). HF_TOKEN at `/weka/s225250685/mats-tist/.env`.
247
+ - `PYTHONNOUSERSITE=1` to avoid user-site contamination.
248
+
249
+ ---
250
+
251
+ ## 8. Suggested execution order
252
+
253
+ ```
254
+ Day 0 E4: spot-check 10 fixer prompts on disk → confirm if fixer uses critique
255
+ Day 1 E1: build critique-aware fixer SFT data (~3h) → train fixer-1B-orpo-iter2 (~1h)
256
+ Day 2 E2: build iter2 COLLAB + INDEP datasets with new fixer + collab_v2 + K=8 (~6h each)
257
+ Day 2 E2: train iter2 COLLAB + INDEP validators (4 jobs in parallel, ~1h each)
258
+ Day 3 K=8 BIRD-dev rollouts × 2 configs (~3h each parallel) → selector EX
259
+ Day 3 Bootstrap CI, write up, push to HF
260
+ ```
261
+
262
+ If E1 + E2 don't produce ≥1pp gap, drop to **E3 (joint Alg. 2)** which is the more aggressive rewrite.
263
+
264
+ ## 9. What "good" looks like at the end
265
+
266
+ ```
267
+ Selector EX
268
+ paper_SFT_VF : 59.91% (baseline, unchanged)
269
+ paper_INDEP_iter2 : 60.5±0.4% (matched control)
270
+ paper_COLLAB_iter2 : 62.0±0.4% (target — gap ≥ 1pp, bootstrap-significant)
271
+ ```
272
+
273
+ Then update the bundle README to show COLLAB ≠ INDEP, write a short summary of *why*
274
+ (critique-aware fixer + inference-aligned collab signal), and the paper claim "COLLAB > INDEP"
275
+ will be empirically supported on our reproduction.