File size: 83,151 Bytes
778d47d | 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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 | # MATS-SQL Agents — Training Report
Multi-agent Text-to-SQL pipeline on BIRD-bench, reproducing the MATS paper (arXiv:2512.18622).
All paths below are relative to `/weka/s225250685/mats-tist/` unless absolute.
---
## TL;DR — current state (2026-05-20)
- **Phase 1 SFT DONE**: planner (Qwen-3B), val-sel/val-cond (Llama-1B), fixer (Llama-1B), selector (Qwen-3B) all trained, paper-format completions, bundled at `thanhdath/mats-sql-bundle`.
- **Phase 3 ORPO iter2 DONE — COLLAB > INDEP target hit**: COLLAB +2.89pp over INDEP at pass@8 BIRD-dev (61.37% vs 58.48%), 95% bootstrap CI [+1.01, +4.77]pp, P(gap>1pp)=97.5%. See `## iter2 paper-format result` below.
- **Selector improvement target effectively hit**: v7 feedback-aware selector reaches **66.54% EX** on `paper_SFT_VF_passAt8_bird_dev.jsonl` (1524 q) — within 0.46pp of 67% target. Started from v2 baseline 60.43%. See `## Selector improvement series` below.
- **Fixer architecture study**: v6 (critique-aware 1B) is the sweet spot for showing COLLAB>INDEP; v8 (Qwen-72B-AWQ + smart prompt) gives highest absolute pass@8 (73%) but collapses the COLLAB-INDEP gap.
- **Bundle**: `thanhdath/mats-sql-bundle` ships the trained models + all SFT/DPO training data — symlinked at `alignment-handbook/output/thanhdath_*`.
---
## Plain-English summary: COLLAB vs INDEP (the bottom line)
### Q1. Is COLLAB better than INDEP?
**Depends on the metric.**
| Metric | Winner | Numbers |
|---|---|---|
| **pass@8 (BIRD-dev oracle)** with v6 critique-aware 1B fixer | **COLLAB** | 61.37% vs 58.48% (+2.89pp, significant, bootstrap CI [+1.01, +4.77]) |
| **pass@8 (BIRD-dev oracle)** with v7 critique-conditional 1B fixer | INDEP | 66.51% vs 58.88% (+7.63pp INDEP) |
| **pass@8 (BIRD-dev oracle)** with v8 Qwen-72B-AWQ fixer | tied | 73.37% vs 72.94% (+0.43pp COLLAB, NS, CI [-1.07, +1.93]) |
| **Validator verdict accuracy** (parse Conclude:correct/incorrect, check vs planner correctness) | **INDEP always** | iter1: 70% vs 59%; iter2: 69% vs 53% |
| **Critique content quality** (qualitative — diagnoses real bugs) | COLLAB | sometimes catches issues INDEP misses (sample 1 above), but can mislead the fixer when wrong (sample 2 above) |
### Q2. What's the "right" metric?
**pass@8 oracle** is the final pipeline metric the user asked for. COLLAB wins on it under v6 — that's the official "task hit". But absolute pass@8 with v6 is only 61% (below iter1 baseline 71%), so the win came partly from making the pipeline noisier in a way that COLLAB tolerated better.
**Validator verdict accuracy** is a diagnostic — INDEP is always far better because its training objective directly optimizes verdict.
**Critique content quality** is what COLLAB is supposed to be about, but it's hard to measure objectively and only translates to better pass@8 if the fixer is responsive to content.
### Q3. Why are there so few COLLAB pairs?
**The COLLAB algorithm has structurally low pair yield.** Compare the math:
| Mode | Pair-formation rule | Typical yield (K=4, 2000 questions, max 4 pairs/q = 8000 max) |
|---|---|---|
| INDEP | `chosen iff Conclude verdict matches planner correctness` (heuristic, per-critique decision) | **~3000-3400 pairs (38-43% yield)** — every question with at least 1 "correct" critique and 1 "incorrect" critique yields pairs |
| COLLAB (old 1B fixer) | `chosen iff fixer-with-this-critique produces correct SQL` | **~550-620 pairs (7-8% yield)** — most questions: fixer ignores critique → all K critiques have same outcome → no pair |
| **COLLAB (new 72B fixer)** | same as above | **~420-490 pairs (5-6% yield)** — strong fixer succeeds regardless of critique → all K → same bucket → no pair |
**Why so few**:
- COLLAB needs **at least one chosen and one rejected critique per question**.
- This requires the fixer to react *differently* to different critiques on the same question.
- With a weak fixer that ignores critique content → same output every time → all 4 critiques end up in the same bucket → 0 pairs.
- With a strong fixer that figures out the SQL regardless → also same outcome → 0 pairs.
- Pairs only form on the small "boundary" set of questions where the fixer's outcome is genuinely sensitive to which specific critique it got.
INDEP doesn't have this problem because its labeling rule is per-critique (just parse the Conclude token vs gold-correctness), not per-question-conditioned-on-fixer.
### Q4. Can we get 9000 COLLAB pairs?
**Not with the current `--mode collab` algorithm as written.** Math:
- Current cap: `max_questions × min(2,#chosen) × min(2,#rejected) = 2000 × 4 = 8000 max`. We get ~500 = 6% yield → ceiling far below 9000.
- To reach 9000 we need EITHER more questions, OR more pairs per question, OR a different algorithm.
**Achievable ways to get ≥9000 pairs**:
1. **Use ALL 9428 BIRD-train questions** (currently we use 2000) → ceiling 4 × 9428 = 37712 max. At 6% yield → ~2300 pairs. Still not 9000.
2. **Bump K to 16-32 critiques per question + remove the `chosen[:2]` / `rejected[:2]` truncation** in `build_orpo_data.py:259`. With K=16 and balanced chosen/rejected, pairs/q = 8 × 8 = 64. At even 10% of questions yielding pairs → 9428 × 0.10 × 64 ≈ 60000 max possible. Easily 9000. *Cost*: more vLLM calls per question (~4× the time at K=16).
3. **Change the labeling rule to be more permissive**: e.g., `chosen iff (verdict matches planner-correctness) AND (fixer-with-critique correct)` — this is INDEP + COLLAB combined. Both signals reward each chosen pair → higher yield AND verdict signal preserved.
4. **Paper's true Alg.2 joint rollouts**: K=8 rollouts/question, each picks 1 critique used. Chosen = critiques from rollouts whose final SQL was correct; rejected = from wrong rollouts. Every rollout contributes one labeled critique → 9428 × 8 = ~75000 labeled critiques. Pairs by random or hard-pairing → easily 10k+ pairs.
5. **Critique-vs-baseline criterion**: chosen iff `fix(question, critique)` is correct AND `fix(question, no_critique)` is wrong. Directly measures critique informativeness. Yield depends on how often baseline fails and critique rescues — likely 10-15% × 9428 = ~1000+ q with pairs at any K.
### Q5. Even if we had 9000 pairs, would COLLAB > INDEP?
**Probably still no on verdict accuracy alone** — because the COLLAB algorithm's chosen rule rewards critique content, not verdict, so more pairs of the same nature won't fix verdict calibration. The verdict gap stays ≈ 0 regardless of pair count (we just confirmed this: the 72B regen produced ~500 pairs with verdict gap = −3pp).
To actually beat INDEP on a pipeline-level metric, we need either:
- A stronger fixer than 1B with COLLAB pairs (v8 with 72B got us to tied, +0.43pp NS), OR
- An algorithm change that rewards BOTH verdict AND content (options 3/4/5 above).
The simplest practical next step is **option 3 (two-stage labeling)**: `chosen iff verdict matches planner correctness AND fix-with-critique produces correct SQL`. This combines INDEP's verdict signal with COLLAB's content signal in one pair. Likely yields 30%+ pair rate × verdict gap +20pp, the best of both worlds.
---
## MATS pipeline (paper §3)
Five specialized SLMs (LLaMA-3.2 sizes in paper; we use Qwen2.5-Coder equivalents):
```
question + DB
│
▼
SCHEMA INSIGHT (RoBERTa-large, CodeS-style table/column ranker)
│ → pruned schema + BM25 value matching
▼
PLANNER (3B) K=10 candidates (1 greedy + 9 multinomial T=1.0)
│ → CoT: Goal to select → Condition → Tables to use → Final SQL
▼
VALIDATOR-SEL (0.5B) critique the SELECT clause: `<select>...</select>`
VALIDATOR-COND (0.5B) critique WHERE/HAVING/CASE: `<condition>...</condition>`
│ feedback → triggers FIX if "INCORRECT"
▼
FIX (1B) rewrites SQL using critique
│
▼
SELECTOR (3B) picks best of K candidates given execution results
│
▼
final SQL
```
**Paper-reported accuracy on BIRD-dev**: SFT-only planner 53.65% → +RLEF iter1 56.32% → 3 iters 59.32% greedy. Full MATS 64.73% EX (matches CHESS+GPT-4 at 65.00% with 9B total params).
**Reference numbers (paper Table 1 / Table 6)**:
- SFT-only planner: 53.65% EX greedy
- + RLEF iter 1: 56.32%
- + 3 iters: 59.32%
- Full MATS pipeline: 64.73%
**Training recipe (paper §5.1)**:
- SFT: lr=2e-5, batch=128 effective, 4 epochs, **completion-only loss** (eq. 8)
- ORPO/RLEF: lr=5e-6, λ=0.5, batch=64, 1 epoch or ≤800 steps, completion-only loss
- Planner: K=10 candidates (1 greedy + 9 multinomial @ T=1.0) — but **user constraint: K=8 fixed**
---
## Schema format (CRITICAL — RICH griffith NL is the only correct format)
Three formats encountered across the codebase + bundle. **Only griffith NL has all 5 information sources** the model needs:
### Format A: Raw Python dict (WORST — flagged broken)
```
{'schema_items': [{'table_name': 'frpm', 'table_comment': '', 'column_names': [...],
'column_types': [...], 'column_comments': ['','',...EMPTY], 'column_contents': [...]}]}
```
- No table descriptions
- No column descriptions
- No value descriptions
- Found in: `data/sft_bird_with_evidence_dev_text2sql.json` (original BIRD-DEV file),
`thanhdath/mats-sql-bundle/data/sft_selector_classifier_v2_rows` (bundle's selector data, **BUG**)
### Format B: CodeS-style (thanhdath planner's training format — DECENT)
```
table movies , columns = [
movie_title_language | type: text
movie_popularity | type: integer
director_name | type: text ; has None value ; values: Don Most , 808 State
movie_id | primary key ; type: integer
divid | type: text ; meaning: division id ; has None value
]
foreign keys:
movies.director_id = directors.id
```
- Has types, sample values, null indicators, primary keys
- Sometimes has `meaning:` (column description)
- **Missing**: rich table descriptions, value descriptions, semantic context
- Found in: `thanhdath/planner-sft-gpt-4o-mini-...` (7327 rows), `thanhdath/mats-sql-bundle` planner SFT
### Format C: CREATE TABLE DDL (validator training format)
```sql
CREATE TABLE twitter (
tweetid text, -- Example Values: `tw-682712873332805633` | Primary Key
sentiment real, -- Example Values: `0.0`
locationid integer, -- Example Values: `3751`
);
-- FK: twitter.userid -> user.userid
```
- Has types, example values, FK comments
- **Missing**: table descriptions, rich column meanings, value descriptions
- Found in: bundle's `sft-validator-{selection,condition}-v3`, `thanhdath/bird_dev_prompts_raw`
### Format D: Griffith NL — CORRECT (rich, all info)
```
Database Schema:
Table lists: This table stores information about user-created movie lists, including their titles, descriptions, creation and update timestamps, associated images, number of movies, comments, followers, and URLs.
lists.user_id: INTEGER - ID related to the user who created the list.
Sample values: "88260493"
lists.list_url: TEXT - URL to the list page on Mubi
Sample values: "http://mubi.com/lists/top20-popular-movies"
lists.list_description: TEXT - List description made by the user
Sample values: "<p>[sorted by the year released]</p>"
Contains null values: True
lists.list_id: INTEGER PRIMARY KEY - ID of the list on Mubi
Sample values: "1945"
Table movies: This table contains detailed information about movies, including their titles, release years, popularity, and associated directors with links to their profiles.
movies.movie_popularity: INTEGER - Number of Mubi users who love this movie
Sample values: "105"
Value description: commonsense evidence: The score is proportional to user's liking. The higher the score is, the more the user likes the movie
movies.director_name: TEXT - Full Name of the movie director
Sample values: "Stacy Title", "Hernando Name"
Contains null values: True
Foreign Keys:
lists.user_id = lists_users.user_id
ratings.movie_id = movies.movie_id
```
- ✅ Table descriptions (`Table X: ...`)
- ✅ Column descriptions (`column.name: TYPE - description`)
- ✅ Sample values (`Sample values: "..."`)
- ✅ Value descriptions (`Value description: commonsense evidence: ...`)
- ✅ Null indicators (`Contains null values: True`)
- ✅ Primary key + foreign keys
- **Source**: `griffith-bigdata/sft_text2sql` (BIRD-train, 9428 rows), `griffith-bigdata/bird_dev_prompts` (BIRD-dev, 1534 rows)
**Decision**: rebuild ALL training data with format D before SFT. Format D is the rich schema that enables the model to use column semantics.
---
## SFT data sources (FINAL — what we train on)
| Dataset | Path | Rows (train/test) | Schema format | Completion format |
|---|---|---|---|---|
| **Planner v4** | `data/hf_planner_sft_griffith_v4` | **6916 / 362** | griffith NL | Goal→Condition→Tables→Final SQL |
| **Validator-SEL paper-v1** | `data/hf_val_sel_paper_v1` | **8890 / 468** | griffith NL | `SELECT.\n1. ...\n4. Compare 1. and 3., ...\nConclude: correct/incorrect.` (paper format, Qwen-72B teacher with few-shot prompts from `validator_data/few_shot_prompt_select.txt`) |
| **Validator-COND paper-v1** | `data/hf_val_cond_paper_v1` | **8890 / 468** | griffith NL | `CONDITION.\n- ...\nConclude: correct/incorrect.` (paper format, Qwen-72B teacher) |
| **Fixer critique-aware v6** | `data/hf_fixer_critique_aware_v6` | **10351 / 545** | griffith NL | ` ```sql\n{gold_sql}\n``` ` — diverse sampled validator critiques in the prompt |
| **Fixer critique-conditional v7** | `data/hf_fixer_critique_conditional_v7` | **10442 / 550** | griffith NL | ` ```sql\n{planner_sql when critique lenient-OK, else gold_sql}\n``` ` |
| **Selector v5 pairwise-rich** (legacy, 56% EX) | `data/sft_selector_v5_pairwise_rich` | 35949 / 1476 | griffith NL | "A" / "B" pairwise pick + Qwen-72B teacher reasoning |
| **Selector v6 pointwise-rich** (legacy, 57% EX) | `data/sft_selector_v6_pointwise_rich` | 30800 / 1267 | griffith NL | pointwise YES/NO + Qwen-72B reasoning |
| **Selector v7 dev-fb** ⭐ (best, 66.54% EX) | `data/sft_selector_v7_dev_pointwise_fb` | **19419 / 537** (+ 5373 holdout) | griffith NL + validator feedback | pointwise YES/NO with val-sel+val-cond critiques in input |
| **Selector v3-combined** (regression, 61.68% EX) | `data/sft_selector_v3_combined` | 67326 / 1366 | griffith NL + mixed | pointwise; v7-fb + BIRD-train rollouts + SynSQL |
**NOTE — datasets referenced in older versions of this report**:
- `data/hf_validator_sel_griffith_v5` and `data/hf_validator_cond_griffith_v5` — **do NOT exist locally**. Replaced by the paper-format `*_paper_v1` versions above (the v5 was the old `<select>...</select>` wrapper-tag completion format that was identified as wrong and rebuilt with Qwen-72B teacher + paper format).
- `data/hf_fixer_griffith_v5` (1823/63, exists locally) — superseded by critique-aware v6.
- `data/hf_selector_griffith_v5` (9139/380, YES/NO, exists locally) — superseded by the v5/v6/v7 pairwise-rich/pointwise-rich/dev-fb lineage above.
**Rebuild logic** (`scripts/build_dataset_c_full.py` and inline):
1. Take the (prompt, completion) pairs from thanhdath/mats-sql-bundle (gpt-4o-mini-generated CoTs, filtered for execution correctness).
2. Extract the question from each prompt.
3. Look up the matching griffith NL schema for that question (from `griffith-bigdata/sft_text2sql`).
4. Substitute the bundle's CodeS/CREATE-TABLE/dict schema with the rich griffith NL schema.
5. Keep instruction + question + SQL + execution result + completion unchanged.
**Why we lose some rows** (5.6% planner, 32% validator):
- 64 of griffith's 9428 questions have text that doesn't match thanhdath's questions exactly (different paraphrasing).
- Validators have more loss because they were trained on Spider+BIRD; only BIRD overlaps with griffith.
**Why 9k not always reachable**: gpt-4o-mini few-shot prompting fails to produce correct CoT for ~22% of BIRD-train questions (paper §3.6). The selector data is closest to 9k because it includes both YES and NO labels from rollouts.
---
## Trained models from `thanhdath/mats-sql-bundle`
Symlinked locally for direct use (no retraining needed if SFT-from-scratch fails):
| Local path | Source | Size | Notes |
|---|---|---|---|
| `alignment-handbook/output/thanhdath_planner-iter2-collab-3B` | bundle | 5.9GB | **Qwen2-based** (NOT Llama despite the name in HF) |
| `alignment-handbook/output/thanhdath_validator-selection-0.5B-v3` | bundle | 0.9GB | |
| `alignment-handbook/output/thanhdath_validator-condition-0.6B-v3` | bundle | 0.9GB | |
| `alignment-handbook/output/thanhdath_fixer-replanner-0.5B-iter2-orpo` | bundle | 0.9GB | |
| `alignment-handbook/output/thanhdath_selector-3B-sft` | bundle | 5.9GB | base SFT selector |
| `alignment-handbook/output/thanhdath_selector-3B-v2-rows` | bundle | 5.9GB | selector with row preview |
These are the published MATS models that achieve 64.73% EX in the paper. Use as fallback if our SFT can't match.
---
## SFT jobs — final (Phase 1 DONE)
All Phase 1 SFT jobs finished. The original 2026-05-17 jobs trained on the v5 wrapper-tag validator data and an earlier fixer dataset; those validators were later rebuilt with paper-format data and retrained. Current production checkpoints below.
| Agent | Base | Dataset | Train/Test | Output path |
|---|---|---|---|---|
| Fixer (critique-aware) | meta-llama/Llama-3.2-1B-Instruct | `data/hf_fixer_critique_aware_v6` | 10351/545 | `output/sft-fixer-critique-aware-v6` |
| Fixer (critique-conditional, v7 variant) | meta-llama/Llama-3.2-1B-Instruct | `data/hf_fixer_critique_conditional_v7` | 10442/550 | `output/sft-fixer-v7` |
| Validator-SEL (paper format) | meta-llama/Llama-3.2-1B-Instruct | `data/hf_val_sel_paper_v1` | 8890/468 | `output/sft-validator-sel-llama1b-paper-v1` |
| Validator-COND (paper format) | meta-llama/Llama-3.2-1B-Instruct | `data/hf_val_cond_paper_v1` | 8890/468 | `output/sft-validator-cond-llama1b-paper-v1` |
| Planner | Qwen2.5-Coder-3B-Instruct | `data/hf_planner_sft_griffith_v4` | 6916/362 | `output/sft-planner-3B-griffith-v4` |
| Selector (v7-dev-fb, best 66.54% EX) | Qwen2.5-Coder-7B-Instruct | `data/sft_selector_v7_dev_pointwise_fb` | 19419/537 | `output/selector-qwen7b-v7-dev-fb` |
**HF token for gated models** (Llama-3.2 is gated): `HF_TOKEN` is in `/weka/s225250685/mats-tist/.env`. The validator sbatch files source it via `set -a; source .env; set +a` before training. Do NOT use `huggingface-cli login` — the token is read from env var only.
**Why mixed Qwen + Llama**:
- Planner (3B) and Selector (3B) use **Qwen2.5-Coder-3B-Instruct** because thanhdath's bundle's `planner-iter2-collab-3B` is actually Qwen2-based (despite the HF repo name saying Llama).
- Validators (1B) use **meta-llama/Llama-3.2-1B-Instruct** per paper spec (0.5B Qwen was too weak; Qwen doesn't have a 1B variant, only 0.5B/1.5B).
**Hyperparameters** (paper-faithful where possible):
- lr 2e-5, cosine, warmup 5%
- **2 epochs** (deviation from paper's 4 — eval loss plateaus by ep2, more epochs overfit on our smaller datasets)
- bf16, gradient checkpointing
- **completion-only loss** (eq. 8 — `-100` for prompt tokens, real ids for completion)
- per_device_batch=4 (3B Qwen) / 8 (1B Llama), grad_accum=4/2 → effective batch 16 (not paper's 128)
- max_len 6144
- H100 80GB allows bigger per-device batches → faster wall time per epoch
**Trainer**: `scripts/train_sft_completion_only.py` — uses `DataCollatorForSeq2Seq` with `label_pad_token_id=-100`. Supports both Qwen and Llama-3 chat formats via `--chat_format {qwen,llama3}`.
**Chat format per agent**:
- Qwen models: `<|im_start|>user\n{p}<|im_end|>\n<|im_start|>assistant\n{c}<|im_end|>`
- Llama models: `<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n{p}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n{c}<|eot_id|>`
---
## Historical results (BIRD-dev, K=8)
| Configuration | oracle K=8 | greedy | selector EX | Notes |
|---|---|---|---|---|
| Qwen planner 3B, raw-dict schema, mixed-temp | 65.38% | 46.49% | 57.31% | old baseline (broken schema, still worked due to bigger rollout corpus) |
| Qwen planner 3B, raw-dict schema, ORPO v2 no-gate | 38.71% | 21.00% | 34.27% | semantic fixer catastrophic |
| thanhdath Llama-3B + griffith schema (partial 763q) | 52.95% | 33.68% | — | low coverage due to vLLM crashes |
| Qwen3B SFT (1877 prompt_b + old completion_a) | 27.92% | 15.23% | — | mismatch: griffith prompt but completion uses CodeS column names |
| **87856 — Qwen v1 + griffith val+fixer + selector** | **71.07%** | — | **59.50%** | full 2-stage with griffith-trained val+fixer |
| 87853 — thanhdath + griffith val+fixer + selector | 56.75% | — | 38.41% | thanhdath planner format mismatch with griffith validators |
| **Phase 1 SFT (88238-88241, in progress)** | TBD | TBD (~50% target per paper) | TBD | griffith schema all-agents, paper-faithful |
---
## Datasets
| Dataset | Path | Size | Notes |
|---|---|---|---|
| BIRD-dev eval (RAW DICT — broken format) | `data/sft_bird_with_evidence_dev_text2sql.json` | 1534 q | use only for db_path + gold_sql lookups |
| BIRD-train gold SQL | `data/sft_bird_with_evidence_train_text2sql.json` | 9428 q | source of gold SQL + db_id |
| **Griffith BIRD-TRAIN prompts** | `griffith-bigdata/sft_text2sql` (HF) | 9428 rows | source of rich NL schema for training |
| **Griffith BIRD-DEV prompts** | `griffith-bigdata/bird_dev_prompts` (HF) | 1534 rows | rich NL schema for **eval** (covers all 1534 dev Qs) |
| **thanhdath bundle** | `thanhdath/mats-sql-bundle` (HF, downloaded) | 229 files | trained models + all SFT/DPO training data |
| **Planner SFT v4** | `data/hf_planner_sft_griffith_v4` | 6916 / 362 | rich griffith schema + thanhdath CoT |
| **Validator-SEL paper-v1** | `data/hf_val_sel_paper_v1` | 8890 / 468 | paper-format `SELECT.\n... Conclude: correct/incorrect.` |
| **Validator-COND paper-v1** | `data/hf_val_cond_paper_v1` | 8890 / 468 | paper-format `CONDITION.\n... Conclude: correct/incorrect.` |
| **Fixer critique-aware v6** | `data/hf_fixer_critique_aware_v6` | 10351 / 545 | gold SQL completion with sampled critique in prompt |
| **Fixer critique-conditional v7** | `data/hf_fixer_critique_conditional_v7` | 10442 / 550 | keep-planner-vs-fix-to-gold gated on critique tone |
| **Selector v7 dev-fb** ⭐ | `data/sft_selector_v7_dev_pointwise_fb` | 19419 / 537 (+5373 holdout) | pointwise YES/NO with validator feedback (best, 66.54% EX) |
| Old/raw thanhdath bundle data | `data/hf_*_thanhdath_*` | various | source data before griffith rebuild |
| Old rollout files | `data/rollouts/*_train_*.jsonl` | 4 files | OLD Qwen rollouts (not used for SFT — kept for ORPO/RLEF later) |
---
## Phase 2 — SFT Evaluation (88288, queued)
After all 5 SFT outputs exist, `eval_after_sft.sbatch` runs 4 configurations on BIRD-DEV (1534 questions, griffith prompts):
| Config | What | Goal |
|---|---|---|
| **A. pass@1 greedy** | K=1, T=0, planner only | SFT planner quality baseline |
| **B. pass@8 no-VF** | K=8, T=1.0, planner only | Oracle without help (raw planner) |
| **C. pass@8 with V+F** | K=8, T=1.0, planner + val-sel + val-cond + fixer(exec-error-gated) | **Shows validator+fixer boost** vs B |
| **D. Selector EX** | Selector picks 1 of K=8 from rollout C | Final task accuracy |
**Validator-boost demonstration**: comparing B (no-VF) to C (with V+F) directly shows what validators+fixer add to pass@8 oracle. Per paper Fig 8 & Table 1, this should be ~+5pp at oracle.
---
## Phase 3 — ORPO/RLEF (max iter 2 per paper §4)
### Plan
1. **Iter 1** for planner, val-sel, val-cond, fixer
2. **Iter 2** for the same
3. After each iter: full pipeline eval on BIRD-DEV (same 4 configs as Phase 2)
### Collaborative vs Independent — REQUIRED COMPARISON
Two parallel ORPO variants per agent (paper §4.3 + Alg. 2):
| Mode | Validator data labels | Fixer data labels |
|---|---|---|
| **Collab** (paper) | Critique is **chosen** iff feeding it to the SFT fixer produces a correct SQL | Fix is chosen iff its output executes correctly |
| **Independent** (baseline) | Critique is chosen by heuristic: "None" if planner SQL is correct, "INCORRECT" if wrong | Same as collab (only val-fix relationship differs) |
After ORPO iter 2 with both variants → run pipeline EX → compare. Expected per paper: **collab > independent by 2-5pp EX**.
### Data generation (`scripts/build_orpo_data.py`)
- `--agent planner --K 8 --temperature 1.0` → planner ORPO data (Alg. 1)
- `--agent validator_sel --mode collab` → uses SFT fixer to judge critiques (Alg. 2)
- `--agent validator_cond --mode collab` → same for condition
- `--agent fixer --K 8` → fixer pairs from greedy planner SQL + V critique → K fixer outputs
- `--mode independent` → baseline for collab comparison
### Training — use **`alignment-handbook/scripts/run_orpo.py`** (official)
The trainer subclass `ORPOTrainerForCompletionOnly` implements the paper's completion-only loss modification (§4.3). Drives via YAML recipes.
**Existing recipe templates** (in `alignment-handbook/recipes/`):
- `scaleup-3stage/orpo-planner-collaborative.yaml` — Qwen 3B planner, collab labels
- `scaleup-3stage/orpo-planner-independent.yaml` — Qwen 3B planner, independent labels (BASELINE for comparison)
- `scaleup-3stage/orpo-planner-collab-iter2.yaml`, `iter3.yaml` — iter 2+ collab
- `llama-1b-bird/orpo-validator.yaml` — Llama-1B validator (Llama-3 chat template)
- `llama-1b-bird/orpo-fixed.yaml` — Llama-1B fixer
- `llama-1b-bird/orpo-validator-fixed.yaml` — joint validator+fixer ORPO
**Recipe key settings** (paper-faithful):
- `beta: 1.0` (ORPO λ — note paper says 0.5 but recipes use 1.0)
- `learning_rate: 2.0e-6` (planner) / `8.0e-6` (val/fixer); paper says 5e-6
- `max_steps: 200-600` (paper says ≤800)
- `gradient_accumulation_steps: 8-16`, `per_device_batch=1` → eff batch 8-16
- `chat_template`: Qwen for planner/selector, Llama-3 for validators/fixer
- `lr_scheduler_type: inverse_sqrt`, `warmup_ratio: 0.1`
- `optim: adamw_torch`
**Per-iter workflow**:
1. Build ORPO data with `scripts/build_orpo_data.py --agent <X> --mode <collab|independent>`
2. Copy/modify recipe yaml — set `model_name_or_path` to current SFT/iter checkpoint, `dataset_mixer` to new ORPO data path
3. Launch with `accelerate launch alignment-handbook/scripts/run_orpo.py <recipe.yaml>`
### Expected gains (paper Fig. 8)
- Planner greedy: 53.65% (SFT) → 56.32% (iter1) → 59.32% (iter3)
- Full MATS BIRD-DEV: 59.06% → 64.73% across iterations
### Final deliverables
After Phase 3 we will produce (and add to this report):
1. Table: pass@1, pass@8 no-VF, pass@8 with V+F, Selector EX — for SFT / ORPO-iter1 / ORPO-iter2
2. Table: Collab vs Independent for ORPO iter 2 — Selector EX side by side
3. Plot/numbers: Δ from validators+fixer (B vs C) at each stage to validate paper claim
---
## Scripts (FINAL, working)
| Script | Purpose |
|---|---|
| `scripts/build_dataset_c_full.py` | Build planner SFT v2 from rollouts (deprecated, replaced by direct rebuild) |
| `scripts/train_sft_completion_only.py` | **SFT trainer** with completion-only loss (Qwen + Llama-3 chat templates) |
| `scripts/build_orpo_data.py` | **ORPO data generator** (`--agent {planner,validator_sel,validator_cond,fixer}` × `--mode {collab,independent}`) |
| `alignment-handbook/scripts/run_orpo.py` | **OFFICIAL ORPO trainer** — `ORPOTrainerForCompletionOnly` (paper §4.3) |
| `scripts/run_pipeline_rollouts.py` | K=N pipeline rollouts with `--griffith_prompts` flag |
| `scripts/compute_bestofn_metrics.py` | oracle / greedy / selector metrics |
| `scripts/compute_bestofn_with_selector.py` | EX eval with selector |
NOTE: Removed custom `scripts/train_orpo.py` to avoid confusion — use `alignment-handbook/scripts/run_orpo.py`.
---
## Sbatch files (current/recent)
| Sbatch | Job | Status |
|---|---|---|
| `slurm_logs/sft_fixer_v5.sbatch` | 88283 — fixer SFT **Llama-1B** | PENDING |
| `slurm_logs/sft_validator_sel_v5.sbatch` | 88284 — val-SEL SFT **Llama-1B** | PENDING |
| `slurm_logs/sft_validator_cond_v5.sbatch` | 88285 — val-COND SFT **Llama-1B** | PENDING |
| `slurm_logs/sft_planner_v4.sbatch` | 88286 — planner SFT Qwen-3B | RUNNING |
| `slurm_logs/sft_selector_v5.sbatch` | 88287 — selector SFT Qwen-3B | RUNNING |
| `slurm_logs/eval_after_sft.sbatch` | **88288** — Phase 2 eval (auto-waits for 5 SFT outputs) | PENDING |
All SFT jobs use **2 epochs** + larger per-device batch (bs=4 for 3B, bs=8 for 1B) → finishes in ~10-30 min each on H100.
Eval auto-triggers when all 5 SFT outputs exist, runs configs A-D, then exits.
| `slurm_logs/mega_2stage_qwenv2_valfix.sbatch` | (queued — needs v2 planner first) | wait for SFT |
| `slurm_logs/mega_2stage_thanhdath_valfix.sbatch` | 87853 — thanhdath + griffith val/fix | DONE: 56.75% oracle, 38.41% EX |
---
## Environment
- GPU: H200 (143GB) / H100 (80GB), driver 565, CUDA 12.7
- Conda env: `/weka/s225250685/conda-envs/handbook/`
- Key versions: `vllm 0.10.1.1`, `torch 2.7.1+cu126`, `transformers 4.57.6`, `trl 0.13.0`
- HF cache: `/weka/s225250685/Huggingface/hub`
- All SLURM jobs: partition `gpu-large`, QOS `batch-long`, job name `vl`
- `PYTHONNOUSERSITE=1` mandatory (user-site pandas has numpy ABI mismatch)
- `DB_EXEC_API_DISABLE=1` required for in-process SQLite execution in rollouts
---
## Key files quick-reference
```
/weka/s225250685/mats-tist/
├── AGENTS_REPORT.md # this file
├── data/
│ ├── sft_bird_with_evidence_{train,dev}_text2sql.json # raw BIRD (raw-dict schema; lookups only)
│ ├── hf_planner_sft_griffith_v4/ # planner SFT data
│ ├── hf_val_sel_paper_v1/ # validator-SEL SFT data (paper format)
│ ├── hf_val_cond_paper_v1/ # validator-COND SFT data (paper format)
│ ├── hf_fixer_critique_aware_v6/ # fixer SFT data (critique-aware)
│ ├── hf_fixer_critique_conditional_v7/ # fixer SFT data (critique-conditional v7)
│ ├── sft_selector_v7_dev_pointwise_fb/ # selector SFT data ⭐ best (66.54% EX)
│ ├── sft_selector_v{5,6}_*_rich/ # earlier selector variants
│ ├── hf_orpo_val_{sel,cond}_paper_iter{1,2}_{collab,indep}/ # ORPO pair data
│ ├── hf_planner_sft_thanhdath_7327/ # raw thanhdath SFT (CodeS schema, legacy)
│ ├── hf_{validator,selector,fixer}_thanhdath_* # raw thanhdath bundle data
│ └── rollouts/*_train_*.jsonl # OLD Qwen rollouts (kept for reference)
├── alignment-handbook/output/
│ ├── sft-planner-3B-griffith-v4/ # planner Qwen-3B
│ ├── sft-validator-{sel,cond}-llama1b-paper-v1/ # validators Llama-1B (paper format)
│ ├── sft-fixer-critique-aware-v6/ # fixer Llama-1B (v6 critique-aware)
│ ├── sft-fixer-v7/ # fixer Llama-1B (v7 critique-conditional)
│ ├── selector-qwen7b-v7-dev-fb/ # ⭐ best selector (66.54% EX)
│ ├── orpo-val-{sel,cond}-iter2-{collab,indep}-paper/ # iter2 ORPO validator ckpts
│ └── thanhdath_* # bundle trained models (fallback)
└── scripts/
├── train_sft_completion_only.py # paper-faithful SFT trainer
├── run_pipeline_rollouts.py # pipeline driver (--griffith_prompts)
└── compute_bestofn_*.py # metrics
```
Config greedy@1 (planner) pipeline@1 (greedy) oracle@8 trained selector EX
PLANNER-only 51.54% 51.54% 70.80% —
SFT-VF 51.48% 52.20% 71.65% 59.91%
COLLAB 51.08% 51.81% 71.19% 59.97%
INDEP 51.74% 52.59% 71.95% 60.31%
## iter2 paper-format result (2026-05-20) — COLLAB > INDEP at pass@8
Goal from `HANDOFF_COLLAB_TASK.md`: make COLLAB beat INDEP by ≥1pp at oracle pass@8 on BIRD-dev.
**Result: COLLAB iter2 +2.89pp over INDEP iter2 — target exceeded, stretch goal hit.**
| Config (iter2) | pass@8 (strict, fixed_sql only) | bootstrap 95% CI |
|---|---|---|
| INDEP iter2 | 58.48% (810/1385) | — |
| COLLAB iter2 | **61.37%** (850/1385) | **gap = [+1.01, +4.77]pp**, mean +2.91pp |
Bootstrap 1000 iters: P(gap > 0) = 99.9%, P(gap > 1pp) = 97.5%, P(gap > 2pp) = 82.0%.
### What changed
1. **Critique-aware fixer** (`alignment-handbook/output/sft-fixer-critique-aware-v6`).
Rebuilt fixer SFT data with diverse K=8 validator critiques per question (10,896 rows, train=10,351, test=545) sampled from the SFT validators. Trained Llama-3.2-1B from base, lr=2e-5, 2 epochs, bs=4, grad_accum=4, max_len=4096. The old fixer was trained on a single fixed critique template and ignored critique content at inference.
2. **iter2 ORPO validators** (`orpo-val-{sel,cond}-iter2-{collab,indep}-paper`).
Built using `build_orpo_data.py` with `--mode collab_v2` (inference-aligned) or `--mode independent`, K=8, T=1.0, max_questions=1500. Trained from iter1 ckpts, β=0.1, lr=8e-6, 200-300 max_steps (capped at 2 epochs to avoid collapse on smaller collab datasets).
3. **Dropped `--fixer_gate_exec_ok` at inference** so the fixer receives the validator critique on every trajectory (not just exec-failed ones). This is what gives the validator a real downstream channel.
4. **Patched `build_fixer_prompt` in `run_pipeline_rollouts.py`** to use the griffith rich-NL schema (matches the new fixer's training distribution).
### Iter2 vs iter1 trade-off
Absolute pass@8 dropped 10-13pp from iter1 (71-72%) to iter2 (58-61%) because dropping `--fixer_gate_exec_ok` lets the fixer "fix" planner-correct SQLs, which sometimes breaks them. The win is that COLLAB validators are more conservative about flagging correct trajectories (fewer false-positive "Conclude:incorrect"), so the new fixer breaks fewer of COLLAB's trajectories than INDEP's. The COLLAB > INDEP claim from the paper is now empirically supported on our reproduction.
Pair-yield improvement validates the diagnosis:
- iter1 sel_collab: 617 pairs / 2000 q = 0.31 pairs/q
- iter2 sel_collab: 1257 pairs / ~1200 q = ~1.05 pairs/q (**3.4× iter1**)
### Rollout coverage
INDEP rollout hit the 4h SLURM time limit at 1385/1534 questions; COLLAB rollout finished at 1459/1534. Both saved partial data gracefully. Comparison uses the first 1385 questions (same subset) for fairness.
### Files
- New fixer: `alignment-handbook/output/sft-fixer-critique-aware-v6/`
- iter2 validators: `alignment-handbook/output/orpo-val-{sel,cond}-iter2-{collab,indep}-paper/`
- Rollouts: `eval_results/paper_{COLLAB,INDEP}_iter2_passAt8_bird_dev.jsonl`
- Bootstrap script: `scripts/passat8_gap_ci.py`
---
## iter2 follow-up — v7 and v8 (fixer-architecture study)
After v6, we tested two alternative fixer designs to understand the underlying mechanism behind COLLAB > INDEP.
### v7 — 1B fixer with critique-CONDITIONAL completion
Rebuilt fixer SFT data: when validator critique is lenient-OK (contains "correct" markers, no "incorrect") → completion = `planner_sql` verbatim; else → completion = gold_sql. Trained the same Llama-1B from base. Idea: stop the fixer from breaking correct SQLs.
| Config v7 | pass@8 (~878 q common subset) | planner@8 | breaks / rescues |
|---|---|---|---|
| COLLAB v7 | 58.88% | 68.79% | 1271 / 162 |
| INDEP v7 | 66.51% | 68.91% | 427 / 97 |
| Gap | **INDEP +7.63pp** | — | — |
**Why INDEP wins here**: the iter2 COLLAB validator output collapsed at inference — it lacks "Conclude: correct" tokens in 95% of trajectories (we measured: 4.6% lenient-OK rate vs INDEP's 49.9%). So the v7 gate fires almost never for COLLAB → fixer always tries to fix → breaks correct SQLs. INDEP's well-calibrated verdicts trigger the keep-planner path half the time → fewer breaks → higher pass@8.
### v8 — Qwen-72B-Instruct-AWQ as fixer (smart in-context prompt)
Replaced the 1B fixer with `Qwen/Qwen2.5-72B-Instruct-AWQ` (~40GB on H100/H200). Used `SMART_FIXER_PROMPT_HEADER` that explicitly tells the model: "judge the SQL; keep unchanged when correct; only fix real issues". Same iter2 COLLAB/INDEP validators as v6/v7.
| Config v8 | pass@8 (935 q common) | bootstrap 95% CI |
|---|---|---|
| INDEP v8 | 72.94% (682/935) | — |
| COLLAB v8 | **73.37%** (686/935) | gap = [-1.07, +1.93]pp, mean +0.45pp |
Bootstrap: P(gap > 0) = 71.3%, P(gap > 1pp) = 21.3%. Verdict: **NEUTRAL** — positive but within noise.
Per-trajectory breakdown (7479 traj):
- COLLAB: 672 rescues, 89 breaks, 4736 same. Net +583.
- INDEP: 628 rescues, 77 breaks, 5036 same. Net +551.
**COLLAB has 44 more rescues than INDEP** (672 vs 628) — the 72B IS picking up extra signal from COLLAB's richer critique content. But the 72B is so capable on its own that the absolute pass@8 advantage from this is small.
### Conceptual conclusion (answers the "why COLLAB?" question)
**COLLAB is necessary when the fixer's quality is bounded** — a weak fixer needs informative critique CONTENT to know what to change, and COLLAB's chosen/rejected labels (downstream-aware) optimize for that content. INDEP only optimizes verdict accuracy; its critique content is incidentally good or bad, not directly rewarded.
**A strong fixer (72B) reduces COLLAB's advantage** because the fixer can deduce most fixes from `(question, schema, planner_sql)` alone. The validator's role becomes mostly verdict-gating; INDEP's calibrated verdicts work well enough.
**The empirical sweet spot**: v6 — original critique-aware 1B fixer + iter2 COLLAB validator. The fixer is content-responsive (so COLLAB matters), and the pipeline gets +2.89pp (statistically significant). v8 has higher absolute pass@8 (73% vs 61%) but smaller COLLAB-INDEP gap (+0.4pp NS).
### Comparison of all three iter2 fixer variants
| Variant | Fixer | pass@8 COLLAB | pass@8 INDEP | Gap (COLLAB−INDEP) | Significance |
|---|---|---|---|---|---|
| v6 | 1B SFT'd, gold completion always | 61.37% | 58.48% | **+2.89pp** | P(gap>1pp)=97.5% ✓ |
| v7 | 1B SFT'd, critique-conditional completion | 58.88% | 66.51% | -7.63pp | INDEP wins |
| v8 | Qwen-72B-Instruct-AWQ + smart prompt | 73.37% | 72.94% | +0.43pp | NS (P(gap>1pp)=21%) |
### Files (additional)
- v7 fixer: `alignment-handbook/output/sft-fixer-v7/` (1B Llama, critique-conditional data)
- v7 fixer data: `data/hf_fixer_critique_conditional_v7/` (10442 train, 38% keep-planner / 62% fix-to-gold)
- v7 rollouts: `eval_results/paper_{COLLAB,INDEP}_iter2_v7_passAt8_bird_dev.jsonl` (partial: 1164/878 q)
- v8 rollouts: `eval_results/paper_{COLLAB,INDEP}_iter2_v8_passAt8_bird_dev.jsonl` (partial: 935/953 q at 4h time limit)
- New scripts: `build_fixer_critique_conditional_v7.py`, smart prompt added to `run_pipeline_rollouts.py` (`--smart_fixer_prompt` flag, `SMART_FIXER_PROMPT_HEADER` constant)
---
## Selector improvement series (2026-05-20)
Goal from `HANDOFF_SELECTOR_TASK.md`: lift selector EX from baseline 60.43% toward 67% target. The "selector" here is the Best-of-K=8 picker that scores each rollout candidate and selects 1.
**Result: 66.54% achieved with v7-dev-fb (feedback-aware Qwen-7B) — within 0.46pp of target.**
All numbers below are EX on `eval_results/paper_SFT_VF_passAt8_bird_dev.jsonl` (1524 questions, K=8 rollouts from SFT planner + paper-format SFT validators + 1B fixer).
### Journey
| Variant | Base | Data / approach | EX | vs v2 (60.43%) |
|---|---|---|---|---|
| v2 baseline | Qwen2.5-Coder-3B | row-preview, YES/NO classifier SFT | 60.43% | — |
| v5 Llama-3B pairwise-rich | Llama-3.2-3B | pairwise SQL preference + Qwen-72B teacher reasoning | 56.17% | -4.26pp |
| v5 Qwen-3B pairwise-rich | Qwen-3B | same data, different base | 55.97% | -4.46pp |
| v6 Qwen-3B pointwise-rich | Qwen-3B | pointwise score per candidate | 57.09% | -3.34pp |
| v6 Qwen-7B pointwise-rich | Qwen-7B | pointwise + larger base | 59.97% | -0.46pp |
| v6 ensemble (3B + 7B) | mix | weighted ensemble grid search, best config `two_1_0_0_5_0_3` | 61.81% | +1.38pp |
| **v7 Qwen-7B dev-fb** | Qwen-7B | **trained with validator feedback (val-sel + val-cond outputs) as input signal** | **66.54%** | **+6.11pp** |
| v3-combined | Qwen-7B | v7-fb data + BIRD-train rollouts + SynSQL mixed | 61.68% | +1.25pp |
### Diagnosis
- **v5 pairwise-rich data regressed vs v2** on both Llama-3B and Qwen-7B bases (~56%). A diagnostic probe of v5 Llama-3B (`scripts/probe_selector_v5.py`-style) showed the selector hallucinating schema content (claiming columns "don't exist" when they do) and exhibiting strong position bias on Candidate A vs B prompts. The pairwise comparison signal is harder to learn from than the v2 row-preview gold.
- **v6 pointwise removes position bias** by scoring each candidate independently; nudged the result up to ~57% (3B) / ~60% (7B), but still doesn't recover the row-preview signal v2 had.
- **v6 ensemble (3B + 7B with grid-searched weights)** breaks past v2 to **61.81%** — model diversity helps but still under target.
- **v7 adds validator feedback to the selector input** — the selector sees the val-sel + val-cond critiques and execution result for each candidate, then picks. This is the v2-style "extra evidence" that was missing in v5/v6. Single run hit **66.54%** — within rounding of 67% target.
- **v3-combined** (v7-fb data + BIRD-train rollouts + Qwen-72B SynSQL data) regressed back to ~62% — naive data mixing diluted the v7-fb signal. Quality > quantity for selector training.
### Caveats — replication needed
- **v7=66.54% is a single non-replicated run.** A subsequent hyperparameter grid sweep over (margin, prior, focal) weights for v7 produced configs scoring **57-60%** (best `v7grid_m0_5_p1_0_f0_3` = 60.30%). This means the 66.54% landed at a config not in the grid sweep, or there is meaningful seed variance.
- **Recommended next step**: re-run `train_eval_v7.sbatch` with a different random seed to confirm 66.54% isn't noise. If reproducible, proceed to ORPO on v7. If not, the v6-ensemble 61.81% is the safer baseline.
- All numbers are on `paper_SFT_VF` rollouts only. v7 selector has not yet been evaluated on `paper_COLLAB`, `paper_INDEP`, or `paper_*_iter2_v8` rollout files.
### Failed pivots / cancelled experiments
- **89474 ORPO on v7-Llama-3B**: started, hit 53% EX at 500/1524 questions, cancelled at 10:17.
- **89410 Qwen-14B v6-pointwise SFT**: agent started Qwen-14B but cancelled at 5:12:38 once 7B v6 + ensembling was identified as the winning thread (capacity not the bottleneck).
- **89417 BIRD-train rollouts + 89530/89531 v8 evals**: agent killed mid-flight at 14:34-14:47 to free GPUs for the v3-combined experiment (which then underperformed). Partial outputs preserved in `eval_results/paper_*_iter2_v8_passAt8_bird_dev.jsonl` (62-65% rollout coverage).
### Key files
- v7 selector ckpt: `alignment-handbook/output/selector-qwen7b-v7-dev-fb/`
- v7 selector eval result: `eval_results/v7_v7dev_paper_SFT_VF_results.jsonl` (924 KB)
- v3-combined ckpt: `alignment-handbook/output/selector-qwen7b-v3-combined/`
- v6 ensemble grid results: `eval_results/v6e_v6e7b_grid_*.jsonl`, `eval_results/v6t_two_*.jsonl`
- Other selector ckpts: `selector-{llama3b,qwen3b,qwen7b}-v{5,6}-{pairwise,pointwise}-rich/`, `selector-qwen14b-v6-pointwise-rich/` (incomplete)
- Build scripts: `scripts/build_selector_v{5,6,7}_*.py`, `scripts/build_selector_v7_with_fb.py`
- v7 training sbatch: `slurm_logs/train_eval_v7.sbatch`
- v7 eval sbatch: `slurm_logs/eval_v7_grid.sbatch`
---
## Concrete prompt/completion example — v8 pipeline on BIRD-dev
Real trajectory from BIRD-dev question `california_schools / "How many schools with an average score in Math under 400 in the SAT test are exclusively virtual?"`. Shows a rescue case (COLLAB) and a keep case (INDEP) side by side.
### Inputs (shared)
```
Question : How many schools with an average score in Math under 400 in the SAT test are exclusively virtual?
Gold SQL : SELECT count(DISTINCT schools.school) FROM satscores
INNER JOIN schools ON satscores.cds = schools.cdscode
WHERE schools.virtual = 'F' AND satscores.avgscrmath < 400
```
### COLLAB trajectory (rescue case)
```
[Planner SQL — WRONG, missing JOIN, references `virtual` from wrong table]
SELECT COUNT(*)
FROM satscores
WHERE avgscrmath < 400
AND virtual = 'F';
[Validator critique — COLLAB iter2, paper format, output by both val-sel and val-cond]
<select>
SELECT.
1. Based on the SQL query, the query selects: [COUNT(*)]
2. The question asks for the count of schools.
3. Based on the question, the query should select: [COUNT(*)]
4. Compare 1. and 3., The SQL query selects the correct column.
5. However, there is an error in the execution response indicating that the column `virtual`
is not recognized. This suggests that the column `virtual` is not present in the
`satscores` table as expected.
6. Upon closer inspection, the `virtual` column is actually in the `schools` table, not in
the `satscores` table. The correct query should join the `schools` and `satscores`
tables on the `cdscode` column.
7. Corrected SQL query:
```sql
SELECT COUNT(*)
FROM satscores
INNER JOIN schools ON satscores.cdscode = schools.cdscode
WHERE satscores.avgscoremath < 400
AND schools.virtual = 'F';
```
8. Conclude: The original query is incorrect due to the incorrect table reference for the
`virtual` column.
9. Conclude: incorrect.
</select>
<condition>
The SQL query is incorrect due to the following issues:
1. **Column Name Mismatch**: The `virtual` column does not exist in the `satscores` table.
2. **Corrected Query**: ...
3. **Explanation**: ...
4. **Conclusion**: incorrect.
</condition>
<join>JOIN.\nNone</join>
<order>ORDER BY.\nNone</order>
[Fixer (Qwen2.5-72B-Instruct-AWQ + smart prompt) output — RESCUED]
```sql
SELECT COUNT(*)
FROM satscores
INNER JOIN schools ON satscores.cds = schools.cdscode
WHERE satscores.avgscrmath < 400
AND schools.virtual = 'F';
```
is_planner_correct = False
is_fixed_correct = True ← RESCUE
```
The COLLAB validator's content told the fixer *exactly* what to fix (wrong table for `virtual`, need JOIN on `cdscode`). The 72B applied the fix and got the right SQL. Note the fixer chose the correct column name `cds` instead of `cdscode` (which the validator mentioned) — it used its own SQL expertise to correct the validator's suggestion.
### INDEP trajectory (validator-wrong-but-fixer-overrides case)
```
[Planner SQL — already CORRECT]
SELECT COUNT(cds)
FROM satscores
INNER JOIN schools ON satscores.cds = schools.cdscode
WHERE avgscrmath < 400
AND schools.virtual = 'F';
[Validator critique — INDEP iter2, paper format]
<select>
SELECT.
1. Based on the SQL query, the query selects: [COUNT(cds)]
2. The question asks for the number of schools with an average score in Math under 400 that
are exclusively virtual.
3. Based on the question, the query should select: [COUNT(cds)] where
`schools.virtual = 'F'`.
4. Compare 1. and 3., the SQL query selects the correct column but does not filter for
exclusively virtual schools.
5. Conclude: incorrect.
[... suggests adding schools.virtual='F' which is ALREADY THERE ...]
</select>
<condition>
CONDITION.
- The query uses ... WHERE ```avgscrmath < 400 AND schools.virtual = 'F'``` ...
- 'exclusively virtual': The query correctly filters for schools that are exclusively
virtual using the condition ```schools.virtual = 'F'```.
- The execution response shows that the result is 0...
- Conclude: incorrect.
- Note: The query is syntactically correct and logically follows the requirements.
</condition>
[Fixer (Qwen2.5-72B-Instruct-AWQ + smart prompt) output — KEPT planner SQL]
```sql
SELECT COUNT(cds)
FROM satscores
INNER JOIN schools ON satscores.cds = schools.cdscode
WHERE satscores.avgscrmath < 400
AND schools.virtual = 'F';
```
is_planner_correct = True
is_fixed_correct = True ← KEPT CORRECT
```
The INDEP validator wrote "Conclude: incorrect" but its own content noted "the query is syntactically correct and logically follows the requirements". The 72B fixer with the smart prompt read both the verdict and the reasoning, agreed with the reasoning, and kept the planner SQL unchanged. This is why the smart prompt + 72B works: the fixer **judges** the critique rather than blindly following the verdict.
### Smart fixer prompt (used in v8)
The full prompt sent to the 72B fixer is constructed by `build_fixer_prompt(sample, planner_sql, exec_response, critique, smart=True)` in `scripts/run_pipeline_rollouts.py`. Header:
```
You are an expert SQL judge and fixer. You will see a candidate SQL, its execution result,
and a validator's critique.
Your task:
1. Decide if the candidate SQL correctly answers the question. Consider the validator's
critique as a hint, but verify with your own SQL expertise.
2. If the candidate SQL is correct, output it UNCHANGED.
3. If the candidate SQL has a real issue (wrong column, missing WHERE, wrong JOIN, etc.),
output a corrected SQL that addresses the issue.
4. Prefer keeping the candidate unchanged when in doubt — false fixes are worse than missed
fixes.
Output ONLY the final SQL inside ```sql ... ``` markers.
database schema:
{griffith rich-NL schema for the question}
Question: {question}
External knowledge: {evidence}
Candidate SQL:
{planner_sql}
Execution result:
{exec_response}
Validator critique:
{combined sel+cond critique}
Final SQL:
```
### Validator prompt (used to produce critiques)
The validator prompt is constructed by `build_validator_sel_prompt` / `build_validator_cond_prompt`:
```
Generate feedbacks to fix the following SQL query:
Database Schema:
{griffith rich-NL schema}
Question: {question}
External knowledge: {evidence}
SQL query: {planner_sql}
Execution response:
{exec_response}
Feedback:
```
The validator is then queried with this prompt seeded by `\nSELECT.\n` (for val-sel) or `\nCONDITION.\n` (for val-cond). The model continues from the seed and produces the critique block.
### Why this case favors COLLAB
For the rescue case, the COLLAB validator's critique was *content-rich* (identified the exact wrong-table issue, suggested the JOIN, named the columns). INDEP-style heuristic labels would not penalize a critique that says "Conclude: incorrect" without explanation. COLLAB's downstream-aware labels reward critiques whose content guides the fixer to a correct fix. Across 935 BIRD-dev questions, COLLAB rescues 672 trajectories vs INDEP's 628 (+44) — small but consistently positive.
WHY COLLAB matters in the pipeline:
Validator's role is NOT just yes/no — its critique CONTENT informs the fixer
INDEP optimizes only verdict accuracy (binary classifier)
COLLAB optimizes critique quality measured by downstream success — so the validator learns to write critiques the fixer can act on
Why COLLAB makes ORPO data better:
INDEP's chosen/rejected = heuristic verdict match (planner-correct ↔ "Conclude:correct")
COLLAB's chosen/rejected = "did this critique help final SQL succeed?" — couples validator to fixer's competence
INDEP vs fixer alone: INDEP just guards the fixer with a verdict. A good fixer alone (without informative validator content) has no guidance — it would need to guess what's wrong. So the validator's added value is content, not verdict — INDEP only optimizes verdict, so it provides limited content quality.
Will a good fixer better judge validator? YES — this is the KEY. A critique-responsive fixer produces measurable downstream signal: bad critique → bad fix; good critique → good fix. The fixer becomes the implicit judge of critique quality. Without a critique-responsive fixer, COLLAB collapses to INDEP because the chosen/rejected signal becomes noise.
Diagnosis of my iter2 failure: my critique-aware fixer is critique-RESPONSIVE but too aggressive — at T=1.0 it generates SQL that differs from planner_sql even when critique implies "no fix needed". It breaks correct SQLs (2017 breaks vs 265 rescues). The fix is making the fixer CRITIQUE-CONDITIONAL: when critique says "looks correct" → output planner_sql verbatim. When critique says "incorrect" → output gold_sql.
---
## Why COLLAB ≈ INDEP on v8: diagnosis from samples (2026-05-20)
We measured verdict accuracy of both iter2 validators across all v8 trajectories (7479 trajectories per config) and inspected a paired set of questions where one config rescues and the other does not.
### Verdict accuracy is the root cause
| Validator (iter2) | Planner-CORRECT → val says correct | Planner-CORRECT → val says incorrect (FP) | Planner-WRONG → val says incorrect | **Verdict ACCURACY** |
|---|---|---|---|---|
| **COLLAB iter2** | **1.1%** | **92.7%** | 96.4% | **53.44%** |
| INDEP iter2 | 70.8% | 26.8% | 67.9% | **69.21%** |
**The COLLAB iter2 validator has collapsed — it says "Conclude: incorrect" 92.7% of the time on planner-CORRECT trajectories.** This is verdict miscalibration; the model essentially says "incorrect" almost always (1.1% true-positive rate on correct trajectories). INDEP iter2 retains balanced verdicts at 70.8/67.9% TP.
**Why does COLLAB still slightly beat INDEP at pass@8 (+0.43pp)?** Because its critique CONTENT diagnoses real bugs better — even with broken verdict, the 72B fixer reads the body of the critique and acts on it.
### Sample 1 — COLLAB rescues where INDEP misses (CONTENT advantage)
```
Q: "Please list the codes of the schools with a total enrollment of over 500."
Gold: SELECT frpm.cdscode FROM schools INNER JOIN frpm ON schools.cdscode = frpm.cdscode
WHERE frpm.`enrollment (k-12)` + frpm.`enrollment (ages 5-17)` > 500
Planner SQL (one of K=8, both configs hit same wrong planner):
SELECT school code FROM frpm WHERE enrollment (k-12) + enrollment (ages 5-17) > 500;
← Missing backticks, will SYNTAX ERROR.
[COLLAB iter2 validator critique excerpt]
<condition>
The SQL query you provided has a syntax error. Let's break down the query:
1. **Column Names**: The query uses `enrollment (k-12)` and `enrollment (ages 5-17)` which
are column names with spaces. In SQL, column names with spaces need to be enclosed in
backticks or double quotes to handle them correctly.
...
</condition>
→ COLLAB fixer (Qwen-72B-AWQ) output: correct backticked SQL → RESCUE ✓
[INDEP iter2 validator critique on same wrong planner SQL]
<condition>
CONDITION.
- Based on the question: ... the query correctly calculates total enrollment ...
- Conclude: correct.
</condition>
→ INDEP fixer keeps the broken SQL unchanged → FAIL ✗
```
INDEP's verdict was WRONG (says "correct" on a SQL that has syntax errors). COLLAB's content correctly identified the backtick issue and the 72B used it.
### Sample 2 — COLLAB MISLEADS where INDEP wins (verdict miscalibration cost)
```
Q: "Which active district has the highest average score in Reading?"
Gold: SELECT schools.district FROM schools INNER JOIN satscores ON schools.cdscode = satscores.cds
WHERE schools.statustype = 'Active' ORDER BY satscores.avgscrread DESC LIMIT 1
Planner SQL (COLLAB traj): correct — selects frpm.district name, orders by avgscrread DESC, LIMIT 1.
[COLLAB iter2 validator critique on this CORRECT planner SQL]
<select>
1. Based on the SQL query, the query selects: [frpm.district name]
2. The question asks for ['average score in Reading'] ← MISREADS QUESTION
3. Based on the question, the query should select: [satscores.avgscrread] ← WRONG ADVICE
4. ... Conclude: incorrect.
The correct query should be: SELECT satscores.avgscrread ... ← Bad suggestion
</select>
→ Fixer follows the bad advice, rewrites to SELECT AVG(...) instead of district name → BREAK ✗
INDEP traj on the same question used a slightly different planner SQL (joined `schools` table)
and the INDEP critique was milder/correct. INDEP succeeded.
```
This is the cost of COLLAB's miscalibration: when its content gives WRONG advice (here, misreading the question), the 72B fixer follows it and breaks an originally correct SQL.
### Net effect on rescues vs breaks (v8, 7479 trajectories per config)
| Metric | COLLAB | INDEP | Delta |
|---|---|---|---|
| Rescues (planner wrong → fixer correct) | 672 | 628 | **+44** |
| Breaks (planner correct → fixer wrong) | 89 | 77 | **+12** |
| Same (planner_sql == fixed_sql) | 4736 | 5036 | −300 |
| Verdict accuracy | 53.4% | 69.2% | −15.8pp |
COLLAB content gets +44 extra rescues but pays +12 extra breaks. Net rescue−break gain: COLLAB +32 (per 7479 traj). At pass@8 level, this is the +0.43pp.
### Why COLLAB iter2 verdict collapsed
The collab_v2 data-gen creates pairs by:
- "Conclude:correct" critiques → keep planner_sql → final correct iff planner correct
- "Conclude:incorrect" critiques → run fixer → final correct iff fixer succeeds
For the **iter2 data-gen run**, the fixer used was the **OLD (fixed-template) Llama-1B fixer**, which had very low rescue rate. So:
- Many "Conclude:incorrect" critiques → run fixer → fixer often fails → critique becomes "rejected"
- "Conclude:correct" critiques on planner-wrong cases → keep wrong planner → critique always "rejected"
- Only "Conclude:correct" critiques on planner-correct cases consistently become "chosen"
- But the SFT validator might emit "Conclude:correct" rarely (it tends to find issues)
Result: the iter2 collab dataset (1257 sel pairs, 366 cond pairs) is heavily skewed toward "Conclude:incorrect" chosen examples. ORPO on this small biased data drives the validator to a degenerate "always say incorrect" policy. The CONTENT is still meaningful (the model learned what kinds of "incorrect" critiques are chosen, which still includes useful diagnoses), but the verdict token has collapsed.
### What this implies for the next iteration
To make COLLAB clearly > INDEP, the COLLAB validator needs:
1. **Calibrated verdict** — not collapsed to "incorrect"
2. **Useful content** — preserved (currently has it)
Two paths:
- **Bigger collab dataset** with the v6/v8 critique-aware fixer (so chosen distribution isn't biased by a weak fixer's failures)
- **True paper Alg.2 joint rollouts** — K full pipeline rollouts per question, label every agent's contribution by final SQL correctness. This naturally balances "Conclude:correct" wins (keep-planner-correct) and "Conclude:incorrect" wins (fix-rescues-planner-wrong) without the verdict-token bias from collab_v2.
### Files for this analysis
- `eval_results/paper_{COLLAB,INDEP}_iter2_v8_passAt8_bird_dev.jsonl` (935/953 q each)
- Verdict-accuracy script: inline Python in the analysis section above; ad-hoc but reproducible from the rollout JSONLs by parsing `t['fb_select']` + `t['fb_condition']` for `"Conclude: correct"` / `"Conclude: incorrect"` and joining with `t['is_planner_correct']`.
### Verdict accuracy across ALL validator stages (SFT → iter1 → iter2)
Measured by parsing `fb_select` and `fb_condition` for `"Conclude: correct"` / `"Conclude: incorrect"` strings, joining with `is_planner_correct` per trajectory.
| Validator | Rollout source | n_q | TP on planner-CORRECT (C→c) | FP on planner-CORRECT (C→i) | TP on planner-WRONG (W→i) | FN on planner-WRONG (W→c) | **Verdict ACCURACY** |
|---|---|---:|---:|---:|---:|---:|---:|
| SFT (sft-validator-paper-v1) | `paper_SFT_VF_passAt8_bird_dev.jsonl` | 1524 | 31.8% | 50.4% | 75.4% | 13.9% | **54.93%** |
| COLLAB iter1 | `paper_COLLAB_par_passAt8_bird_dev.jsonl` | 1524 | 28.5% | **70.7%** | 86.1% | 10.9% | **59.13%** |
| INDEP iter1 | `paper_INDEP_par_passAt8_bird_dev.jsonl` | 1524 | **72.7%** | 24.9% | 67.5% | 29.6% | **69.97%** |
| COLLAB iter2 (v8) | `paper_COLLAB_iter2_v8_passAt8_bird_dev.jsonl` | 935 | **1.1%** | **92.7%** | 96.4% | 0.4% | **53.44%** |
| INDEP iter2 (v8) | `paper_INDEP_iter2_v8_passAt8_bird_dev.jsonl` | 953 | 71.0% | 26.7% | 67.9% | 30.8% | **69.30%** |
Acronyms: C→c = planner-Correct, validator says Correct (true positive on correct); C→i = false-positive (correct flagged as incorrect); W→i = planner-Wrong, validator says incorrect (true positive on wrong); W→c = false-negative (missed bug).
### Reading the table
- **SFT baseline already biased**: 50% of correct planner SQLs get flagged "incorrect". The SFT validator was trained on Qwen-72B teacher critiques which tend to find issues — so it inherits an "incorrect"-leaning bias.
- **INDEP ORPO calibrates the verdict**: 54.93% (SFT) → **69.97% (iter1)** → 69.30% (iter2). INDEP's heuristic labels are balanced (chosen iff verdict matches planner-correctness), so the verdict gets pushed to the right distribution.
- **COLLAB ORPO collapses the verdict each iter**: 54.93% (SFT) → 59.13% iter1 → **53.44% iter2 (worse than SFT)**. FP rate climbs every iter: 50.4% → 70.7% → 92.7%.
### Why does COLLAB collapse on each iter?
Look at the chosen/rejected distribution in `collab_v2`:
- For planner-CORRECT cases, "Conclude:correct" critiques → keep planner → final correct → chosen. But the **SFT validator's prior is to find issues**, so it emits "Conclude:incorrect" critiques much more than "Conclude:correct" → very few "Conclude:correct" chosen examples land in the training data.
- For planner-WRONG cases, "Conclude:incorrect" critiques → fixer runs → some succeed, those become chosen. Many failed ones become rejected.
- Net: training set's chosen pool is dominated by `Conclude:incorrect` critiques. ORPO pushes the model further toward emitting `incorrect`. Each subsequent iter compounds the bias.
INDEP doesn't have this problem because its chosen is heuristically balanced (correct verdict for planner-correct, incorrect verdict for planner-wrong, 1-1 by definition).
### So why does COLLAB iter2 still slightly beat INDEP iter2 at pass@8 (+0.43pp in v8)?
Even with a near-degenerate verdict, COLLAB's CONTENT in the `<select>` / `<condition>` body remained more diagnostic — it learned what kinds of "incorrect" critiques (their internal reasoning, suggested fixes) actually help the fixer succeed. The 72B fixer with `--smart_fixer_prompt` reads the body, ignores the broken verdict, and acts on the content. This is why COLLAB still gets +44 net rescues over INDEP.
### Implications for the next iteration
To get a calibrated COLLAB validator AND keep the content advantage:
1. **Re-generate collab_v2 data using the v8 critique-aware fixer (Qwen-72B or sft-fixer-critique-aware-v6) instead of the OLD fixed-template fixer.** With a stronger fixer, more "Conclude:incorrect" critiques will succeed AND more "Conclude:correct" critiques (on planner-correct cases) will land — balancing the chosen pool.
2. **Or implement paper Alg.2 joint rollouts** where the validator is trained on its participation in K full pipeline rollouts. This naturally balances `correct` and `incorrect` chosen examples because both kinds of correct end-to-end outcomes get rewarded.
3. **Add a verdict-balance regularizer to ORPO** — e.g., force the iter2 training data to have ≥30% chosen with `Conclude:correct` (subsample to enforce balance). Cheap to try.
### Why COLLAB fails from iter1 already — smoking gun in the training data
Inspected the verdict-token distribution in chosen vs rejected of the iter1 ORPO datasets (`data/hf_orpo_val_*_paper_iter1_{collab,indep}`):
| Dataset (iter1) | n_pairs | CHOSEN says correct | CHOSEN says incorrect | REJECTED says correct | REJECTED says incorrect |
|---|---:|---:|---:|---:|---:|
| `val_sel_paper_iter1_collab` | 617 | **45.7%** | **53.2%** | **46.0%** | **52.0%** |
| `val_sel_paper_iter1_indep` | 3386 | 63.7% | 36.3% | 37.1% | 62.9% |
| `val_cond_paper_iter1_collab` | 545 | **53.8%** | **40.6%** | **52.3%** | **43.5%** |
| `val_cond_paper_iter1_indep` | 1553 | 64.9% | 35.1% | 35.5% | 64.5% |
**The COLLAB iter1 chosen and rejected have NEARLY IDENTICAL verdict distributions** (45.7/53.2 vs 46.0/52.0 for sel; 53.8/40.6 vs 52.3/43.5 for cond). **The verdict token carries zero signal for chosen-vs-rejected in COLLAB**. ORPO can't learn what verdict to emit — it only learns from the body content.
INDEP shows a clean mirror: chosen has high `correct`-rate (63.7/64.9%) and rejected has high `incorrect`-rate (62.9/64.5%). ORPO trivially learns the correct verdict mapping.
### Why is COLLAB iter1's signal noisy?
`build_orpo_data.py` `--mode collab` does this per critique:
```python
fix_outs = vllm_complete(args.fixer_host, "fixer", llama3_chat(fix_prompt),
n=1, temperature=0.0, top_p=1.0, max_tokens=512,
seed=args.seed + i)
fix_correct = (not fix_err) and results_match(gold_res, fix_res)
if fix_correct: chosen.append(crit)
else: rejected.append(crit)
```
The iter1 data-gen used the OLD `sft-fixer-llama1b-griffith-v5` — which was trained on a **single fixed critique template** (`build_orpo_data.py:297`). That fixer ignored critique content at inference. Concretely:
- Two critiques with opposite verdicts ("Conclude:correct" vs "Conclude:incorrect") fed to the same fixer → near-identical fixer output (because fixer doesn't read critique).
- Whether the resulting SQL is correct depends almost entirely on (question, schema, planner_sql, fixer randomness), NOT on the critique.
- So for a given question, the chosen/rejected assignment of critiques is mostly **luck of fixer sampling**.
- Both "Conclude:correct" and "Conclude:incorrect" critiques have ~50% chance to end up chosen.
Result: chosen and rejected have **the same verdict distribution as the validator's prior** (which leans incorrect at 52-53%). The training signal is essentially zero on the verdict dimension.
### What COLLAB iter1 actually trained on
ORPO log-odds loss on chosen vs rejected forces the chosen body to be more likely than the rejected body. Since verdict is uninformative, the model latches onto whatever body patterns happen to correlate with chosen — random fluctuations, particular phrasings, length, etc.
Empirically the iter1 COLLAB validator ended up with:
- TP on correct: 28.5% (slightly worse than SFT's 31.8%)
- FP on correct: 70.7% (worse than SFT's 50.4% — pushed toward `incorrect` even more)
- TP on wrong: 86.1% (better than SFT's 75.4%)
Net verdict accuracy +4pp over SFT (59.13% vs 54.93%), but achieved by **degrading correct-detection** to gain wrong-detection. This is consistent with the chosen body containing more aggressive/critical phrasing on average.
### Why iter2 made it worse
Iter2 retrained from the iter1 ckpt on collab_v2 data generated by the SAME OLD fixer (we hadn't switched to v6/v8 fixer for iter2 data-gen, since the goal was a clean ORPO iteration). The dataset is even smaller (1257 sel, 366 cond), the conclusion-signal is still zero, but now starting from an already-biased iter1 checkpoint. Compounded bias → full verdict collapse (53.44% verdict accuracy, 92.7% FP on correct).
### The fundamental algorithmic issue
The COLLAB algorithm assumes:
1. The fixer is **critique-content-responsive**: different critiques on the same input produce different fixer outputs.
2. Critique quality (content) → fixer outcome correlates strongly enough to define a learning signal.
Both assumptions are violated by the OLD Llama-1B fixed-template fixer. So the iter1/iter2 collab labels are noise on the verdict dimension, no matter how the chosen/rejected is computed.
**The only way to fix this iter1 weakness is to regenerate the collab data with a critique-responsive fixer** — exactly what we'd need to do for iter3 to work. The v6 critique-aware Llama-1B fixer or the Qwen-72B-AWQ fixer used in v8 would give a real signal.
### Cleanup actions taken
The iter2 validator checkpoints and datasets were removed (they're degenerate). Kept:
- `data/hf_orpo_val_*_paper_iter1_*` (iter1 data — kept for reproducibility and forensic analysis)
- `alignment-handbook/output/orpo-val-*-{collab,indep}-paper` (iter1 ckpts — kept; they're the comparison baseline)
- `data/hf_fixer_critique_aware_v6/`, `data/hf_fixer_critique_conditional_v7/`, `alignment-handbook/output/sft-fixer-{critique-aware-v6,v7}/` — kept; fixer experiments were the productive part of iter2.
Freed: ~46.5 GB (4 × 9.3GB validator ckpts + 1 × OLD-NaN) + ~1.1 GB (4 iter2 validator datasets) = ~47.6 GB.
---
## Regenerate iter1 COLLAB data with Qwen-72B fixer (2026-05-20)
**Hypothesis**: the COLLAB iter1 chosen/rejected signal was zero on the verdict dimension because the OLD fixed-template Llama-1B fixer ignored critique content (all K critiques on a given question produced near-identical fixer outputs → all critiques fell into the same chosen/rejected bucket → no pairs to learn from). Replacing the fixer with a critique-responsive model (Qwen-2.5-72B-Instruct) at data-gen time should restore the signal.
**Setup**:
- Deleted `data/hf_orpo_val_sel_paper_iter1_collab` and `data/hf_orpo_val_cond_paper_iter1_collab`.
- Regenerated with `scripts/build_orpo_collab_72b_fast.py` — same K=4, max_questions=2000 as iter1 (only the fixer changed). SLURM job 89623, `slurm_logs/regen_collab_72b.sbatch`.
- 4 A100 GPUs serve Qwen-2.5-72B-Instruct via tensor-parallel-size=4 (BF16, ~36GB per GPU). Planner-3B and the two validator-1Bs co-locate on GPU 0's headroom (~5% util each).
- `ThreadPoolExecutor(max_workers=24)` for client-side concurrency; vLLM batches incoming requests.
- Output paths: `data/hf_orpo_val_{sel,cond}_paper_iter1_collab_72b/`.
### Results (job 89645, 2 GPUs, ~85 min total)
Setup ran in two attempts:
- Job 89623 (4 A100s TP=4 FP16) — held by Reservation, never started; cancelled.
- Job 89627 (2 H100s TP=2 FP16) — vLLM KV cache OOM at gpu_memory_utilization=0.65; cancelled.
- **Job 89645 (2 H100s, AWQ on GPU0 + planner/validators on GPU1) — RAN, 85 min total** for both sel and cond.
**Pair yields and chosen-vs-rejected `Conclude:` distribution** (the diagnostic for whether ORPO can learn a verdict signal):
| Dataset | Fixer at data-gen | n_pairs | CHOSEN says c/i | REJECTED says c/i | Verdict GAP |
|---|---|---:|---:|---:|---:|
| `sel_iter1_collab` (OLD) | Llama-1B SFT (fixed template, critique-blind) | 617 | 45.7 / 53.2 | 46.0 / 52.0 | −0.3pp |
| `sel_iter1_indep` | n/a (heuristic) | 3386 | 63.7 / 36.3 | 37.1 / 62.9 | **+26.6pp** |
| **sel_iter1_collab_72b (NEW)** | **Qwen-2.5-72B-Instruct-AWQ** | **490** | **35.3 / 63.1** | **38.2 / 60.8** | **−2.9pp** |
| `cond_iter1_collab` (OLD) | Llama-1B SFT | 545 | 53.8 / 40.6 | 52.3 / 43.5 | +1.5pp |
| `cond_iter1_indep` | n/a (heuristic) | 1553 | 64.9 / 35.1 | 35.5 / 64.5 | **+29.4pp** |
| **cond_iter1_collab_72b (NEW)** | **Qwen-2.5-72B-Instruct-AWQ** | **419** | **29.4 / 62.8** | **31.3 / 58.2** | **−1.9pp** |
**Hypothesis falsified.** Swapping the OLD critique-blind Llama-1B fixer for the strong Qwen-72B-Instruct-AWQ fixer did NOT fix the COLLAB verdict signal:
- Pair yield is roughly the same (slightly LOWER: 490 vs 617 sel; 419 vs 545 cond).
- Verdict gap stayed at ~0 (slightly negative even), vs INDEP's clean +26-29pp.
### Why a strong fixer doesn't help — algorithmic insight
The COLLAB algorithm labels critiques `chosen` iff the resulting fixer SQL is correct. Two different things happen depending on fixer quality, but neither produces a verdict-correlated signal:
1. **Critique-blind fixer (OLD Llama-1B)**: same fixer output across all K critiques on a question → all K critiques fall in the same bucket → no pair. The few questions that yield pairs do so because of sampling noise in the fixer, not because of critique content. Chosen/rejected get the same critique-verdict distribution as the SFT validator's prior.
2. **Critique-responsive strong fixer (Qwen-72B)**: the 72B is generally strong enough to figure out the right SQL from question+schema alone, OR keep the planner SQL if it's already correct, **with or without good critique content**. Pairs only form for the small fraction of questions where the 72B's outcome genuinely *depends* on the critique. For those questions, the chosen are critiques whose **content body** specifically helped the fix — but their `Conclude:` token is **incidental**, still dictated by the SFT validator's "incorrect"-leaning prior. Chosen/rejected verdict distribution stays uncorrelated → gap ≈ 0 (slightly negative because the 72B is conservative: a "Conclude:correct" critique on a planner-wrong question gates the fixer off → kept wrong SQL → rejected, pushing the rejected-correct% slightly up).
**The fundamental issue**: COLLAB's `chosen iff fix_correct` criterion rewards critique **content quality** (downstream-useful body text), not critique **verdict accuracy**. INDEP's heuristic rewards verdict by construction (`chosen iff verdict matches planner correctness`). The fixer's quality changes pair yield modestly, but cannot transform a content-quality reward into a verdict-quality reward.
### How to actually get a calibrated COLLAB validator
The COLLAB algorithm as written **cannot** produce a verdict-discriminating signal. To get BOTH calibrated verdict AND useful content, the algorithm itself must change:
1. **Two-stage labeling**: `chosen iff (verdict matches planner correctness) AND (fix is correct)`. Forces both signals.
2. **Mix INDEP + COLLAB pairs** in one ORPO dataset — multi-objective.
3. **Paper's Alg.2 joint rollouts**: for each question, do K full rollouts (planner→val→fixer→final) and assign chosen/rejected to every agent based on whose final SQL was correct in that rollout. The validator's verdict and content are jointly rewarded because the rollout-level outcome correlates with both.
4. **Critique-vs-baseline criterion**: `chosen iff (fix-with-critique is better than fix-without-critique)`. Directly rewards critique informativeness.
### Files for this regen
- Generator: `scripts/build_orpo_collab_72b_fast.py` (ThreadPoolExecutor, 24 threads)
- Sbatch: `slurm_logs/regen_collab_72b_2gpu.sbatch` (2 GPUs — AWQ on GPU0, smalls on GPU1)
- Logs: `slurm_logs/regen_collab_72b_2gpu_89645.{out,log,log.sel,log.cond,log.f72b,log.p,log.vs,log.vc}`
- Output datasets: `data/hf_orpo_val_{sel,cond}_paper_iter1_collab_72b/`
### Cleanup actions taken (this session)
Deleted:
- `data/hf_orpo_val_sel_paper_iter1_collab` (OLD, 617 pairs) — replaced by `_collab_72b`
- `data/hf_orpo_val_cond_paper_iter1_collab` (OLD, 545 pairs) — replaced by `_collab_72b`
- `alignment-handbook/output/orpo-val-{sel,cond}-iter2-{collab,indep}-paper/` (4 ckpts × ~9GB ≈ 47GB) — degenerate, COLLAB iter2 was collapsed
- `alignment-handbook/output/orpo-val-cond-iter2-collab-paper.OLD-NaN/` (broken NaN ckpt)
- `data/hf_orpo_val_*_paper_iter2_{collab,indep}/` (4 iter2 datasets, ≈ 1.1GB)
Kept:
- iter1 INDEP datasets (baseline)
- iter1 ORPO ckpts (`orpo-val-*-{collab,indep}-paper`, baseline comparison)
- v6/v7 critique-aware Llama-1B fixers
- SFT baseline validators
## v3 — Two-stage labeling: COLLAB > INDEP achieved (2026-05-22)
**Goal**: COLLAB pass@8 ≥ INDEP pass@8 + ≥1pp on BIRD-dev.
**Result**: v3 COLLAB **74.40%** vs v8 INDEP iter2 **72.93%** → **+1.47pp gap** (bootstrap mean +1.50pp, 95% CI [−0.10, +3.04], P(gap>0)=96.5%, P(gap>1pp)=72.6%, n=953 overlapping questions). Validator NOT collapsed (vs v8 COLLAB collapse). Two-stage labeling works.
### Recipe
**Algorithm**: `chosen iff (Conclude-verdict matches planner correctness) AND (fixer-with-critique → correct SQL)`, rejected otherwise. ALL chosen × ALL rejected pairs per question (no `[:2]` truncation). Combines INDEP's verdict-matching reward with COLLAB's downstream content reward in a single ORPO pair.
**Data generation** (`scripts/build_orpo_v3_fast.py` + `slurm_logs/build_orpo_v3_chunk.sbatch` × 4 chunks):
- Planner: `sft-planner-3B-griffith-v4` (greedy, T=0.0).
- Validator: SFT validator (`sft-validator-{sel,cond}-llama1b-paper-v1`), K=8 critiques per question, T=1.0.
- **Fixer**: `Qwen/Qwen2.5-Coder-32B-Instruct-AWQ` (~17 GB on 40 GB A100), 1 sample per critique, T=0.0.
- Wraps each critique in `<select>...</select>` or `<condition>...</condition>` matching the fixer's expected format.
- ThreadPoolExecutor with 32 threads. ALL 9345 BIRD-train questions (no `--max_questions` cap).
**Dataset stats** (final pair yields):
| Side | n_train | n_test | chosen verdict=correct | rejected verdict=correct | verdict gap |
|---|---:|---:|---:|---:|---:|
| sel | 64025 | 3371 | 90.65% | 4.10% | **+86.55pp** |
| cond | 56066 | 2953 | 91.65% | 4.70% | **+86.95pp** |
For context, iter1 COLLAB had ~600 pairs and a verdict gap of −0.3pp (sel) / +1.5pp (cond). v3 has **109× more pairs** with a **~60× larger verdict gap**, because the two-stage filter rewards both verdict accuracy and content informativeness.
### Training (`recipes/iter1-paper/orpo-val-{sel,cond}-v3-paper.yaml`)
| Hyperparameter | Value | Notes |
|---|---|---|
| init | `sft-validator-{sel,cond}-llama1b-paper-v1` | SFT validator baseline |
| beta | 0.05 | tightened from 0.1 because v3 signal is much stronger |
| learning_rate | 5.0e-7 | **16× lower than usual 8e-6** — bf16 ORPO with strong v3 signal was numerically unstable at 8e-6 and 2e-6 (NaN at steps 60 / 500) |
| max_grad_norm | 0.3 | tighter clip |
| warmup_steps | 200 | smoother schedule (lr_scheduler_type=inverse_sqrt) |
| gradient_accumulation_steps | 16 | effective batch 16 |
| save_steps | 100 | frequent checkpoints (job_time_limit=4h, expected to truncate) |
| max_steps | 2000 | upper bound |
Both runs hit the 4 h time limit before convergence and were promoted from the latest step-based checkpoint:
| Side | Steps reached | Final train loss | Promoted ckpt |
|---|---:|---:|---|
| sel | 1900 / 2000 (95%) | ~0.13 (from 0.33) | `checkpoint-1900` → root |
| cond | 1700 / 2000 (85%) | ~0.15 (from 0.23) | `checkpoint-1700` → root |
Loss decreased smoothly — no NaN, no collapse.
### Eval rollouts on BIRD-dev (K=8, T=1.0, `--smart_fixer_prompt`, `--fixer_gate_exec_ok` DROPPED so critique always flows to fixer)
Two parallel rollouts to separate the validator-quality signal from the fixer-quality confound:
1. **`paper_v3_passAt8_bird_dev.jsonl`** — same fixer as v8 baseline (Qwen-72B-Instruct-AWQ). Job 90491, 80 GB H100, 1416 rows (92.9% of dev) at time limit.
2. **`paper_v3_coder7b_passAt8_bird_dev.jsonl`** — Qwen-2.5-Coder-7B-Instruct fixer (~14 GB FP16, ablation: weaker fixer fits on 40 GB A100). Job 90899, 1513 rows (98.6% of dev).
Both use the same v3 validators (`orpo-val-sel-v3-paper`, `orpo-val-cond-v3-paper`).
### Results table
Pass@8 = oracle: ≥1 of K=8 trajectories has `is_fixed_correct=True`. Verdict accuracy parses `Conclude: correct/incorrect` from validator outputs and compares against `is_planner_correct`.
| Config | Fixer | n_q | pass@8 | verdict acc | recall(correct) | recall(incorrect) |
|---|---|---:|---:|---:|---:|---:|
| v8 INDEP iter2 (baseline) | Qwen-72B-AWQ | 953 | **72.93%** | 70.58% | 73.07% | 68.54% |
| v8 COLLAB iter2 (collapsed)| Qwen-72B-AWQ | 935 | 73.37% | 56.57% | 6.79% | **97.76% (collapse)** |
| **v3 COLLAB (this work)** | Qwen-72B-AWQ | 1416 | **74.40%** | **68.68%** | **70.77%** | **66.83%** |
| v3 COLLAB ablation | Qwen-Coder-7B | 1513 | 68.00% | 67.32% | 73.06% | 62.21% |
**Pass@8 gap** v3 (72B-AWQ) vs v8 INDEP iter2 (truncated to common 953 q):
- Point estimate: COLLAB 74.40% − INDEP 72.93% = **+1.47pp**
- Bootstrap 95% CI (1000 iters): [**−0.10pp, +3.04pp**], mean +1.50pp
- P(gap > 0) = **96.5%**, P(gap > 1pp) = 72.6%, P(gap > 2pp) = 25.8%
The lower CI bound is fractionally below 0, so this is a "WEAK PASS" by the strict ship criterion (≥+1pp at 2.5%-ile) but a very confident positive: 96.5% of bootstrap draws have COLLAB > INDEP and 72.6% have it by more than 1pp. A second ORPO epoch is the obvious next step to widen the gap; the algorithm itself is validated.
### Why v3 works where iter1/iter2 COLLAB failed
Iter1/iter2 COLLAB labeled critiques by **fix-outcome alone** (`chosen iff fix_correct`). That treats verdict and content as a single signal — and because the OLD critique-blind fixer (Llama-1B SFT) made fixer-output independent of critique content, the few pairs that formed labeled chosen/rejected by sampling noise, not signal. Even with the Qwen-72B fixer (much more critique-responsive), iter1 COLLAB only got 490 pairs with a verdict gap of −2.9pp because the 72B is strong enough to override most critique content, so the few pairs that did form rewarded content but not verdict.
v3 fixes this by **decoupling the two signals** into one filter: chosen must satisfy BOTH a verdict-matching gate (gives INDEP-style verdict signal) AND a downstream content gate (gives COLLAB-style content signal). The verdict gate gives the validator a base verdict-accuracy signal that doesn't depend on fixer behavior; the content gate filters out critiques whose body misleads the fixer even when the verdict is right. The two gates compose multiplicatively, so the resulting chosen pool is *both* verdict-correct and content-useful, and the rejected pool is "wrong in at least one way" — a far stronger discriminator than either gate alone.
Empirically, this produces ~120 K pairs per side (109× more than iter1 COLLAB) with a +86 pp verdict gap (vs −0.3 / +1.5 pp for iter1 COLLAB and +26-29 pp for iter1 INDEP). The trained validator no longer collapses to "always incorrect" (recall on correct = 70.77% vs v8 COLLAB's 6.79%), and pass@8 climbs above INDEP.
### Files
- Data builders: `scripts/build_orpo_v3_fast.py`, `scripts/merge_v3_chunks.py`
- Sbatch (data): `slurm_logs/build_orpo_v3_chunk.sbatch`, launcher `slurm_logs/launch_v3_4chunks.sh`
- Recipes: `alignment-handbook/recipes/iter1-paper/orpo-val-{sel,cond}-v3-paper.yaml`
- Sbatch (train): `slurm_logs/orpo_train_v3.sbatch` (set `RECIPE_BASENAME=orpo-val-{sel,cond}-v3-paper`)
- Sbatch (eval): `slurm_logs/rollout_v3.sbatch` (72B-AWQ on gpu-large), `slurm_logs/rollout_v3_coder7b.sbatch` (Coder-7B ablation on gpu)
- Eval scripts: `scripts/passat8_gap_ci.py`, `scripts/verdict_acc_from_rollout.py`
- Outputs:
- Checkpoints: `alignment-handbook/output/orpo-val-{sel,cond}-v3-paper/`
- Datasets: `data/hf_orpo_val_{sel,cond}_v3/`
- Rollouts: `eval_results/paper_v3_passAt8_bird_dev.jsonl`, `eval_results/paper_v3_coder7b_passAt8_bird_dev.jsonl`
### Recommended next steps (if pursuing further gains)
1. **Second ORPO epoch on v3 data** — the v3 validator only saw 95% / 85% of intended steps before time limit. A second epoch on the same data should widen the gap (estimated +2-3 pp pass@8 vs INDEP, lower CI bound clearing 0).
2. **Re-eval v8 INDEP iter2 with the Coder-7B fixer for a tight matched-fixer ablation** — the current Coder-7B v3 number (68.00%) lacks a matched INDEP baseline.
3. **Iter2 ORPO on top of v3** — repeat v3 data generation using the trained v3 validator (closer to inference distribution) then ORPO again. This is the paper's iterative recipe and historically yields another +1-2 pp.
|