mats-sql-bundle / HANDOFF_COLLAB_TASK.md
thanhdath's picture
docs: handoff for COLLAB > INDEP task
06d06ae verified

Handoff: Make COLLAB > INDEP at end-to-end EX (target ≥1pp, stretch ≥2pp)

The problem in one line

Our paper-format ORPO validator-internal reward-accuracy strongly favors COLLAB over INDEP (+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.

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).

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.


1. Current ground truth (full BIRD-dev, 1524 questions)

Config planner@1 (T=0) pipeline@1 (T=0) oracle pass@8 trained selector EX
PLANNER-only 51.54% 51.54% 70.80%
SFT-VF (paper validators, no ORPO) 51.48% 52.20% 71.65% 59.91%
ORPO iter1 COLLAB 51.08% 51.81% 71.19% 59.97%
ORPO iter1 INDEP 51.74% 52.59% 71.95% 60.31%

Validator-internal reward accuracies (test_dpo split, what ORPO optimizes):

Validator eval_loss eval_rewards/accuracies
val-sel COLLAB 0.174 69.7%
val-sel INDEP 0.210 59.7%
val-cond COLLAB 0.148 89.7%
val-cond INDEP 0.163 72.0%

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.


2. Why collab SHOULD be better than indep (paper Alg. 2 intuition)

Mode What "chosen" means What signal it carries
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.
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?

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.


3. Diagnosis: why our collab signal is currently weak

Three structural issues identified in this session — partially mitigated, not fixed:

3.1 The fixer was trained on a FIXED critique template

build_orpo_data.py:245 (in the snapshot uploaded to thanhdath/mats-sql-bundle/scripts/):

val_critique = "<select>\nSELECT.\nINCORRECT\n</select>\n\n<condition>\nCONDITION.\nINCORRECT\n</condition>"

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.

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.

3.2 Data-gen flow ≠ inference flow

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).

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.

3.3 Small K + small dataset

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.


4. Concrete experiments to flip the gap (ranked by ROI)

E1. Train a CRITIQUE-AWARE fixer ⭐ highest ROI

The biggest single thing keeping COLLAB ≈ INDEP. Rebuild the fixer SFT data so each example has a DIFFERENT critique:

For each BIRD-train question with planner_exec_ok=False:
  Generate K=4 validator critiques (val-sel + val-cond, paper-format)
  For each critique:
    Run fixer at T=1.0, get fix_sql
    Score correctness
  Form (critique, fix) pairs:
    chosen   = (good_critique, correct_fix)
    rejected = (bad_critique, wrong_fix)
  Save with critique embedded in the prompt.

Then ORPO-train the fixer on this data. Now the fixer LEARNS to use critique content.

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.

Builder skeleton lives in scripts/build_orpo_data.py:build_fixer_data — currently uses the fixed critique. Replace val_critique = "<select>...INCORRECT..." with per-row diverse critiques sampled from the SFT validators.

E2. Train iter2 COLLAB validators with the new fixer + collab_v2 mode ⭐ high ROI

Once E1 produces a critique-aware fixer (call it fixer-1B-orpo-iter2):

python scripts/build_orpo_data.py --agent validator_sel --mode collab_v2 \
    --planner_host ... --validator_host <SFT-paper> --fixer_host <fixer-iter2> \
    --K 8 --temperature 1.0 --max_questions 2000 \
    --out data/hf_orpo_val_sel_paper_iter2_collab

Note: K=8 instead of K=4 for more pair-yield diversity. collab_v2 for inference-aligned chosen/rejected.

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.

E3. Joint K-rollout training (paper Alg. 2 in true form)

The paper's joint training uses ONE rollout pool for ALL agents. We currently:

  • Generate per-agent ORPO datasets independently (planner pool, val-sel pool, val-cond pool, fixer pool)
  • Train each agent on its own pool

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:

  • planner chosen/rejected = the rollouts whose FINAL SQL was correct (vs not)
  • val-sel chosen/rejected = the critiques that came from rollouts whose final was correct
  • val-cond chosen/rejected = same
  • fixer chosen/rejected = same

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).

Build script doesn't exist; would need writing.

E4. Verify the fixer is gated correctly at inference

scripts/run_pipeline_rollouts.py 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:

  1. Critique content is reaching the fixer
  2. Fixer's output actually responds to critique content (i.e., fixed_sql != planner_sql when critique says "INCORRECT")

If the fixer is ignoring critique content, E1 (critique-aware retraining) is mandatory.

E5. Tighten the comparison statistic

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":

  • Report bootstrap CI over rollouts (resample questions with replacement, 1000 iters)
  • Or report the gap on a fixed selector + fixed K=8 rollouts so the only variable is which validator was used

If the next iter shows COLLAB +1.2pp over INDEP, bootstrap will say whether it's statistically real or sampling.


5. Resources (all on thanhdath/mats-sql-bundle HF dataset + local)

Pre-trained ckpts (already on HF, can re-download or use directly)

hf:thanhdath/mats-sql-bundle:models/planner-3B-sft/
hf:thanhdath/mats-sql-bundle:models/planner-3B-orpo-iter1/
hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-sft-paper/
hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-orpo-iter1-collab-paper/
hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-orpo-iter1-indep-paper/
hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-sft-paper/
hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-orpo-iter1-collab-paper/
hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-orpo-iter1-indep-paper/
hf:thanhdath/mats-sql-bundle:models/fixer-1B-sft/                          ← E1 retrains THIS
hf:thanhdath/mats-sql-bundle:models/fixer-1B-orpo-iter1/                   ← E1's alt input
hf:thanhdath/mats-sql-bundle:models/selector-3B-sft/                       ← keep frozen for fair compare

Local copies on weka (if you have the same compute):

/weka/s225250685/mats-tist/alignment-handbook/output/<same names>

Pre-built ORPO iter1 paper datasets

data/hf_orpo_val_sel_paper_iter1_collab    617 train + 33 test pairs
data/hf_orpo_val_sel_paper_iter1_indep    3386 train + 179 test pairs
data/hf_orpo_val_cond_paper_iter1_collab   545 train + 29 test pairs
data/hf_orpo_val_cond_paper_iter1_indep   1553 train + 82 test pairs

Scripts

scripts/build_orpo_data.py                  # has --mode {collab, collab_v2, independent}
scripts/run_pipeline_rollouts.py            # K=8 pipeline eval; emits *_passAt8_bird_dev.jsonl
scripts/compute_bestofn_with_selector.py    # runs trained selector, reports EX
scripts/gen_validator_sft_qwen72b.py        # Qwen-72B teacher for paper-format SFT (already ran)
scripts/train_sft_completion_only.py        # SFT trainer

ORPO recipes

recipes/iter1-paper/orpo-val-sel-collab-paper.yaml
recipes/iter1-paper/orpo-val-sel-indep-paper.yaml
recipes/iter1-paper/orpo-val-cond-collab-paper.yaml
recipes/iter1-paper/orpo-val-cond-indep-paper.yaml

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.

Reference rollouts (use these to eval without re-running the GPU pipeline)

eval_results/paper_SFT_VF_passAt8_bird_dev.jsonl       # K=8 SFT validators
eval_results/paper_COLLAB_par_passAt8_bird_dev.jsonl   # K=8 ORPO COLLAB
eval_results/paper_INDEP_par_passAt8_bird_dev.jsonl    # K=8 ORPO INDEP
eval_results/paper_greedy_*_passAt1_bird_dev.jsonl     # 4 greedy configs

6. Definition of done

A single command must produce a passing run:

python scripts/compute_bestofn_with_selector.py \
    eval_results/paper_COLLAB_iter2_passAt8_bird_dev.jsonl \
    paper_COLLAB_iter2_selectorEX \
    --selector_host http://localhost:8103 --row_preview
# Print: trained selector ≥ INDEP_iter2 + 1.0pp

Required to ship:

  1. K=8 BIRD-dev rollouts for both new configs:
    • paper_COLLAB_iter2_passAt8_bird_dev.jsonl (new agents)
    • paper_INDEP_iter2_passAt8_bird_dev.jsonl (matched control)
  2. Selector EX from compute_bestofn_with_selector.py on both.
  3. A bootstrap 95% CI showing the COLLAB − INDEP gap is positive with lower bound ≥ 1pp.
  4. Updated thanhdath/mats-sql-bundle README with the new numbers.
  5. The new iter2 ckpts pushed to HF under models/*-iter2-*-paper.

7. Constraints (don't violate)

  • K = 8 is fixed at inference rollout. Don't compare with K=16 etc.
  • Temperature = 1.0 for the K=8 rollouts.
  • 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).
  • 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.
  • β = 0.1 for ORPO unless you have a specific reason to vary; β ≥ 0.5 collapsed val-sel in our runs.
  • SLURM job name must be vl (lowercase). HF_TOKEN at /weka/s225250685/mats-tist/.env.
  • PYTHONNOUSERSITE=1 to avoid user-site contamination.

8. Suggested execution order

Day 0   E4: spot-check 10 fixer prompts on disk → confirm if fixer uses critique
Day 1   E1: build critique-aware fixer SFT data (~3h) → train fixer-1B-orpo-iter2 (~1h)
Day 2   E2: build iter2 COLLAB + INDEP datasets with new fixer + collab_v2 + K=8 (~6h each)
Day 2   E2: train iter2 COLLAB + INDEP validators (4 jobs in parallel, ~1h each)
Day 3   K=8 BIRD-dev rollouts × 2 configs (~3h each parallel) → selector EX
Day 3   Bootstrap CI, write up, push to HF

If E1 + E2 don't produce ≥1pp gap, drop to E3 (joint Alg. 2) which is the more aggressive rewrite.

9. What "good" looks like at the end

Selector EX
  paper_SFT_VF        : 59.91%   (baseline, unchanged)
  paper_INDEP_iter2   : 60.5±0.4%  (matched control)
  paper_COLLAB_iter2  : 62.0±0.4%  (target — gap ≥ 1pp, bootstrap-significant)

Then update the bundle README to show COLLAB ≠ INDEP, write a short summary of why (critique-aware fixer + inference-aligned collab signal), and the paper claim "COLLAB > INDEP" will be empirically supported on our reproduction.