thanhdath commited on
Commit
778d47d
·
verified ·
1 Parent(s): 11471f8

Push code: scripts, slurm sbatch, recipes, utils (v3 + selector series)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. code/.gitignore +51 -0
  2. code/AGENTS_REPORT.md +1257 -0
  3. code/AGENT_WAKE.md +58 -0
  4. code/CANONICAL.md +69 -0
  5. code/HANDOFF_COLLAB_TASK.md +275 -0
  6. code/HANDOFF_SELECTOR_TASK.md +250 -0
  7. code/MATS_SQL_BUNDLE_PROGRESS.md +144 -0
  8. code/PROGRESS.md +334 -0
  9. code/PROGRESS_bundle.md +144 -0
  10. code/PROGRESS_v3.md +58 -0
  11. code/README.md +90 -0
  12. code/WORKFLOW_GF_HENRY.md +186 -0
  13. code/alignment-handbook/.github/workflows/build_documentation.yml +18 -0
  14. code/alignment-handbook/.github/workflows/build_pr_documentation.yml +19 -0
  15. code/alignment-handbook/.github/workflows/quality.yml +31 -0
  16. code/alignment-handbook/.github/workflows/tests.yml +31 -0
  17. code/alignment-handbook/.github/workflows/upload_pr_documentation.yml +16 -0
  18. code/alignment-handbook/.gitignore +165 -0
  19. code/alignment-handbook/LICENSE +201 -0
  20. code/alignment-handbook/Makefile +44 -0
  21. code/alignment-handbook/README.md +5 -0
  22. code/alignment-handbook/environment.yml +221 -0
  23. code/alignment-handbook/recipes/accelerate_configs/deepspeed_dpo.yaml +17 -0
  24. code/alignment-handbook/recipes/accelerate_configs/deepspeed_original.yaml +22 -0
  25. code/alignment-handbook/recipes/accelerate_configs/deepspeed_zero3.yaml +17 -0
  26. code/alignment-handbook/recipes/accelerate_configs/multi_gpu.yaml +16 -0
  27. code/alignment-handbook/recipes/accelerate_configs/no_offload_optimizer.yaml +17 -0
  28. code/alignment-handbook/recipes/accelerate_configs/single_gpu.yaml +16 -0
  29. code/alignment-handbook/recipes/accelerate_configs/single_gpu0_local.yaml +16 -0
  30. code/alignment-handbook/recipes/accelerate_configs/single_gpu1_local.yaml +15 -0
  31. code/alignment-handbook/recipes/accelerate_configs/single_gpu_gf_henry.yaml +16 -0
  32. code/alignment-handbook/recipes/accelerate_configs/zero2.yaml +16 -0
  33. code/alignment-handbook/recipes/iter1-paper/orpo-val-cond-collab-paper.yaml +42 -0
  34. code/alignment-handbook/recipes/iter1-paper/orpo-val-cond-indep-paper.yaml +42 -0
  35. code/alignment-handbook/recipes/iter1-paper/orpo-val-cond-v3-paper.yaml +42 -0
  36. code/alignment-handbook/recipes/iter1-paper/orpo-val-sel-collab-paper.yaml +42 -0
  37. code/alignment-handbook/recipes/iter1-paper/orpo-val-sel-indep-paper.yaml +42 -0
  38. code/alignment-handbook/recipes/iter1-paper/orpo-val-sel-v3-paper.yaml +42 -0
  39. code/alignment-handbook/recipes/iter1/orpo-fixer-iter1.yaml +42 -0
  40. code/alignment-handbook/recipes/iter1/orpo-planner-iter1.yaml +42 -0
  41. code/alignment-handbook/recipes/iter1/orpo-val-cond-collab-iter1.yaml +42 -0
  42. code/alignment-handbook/recipes/iter1/orpo-val-cond-indep-iter1.yaml +42 -0
  43. code/alignment-handbook/recipes/iter1/orpo-val-sel-collab-iter1.yaml +42 -0
  44. code/alignment-handbook/recipes/iter1/orpo-val-sel-indep-iter1.yaml +42 -0
  45. code/alignment-handbook/recipes/iter2-paper/orpo-val-cond-collab-iter2-paper.yaml +42 -0
  46. code/alignment-handbook/recipes/iter2-paper/orpo-val-cond-indep-iter2-paper.yaml +42 -0
  47. code/alignment-handbook/recipes/iter2-paper/orpo-val-sel-collab-iter2-paper.yaml +42 -0
  48. code/alignment-handbook/recipes/iter2-paper/orpo-val-sel-indep-iter2-paper.yaml +42 -0
  49. code/alignment-handbook/recipes/llama-1b-bird/fixed-fft.yaml +42 -0
  50. code/alignment-handbook/recipes/llama-1b-bird/llama-3-bird-planner-fft.yaml +44 -0
code/.gitignore ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__
2
+ pred_sqls.txt
3
+ predict_dev.json
4
+ output/
5
+ test_suite_sql_eval
6
+ seeklhy/
7
+ sic_ckpts/
8
+ data/
9
+ log-tensorboard/
10
+ *.json
11
+ temp/
12
+ *.log
13
+ *.csv
14
+ db_content_retrieval/volumes
15
+ offload/
16
+ *.xlsx
17
+ test_suite_sql_eval
18
+ alignment-handbook/thanhdath/
19
+ progress.jsonl
20
+ logs/
21
+ temp.sh
22
+ *.pkl
23
+ *.jsonl
24
+ *.safetensors
25
+ *.bin
26
+ .ipynb_checkpoints/
27
+ .claude/
28
+ .env
29
+ hs_err_pid*.log
30
+ hs_err_pid*
31
+ eval_results/*
32
+ !eval_results/.gitkeep
33
+ core.*
34
+ .DS_Store
35
+ *.swp
36
+ *.swo
37
+ node_modules/
38
+ build/
39
+ dist/
40
+ *.egg-info/
41
+ .pytest_cache/
42
+ .coverage
43
+ htmlcov/
44
+
45
+ # Allow important config JSONs that *.json would otherwise hide
46
+ !environment.yml
47
+ !README.md
48
+ !*.md
49
+ !.gitignore
50
+ !alignment-handbook/recipes/**/*.yaml
51
+ !alignment-handbook/recipes/**/*.yml
code/AGENTS_REPORT.md ADDED
@@ -0,0 +1,1257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MATS-SQL Agents — Training Report
2
+
3
+ Multi-agent Text-to-SQL pipeline on BIRD-bench, reproducing the MATS paper (arXiv:2512.18622).
4
+
5
+ All paths below are relative to `/weka/s225250685/mats-tist/` unless absolute.
6
+
7
+ ---
8
+
9
+ ## TL;DR — current state (2026-05-20)
10
+
11
+ - **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`.
12
+ - **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.
13
+ - **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.
14
+ - **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.
15
+ - **Bundle**: `thanhdath/mats-sql-bundle` ships the trained models + all SFT/DPO training data — symlinked at `alignment-handbook/output/thanhdath_*`.
16
+
17
+ ---
18
+
19
+ ## Plain-English summary: COLLAB vs INDEP (the bottom line)
20
+
21
+ ### Q1. Is COLLAB better than INDEP?
22
+
23
+ **Depends on the metric.**
24
+
25
+ | Metric | Winner | Numbers |
26
+ |---|---|---|
27
+ | **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]) |
28
+ | **pass@8 (BIRD-dev oracle)** with v7 critique-conditional 1B fixer | INDEP | 66.51% vs 58.88% (+7.63pp INDEP) |
29
+ | **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]) |
30
+ | **Validator verdict accuracy** (parse Conclude:correct/incorrect, check vs planner correctness) | **INDEP always** | iter1: 70% vs 59%; iter2: 69% vs 53% |
31
+ | **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) |
32
+
33
+ ### Q2. What's the "right" metric?
34
+
35
+ **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.
36
+
37
+ **Validator verdict accuracy** is a diagnostic — INDEP is always far better because its training objective directly optimizes verdict.
38
+
39
+ **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.
40
+
41
+ ### Q3. Why are there so few COLLAB pairs?
42
+
43
+ **The COLLAB algorithm has structurally low pair yield.** Compare the math:
44
+
45
+ | Mode | Pair-formation rule | Typical yield (K=4, 2000 questions, max 4 pairs/q = 8000 max) |
46
+ |---|---|---|
47
+ | 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 |
48
+ | 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 |
49
+ | **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 |
50
+
51
+ **Why so few**:
52
+ - COLLAB needs **at least one chosen and one rejected critique per question**.
53
+ - This requires the fixer to react *differently* to different critiques on the same question.
54
+ - With a weak fixer that ignores critique content → same output every time → all 4 critiques end up in the same bucket → 0 pairs.
55
+ - With a strong fixer that figures out the SQL regardless → also same outcome → 0 pairs.
56
+ - Pairs only form on the small "boundary" set of questions where the fixer's outcome is genuinely sensitive to which specific critique it got.
57
+
58
+ 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.
59
+
60
+ ### Q4. Can we get 9000 COLLAB pairs?
61
+
62
+ **Not with the current `--mode collab` algorithm as written.** Math:
63
+
64
+ - Current cap: `max_questions × min(2,#chosen) × min(2,#rejected) = 2000 × 4 = 8000 max`. We get ~500 = 6% yield → ceiling far below 9000.
65
+ - To reach 9000 we need EITHER more questions, OR more pairs per question, OR a different algorithm.
66
+
67
+ **Achievable ways to get ≥9000 pairs**:
68
+
69
+ 1. **Use ALL 9428 BIRD-train questions** (currently we use 2000) → ceiling 4 × 9428 = 37712 max. At 6% yield → ~2300 pairs. Still not 9000.
70
+
71
+ 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).
72
+
73
+ 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.
74
+
75
+ 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.
76
+
77
+ 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.
78
+
79
+ ### Q5. Even if we had 9000 pairs, would COLLAB > INDEP?
80
+
81
+ **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).
82
+
83
+ To actually beat INDEP on a pipeline-level metric, we need either:
84
+ - A stronger fixer than 1B with COLLAB pairs (v8 with 72B got us to tied, +0.43pp NS), OR
85
+ - An algorithm change that rewards BOTH verdict AND content (options 3/4/5 above).
86
+
87
+ 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.
88
+
89
+ ---
90
+
91
+ ## MATS pipeline (paper §3)
92
+
93
+ Five specialized SLMs (LLaMA-3.2 sizes in paper; we use Qwen2.5-Coder equivalents):
94
+
95
+ ```
96
+ question + DB
97
+
98
+
99
+ SCHEMA INSIGHT (RoBERTa-large, CodeS-style table/column ranker)
100
+ │ → pruned schema + BM25 value matching
101
+
102
+ PLANNER (3B) K=10 candidates (1 greedy + 9 multinomial T=1.0)
103
+ │ → CoT: Goal to select → Condition → Tables to use → Final SQL
104
+
105
+ VALIDATOR-SEL (0.5B) critique the SELECT clause: `<select>...</select>`
106
+ VALIDATOR-COND (0.5B) critique WHERE/HAVING/CASE: `<condition>...</condition>`
107
+ │ feedback → triggers FIX if "INCORRECT"
108
+
109
+ FIX (1B) rewrites SQL using critique
110
+
111
+
112
+ SELECTOR (3B) picks best of K candidates given execution results
113
+
114
+
115
+ final SQL
116
+ ```
117
+
118
+ **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).
119
+
120
+ **Reference numbers (paper Table 1 / Table 6)**:
121
+ - SFT-only planner: 53.65% EX greedy
122
+ - + RLEF iter 1: 56.32%
123
+ - + 3 iters: 59.32%
124
+ - Full MATS pipeline: 64.73%
125
+
126
+ **Training recipe (paper §5.1)**:
127
+ - SFT: lr=2e-5, batch=128 effective, 4 epochs, **completion-only loss** (eq. 8)
128
+ - ORPO/RLEF: lr=5e-6, λ=0.5, batch=64, 1 epoch or ≤800 steps, completion-only loss
129
+ - Planner: K=10 candidates (1 greedy + 9 multinomial @ T=1.0) — but **user constraint: K=8 fixed**
130
+
131
+ ---
132
+
133
+ ## Schema format (CRITICAL — RICH griffith NL is the only correct format)
134
+
135
+ Three formats encountered across the codebase + bundle. **Only griffith NL has all 5 information sources** the model needs:
136
+
137
+ ### Format A: Raw Python dict (WORST — flagged broken)
138
+ ```
139
+ {'schema_items': [{'table_name': 'frpm', 'table_comment': '', 'column_names': [...],
140
+ 'column_types': [...], 'column_comments': ['','',...EMPTY], 'column_contents': [...]}]}
141
+ ```
142
+ - No table descriptions
143
+ - No column descriptions
144
+ - No value descriptions
145
+ - Found in: `data/sft_bird_with_evidence_dev_text2sql.json` (original BIRD-DEV file),
146
+ `thanhdath/mats-sql-bundle/data/sft_selector_classifier_v2_rows` (bundle's selector data, **BUG**)
147
+
148
+ ### Format B: CodeS-style (thanhdath planner's training format — DECENT)
149
+ ```
150
+ table movies , columns = [
151
+ movie_title_language | type: text
152
+ movie_popularity | type: integer
153
+ director_name | type: text ; has None value ; values: Don Most , 808 State
154
+ movie_id | primary key ; type: integer
155
+ divid | type: text ; meaning: division id ; has None value
156
+ ]
157
+ foreign keys:
158
+ movies.director_id = directors.id
159
+ ```
160
+ - Has types, sample values, null indicators, primary keys
161
+ - Sometimes has `meaning:` (column description)
162
+ - **Missing**: rich table descriptions, value descriptions, semantic context
163
+ - Found in: `thanhdath/planner-sft-gpt-4o-mini-...` (7327 rows), `thanhdath/mats-sql-bundle` planner SFT
164
+
165
+ ### Format C: CREATE TABLE DDL (validator training format)
166
+ ```sql
167
+ CREATE TABLE twitter (
168
+ tweetid text, -- Example Values: `tw-682712873332805633` | Primary Key
169
+ sentiment real, -- Example Values: `0.0`
170
+ locationid integer, -- Example Values: `3751`
171
+ );
172
+ -- FK: twitter.userid -> user.userid
173
+ ```
174
+ - Has types, example values, FK comments
175
+ - **Missing**: table descriptions, rich column meanings, value descriptions
176
+ - Found in: bundle's `sft-validator-{selection,condition}-v3`, `thanhdath/bird_dev_prompts_raw`
177
+
178
+ ### Format D: Griffith NL — CORRECT (rich, all info)
179
+ ```
180
+ Database Schema:
181
+
182
+ 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.
183
+ lists.user_id: INTEGER - ID related to the user who created the list.
184
+ Sample values: "88260493"
185
+ lists.list_url: TEXT - URL to the list page on Mubi
186
+ Sample values: "http://mubi.com/lists/top20-popular-movies"
187
+ lists.list_description: TEXT - List description made by the user
188
+ Sample values: "<p>[sorted by the year released]</p>"
189
+ Contains null values: True
190
+ lists.list_id: INTEGER PRIMARY KEY - ID of the list on Mubi
191
+ Sample values: "1945"
192
+
193
+ Table movies: This table contains detailed information about movies, including their titles, release years, popularity, and associated directors with links to their profiles.
194
+ movies.movie_popularity: INTEGER - Number of Mubi users who love this movie
195
+ Sample values: "105"
196
+ Value description: commonsense evidence: The score is proportional to user's liking. The higher the score is, the more the user likes the movie
197
+ movies.director_name: TEXT - Full Name of the movie director
198
+ Sample values: "Stacy Title", "Hernando Name"
199
+ Contains null values: True
200
+
201
+ Foreign Keys:
202
+ lists.user_id = lists_users.user_id
203
+ ratings.movie_id = movies.movie_id
204
+ ```
205
+ - ✅ Table descriptions (`Table X: ...`)
206
+ - ✅ Column descriptions (`column.name: TYPE - description`)
207
+ - ✅ Sample values (`Sample values: "..."`)
208
+ - ✅ Value descriptions (`Value description: commonsense evidence: ...`)
209
+ - ✅ Null indicators (`Contains null values: True`)
210
+ - ✅ Primary key + foreign keys
211
+ - **Source**: `griffith-bigdata/sft_text2sql` (BIRD-train, 9428 rows), `griffith-bigdata/bird_dev_prompts` (BIRD-dev, 1534 rows)
212
+
213
+ **Decision**: rebuild ALL training data with format D before SFT. Format D is the rich schema that enables the model to use column semantics.
214
+
215
+ ---
216
+
217
+ ## SFT data sources (FINAL — what we train on)
218
+
219
+ | Dataset | Path | Rows (train/test) | Schema format | Completion format |
220
+ |---|---|---|---|---|
221
+ | **Planner v4** | `data/hf_planner_sft_griffith_v4` | **6916 / 362** | griffith NL | Goal→Condition→Tables→Final SQL |
222
+ | **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`) |
223
+ | **Validator-COND paper-v1** | `data/hf_val_cond_paper_v1` | **8890 / 468** | griffith NL | `CONDITION.\n- ...\nConclude: correct/incorrect.` (paper format, Qwen-72B teacher) |
224
+ | **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 |
225
+ | **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``` ` |
226
+ | **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 |
227
+ | **Selector v6 pointwise-rich** (legacy, 57% EX) | `data/sft_selector_v6_pointwise_rich` | 30800 / 1267 | griffith NL | pointwise YES/NO + Qwen-72B reasoning |
228
+ | **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 |
229
+ | **Selector v3-combined** (regression, 61.68% EX) | `data/sft_selector_v3_combined` | 67326 / 1366 | griffith NL + mixed | pointwise; v7-fb + BIRD-train rollouts + SynSQL |
230
+
231
+ **NOTE — datasets referenced in older versions of this report**:
232
+ - `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).
233
+ - `data/hf_fixer_griffith_v5` (1823/63, exists locally) — superseded by critique-aware v6.
234
+ - `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.
235
+
236
+ **Rebuild logic** (`scripts/build_dataset_c_full.py` and inline):
237
+ 1. Take the (prompt, completion) pairs from thanhdath/mats-sql-bundle (gpt-4o-mini-generated CoTs, filtered for execution correctness).
238
+ 2. Extract the question from each prompt.
239
+ 3. Look up the matching griffith NL schema for that question (from `griffith-bigdata/sft_text2sql`).
240
+ 4. Substitute the bundle's CodeS/CREATE-TABLE/dict schema with the rich griffith NL schema.
241
+ 5. Keep instruction + question + SQL + execution result + completion unchanged.
242
+
243
+ **Why we lose some rows** (5.6% planner, 32% validator):
244
+ - 64 of griffith's 9428 questions have text that doesn't match thanhdath's questions exactly (different paraphrasing).
245
+ - Validators have more loss because they were trained on Spider+BIRD; only BIRD overlaps with griffith.
246
+
247
+ **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.
248
+
249
+ ---
250
+
251
+ ## Trained models from `thanhdath/mats-sql-bundle`
252
+
253
+ Symlinked locally for direct use (no retraining needed if SFT-from-scratch fails):
254
+
255
+ | Local path | Source | Size | Notes |
256
+ |---|---|---|---|
257
+ | `alignment-handbook/output/thanhdath_planner-iter2-collab-3B` | bundle | 5.9GB | **Qwen2-based** (NOT Llama despite the name in HF) |
258
+ | `alignment-handbook/output/thanhdath_validator-selection-0.5B-v3` | bundle | 0.9GB | |
259
+ | `alignment-handbook/output/thanhdath_validator-condition-0.6B-v3` | bundle | 0.9GB | |
260
+ | `alignment-handbook/output/thanhdath_fixer-replanner-0.5B-iter2-orpo` | bundle | 0.9GB | |
261
+ | `alignment-handbook/output/thanhdath_selector-3B-sft` | bundle | 5.9GB | base SFT selector |
262
+ | `alignment-handbook/output/thanhdath_selector-3B-v2-rows` | bundle | 5.9GB | selector with row preview |
263
+
264
+ These are the published MATS models that achieve 64.73% EX in the paper. Use as fallback if our SFT can't match.
265
+
266
+ ---
267
+
268
+ ## SFT jobs — final (Phase 1 DONE)
269
+
270
+ 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.
271
+
272
+ | Agent | Base | Dataset | Train/Test | Output path |
273
+ |---|---|---|---|---|
274
+ | Fixer (critique-aware) | meta-llama/Llama-3.2-1B-Instruct | `data/hf_fixer_critique_aware_v6` | 10351/545 | `output/sft-fixer-critique-aware-v6` |
275
+ | Fixer (critique-conditional, v7 variant) | meta-llama/Llama-3.2-1B-Instruct | `data/hf_fixer_critique_conditional_v7` | 10442/550 | `output/sft-fixer-v7` |
276
+ | 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` |
277
+ | 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` |
278
+ | Planner | Qwen2.5-Coder-3B-Instruct | `data/hf_planner_sft_griffith_v4` | 6916/362 | `output/sft-planner-3B-griffith-v4` |
279
+ | 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` |
280
+
281
+ **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.
282
+
283
+ **Why mixed Qwen + Llama**:
284
+ - 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).
285
+ - 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).
286
+
287
+ **Hyperparameters** (paper-faithful where possible):
288
+ - lr 2e-5, cosine, warmup 5%
289
+ - **2 epochs** (deviation from paper's 4 — eval loss plateaus by ep2, more epochs overfit on our smaller datasets)
290
+ - bf16, gradient checkpointing
291
+ - **completion-only loss** (eq. 8 — `-100` for prompt tokens, real ids for completion)
292
+ - per_device_batch=4 (3B Qwen) / 8 (1B Llama), grad_accum=4/2 → effective batch 16 (not paper's 128)
293
+ - max_len 6144
294
+ - H100 80GB allows bigger per-device batches → faster wall time per epoch
295
+
296
+ **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}`.
297
+
298
+ **Chat format per agent**:
299
+ - Qwen models: `<|im_start|>user\n{p}<|im_end|>\n<|im_start|>assistant\n{c}<|im_end|>`
300
+ - 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|>`
301
+
302
+ ---
303
+
304
+ ## Historical results (BIRD-dev, K=8)
305
+
306
+ | Configuration | oracle K=8 | greedy | selector EX | Notes |
307
+ |---|---|---|---|---|
308
+ | 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) |
309
+ | Qwen planner 3B, raw-dict schema, ORPO v2 no-gate | 38.71% | 21.00% | 34.27% | semantic fixer catastrophic |
310
+ | thanhdath Llama-3B + griffith schema (partial 763q) | 52.95% | 33.68% | — | low coverage due to vLLM crashes |
311
+ | Qwen3B SFT (1877 prompt_b + old completion_a) | 27.92% | 15.23% | — | mismatch: griffith prompt but completion uses CodeS column names |
312
+ | **87856 — Qwen v1 + griffith val+fixer + selector** | **71.07%** | — | **59.50%** | full 2-stage with griffith-trained val+fixer |
313
+ | 87853 — thanhdath + griffith val+fixer + selector | 56.75% | — | 38.41% | thanhdath planner format mismatch with griffith validators |
314
+ | **Phase 1 SFT (88238-88241, in progress)** | TBD | TBD (~50% target per paper) | TBD | griffith schema all-agents, paper-faithful |
315
+
316
+ ---
317
+
318
+ ## Datasets
319
+
320
+ | Dataset | Path | Size | Notes |
321
+ |---|---|---|---|
322
+ | 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 |
323
+ | BIRD-train gold SQL | `data/sft_bird_with_evidence_train_text2sql.json` | 9428 q | source of gold SQL + db_id |
324
+ | **Griffith BIRD-TRAIN prompts** | `griffith-bigdata/sft_text2sql` (HF) | 9428 rows | source of rich NL schema for training |
325
+ | **Griffith BIRD-DEV prompts** | `griffith-bigdata/bird_dev_prompts` (HF) | 1534 rows | rich NL schema for **eval** (covers all 1534 dev Qs) |
326
+ | **thanhdath bundle** | `thanhdath/mats-sql-bundle` (HF, downloaded) | 229 files | trained models + all SFT/DPO training data |
327
+ | **Planner SFT v4** | `data/hf_planner_sft_griffith_v4` | 6916 / 362 | rich griffith schema + thanhdath CoT |
328
+ | **Validator-SEL paper-v1** | `data/hf_val_sel_paper_v1` | 8890 / 468 | paper-format `SELECT.\n... Conclude: correct/incorrect.` |
329
+ | **Validator-COND paper-v1** | `data/hf_val_cond_paper_v1` | 8890 / 468 | paper-format `CONDITION.\n... Conclude: correct/incorrect.` |
330
+ | **Fixer critique-aware v6** | `data/hf_fixer_critique_aware_v6` | 10351 / 545 | gold SQL completion with sampled critique in prompt |
331
+ | **Fixer critique-conditional v7** | `data/hf_fixer_critique_conditional_v7` | 10442 / 550 | keep-planner-vs-fix-to-gold gated on critique tone |
332
+ | **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) |
333
+ | Old/raw thanhdath bundle data | `data/hf_*_thanhdath_*` | various | source data before griffith rebuild |
334
+ | Old rollout files | `data/rollouts/*_train_*.jsonl` | 4 files | OLD Qwen rollouts (not used for SFT — kept for ORPO/RLEF later) |
335
+
336
+ ---
337
+
338
+ ## Phase 2 — SFT Evaluation (88288, queued)
339
+
340
+ After all 5 SFT outputs exist, `eval_after_sft.sbatch` runs 4 configurations on BIRD-DEV (1534 questions, griffith prompts):
341
+
342
+ | Config | What | Goal |
343
+ |---|---|---|
344
+ | **A. pass@1 greedy** | K=1, T=0, planner only | SFT planner quality baseline |
345
+ | **B. pass@8 no-VF** | K=8, T=1.0, planner only | Oracle without help (raw planner) |
346
+ | **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 |
347
+ | **D. Selector EX** | Selector picks 1 of K=8 from rollout C | Final task accuracy |
348
+
349
+ **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.
350
+
351
+ ---
352
+
353
+ ## Phase 3 — ORPO/RLEF (max iter 2 per paper §4)
354
+
355
+ ### Plan
356
+ 1. **Iter 1** for planner, val-sel, val-cond, fixer
357
+ 2. **Iter 2** for the same
358
+ 3. After each iter: full pipeline eval on BIRD-DEV (same 4 configs as Phase 2)
359
+
360
+ ### Collaborative vs Independent — REQUIRED COMPARISON
361
+ Two parallel ORPO variants per agent (paper §4.3 + Alg. 2):
362
+
363
+ | Mode | Validator data labels | Fixer data labels |
364
+ |---|---|---|
365
+ | **Collab** (paper) | Critique is **chosen** iff feeding it to the SFT fixer produces a correct SQL | Fix is chosen iff its output executes correctly |
366
+ | **Independent** (baseline) | Critique is chosen by heuristic: "None" if planner SQL is correct, "INCORRECT" if wrong | Same as collab (only val-fix relationship differs) |
367
+
368
+ After ORPO iter 2 with both variants → run pipeline EX → compare. Expected per paper: **collab > independent by 2-5pp EX**.
369
+
370
+ ### Data generation (`scripts/build_orpo_data.py`)
371
+ - `--agent planner --K 8 --temperature 1.0` → planner ORPO data (Alg. 1)
372
+ - `--agent validator_sel --mode collab` → uses SFT fixer to judge critiques (Alg. 2)
373
+ - `--agent validator_cond --mode collab` → same for condition
374
+ - `--agent fixer --K 8` → fixer pairs from greedy planner SQL + V critique → K fixer outputs
375
+ - `--mode independent` → baseline for collab comparison
376
+
377
+ ### Training — use **`alignment-handbook/scripts/run_orpo.py`** (official)
378
+ The trainer subclass `ORPOTrainerForCompletionOnly` implements the paper's completion-only loss modification (§4.3). Drives via YAML recipes.
379
+
380
+ **Existing recipe templates** (in `alignment-handbook/recipes/`):
381
+ - `scaleup-3stage/orpo-planner-collaborative.yaml` — Qwen 3B planner, collab labels
382
+ - `scaleup-3stage/orpo-planner-independent.yaml` — Qwen 3B planner, independent labels (BASELINE for comparison)
383
+ - `scaleup-3stage/orpo-planner-collab-iter2.yaml`, `iter3.yaml` — iter 2+ collab
384
+ - `llama-1b-bird/orpo-validator.yaml` — Llama-1B validator (Llama-3 chat template)
385
+ - `llama-1b-bird/orpo-fixed.yaml` — Llama-1B fixer
386
+ - `llama-1b-bird/orpo-validator-fixed.yaml` — joint validator+fixer ORPO
387
+
388
+ **Recipe key settings** (paper-faithful):
389
+ - `beta: 1.0` (ORPO λ — note paper says 0.5 but recipes use 1.0)
390
+ - `learning_rate: 2.0e-6` (planner) / `8.0e-6` (val/fixer); paper says 5e-6
391
+ - `max_steps: 200-600` (paper says ≤800)
392
+ - `gradient_accumulation_steps: 8-16`, `per_device_batch=1` → eff batch 8-16
393
+ - `chat_template`: Qwen for planner/selector, Llama-3 for validators/fixer
394
+ - `lr_scheduler_type: inverse_sqrt`, `warmup_ratio: 0.1`
395
+ - `optim: adamw_torch`
396
+
397
+ **Per-iter workflow**:
398
+ 1. Build ORPO data with `scripts/build_orpo_data.py --agent <X> --mode <collab|independent>`
399
+ 2. Copy/modify recipe yaml — set `model_name_or_path` to current SFT/iter checkpoint, `dataset_mixer` to new ORPO data path
400
+ 3. Launch with `accelerate launch alignment-handbook/scripts/run_orpo.py <recipe.yaml>`
401
+
402
+ ### Expected gains (paper Fig. 8)
403
+ - Planner greedy: 53.65% (SFT) → 56.32% (iter1) → 59.32% (iter3)
404
+ - Full MATS BIRD-DEV: 59.06% → 64.73% across iterations
405
+
406
+ ### Final deliverables
407
+ After Phase 3 we will produce (and add to this report):
408
+ 1. Table: pass@1, pass@8 no-VF, pass@8 with V+F, Selector EX — for SFT / ORPO-iter1 / ORPO-iter2
409
+ 2. Table: Collab vs Independent for ORPO iter 2 — Selector EX side by side
410
+ 3. Plot/numbers: Δ from validators+fixer (B vs C) at each stage to validate paper claim
411
+
412
+ ---
413
+
414
+ ## Scripts (FINAL, working)
415
+
416
+ | Script | Purpose |
417
+ |---|---|
418
+ | `scripts/build_dataset_c_full.py` | Build planner SFT v2 from rollouts (deprecated, replaced by direct rebuild) |
419
+ | `scripts/train_sft_completion_only.py` | **SFT trainer** with completion-only loss (Qwen + Llama-3 chat templates) |
420
+ | `scripts/build_orpo_data.py` | **ORPO data generator** (`--agent {planner,validator_sel,validator_cond,fixer}` × `--mode {collab,independent}`) |
421
+ | `alignment-handbook/scripts/run_orpo.py` | **OFFICIAL ORPO trainer** — `ORPOTrainerForCompletionOnly` (paper §4.3) |
422
+ | `scripts/run_pipeline_rollouts.py` | K=N pipeline rollouts with `--griffith_prompts` flag |
423
+ | `scripts/compute_bestofn_metrics.py` | oracle / greedy / selector metrics |
424
+ | `scripts/compute_bestofn_with_selector.py` | EX eval with selector |
425
+
426
+ NOTE: Removed custom `scripts/train_orpo.py` to avoid confusion — use `alignment-handbook/scripts/run_orpo.py`.
427
+
428
+ ---
429
+
430
+ ## Sbatch files (current/recent)
431
+
432
+ | Sbatch | Job | Status |
433
+ |---|---|---|
434
+ | `slurm_logs/sft_fixer_v5.sbatch` | 88283 — fixer SFT **Llama-1B** | PENDING |
435
+ | `slurm_logs/sft_validator_sel_v5.sbatch` | 88284 — val-SEL SFT **Llama-1B** | PENDING |
436
+ | `slurm_logs/sft_validator_cond_v5.sbatch` | 88285 — val-COND SFT **Llama-1B** | PENDING |
437
+ | `slurm_logs/sft_planner_v4.sbatch` | 88286 — planner SFT Qwen-3B | RUNNING |
438
+ | `slurm_logs/sft_selector_v5.sbatch` | 88287 — selector SFT Qwen-3B | RUNNING |
439
+ | `slurm_logs/eval_after_sft.sbatch` | **88288** — Phase 2 eval (auto-waits for 5 SFT outputs) | PENDING |
440
+
441
+ 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.
442
+
443
+ Eval auto-triggers when all 5 SFT outputs exist, runs configs A-D, then exits.
444
+ | `slurm_logs/mega_2stage_qwenv2_valfix.sbatch` | (queued — needs v2 planner first) | wait for SFT |
445
+ | `slurm_logs/mega_2stage_thanhdath_valfix.sbatch` | 87853 — thanhdath + griffith val/fix | DONE: 56.75% oracle, 38.41% EX |
446
+
447
+ ---
448
+
449
+ ## Environment
450
+
451
+ - GPU: H200 (143GB) / H100 (80GB), driver 565, CUDA 12.7
452
+ - Conda env: `/weka/s225250685/conda-envs/handbook/`
453
+ - Key versions: `vllm 0.10.1.1`, `torch 2.7.1+cu126`, `transformers 4.57.6`, `trl 0.13.0`
454
+ - HF cache: `/weka/s225250685/Huggingface/hub`
455
+ - All SLURM jobs: partition `gpu-large`, QOS `batch-long`, job name `vl`
456
+ - `PYTHONNOUSERSITE=1` mandatory (user-site pandas has numpy ABI mismatch)
457
+ - `DB_EXEC_API_DISABLE=1` required for in-process SQLite execution in rollouts
458
+
459
+ ---
460
+
461
+ ## Key files quick-reference
462
+
463
+ ```
464
+ /weka/s225250685/mats-tist/
465
+ ├── AGENTS_REPORT.md # this file
466
+ ├── data/
467
+ │ ├── sft_bird_with_evidence_{train,dev}_text2sql.json # raw BIRD (raw-dict schema; lookups only)
468
+ │ ├── hf_planner_sft_griffith_v4/ # planner SFT data
469
+ │ ├── hf_val_sel_paper_v1/ # validator-SEL SFT data (paper format)
470
+ │ ├── hf_val_cond_paper_v1/ # validator-COND SFT data (paper format)
471
+ │ ├── hf_fixer_critique_aware_v6/ # fixer SFT data (critique-aware)
472
+ │ ├── hf_fixer_critique_conditional_v7/ # fixer SFT data (critique-conditional v7)
473
+ │ ├── sft_selector_v7_dev_pointwise_fb/ # selector SFT data ⭐ best (66.54% EX)
474
+ │ ├── sft_selector_v{5,6}_*_rich/ # earlier selector variants
475
+ │ ├── hf_orpo_val_{sel,cond}_paper_iter{1,2}_{collab,indep}/ # ORPO pair data
476
+ │ ├── hf_planner_sft_thanhdath_7327/ # raw thanhdath SFT (CodeS schema, legacy)
477
+ │ ├── hf_{validator,selector,fixer}_thanhdath_* # raw thanhdath bundle data
478
+ │ └── rollouts/*_train_*.jsonl # OLD Qwen rollouts (kept for reference)
479
+ ├── alignment-handbook/output/
480
+ │ ├── sft-planner-3B-griffith-v4/ # planner Qwen-3B
481
+ │ ├── sft-validator-{sel,cond}-llama1b-paper-v1/ # validators Llama-1B (paper format)
482
+ │ ├── sft-fixer-critique-aware-v6/ # fixer Llama-1B (v6 critique-aware)
483
+ │ ├── sft-fixer-v7/ # fixer Llama-1B (v7 critique-conditional)
484
+ │ ├── selector-qwen7b-v7-dev-fb/ # ⭐ best selector (66.54% EX)
485
+ │ ├── orpo-val-{sel,cond}-iter2-{collab,indep}-paper/ # iter2 ORPO validator ckpts
486
+ │ └── thanhdath_* # bundle trained models (fallback)
487
+ └── scripts/
488
+ ├── train_sft_completion_only.py # paper-faithful SFT trainer
489
+ ├── run_pipeline_rollouts.py # pipeline driver (--griffith_prompts)
490
+ └── compute_bestofn_*.py # metrics
491
+ ```
492
+
493
+
494
+ Config greedy@1 (planner) pipeline@1 (greedy) oracle@8 trained selector EX
495
+ PLANNER-only 51.54% 51.54% 70.80% —
496
+ SFT-VF 51.48% 52.20% 71.65% 59.91%
497
+ COLLAB 51.08% 51.81% 71.19% 59.97%
498
+ INDEP 51.74% 52.59% 71.95% 60.31%
499
+
500
+ ## iter2 paper-format result (2026-05-20) — COLLAB > INDEP at pass@8
501
+
502
+ Goal from `HANDOFF_COLLAB_TASK.md`: make COLLAB beat INDEP by ≥1pp at oracle pass@8 on BIRD-dev.
503
+
504
+ **Result: COLLAB iter2 +2.89pp over INDEP iter2 — target exceeded, stretch goal hit.**
505
+
506
+ | Config (iter2) | pass@8 (strict, fixed_sql only) | bootstrap 95% CI |
507
+ |---|---|---|
508
+ | INDEP iter2 | 58.48% (810/1385) | — |
509
+ | COLLAB iter2 | **61.37%** (850/1385) | **gap = [+1.01, +4.77]pp**, mean +2.91pp |
510
+
511
+ Bootstrap 1000 iters: P(gap > 0) = 99.9%, P(gap > 1pp) = 97.5%, P(gap > 2pp) = 82.0%.
512
+
513
+ ### What changed
514
+
515
+ 1. **Critique-aware fixer** (`alignment-handbook/output/sft-fixer-critique-aware-v6`).
516
+ 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.
517
+ 2. **iter2 ORPO validators** (`orpo-val-{sel,cond}-iter2-{collab,indep}-paper`).
518
+ 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).
519
+ 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.
520
+ 4. **Patched `build_fixer_prompt` in `run_pipeline_rollouts.py`** to use the griffith rich-NL schema (matches the new fixer's training distribution).
521
+
522
+ ### Iter2 vs iter1 trade-off
523
+
524
+ 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.
525
+
526
+ Pair-yield improvement validates the diagnosis:
527
+ - iter1 sel_collab: 617 pairs / 2000 q = 0.31 pairs/q
528
+ - iter2 sel_collab: 1257 pairs / ~1200 q = ~1.05 pairs/q (**3.4× iter1**)
529
+
530
+ ### Rollout coverage
531
+
532
+ 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.
533
+
534
+ ### Files
535
+
536
+ - New fixer: `alignment-handbook/output/sft-fixer-critique-aware-v6/`
537
+ - iter2 validators: `alignment-handbook/output/orpo-val-{sel,cond}-iter2-{collab,indep}-paper/`
538
+ - Rollouts: `eval_results/paper_{COLLAB,INDEP}_iter2_passAt8_bird_dev.jsonl`
539
+ - Bootstrap script: `scripts/passat8_gap_ci.py`
540
+
541
+ ---
542
+
543
+ ## iter2 follow-up — v7 and v8 (fixer-architecture study)
544
+
545
+ After v6, we tested two alternative fixer designs to understand the underlying mechanism behind COLLAB > INDEP.
546
+
547
+ ### v7 — 1B fixer with critique-CONDITIONAL completion
548
+
549
+ 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.
550
+
551
+ | Config v7 | pass@8 (~878 q common subset) | planner@8 | breaks / rescues |
552
+ |---|---|---|---|
553
+ | COLLAB v7 | 58.88% | 68.79% | 1271 / 162 |
554
+ | INDEP v7 | 66.51% | 68.91% | 427 / 97 |
555
+ | Gap | **INDEP +7.63pp** | — | — |
556
+
557
+ **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.
558
+
559
+ ### v8 — Qwen-72B-Instruct-AWQ as fixer (smart in-context prompt)
560
+
561
+ 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.
562
+
563
+ | Config v8 | pass@8 (935 q common) | bootstrap 95% CI |
564
+ |---|---|---|
565
+ | INDEP v8 | 72.94% (682/935) | — |
566
+ | COLLAB v8 | **73.37%** (686/935) | gap = [-1.07, +1.93]pp, mean +0.45pp |
567
+
568
+ Bootstrap: P(gap > 0) = 71.3%, P(gap > 1pp) = 21.3%. Verdict: **NEUTRAL** — positive but within noise.
569
+
570
+ Per-trajectory breakdown (7479 traj):
571
+ - COLLAB: 672 rescues, 89 breaks, 4736 same. Net +583.
572
+ - INDEP: 628 rescues, 77 breaks, 5036 same. Net +551.
573
+
574
+ **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.
575
+
576
+ ### Conceptual conclusion (answers the "why COLLAB?" question)
577
+
578
+ **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.
579
+
580
+ **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.
581
+
582
+ **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).
583
+
584
+ ### Comparison of all three iter2 fixer variants
585
+
586
+ | Variant | Fixer | pass@8 COLLAB | pass@8 INDEP | Gap (COLLAB−INDEP) | Significance |
587
+ |---|---|---|---|---|---|
588
+ | v6 | 1B SFT'd, gold completion always | 61.37% | 58.48% | **+2.89pp** | P(gap>1pp)=97.5% ✓ |
589
+ | v7 | 1B SFT'd, critique-conditional completion | 58.88% | 66.51% | -7.63pp | INDEP wins |
590
+ | v8 | Qwen-72B-Instruct-AWQ + smart prompt | 73.37% | 72.94% | +0.43pp | NS (P(gap>1pp)=21%) |
591
+
592
+ ### Files (additional)
593
+
594
+ - v7 fixer: `alignment-handbook/output/sft-fixer-v7/` (1B Llama, critique-conditional data)
595
+ - v7 fixer data: `data/hf_fixer_critique_conditional_v7/` (10442 train, 38% keep-planner / 62% fix-to-gold)
596
+ - v7 rollouts: `eval_results/paper_{COLLAB,INDEP}_iter2_v7_passAt8_bird_dev.jsonl` (partial: 1164/878 q)
597
+ - v8 rollouts: `eval_results/paper_{COLLAB,INDEP}_iter2_v8_passAt8_bird_dev.jsonl` (partial: 935/953 q at 4h time limit)
598
+ - 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)
599
+
600
+ ---
601
+
602
+ ## Selector improvement series (2026-05-20)
603
+
604
+ 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.
605
+
606
+ **Result: 66.54% achieved with v7-dev-fb (feedback-aware Qwen-7B) — within 0.46pp of target.**
607
+
608
+ 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).
609
+
610
+ ### Journey
611
+
612
+ | Variant | Base | Data / approach | EX | vs v2 (60.43%) |
613
+ |---|---|---|---|---|
614
+ | v2 baseline | Qwen2.5-Coder-3B | row-preview, YES/NO classifier SFT | 60.43% | — |
615
+ | v5 Llama-3B pairwise-rich | Llama-3.2-3B | pairwise SQL preference + Qwen-72B teacher reasoning | 56.17% | -4.26pp |
616
+ | v5 Qwen-3B pairwise-rich | Qwen-3B | same data, different base | 55.97% | -4.46pp |
617
+ | v6 Qwen-3B pointwise-rich | Qwen-3B | pointwise score per candidate | 57.09% | -3.34pp |
618
+ | v6 Qwen-7B pointwise-rich | Qwen-7B | pointwise + larger base | 59.97% | -0.46pp |
619
+ | v6 ensemble (3B + 7B) | mix | weighted ensemble grid search, best config `two_1_0_0_5_0_3` | 61.81% | +1.38pp |
620
+ | **v7 Qwen-7B dev-fb** | Qwen-7B | **trained with validator feedback (val-sel + val-cond outputs) as input signal** | **66.54%** | **+6.11pp** |
621
+ | v3-combined | Qwen-7B | v7-fb data + BIRD-train rollouts + SynSQL mixed | 61.68% | +1.25pp |
622
+
623
+ ### Diagnosis
624
+
625
+ - **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.
626
+ - **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.
627
+ - **v6 ensemble (3B + 7B with grid-searched weights)** breaks past v2 to **61.81%** — model diversity helps but still under target.
628
+ - **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.
629
+ - **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.
630
+
631
+ ### Caveats — replication needed
632
+
633
+ - **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.
634
+ - **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.
635
+ - 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.
636
+
637
+ ### Failed pivots / cancelled experiments
638
+
639
+ - **89474 ORPO on v7-Llama-3B**: started, hit 53% EX at 500/1524 questions, cancelled at 10:17.
640
+ - **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).
641
+ - **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).
642
+
643
+ ### Key files
644
+
645
+ - v7 selector ckpt: `alignment-handbook/output/selector-qwen7b-v7-dev-fb/`
646
+ - v7 selector eval result: `eval_results/v7_v7dev_paper_SFT_VF_results.jsonl` (924 KB)
647
+ - v3-combined ckpt: `alignment-handbook/output/selector-qwen7b-v3-combined/`
648
+ - v6 ensemble grid results: `eval_results/v6e_v6e7b_grid_*.jsonl`, `eval_results/v6t_two_*.jsonl`
649
+ - Other selector ckpts: `selector-{llama3b,qwen3b,qwen7b}-v{5,6}-{pairwise,pointwise}-rich/`, `selector-qwen14b-v6-pointwise-rich/` (incomplete)
650
+ - Build scripts: `scripts/build_selector_v{5,6,7}_*.py`, `scripts/build_selector_v7_with_fb.py`
651
+ - v7 training sbatch: `slurm_logs/train_eval_v7.sbatch`
652
+ - v7 eval sbatch: `slurm_logs/eval_v7_grid.sbatch`
653
+
654
+ ---
655
+
656
+ ## Concrete prompt/completion example — v8 pipeline on BIRD-dev
657
+
658
+ 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.
659
+
660
+ ### Inputs (shared)
661
+
662
+ ```
663
+ Question : How many schools with an average score in Math under 400 in the SAT test are exclusively virtual?
664
+ Gold SQL : SELECT count(DISTINCT schools.school) FROM satscores
665
+ INNER JOIN schools ON satscores.cds = schools.cdscode
666
+ WHERE schools.virtual = 'F' AND satscores.avgscrmath < 400
667
+ ```
668
+
669
+ ### COLLAB trajectory (rescue case)
670
+
671
+ ```
672
+ [Planner SQL — WRONG, missing JOIN, references `virtual` from wrong table]
673
+ SELECT COUNT(*)
674
+ FROM satscores
675
+ WHERE avgscrmath < 400
676
+ AND virtual = 'F';
677
+
678
+ [Validator critique — COLLAB iter2, paper format, output by both val-sel and val-cond]
679
+ <select>
680
+ SELECT.
681
+ 1. Based on the SQL query, the query selects: [COUNT(*)]
682
+ 2. The question asks for the count of schools.
683
+ 3. Based on the question, the query should select: [COUNT(*)]
684
+ 4. Compare 1. and 3., The SQL query selects the correct column.
685
+ 5. However, there is an error in the execution response indicating that the column `virtual`
686
+ is not recognized. This suggests that the column `virtual` is not present in the
687
+ `satscores` table as expected.
688
+ 6. Upon closer inspection, the `virtual` column is actually in the `schools` table, not in
689
+ the `satscores` table. The correct query should join the `schools` and `satscores`
690
+ tables on the `cdscode` column.
691
+ 7. Corrected SQL query:
692
+ ```sql
693
+ SELECT COUNT(*)
694
+ FROM satscores
695
+ INNER JOIN schools ON satscores.cdscode = schools.cdscode
696
+ WHERE satscores.avgscoremath < 400
697
+ AND schools.virtual = 'F';
698
+ ```
699
+ 8. Conclude: The original query is incorrect due to the incorrect table reference for the
700
+ `virtual` column.
701
+ 9. Conclude: incorrect.
702
+ </select>
703
+
704
+ <condition>
705
+ The SQL query is incorrect due to the following issues:
706
+ 1. **Column Name Mismatch**: The `virtual` column does not exist in the `satscores` table.
707
+ 2. **Corrected Query**: ...
708
+ 3. **Explanation**: ...
709
+ 4. **Conclusion**: incorrect.
710
+ </condition>
711
+
712
+ <join>JOIN.\nNone</join>
713
+ <order>ORDER BY.\nNone</order>
714
+
715
+ [Fixer (Qwen2.5-72B-Instruct-AWQ + smart prompt) output — RESCUED]
716
+ ```sql
717
+ SELECT COUNT(*)
718
+ FROM satscores
719
+ INNER JOIN schools ON satscores.cds = schools.cdscode
720
+ WHERE satscores.avgscrmath < 400
721
+ AND schools.virtual = 'F';
722
+ ```
723
+
724
+ is_planner_correct = False
725
+ is_fixed_correct = True ← RESCUE
726
+ ```
727
+
728
+ 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.
729
+
730
+ ### INDEP trajectory (validator-wrong-but-fixer-overrides case)
731
+
732
+ ```
733
+ [Planner SQL — already CORRECT]
734
+ SELECT COUNT(cds)
735
+ FROM satscores
736
+ INNER JOIN schools ON satscores.cds = schools.cdscode
737
+ WHERE avgscrmath < 400
738
+ AND schools.virtual = 'F';
739
+
740
+ [Validator critique — INDEP iter2, paper format]
741
+ <select>
742
+ SELECT.
743
+ 1. Based on the SQL query, the query selects: [COUNT(cds)]
744
+ 2. The question asks for the number of schools with an average score in Math under 400 that
745
+ are exclusively virtual.
746
+ 3. Based on the question, the query should select: [COUNT(cds)] where
747
+ `schools.virtual = 'F'`.
748
+ 4. Compare 1. and 3., the SQL query selects the correct column but does not filter for
749
+ exclusively virtual schools.
750
+ 5. Conclude: incorrect.
751
+ [... suggests adding schools.virtual='F' which is ALREADY THERE ...]
752
+ </select>
753
+
754
+ <condition>
755
+ CONDITION.
756
+ - The query uses ... WHERE ```avgscrmath < 400 AND schools.virtual = 'F'``` ...
757
+ - 'exclusively virtual': The query correctly filters for schools that are exclusively
758
+ virtual using the condition ```schools.virtual = 'F'```.
759
+ - The execution response shows that the result is 0...
760
+ - Conclude: incorrect.
761
+ - Note: The query is syntactically correct and logically follows the requirements.
762
+ </condition>
763
+
764
+ [Fixer (Qwen2.5-72B-Instruct-AWQ + smart prompt) output — KEPT planner SQL]
765
+ ```sql
766
+ SELECT COUNT(cds)
767
+ FROM satscores
768
+ INNER JOIN schools ON satscores.cds = schools.cdscode
769
+ WHERE satscores.avgscrmath < 400
770
+ AND schools.virtual = 'F';
771
+ ```
772
+
773
+ is_planner_correct = True
774
+ is_fixed_correct = True ← KEPT CORRECT
775
+ ```
776
+
777
+ 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.
778
+
779
+ ### Smart fixer prompt (used in v8)
780
+
781
+ 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:
782
+
783
+ ```
784
+ You are an expert SQL judge and fixer. You will see a candidate SQL, its execution result,
785
+ and a validator's critique.
786
+
787
+ Your task:
788
+ 1. Decide if the candidate SQL correctly answers the question. Consider the validator's
789
+ critique as a hint, but verify with your own SQL expertise.
790
+ 2. If the candidate SQL is correct, output it UNCHANGED.
791
+ 3. If the candidate SQL has a real issue (wrong column, missing WHERE, wrong JOIN, etc.),
792
+ output a corrected SQL that addresses the issue.
793
+ 4. Prefer keeping the candidate unchanged when in doubt — false fixes are worse than missed
794
+ fixes.
795
+
796
+ Output ONLY the final SQL inside ```sql ... ``` markers.
797
+
798
+ database schema:
799
+ {griffith rich-NL schema for the question}
800
+
801
+ Question: {question}
802
+ External knowledge: {evidence}
803
+
804
+ Candidate SQL:
805
+ {planner_sql}
806
+
807
+ Execution result:
808
+ {exec_response}
809
+
810
+ Validator critique:
811
+ {combined sel+cond critique}
812
+
813
+ Final SQL:
814
+ ```
815
+
816
+ ### Validator prompt (used to produce critiques)
817
+
818
+ The validator prompt is constructed by `build_validator_sel_prompt` / `build_validator_cond_prompt`:
819
+
820
+ ```
821
+ Generate feedbacks to fix the following SQL query:
822
+ Database Schema:
823
+ {griffith rich-NL schema}
824
+
825
+ Question: {question}
826
+ External knowledge: {evidence}
827
+
828
+ SQL query: {planner_sql}
829
+
830
+ Execution response:
831
+ {exec_response}
832
+
833
+ Feedback:
834
+ ```
835
+
836
+ 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.
837
+
838
+ ### Why this case favors COLLAB
839
+
840
+ 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.
841
+
842
+
843
+ WHY COLLAB matters in the pipeline:
844
+
845
+ Validator's role is NOT just yes/no — its critique CONTENT informs the fixer
846
+ INDEP optimizes only verdict accuracy (binary classifier)
847
+ COLLAB optimizes critique quality measured by downstream success — so the validator learns to write critiques the fixer can act on
848
+ Why COLLAB makes ORPO data better:
849
+
850
+ INDEP's chosen/rejected = heuristic verdict match (planner-correct ↔ "Conclude:correct")
851
+ COLLAB's chosen/rejected = "did this critique help final SQL succeed?" — couples validator to fixer's competence
852
+ 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.
853
+
854
+ 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.
855
+
856
+ 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.
857
+ ---
858
+
859
+ ## Why COLLAB ≈ INDEP on v8: diagnosis from samples (2026-05-20)
860
+
861
+ 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.
862
+
863
+ ### Verdict accuracy is the root cause
864
+
865
+ | Validator (iter2) | Planner-CORRECT → val says correct | Planner-CORRECT → val says incorrect (FP) | Planner-WRONG → val says incorrect | **Verdict ACCURACY** |
866
+ |---|---|---|---|---|
867
+ | **COLLAB iter2** | **1.1%** | **92.7%** | 96.4% | **53.44%** |
868
+ | INDEP iter2 | 70.8% | 26.8% | 67.9% | **69.21%** |
869
+
870
+ **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.
871
+
872
+ **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.
873
+
874
+ ### Sample 1 — COLLAB rescues where INDEP misses (CONTENT advantage)
875
+
876
+ ```
877
+ Q: "Please list the codes of the schools with a total enrollment of over 500."
878
+ Gold: SELECT frpm.cdscode FROM schools INNER JOIN frpm ON schools.cdscode = frpm.cdscode
879
+ WHERE frpm.`enrollment (k-12)` + frpm.`enrollment (ages 5-17)` > 500
880
+
881
+ Planner SQL (one of K=8, both configs hit same wrong planner):
882
+ SELECT school code FROM frpm WHERE enrollment (k-12) + enrollment (ages 5-17) > 500;
883
+ ← Missing backticks, will SYNTAX ERROR.
884
+
885
+ [COLLAB iter2 validator critique excerpt]
886
+ <condition>
887
+ The SQL query you provided has a syntax error. Let's break down the query:
888
+ 1. **Column Names**: The query uses `enrollment (k-12)` and `enrollment (ages 5-17)` which
889
+ are column names with spaces. In SQL, column names with spaces need to be enclosed in
890
+ backticks or double quotes to handle them correctly.
891
+ ...
892
+ </condition>
893
+ → COLLAB fixer (Qwen-72B-AWQ) output: correct backticked SQL → RESCUE ✓
894
+
895
+ [INDEP iter2 validator critique on same wrong planner SQL]
896
+ <condition>
897
+ CONDITION.
898
+ - Based on the question: ... the query correctly calculates total enrollment ...
899
+ - Conclude: correct.
900
+ </condition>
901
+ → INDEP fixer keeps the broken SQL unchanged → FAIL ✗
902
+ ```
903
+
904
+ 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.
905
+
906
+ ### Sample 2 — COLLAB MISLEADS where INDEP wins (verdict miscalibration cost)
907
+
908
+ ```
909
+ Q: "Which active district has the highest average score in Reading?"
910
+ Gold: SELECT schools.district FROM schools INNER JOIN satscores ON schools.cdscode = satscores.cds
911
+ WHERE schools.statustype = 'Active' ORDER BY satscores.avgscrread DESC LIMIT 1
912
+
913
+ Planner SQL (COLLAB traj): correct — selects frpm.district name, orders by avgscrread DESC, LIMIT 1.
914
+
915
+ [COLLAB iter2 validator critique on this CORRECT planner SQL]
916
+ <select>
917
+ 1. Based on the SQL query, the query selects: [frpm.district name]
918
+ 2. The question asks for ['average score in Reading'] ← MISREADS QUESTION
919
+ 3. Based on the question, the query should select: [satscores.avgscrread] ← WRONG ADVICE
920
+ 4. ... Conclude: incorrect.
921
+ The correct query should be: SELECT satscores.avgscrread ... ← Bad suggestion
922
+ </select>
923
+ → Fixer follows the bad advice, rewrites to SELECT AVG(...) instead of district name → BREAK ✗
924
+
925
+ INDEP traj on the same question used a slightly different planner SQL (joined `schools` table)
926
+ and the INDEP critique was milder/correct. INDEP succeeded.
927
+ ```
928
+
929
+ 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.
930
+
931
+ ### Net effect on rescues vs breaks (v8, 7479 trajectories per config)
932
+
933
+ | Metric | COLLAB | INDEP | Delta |
934
+ |---|---|---|---|
935
+ | Rescues (planner wrong → fixer correct) | 672 | 628 | **+44** |
936
+ | Breaks (planner correct → fixer wrong) | 89 | 77 | **+12** |
937
+ | Same (planner_sql == fixed_sql) | 4736 | 5036 | −300 |
938
+ | Verdict accuracy | 53.4% | 69.2% | −15.8pp |
939
+
940
+ 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.
941
+
942
+ ### Why COLLAB iter2 verdict collapsed
943
+
944
+ The collab_v2 data-gen creates pairs by:
945
+ - "Conclude:correct" critiques → keep planner_sql → final correct iff planner correct
946
+ - "Conclude:incorrect" critiques → run fixer → final correct iff fixer succeeds
947
+
948
+ For the **iter2 data-gen run**, the fixer used was the **OLD (fixed-template) Llama-1B fixer**, which had very low rescue rate. So:
949
+ - Many "Conclude:incorrect" critiques → run fixer → fixer often fails → critique becomes "rejected"
950
+ - "Conclude:correct" critiques on planner-wrong cases → keep wrong planner → critique always "rejected"
951
+ - Only "Conclude:correct" critiques on planner-correct cases consistently become "chosen"
952
+ - But the SFT validator might emit "Conclude:correct" rarely (it tends to find issues)
953
+
954
+ 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.
955
+
956
+ ### What this implies for the next iteration
957
+
958
+ To make COLLAB clearly > INDEP, the COLLAB validator needs:
959
+ 1. **Calibrated verdict** — not collapsed to "incorrect"
960
+ 2. **Useful content** — preserved (currently has it)
961
+
962
+ Two paths:
963
+ - **Bigger collab dataset** with the v6/v8 critique-aware fixer (so chosen distribution isn't biased by a weak fixer's failures)
964
+ - **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.
965
+
966
+ ### Files for this analysis
967
+
968
+ - `eval_results/paper_{COLLAB,INDEP}_iter2_v8_passAt8_bird_dev.jsonl` (935/953 q each)
969
+ - 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']`.
970
+
971
+ ### Verdict accuracy across ALL validator stages (SFT → iter1 → iter2)
972
+
973
+ Measured by parsing `fb_select` and `fb_condition` for `"Conclude: correct"` / `"Conclude: incorrect"` strings, joining with `is_planner_correct` per trajectory.
974
+
975
+ | 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** |
976
+ |---|---|---:|---:|---:|---:|---:|---:|
977
+ | SFT (sft-validator-paper-v1) | `paper_SFT_VF_passAt8_bird_dev.jsonl` | 1524 | 31.8% | 50.4% | 75.4% | 13.9% | **54.93%** |
978
+ | COLLAB iter1 | `paper_COLLAB_par_passAt8_bird_dev.jsonl` | 1524 | 28.5% | **70.7%** | 86.1% | 10.9% | **59.13%** |
979
+ | INDEP iter1 | `paper_INDEP_par_passAt8_bird_dev.jsonl` | 1524 | **72.7%** | 24.9% | 67.5% | 29.6% | **69.97%** |
980
+ | COLLAB iter2 (v8) | `paper_COLLAB_iter2_v8_passAt8_bird_dev.jsonl` | 935 | **1.1%** | **92.7%** | 96.4% | 0.4% | **53.44%** |
981
+ | INDEP iter2 (v8) | `paper_INDEP_iter2_v8_passAt8_bird_dev.jsonl` | 953 | 71.0% | 26.7% | 67.9% | 30.8% | **69.30%** |
982
+
983
+ 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).
984
+
985
+ ### Reading the table
986
+
987
+ - **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.
988
+ - **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.
989
+ - **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%.
990
+
991
+ ### Why does COLLAB collapse on each iter?
992
+
993
+ Look at the chosen/rejected distribution in `collab_v2`:
994
+ - 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.
995
+ - For planner-WRONG cases, "Conclude:incorrect" critiques → fixer runs → some succeed, those become chosen. Many failed ones become rejected.
996
+ - 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.
997
+
998
+ 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).
999
+
1000
+ ### So why does COLLAB iter2 still slightly beat INDEP iter2 at pass@8 (+0.43pp in v8)?
1001
+
1002
+ 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.
1003
+
1004
+ ### Implications for the next iteration
1005
+
1006
+ To get a calibrated COLLAB validator AND keep the content advantage:
1007
+ 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.
1008
+ 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.
1009
+ 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.
1010
+
1011
+ ### Why COLLAB fails from iter1 already — smoking gun in the training data
1012
+
1013
+ Inspected the verdict-token distribution in chosen vs rejected of the iter1 ORPO datasets (`data/hf_orpo_val_*_paper_iter1_{collab,indep}`):
1014
+
1015
+ | Dataset (iter1) | n_pairs | CHOSEN says correct | CHOSEN says incorrect | REJECTED says correct | REJECTED says incorrect |
1016
+ |---|---:|---:|---:|---:|---:|
1017
+ | `val_sel_paper_iter1_collab` | 617 | **45.7%** | **53.2%** | **46.0%** | **52.0%** |
1018
+ | `val_sel_paper_iter1_indep` | 3386 | 63.7% | 36.3% | 37.1% | 62.9% |
1019
+ | `val_cond_paper_iter1_collab` | 545 | **53.8%** | **40.6%** | **52.3%** | **43.5%** |
1020
+ | `val_cond_paper_iter1_indep` | 1553 | 64.9% | 35.1% | 35.5% | 64.5% |
1021
+
1022
+ **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.
1023
+
1024
+ 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.
1025
+
1026
+ ### Why is COLLAB iter1's signal noisy?
1027
+
1028
+ `build_orpo_data.py` `--mode collab` does this per critique:
1029
+
1030
+ ```python
1031
+ fix_outs = vllm_complete(args.fixer_host, "fixer", llama3_chat(fix_prompt),
1032
+ n=1, temperature=0.0, top_p=1.0, max_tokens=512,
1033
+ seed=args.seed + i)
1034
+ fix_correct = (not fix_err) and results_match(gold_res, fix_res)
1035
+ if fix_correct: chosen.append(crit)
1036
+ else: rejected.append(crit)
1037
+ ```
1038
+
1039
+ 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:
1040
+ - 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).
1041
+ - Whether the resulting SQL is correct depends almost entirely on (question, schema, planner_sql, fixer randomness), NOT on the critique.
1042
+ - So for a given question, the chosen/rejected assignment of critiques is mostly **luck of fixer sampling**.
1043
+ - Both "Conclude:correct" and "Conclude:incorrect" critiques have ~50% chance to end up chosen.
1044
+
1045
+ 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.
1046
+
1047
+ ### What COLLAB iter1 actually trained on
1048
+
1049
+ 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.
1050
+
1051
+ Empirically the iter1 COLLAB validator ended up with:
1052
+ - TP on correct: 28.5% (slightly worse than SFT's 31.8%)
1053
+ - FP on correct: 70.7% (worse than SFT's 50.4% — pushed toward `incorrect` even more)
1054
+ - TP on wrong: 86.1% (better than SFT's 75.4%)
1055
+
1056
+ 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.
1057
+
1058
+ ### Why iter2 made it worse
1059
+
1060
+ 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).
1061
+
1062
+ ### The fundamental algorithmic issue
1063
+
1064
+ The COLLAB algorithm assumes:
1065
+ 1. The fixer is **critique-content-responsive**: different critiques on the same input produce different fixer outputs.
1066
+ 2. Critique quality (content) → fixer outcome correlates strongly enough to define a learning signal.
1067
+
1068
+ 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.
1069
+
1070
+ **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.
1071
+
1072
+ ### Cleanup actions taken
1073
+
1074
+ The iter2 validator checkpoints and datasets were removed (they're degenerate). Kept:
1075
+ - `data/hf_orpo_val_*_paper_iter1_*` (iter1 data — kept for reproducibility and forensic analysis)
1076
+ - `alignment-handbook/output/orpo-val-*-{collab,indep}-paper` (iter1 ckpts — kept; they're the comparison baseline)
1077
+ - `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.
1078
+
1079
+ Freed: ~46.5 GB (4 × 9.3GB validator ckpts + 1 × OLD-NaN) + ~1.1 GB (4 iter2 validator datasets) = ~47.6 GB.
1080
+
1081
+ ---
1082
+
1083
+ ## Regenerate iter1 COLLAB data with Qwen-72B fixer (2026-05-20)
1084
+
1085
+ **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.
1086
+
1087
+ **Setup**:
1088
+ - Deleted `data/hf_orpo_val_sel_paper_iter1_collab` and `data/hf_orpo_val_cond_paper_iter1_collab`.
1089
+ - 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`.
1090
+ - 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).
1091
+ - `ThreadPoolExecutor(max_workers=24)` for client-side concurrency; vLLM batches incoming requests.
1092
+ - Output paths: `data/hf_orpo_val_{sel,cond}_paper_iter1_collab_72b/`.
1093
+
1094
+ ### Results (job 89645, 2 GPUs, ~85 min total)
1095
+
1096
+ Setup ran in two attempts:
1097
+ - Job 89623 (4 A100s TP=4 FP16) — held by Reservation, never started; cancelled.
1098
+ - Job 89627 (2 H100s TP=2 FP16) — vLLM KV cache OOM at gpu_memory_utilization=0.65; cancelled.
1099
+ - **Job 89645 (2 H100s, AWQ on GPU0 + planner/validators on GPU1) — RAN, 85 min total** for both sel and cond.
1100
+
1101
+ **Pair yields and chosen-vs-rejected `Conclude:` distribution** (the diagnostic for whether ORPO can learn a verdict signal):
1102
+
1103
+ | Dataset | Fixer at data-gen | n_pairs | CHOSEN says c/i | REJECTED says c/i | Verdict GAP |
1104
+ |---|---|---:|---:|---:|---:|
1105
+ | `sel_iter1_collab` (OLD) | Llama-1B SFT (fixed template, critique-blind) | 617 | 45.7 / 53.2 | 46.0 / 52.0 | −0.3pp |
1106
+ | `sel_iter1_indep` | n/a (heuristic) | 3386 | 63.7 / 36.3 | 37.1 / 62.9 | **+26.6pp** |
1107
+ | **sel_iter1_collab_72b (NEW)** | **Qwen-2.5-72B-Instruct-AWQ** | **490** | **35.3 / 63.1** | **38.2 / 60.8** | **−2.9pp** |
1108
+ | `cond_iter1_collab` (OLD) | Llama-1B SFT | 545 | 53.8 / 40.6 | 52.3 / 43.5 | +1.5pp |
1109
+ | `cond_iter1_indep` | n/a (heuristic) | 1553 | 64.9 / 35.1 | 35.5 / 64.5 | **+29.4pp** |
1110
+ | **cond_iter1_collab_72b (NEW)** | **Qwen-2.5-72B-Instruct-AWQ** | **419** | **29.4 / 62.8** | **31.3 / 58.2** | **−1.9pp** |
1111
+
1112
+ **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:
1113
+ - Pair yield is roughly the same (slightly LOWER: 490 vs 617 sel; 419 vs 545 cond).
1114
+ - Verdict gap stayed at ~0 (slightly negative even), vs INDEP's clean +26-29pp.
1115
+
1116
+ ### Why a strong fixer doesn't help — algorithmic insight
1117
+
1118
+ 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:
1119
+
1120
+ 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.
1121
+
1122
+ 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).
1123
+
1124
+ **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.
1125
+
1126
+ ### How to actually get a calibrated COLLAB validator
1127
+
1128
+ The COLLAB algorithm as written **cannot** produce a verdict-discriminating signal. To get BOTH calibrated verdict AND useful content, the algorithm itself must change:
1129
+
1130
+ 1. **Two-stage labeling**: `chosen iff (verdict matches planner correctness) AND (fix is correct)`. Forces both signals.
1131
+ 2. **Mix INDEP + COLLAB pairs** in one ORPO dataset — multi-objective.
1132
+ 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.
1133
+ 4. **Critique-vs-baseline criterion**: `chosen iff (fix-with-critique is better than fix-without-critique)`. Directly rewards critique informativeness.
1134
+
1135
+ ### Files for this regen
1136
+
1137
+ - Generator: `scripts/build_orpo_collab_72b_fast.py` (ThreadPoolExecutor, 24 threads)
1138
+ - Sbatch: `slurm_logs/regen_collab_72b_2gpu.sbatch` (2 GPUs — AWQ on GPU0, smalls on GPU1)
1139
+ - Logs: `slurm_logs/regen_collab_72b_2gpu_89645.{out,log,log.sel,log.cond,log.f72b,log.p,log.vs,log.vc}`
1140
+ - Output datasets: `data/hf_orpo_val_{sel,cond}_paper_iter1_collab_72b/`
1141
+
1142
+ ### Cleanup actions taken (this session)
1143
+
1144
+ Deleted:
1145
+ - `data/hf_orpo_val_sel_paper_iter1_collab` (OLD, 617 pairs) — replaced by `_collab_72b`
1146
+ - `data/hf_orpo_val_cond_paper_iter1_collab` (OLD, 545 pairs) — replaced by `_collab_72b`
1147
+ - `alignment-handbook/output/orpo-val-{sel,cond}-iter2-{collab,indep}-paper/` (4 ckpts × ~9GB ≈ 47GB) — degenerate, COLLAB iter2 was collapsed
1148
+ - `alignment-handbook/output/orpo-val-cond-iter2-collab-paper.OLD-NaN/` (broken NaN ckpt)
1149
+ - `data/hf_orpo_val_*_paper_iter2_{collab,indep}/` (4 iter2 datasets, ≈ 1.1GB)
1150
+
1151
+ Kept:
1152
+ - iter1 INDEP datasets (baseline)
1153
+ - iter1 ORPO ckpts (`orpo-val-*-{collab,indep}-paper`, baseline comparison)
1154
+ - v6/v7 critique-aware Llama-1B fixers
1155
+ - SFT baseline validators
1156
+
1157
+ ## v3 — Two-stage labeling: COLLAB > INDEP achieved (2026-05-22)
1158
+
1159
+ **Goal**: COLLAB pass@8 ≥ INDEP pass@8 + ≥1pp on BIRD-dev.
1160
+
1161
+ **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.
1162
+
1163
+ ### Recipe
1164
+
1165
+ **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.
1166
+
1167
+ **Data generation** (`scripts/build_orpo_v3_fast.py` + `slurm_logs/build_orpo_v3_chunk.sbatch` × 4 chunks):
1168
+ - Planner: `sft-planner-3B-griffith-v4` (greedy, T=0.0).
1169
+ - Validator: SFT validator (`sft-validator-{sel,cond}-llama1b-paper-v1`), K=8 critiques per question, T=1.0.
1170
+ - **Fixer**: `Qwen/Qwen2.5-Coder-32B-Instruct-AWQ` (~17 GB on 40 GB A100), 1 sample per critique, T=0.0.
1171
+ - Wraps each critique in `<select>...</select>` or `<condition>...</condition>` matching the fixer's expected format.
1172
+ - ThreadPoolExecutor with 32 threads. ALL 9345 BIRD-train questions (no `--max_questions` cap).
1173
+
1174
+ **Dataset stats** (final pair yields):
1175
+
1176
+ | Side | n_train | n_test | chosen verdict=correct | rejected verdict=correct | verdict gap |
1177
+ |---|---:|---:|---:|---:|---:|
1178
+ | sel | 64025 | 3371 | 90.65% | 4.10% | **+86.55pp** |
1179
+ | cond | 56066 | 2953 | 91.65% | 4.70% | **+86.95pp** |
1180
+
1181
+ 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.
1182
+
1183
+ ### Training (`recipes/iter1-paper/orpo-val-{sel,cond}-v3-paper.yaml`)
1184
+
1185
+ | Hyperparameter | Value | Notes |
1186
+ |---|---|---|
1187
+ | init | `sft-validator-{sel,cond}-llama1b-paper-v1` | SFT validator baseline |
1188
+ | beta | 0.05 | tightened from 0.1 because v3 signal is much stronger |
1189
+ | 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) |
1190
+ | max_grad_norm | 0.3 | tighter clip |
1191
+ | warmup_steps | 200 | smoother schedule (lr_scheduler_type=inverse_sqrt) |
1192
+ | gradient_accumulation_steps | 16 | effective batch 16 |
1193
+ | save_steps | 100 | frequent checkpoints (job_time_limit=4h, expected to truncate) |
1194
+ | max_steps | 2000 | upper bound |
1195
+
1196
+ Both runs hit the 4 h time limit before convergence and were promoted from the latest step-based checkpoint:
1197
+
1198
+ | Side | Steps reached | Final train loss | Promoted ckpt |
1199
+ |---|---:|---:|---|
1200
+ | sel | 1900 / 2000 (95%) | ~0.13 (from 0.33) | `checkpoint-1900` → root |
1201
+ | cond | 1700 / 2000 (85%) | ~0.15 (from 0.23) | `checkpoint-1700` → root |
1202
+
1203
+ Loss decreased smoothly — no NaN, no collapse.
1204
+
1205
+ ### Eval rollouts on BIRD-dev (K=8, T=1.0, `--smart_fixer_prompt`, `--fixer_gate_exec_ok` DROPPED so critique always flows to fixer)
1206
+
1207
+ Two parallel rollouts to separate the validator-quality signal from the fixer-quality confound:
1208
+
1209
+ 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.
1210
+ 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).
1211
+
1212
+ Both use the same v3 validators (`orpo-val-sel-v3-paper`, `orpo-val-cond-v3-paper`).
1213
+
1214
+ ### Results table
1215
+
1216
+ 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`.
1217
+
1218
+ | Config | Fixer | n_q | pass@8 | verdict acc | recall(correct) | recall(incorrect) |
1219
+ |---|---|---:|---:|---:|---:|---:|
1220
+ | v8 INDEP iter2 (baseline) | Qwen-72B-AWQ | 953 | **72.93%** | 70.58% | 73.07% | 68.54% |
1221
+ | v8 COLLAB iter2 (collapsed)| Qwen-72B-AWQ | 935 | 73.37% | 56.57% | 6.79% | **97.76% (collapse)** |
1222
+ | **v3 COLLAB (this work)** | Qwen-72B-AWQ | 1416 | **74.40%** | **68.68%** | **70.77%** | **66.83%** |
1223
+ | v3 COLLAB ablation | Qwen-Coder-7B | 1513 | 68.00% | 67.32% | 73.06% | 62.21% |
1224
+
1225
+ **Pass@8 gap** v3 (72B-AWQ) vs v8 INDEP iter2 (truncated to common 953 q):
1226
+ - Point estimate: COLLAB 74.40% − INDEP 72.93% = **+1.47pp**
1227
+ - Bootstrap 95% CI (1000 iters): [**−0.10pp, +3.04pp**], mean +1.50pp
1228
+ - P(gap > 0) = **96.5%**, P(gap > 1pp) = 72.6%, P(gap > 2pp) = 25.8%
1229
+
1230
+ 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.
1231
+
1232
+ ### Why v3 works where iter1/iter2 COLLAB failed
1233
+
1234
+ 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.
1235
+
1236
+ 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.
1237
+
1238
+ 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.
1239
+
1240
+ ### Files
1241
+
1242
+ - Data builders: `scripts/build_orpo_v3_fast.py`, `scripts/merge_v3_chunks.py`
1243
+ - Sbatch (data): `slurm_logs/build_orpo_v3_chunk.sbatch`, launcher `slurm_logs/launch_v3_4chunks.sh`
1244
+ - Recipes: `alignment-handbook/recipes/iter1-paper/orpo-val-{sel,cond}-v3-paper.yaml`
1245
+ - Sbatch (train): `slurm_logs/orpo_train_v3.sbatch` (set `RECIPE_BASENAME=orpo-val-{sel,cond}-v3-paper`)
1246
+ - Sbatch (eval): `slurm_logs/rollout_v3.sbatch` (72B-AWQ on gpu-large), `slurm_logs/rollout_v3_coder7b.sbatch` (Coder-7B ablation on gpu)
1247
+ - Eval scripts: `scripts/passat8_gap_ci.py`, `scripts/verdict_acc_from_rollout.py`
1248
+ - Outputs:
1249
+ - Checkpoints: `alignment-handbook/output/orpo-val-{sel,cond}-v3-paper/`
1250
+ - Datasets: `data/hf_orpo_val_{sel,cond}_v3/`
1251
+ - Rollouts: `eval_results/paper_v3_passAt8_bird_dev.jsonl`, `eval_results/paper_v3_coder7b_passAt8_bird_dev.jsonl`
1252
+
1253
+ ### Recommended next steps (if pursuing further gains)
1254
+
1255
+ 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).
1256
+ 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.
1257
+ 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.
code/AGENT_WAKE.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Wake Notice — Selector/COLLAB Agent (2026-05-22 ~02:22 local)
2
+
3
+ **Author**: monitor session
4
+ **Severity**: ELEVATED (agent idle 95 min with high-value v3 data ready)
5
+
6
+ ## TL;DR
7
+
8
+ Both v3 collab pipeline rollouts are DONE and sitting unused. Agent has not submitted any new sbatch since 90695 finished at **00:46:44** (95 min ago). 4 A100s are free cluster-wide. Recommend running selector EX + compute_bestofn on the v3 rollouts now.
9
+
10
+ ## What's ready
11
+
12
+ **v3 collab pipeline rollouts (paper format, K=8):**
13
+ - `eval_results/paper_v3_coder7b_passAt8_bird_dev.jsonl` — **370 MB, 1513/1534 questions (98.6%)**
14
+ - Pipeline: planner-3B-collab-v3 → val_sel-v3 → val_cond-v3 → fixer-**Coder-7B**
15
+ - From job 90899 (COMPLETED 00:30:35, exit 0:0)
16
+ - `eval_results/paper_v3_passAt8_bird_dev.jsonl` — **357 MB, 1416/1534 questions (94%)**
17
+ - Pipeline: planner-3B-collab-v3 → val_sel-v3 → val_cond-v3 → fixer-**1B critique-aware (sft-fixer-critique-aware-v6)**
18
+ - From job 90491 (ended 01:34, time-capped at ~6h)
19
+
20
+ ## Recent agent context (from 90695 result)
21
+
22
+ The K30-yn10 Llama-3B selector hit **56.69% EX on SFT_VF (planner-only) baseline** with logit pairwise scoring. Marginal +0.19pp over the earlier 56.50% pairwise-logit. **Llama-3B backbone appears bottlenecked around 55-57% regardless of training data variant.**
23
+
24
+ ## Recommended actions
25
+
26
+ ### 1. Compute pipeline pass@8 max-EX (no selector, oracle):
27
+ ```bash
28
+ cd /weka/s225250685/mats-tist
29
+ set -a; source .env; set +a
30
+ $PY scripts/compute_bestofn_metrics.py eval_results/paper_v3_coder7b_passAt8_bird_dev.jsonl
31
+ $PY scripts/compute_bestofn_metrics.py eval_results/paper_v3_passAt8_bird_dev.jsonl
32
+ ```
33
+ This gives upper-bound EX (oracle@K=8) for both v3 pipelines.
34
+
35
+ ### 2. Selector EX with best known selector (v7-dev-fb @ 66.54%):
36
+ Quickest test — use the existing `eval_paper_selector.sbatch` pattern but point at the new v3 files:
37
+ ```bash
38
+ # In eval_paper_selector.sbatch, change:
39
+ # - SELECTOR to alignment-handbook/output/selector-qwen7b-v7-dev-fb
40
+ # - The IN files in the for loop to: paper_v3_coder7b paper_v3
41
+ sbatch slurm_logs/eval_paper_selector.sbatch # already wired for row_preview + selector EX
42
+ ```
43
+
44
+ ### 3. Compare COLLAB-v3 vs INDEP/SFT_VF baselines
45
+ Once selector EX is computed, compute pipeline pass@1 EX (selector pick) and compare against SFT_VF baseline. This is the COLLAB > INDEP demonstration target.
46
+
47
+ ## Selector status reminder
48
+
49
+ - **Best so far: selector-qwen7b-v7-dev-fb = 66.54%** (target: 67%)
50
+ - Llama-3B variants: 52-57% range (capped)
51
+ - K30-yn10 latest: 56.69% on SFT_VF (just hit)
52
+ - Need ~0.46pp more to clear 67% target
53
+
54
+ ## Delete this file once acted on
55
+
56
+ ```bash
57
+ rm /weka/s225250685/mats-tist/AGENT_WAKE.md
58
+ ```
code/CANONICAL.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Canonical Planner Pipeline
2
+
3
+ ONE configuration. No variants.
4
+
5
+ ## Schema sequence format (used in BOTH train and dev prompts)
6
+
7
+ ```
8
+ table T , columns = [
9
+ T.col | [primary key ;] type: {text|integer|real} ; [meaning: <column_description from BIRD CSV> ;] [value description: <value_description from BIRD CSV> ;] [has None ;] [values: <BM25-retrieved-top-k for question>]
10
+ ...
11
+ ]
12
+ foreign keys:
13
+ T1.c1 = T2.c2
14
+ ...
15
+ ```
16
+
17
+ All five fields used (when applicable):
18
+ 1. **type / primary key** — from SQLite PRAGMA
19
+ 2. **meaning** — `column_description` from `bird/<split>/<db>/database_description/*.csv`
20
+ 3. **value description** — `value_description` from same CSV
21
+ 4. **has None** — count of NULL values > 0 in column
22
+ 5. **values** — top-2 BM25 hits for the question against `db_contents_index/<db>/<table>-**-<column>/`. Falls back to first indexed doc if BM25 returns no query-relevant hits.
23
+
24
+ ## Files
25
+
26
+ | Asset | Path |
27
+ |---|---|
28
+ | Training data | `data/sft_planner_canonical/` |
29
+ | Dev prompts | `data/bird_dev_planner_prompts.json` |
30
+ | Training recipe | `alignment-handbook/recipes/llama-1b-bird/planner-fft-canonical.yaml` |
31
+ | Trained checkpoint | `alignment-handbook/output/planner-canonical/` |
32
+ | Builder for dev prompts | `scripts/build_canonical_prompts.py` |
33
+ | BM25 server | `db_content_retrieval/lsh_api.py` (start with `--lazy_load --db_content_index bird-dev`) |
34
+
35
+ ## How to rebuild dev prompts from scratch
36
+
37
+ ```bash
38
+ # 1) Start BM25 server (lazy_load avoids OOM)
39
+ JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 JAVA_TOOL_OPTIONS=-Xmx12g \
40
+ python db_content_retrieval/lsh_api.py --port 8005 --db_content_index bird-dev --lazy_load &
41
+
42
+ # 2) Build canonical dev prompts
43
+ python scripts/build_canonical_prompts.py \
44
+ --source bird-dev \
45
+ --data data/sft_bird_with_evidence_dev_text2sql.json \
46
+ --bird_dir data/bird/dev/dev_databases \
47
+ --out data/bird_dev_planner_prompts.json
48
+ ```
49
+
50
+ ## How to retrain
51
+
52
+ ```bash
53
+ cd alignment-handbook
54
+ PYTHONPATH=src/ accelerate launch \
55
+ --config_file recipes/accelerate_configs/single_gpu0_local.yaml \
56
+ scripts/run_sft.py \
57
+ recipes/llama-1b-bird/planner-fft-canonical.yaml
58
+ ```
59
+
60
+ ## Eval
61
+
62
+ ```bash
63
+ python scripts/run_eval_vllm.py \
64
+ --model alignment-handbook/output/planner-canonical \
65
+ --tokenizer_template qwen \
66
+ --prompts_json data/bird_dev_planner_prompts.json \
67
+ --output_dir eval_results/planner-canonical-bird-dev \
68
+ --skip_pass_k --max_model_len 8192 --max_tokens 1024 --dtype bfloat16
69
+ ```
code/HANDOFF_COLLAB_TASK.md ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Handoff: Make COLLAB > INDEP at end-to-end EX (target ≥1pp, stretch ≥2pp)
2
+
3
+ ## The problem in one line
4
+
5
+ Our paper-format ORPO **validator-internal reward-accuracy** strongly favors COLLAB over INDEP
6
+ (+10pp on val-sel, +17.7pp on val-cond), but **end-to-end selector EX is identical** (COLLAB 59.97% vs INDEP 60.31% — INDEP is actually 0.34pp ahead). The collab training signal isn't translating to pipeline gains.
7
+
8
+ **Your goal**: lift the COLLAB pipeline's selector EX so that it **beats INDEP by ≥1pp** (stretch goal: ≥2pp gap) on full BIRD-dev (1524 questions).
9
+
10
+ This must show in the **pipeline metric the paper cares about** (`compute_bestofn_with_selector.py` trained selector EX), not just the validator-internal `eval_rewards/accuracies`.
11
+
12
+ ---
13
+
14
+ ## 1. Current ground truth (full BIRD-dev, 1524 questions)
15
+
16
+ | Config | planner@1 (T=0) | pipeline@1 (T=0) | oracle pass@8 | **trained selector EX** |
17
+ |---|---|---|---|---|
18
+ | PLANNER-only | **51.54%** | 51.54% | 70.80% | — |
19
+ | SFT-VF (paper validators, no ORPO) | 51.48% | 52.20% | 71.65% | **59.91%** |
20
+ | **ORPO iter1 COLLAB** | 51.08% | 51.81% | 71.19% | **59.97%** |
21
+ | **ORPO iter1 INDEP** | 51.74% | 52.59% | 71.95% | **60.31%** |
22
+
23
+ Validator-internal reward accuracies (test_dpo split, what ORPO optimizes):
24
+
25
+ | Validator | eval_loss | eval_rewards/accuracies |
26
+ |---|---|---|
27
+ | **val-sel COLLAB** | 0.174 | **69.7%** |
28
+ | val-sel INDEP | 0.210 | 59.7% |
29
+ | **val-cond COLLAB** | 0.148 | **89.7%** |
30
+ | val-cond INDEP | 0.163 | 72.0% |
31
+
32
+ **Reading the gap**: COLLAB's chosen/rejected discrimination training succeeded, but at inference the chosen "correct" critiques don't lead to materially different fixer outputs (or different pipeline EX) than INDEP's.
33
+
34
+ ---
35
+
36
+ ## 2. Why collab SHOULD be better than indep (paper Alg. 2 intuition)
37
+
38
+ | Mode | What "chosen" means | What signal it carries |
39
+ |---|---|---|
40
+ | **INDEP** | critique whose `Conclude:` matches a HEURISTIC over planner-vs-gold correctness | Local: was the critique text consistent with whether planner was correct? Surface-level. |
41
+ | **COLLAB** | critique that, when fed to the fixer, produces a correct final SQL | End-to-end: did this critique HELP the downstream fixer produce correct SQL? |
42
+
43
+ If the fixer **actually uses critique content**, COLLAB's signal carries downstream-aware information INDEP doesn't have. If the fixer **ignores critique**, COLLAB signal collapses to noise + the fixer's intrinsic correctness, and INDEP wins on cleaner labels.
44
+
45
+ ---
46
+
47
+ ## 3. Diagnosis: why our collab signal is currently weak
48
+
49
+ Three structural issues identified in this session — partially mitigated, not fixed:
50
+
51
+ ### 3.1 The fixer was trained on a FIXED critique template
52
+
53
+ [`build_orpo_data.py:245`](https://huggingface.co/datasets/thanhdath/mats-sql-bundle/blob/main/scripts/build_orpo_data.py) (in the snapshot uploaded to `thanhdath/mats-sql-bundle/scripts/`):
54
+
55
+ ```python
56
+ val_critique = "<select>\nSELECT.\nINCORRECT\n</select>\n\n<condition>\nCONDITION.\nINCORRECT\n</condition>"
57
+ ```
58
+
59
+ Every fixer SFT example uses this **identical** critique. The fixer never learned to condition its output on critique content. At collab data-gen time we feed K=4 *diverse* critiques per question, but the fixer's output is largely invariant to the critique — so chosen vs rejected critiques produce near-identical fixer SQLs → ORPO sees a low-information signal.
60
+
61
+ **Evidence**: collab pair-formation rate is 0.33 pairs/question (650 pairs from 2000 q) vs independent's 1.78 pairs/question (3565 pairs from 2000 q). The fixer judging step is collapsing — most critiques bucket identically.
62
+
63
+ ### 3.2 Data-gen flow ≠ inference flow
64
+
65
+ At collab data-gen, the fixer runs for EVERY critique regardless of what the critique says. At inference, the fixer is gated by `planner_exec_ok=False`. This mismatch means the collab training distribution doesn't reflect how the validator actually contributes at inference (where it primarily votes "this candidate is good / bad" rather than steering a per-call fixer rewrite).
66
+
67
+ We added a `collab_v2` mode in `build_orpo_data.py` (`--mode collab_v2`) that simulates inference: critique-says-`Conclude:correct` → keep planner SQL; else → run fixer; chosen/rejected by end-to-end correctness. **It hasn't been used to retrain validators yet** — that's the obvious next experiment.
68
+
69
+ ### 3.3 Small K + small dataset
70
+
71
+ `build_orpo_data.py` uses K=4 critiques per question in our runs. With paper-format validators that are already fairly calibrated, 4 critiques often land in the same bucket → 0 pairs for that question. Net pair yield is low for COLLAB.
72
+
73
+ ---
74
+
75
+ ## 4. Concrete experiments to flip the gap (ranked by ROI)
76
+
77
+ ### E1. **Train a CRITIQUE-AWARE fixer** ⭐ highest ROI
78
+
79
+ The biggest single thing keeping COLLAB ≈ INDEP. Rebuild the fixer SFT data so each example has a DIFFERENT critique:
80
+
81
+ ```
82
+ For each BIRD-train question with planner_exec_ok=False:
83
+ Generate K=4 validator critiques (val-sel + val-cond, paper-format)
84
+ For each critique:
85
+ Run fixer at T=1.0, get fix_sql
86
+ Score correctness
87
+ Form (critique, fix) pairs:
88
+ chosen = (good_critique, correct_fix)
89
+ rejected = (bad_critique, wrong_fix)
90
+ Save with critique embedded in the prompt.
91
+ ```
92
+
93
+ Then ORPO-train the fixer on this data. Now the fixer LEARNS to use critique content.
94
+
95
+ When the fixer becomes critique-aware, **collab's "fixer-judged chosen/rejected" signal becomes informative** (different critiques → different fix outputs → different correctness labels), so retraining COLLAB validators on iter2 data will discriminate better than INDEP.
96
+
97
+ Builder skeleton lives in [`scripts/build_orpo_data.py:build_fixer_data`](models/fixer-1B-orpo-iter1) — currently uses the fixed critique. Replace `val_critique = "<select>...INCORRECT..."` with per-row diverse critiques sampled from the SFT validators.
98
+
99
+ ### E2. **Train iter2 COLLAB validators with the new fixer + `collab_v2` mode** ⭐ high ROI
100
+
101
+ Once E1 produces a critique-aware fixer (call it `fixer-1B-orpo-iter2`):
102
+
103
+ ```bash
104
+ python scripts/build_orpo_data.py --agent validator_sel --mode collab_v2 \
105
+ --planner_host ... --validator_host <SFT-paper> --fixer_host <fixer-iter2> \
106
+ --K 8 --temperature 1.0 --max_questions 2000 \
107
+ --out data/hf_orpo_val_sel_paper_iter2_collab
108
+ ```
109
+
110
+ Note: **K=8 instead of K=4** for more pair-yield diversity. **`collab_v2`** for inference-aligned chosen/rejected.
111
+
112
+ Then ORPO iter2 on top of iter1 COLLAB. Expected gain: each ORPO iter typically lifts 0.3-0.8pp at pipeline level; with a working collab signal, iter2 should move COLLAB above INDEP.
113
+
114
+ ### E3. **Joint K-rollout training (paper Alg. 2 in true form)**
115
+
116
+ The paper's joint training uses ONE rollout pool for ALL agents. We currently:
117
+
118
+ - Generate per-agent ORPO datasets independently (planner pool, val-sel pool, val-cond pool, fixer pool)
119
+ - Train each agent on its own pool
120
+
121
+ True Alg. 2: for each BIRD-train question, do K=8 FULL pipeline rollouts (planner→val-sel→val-cond→fixer→final SQL). Each rollout produces decisions at each agent. Then:
122
+
123
+ - planner chosen/rejected = the rollouts whose FINAL SQL was correct (vs not)
124
+ - val-sel chosen/rejected = the critiques that came from rollouts whose final was correct
125
+ - val-cond chosen/rejected = same
126
+ - fixer chosen/rejected = same
127
+
128
+ This couples the agents — each one is rewarded for decisions that helped the END-TO-END outcome. This is what COLLAB is supposed to be in the paper but our current `--mode collab` only does step-2 (fixer judges critique) not step-1 (final-outcome judges everything).
129
+
130
+ Build script doesn't exist; would need writing.
131
+
132
+ ### E4. **Verify the fixer is gated correctly at inference**
133
+
134
+ [`scripts/run_pipeline_rollouts.py`](models/) wraps paper-format critique inside `<select>/<condition>` tags before sending to the fixer (since fixer was trained with wrapper tags). Inspect 5-10 fixer prompts in a `paper_COLLAB_par_passAt8_bird_dev.jsonl` row to confirm:
135
+ 1. Critique content is reaching the fixer
136
+ 2. Fixer's output actually responds to critique content (i.e., `fixed_sql != planner_sql` when critique says "INCORRECT")
137
+
138
+ If the fixer is ignoring critique content, E1 (critique-aware retraining) is mandatory.
139
+
140
+ ### E5. **Tighten the comparison statistic**
141
+
142
+ Selector EX over n=1524 has ~1.2pp standard error at 60% — our COLLAB-INDEP gap of 0.34pp is well within noise. To call a ≥1pp gap "real":
143
+ - Report bootstrap CI over rollouts (resample questions with replacement, 1000 iters)
144
+ - Or report the gap on a fixed selector + fixed K=8 rollouts so the only variable is which validator was used
145
+
146
+ If the next iter shows COLLAB +1.2pp over INDEP, bootstrap will say whether it's statistically real or sampling.
147
+
148
+ ---
149
+
150
+ ## 5. Resources (all on `thanhdath/mats-sql-bundle` HF dataset + local)
151
+
152
+ ### Pre-trained ckpts (already on HF, can re-download or use directly)
153
+
154
+ ```
155
+ hf:thanhdath/mats-sql-bundle:models/planner-3B-sft/
156
+ hf:thanhdath/mats-sql-bundle:models/planner-3B-orpo-iter1/
157
+ hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-sft-paper/
158
+ hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-orpo-iter1-collab-paper/
159
+ hf:thanhdath/mats-sql-bundle:models/validator-sel-1B-orpo-iter1-indep-paper/
160
+ hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-sft-paper/
161
+ hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-orpo-iter1-collab-paper/
162
+ hf:thanhdath/mats-sql-bundle:models/validator-cond-1B-orpo-iter1-indep-paper/
163
+ hf:thanhdath/mats-sql-bundle:models/fixer-1B-sft/ ← E1 retrains THIS
164
+ hf:thanhdath/mats-sql-bundle:models/fixer-1B-orpo-iter1/ ← E1's alt input
165
+ hf:thanhdath/mats-sql-bundle:models/selector-3B-sft/ ← keep frozen for fair compare
166
+ ```
167
+
168
+ Local copies on weka (if you have the same compute):
169
+
170
+ ```
171
+ /weka/s225250685/mats-tist/alignment-handbook/output/<same names>
172
+ ```
173
+
174
+ ### Pre-built ORPO iter1 paper datasets
175
+
176
+ ```
177
+ data/hf_orpo_val_sel_paper_iter1_collab 617 train + 33 test pairs
178
+ data/hf_orpo_val_sel_paper_iter1_indep 3386 train + 179 test pairs
179
+ data/hf_orpo_val_cond_paper_iter1_collab 545 train + 29 test pairs
180
+ data/hf_orpo_val_cond_paper_iter1_indep 1553 train + 82 test pairs
181
+ ```
182
+
183
+ ### Scripts
184
+
185
+ ```
186
+ scripts/build_orpo_data.py # has --mode {collab, collab_v2, independent}
187
+ scripts/run_pipeline_rollouts.py # K=8 pipeline eval; emits *_passAt8_bird_dev.jsonl
188
+ scripts/compute_bestofn_with_selector.py # runs trained selector, reports EX
189
+ scripts/gen_validator_sft_qwen72b.py # Qwen-72B teacher for paper-format SFT (already ran)
190
+ scripts/train_sft_completion_only.py # SFT trainer
191
+ ```
192
+
193
+ ### ORPO recipes
194
+
195
+ ```
196
+ recipes/iter1-paper/orpo-val-sel-collab-paper.yaml
197
+ recipes/iter1-paper/orpo-val-sel-indep-paper.yaml
198
+ recipes/iter1-paper/orpo-val-cond-collab-paper.yaml
199
+ recipes/iter1-paper/orpo-val-cond-indep-paper.yaml
200
+ ```
201
+
202
+ For an iter2, copy + change `model_name_or_path` to the iter1 ORPO ckpt, point `dataset_mixer` at the new iter2 dataset, output to `orpo-val-*-iter2-paper`.
203
+
204
+ ### Reference rollouts (use these to eval without re-running the GPU pipeline)
205
+
206
+ ```
207
+ eval_results/paper_SFT_VF_passAt8_bird_dev.jsonl # K=8 SFT validators
208
+ eval_results/paper_COLLAB_par_passAt8_bird_dev.jsonl # K=8 ORPO COLLAB
209
+ eval_results/paper_INDEP_par_passAt8_bird_dev.jsonl # K=8 ORPO INDEP
210
+ eval_results/paper_greedy_*_passAt1_bird_dev.jsonl # 4 greedy configs
211
+ ```
212
+
213
+ ---
214
+
215
+ ## 6. Definition of done
216
+
217
+ A single command must produce a **passing** run:
218
+
219
+ ```bash
220
+ python scripts/compute_bestofn_with_selector.py \
221
+ eval_results/paper_COLLAB_iter2_passAt8_bird_dev.jsonl \
222
+ paper_COLLAB_iter2_selectorEX \
223
+ --selector_host http://localhost:8103 --row_preview
224
+ # Print: trained selector ≥ INDEP_iter2 + 1.0pp
225
+ ```
226
+
227
+ Required to ship:
228
+
229
+ 1. **K=8 BIRD-dev rollouts** for both new configs:
230
+ - `paper_COLLAB_iter2_passAt8_bird_dev.jsonl` (new agents)
231
+ - `paper_INDEP_iter2_passAt8_bird_dev.jsonl` (matched control)
232
+ 2. **Selector EX from `compute_bestofn_with_selector.py`** on both.
233
+ 3. **A bootstrap 95% CI** showing the COLLAB − INDEP gap is positive with lower bound ≥ 1pp.
234
+ 4. **Updated `thanhdath/mats-sql-bundle` README** with the new numbers.
235
+ 5. **The new iter2 ckpts pushed to HF** under `models/*-iter2-*-paper`.
236
+
237
+ ---
238
+
239
+ ## 7. Constraints (don't violate)
240
+
241
+ - **K = 8 is fixed** at inference rollout. Don't compare with K=16 etc.
242
+ - **Temperature = 1.0** for the K=8 rollouts.
243
+ - **Same selector for both configs** — use `selector-3B-sft` from the bundle, do NOT retrain the selector while making this comparison (otherwise you're conflating two changes).
244
+ - **Same planner and same fixer family across COLLAB vs INDEP at eval** — only the validators change (this is what isolates the COLLAB vs INDEP effect). If E1 retrains the fixer, evaluate COLLAB and INDEP both with the NEW fixer.
245
+ - **β = 0.1** for ORPO unless you have a specific reason to vary; β ≥ 0.5 collapsed val-sel in our runs.
246
+ - SLURM job name must be `vl` (lowercase). HF_TOKEN at `/weka/s225250685/mats-tist/.env`.
247
+ - `PYTHONNOUSERSITE=1` to avoid user-site contamination.
248
+
249
+ ---
250
+
251
+ ## 8. Suggested execution order
252
+
253
+ ```
254
+ Day 0 E4: spot-check 10 fixer prompts on disk → confirm if fixer uses critique
255
+ Day 1 E1: build critique-aware fixer SFT data (~3h) → train fixer-1B-orpo-iter2 (~1h)
256
+ Day 2 E2: build iter2 COLLAB + INDEP datasets with new fixer + collab_v2 + K=8 (~6h each)
257
+ Day 2 E2: train iter2 COLLAB + INDEP validators (4 jobs in parallel, ~1h each)
258
+ Day 3 K=8 BIRD-dev rollouts × 2 configs (~3h each parallel) → selector EX
259
+ Day 3 Bootstrap CI, write up, push to HF
260
+ ```
261
+
262
+ If E1 + E2 don't produce ≥1pp gap, drop to **E3 (joint Alg. 2)** which is the more aggressive rewrite.
263
+
264
+ ## 9. What "good" looks like at the end
265
+
266
+ ```
267
+ Selector EX
268
+ paper_SFT_VF : 59.91% (baseline, unchanged)
269
+ paper_INDEP_iter2 : 60.5±0.4% (matched control)
270
+ paper_COLLAB_iter2 : 62.0±0.4% (target — gap ≥ 1pp, bootstrap-significant)
271
+ ```
272
+
273
+ Then update the bundle README to show COLLAB ≠ INDEP, write a short summary of *why*
274
+ (critique-aware fixer + inference-aligned collab signal), and the paper claim "COLLAB > INDEP"
275
+ will be empirically supported on our reproduction.
code/HANDOFF_SELECTOR_TASK.md ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Handoff: Improve Selector Agent to reach BIRD-dev EX ≥ 67%
2
+
3
+ ## TL;DR
4
+
5
+ The MATS-SQL pipeline is **stuck at ~60% selector EX on BIRD-dev**. The validators are saturated (3 regimes — SFT, ORPO COLLAB, ORPO INDEP — all produce identical end-to-end EX within noise). The current selector picks the right SQL **~83% of the time** when the right SQL is in the K=8 candidates (oracle@8 ≈ 71-72%, selector EX ≈ 60%).
6
+
7
+ **Your job**: lift selector EX from ~60% to ≥67%. Two main levers:
8
+
9
+ 1. **Stronger selector model** that picks the correct candidate more often given K=8 rollouts (need ~93% pick-rate to hit 67%).
10
+ 2. **Higher oracle@8 ceiling** via better/more diverse K=8 sampling, stronger planner, or stronger fixer (so selector has better candidates to choose from).
11
+
12
+ This doc describes the current state, all paths/files needed, what's been tried, and concrete experiment ideas.
13
+
14
+ ---
15
+
16
+ ## 1. Current numbers on full BIRD-dev (1534 questions, 1524 with usable db_path)
17
+
18
+ | Config | greedy@1 | oracle@8 | rule-based maj | **trained selector EX** |
19
+ |---|---|---|---|---|
20
+ | PLANNER-only | 51.54% | 70.80% | — | — |
21
+ | SFT-VF (paper validators) | 52.20% | 71.65% | 56.30% | **59.91%** |
22
+ | ORPO COLLAB (paper) | 51.81% | 71.19% | 56.69% | **59.97%** |
23
+ | ORPO INDEP (paper) | 52.59% | 71.95% | 56.64% | **60.31%** |
24
+
25
+ **Selector recall vs oracle**: 60 / 72 ≈ **83%**. To hit 67% EX with the same oracle ceiling, we'd need **93% pick-rate**. To hit 67% with a stable 83% pick-rate, we'd need **oracle@8 ≈ 80%**.
26
+
27
+ Selector currently used: **`sft-selector-3B-griffith-v5`** (Qwen2.5-Coder-3B SFT on griffith data). Hyperparameters are documented in `AGENTS_REPORT.md`.
28
+
29
+ ---
30
+
31
+ ## 2. Absolute paths to all checkpoints and data
32
+
33
+ ### Selector models
34
+
35
+ ```
36
+ /weka/s225250685/mats-tist/alignment-handbook/output/sft-selector-3B-griffith-v5 ← current "v1" used in eval above
37
+ ```
38
+
39
+ A second selector ("v2") was previously trained on 45k pairs built from iter1 rollouts:
40
+ ```
41
+ /weka/s225250685/mats-tist/data/hf_selector_v2_from_orpo1 ← 32193 train + 1695 test pairs
42
+ ```
43
+ The trained v2 model: was tried in earlier iter1 eval and gave the same ~60% as v1 (no improvement). Output dir may need to be checked at `alignment-handbook/output/sft-selector-3B-v2-*` if it exists, otherwise can be retrained from `hf_selector_v2_from_orpo1`.
44
+
45
+ ### Planner + Validator + Fixer checkpoints (used by pipeline; freeze for selector work)
46
+
47
+ ```
48
+ /weka/s225250685/mats-tist/alignment-handbook/output/sft-planner-3B-griffith-v4 # Qwen2.5-Coder-3B, planner
49
+ /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-sel-llama1b-paper-v1 # paper-format val-sel SFT
50
+ /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-cond-llama1b-paper-v1 # paper-format val-cond SFT
51
+ /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-collab-paper # paper-format val-sel ORPO collab
52
+ /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-indep-paper # paper-format val-sel ORPO indep
53
+ /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-collab-paper # paper-format val-cond ORPO collab
54
+ /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-indep-paper # paper-format val-cond ORPO indep
55
+ /weka/s225250685/mats-tist/alignment-handbook/output/sft-fixer-llama1b-griffith-v5 # fixer
56
+ ```
57
+
58
+ ### Pre-computed K=8 rollouts on BIRD-dev (use these to train + eval selectors offline — no GPU pipeline replay needed)
59
+
60
+ Each JSONL has 1469-1524 rows; each row = 1 question × 8 trajectories. Field per traj: `planner_sql`, `planner_exec_ok`, `is_planner_correct`, `fixed_sql`, `is_fixed_correct`, validator outputs (`fb_select`, `fb_condition`, `fb_join`, `fb_order`), full prompts.
61
+
62
+ ```
63
+ /weka/s225250685/mats-tist/eval_results/paper_SFT_VF_passAt8_bird_dev.jsonl # 1524 rows
64
+ /weka/s225250685/mats-tist/eval_results/paper_COLLAB_par_passAt8_bird_dev.jsonl # 1524 rows
65
+ /weka/s225250685/mats-tist/eval_results/paper_INDEP_par_passAt8_bird_dev.jsonl # 1469 rows
66
+ ```
67
+
68
+ ### Greedy (T=0, K=1) rollouts on BIRD-dev (for planner@1 / pipeline@1 sanity)
69
+
70
+ ```
71
+ /weka/s225250685/mats-tist/eval_results/paper_greedy_PLANNER_ONLY_passAt1_bird_dev.jsonl # 1524 rows
72
+ /weka/s225250685/mats-tist/eval_results/paper_greedy_SFT_VF_passAt1_bird_dev.jsonl # 1524 rows
73
+ /weka/s225250685/mats-tist/eval_results/paper_greedy_COLLAB_passAt1_bird_dev.jsonl # 1524 rows
74
+ /weka/s225250685/mats-tist/eval_results/paper_greedy_INDEP_passAt1_bird_dev.jsonl # 1524 rows
75
+ ```
76
+
77
+ ### BIRD-train rollouts (for selector training data)
78
+
79
+ ```
80
+ /weka/s225250685/mats-tist/data/planner_3B_greedy_bird_train.jsonl # 9360 planner-3B greedy preds on BIRD-train; 5388 correct (57.6%)
81
+ ```
82
+
83
+ You'll likely want K=8 BIRD-train rollouts too — generation script is `scripts/run_pipeline_rollouts.py` (used with `--max_questions -1` and BIRD-train json).
84
+
85
+ ### Data builders for selector training
86
+
87
+ ```
88
+ /weka/s225250685/mats-tist/scripts/build_selector_sft_data.py # selector v1 builder
89
+ /weka/s225250685/mats-tist/scripts/build_selector_v2_fast.py # selector v2 builder (used hf_selector_v2_from_orpo1)
90
+ /weka/s225250685/mats-tist/scripts/build_selector_v3_pairwise.py # exists but not used in v1/v2
91
+ /weka/s225250685/mats-tist/scripts/build_selector_v3_rich.py # ditto
92
+ /weka/s225250685/mats-tist/scripts/build_selector_v4_pairwise.py # ditto
93
+ /weka/s225250685/mats-tist/scripts/rich_schema.py # helper
94
+ ```
95
+
96
+ ### Selector trainer
97
+
98
+ ```
99
+ /weka/s225250685/mats-tist/scripts/train_sft_completion_only.py # used for all SFT (incl. selector v1)
100
+ ```
101
+
102
+ ### Selector evaluator (read-only, no GPU pipeline needed)
103
+
104
+ ```
105
+ /weka/s225250685/mats-tist/scripts/compute_bestofn_with_selector.py
106
+ ```
107
+
108
+ Usage:
109
+ ```
110
+ python scripts/compute_bestofn_with_selector.py \
111
+ eval_results/paper_SFT_VF_passAt8_bird_dev.jsonl \
112
+ paper_SFT_VF_selectorEX \
113
+ --selector_host http://localhost:PORT \
114
+ --row_preview
115
+ ```
116
+
117
+ Where the selector host is a vLLM server hosting the selector model:
118
+ ```
119
+ vllm serve <PATH_TO_SELECTOR> --served-model-name selector --port PORT \
120
+ --dtype bfloat16 --gpu-memory-utilization 0.85 \
121
+ --enforce-eager --max-model-len 4096
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 3. What's been tried (don't repeat)
127
+
128
+ 1. **Selector v1** (`sft-selector-3B-griffith-v5`): trained on griffith binary YES/NO labels (~9k pairs from griffith dataset). EX ≈ 59-60% across all pipeline configs.
129
+ 2. **Selector v2** (`hf_selector_v2_from_orpo1`): trained on 45k pairs built from wrapper-tag iter1 rollouts (COLLAB, INDEP, SFT-VF). EX ≈ 60% — no improvement over v1.
130
+ 3. **Validator regime ablations**: SFT, ORPO COLLAB, ORPO INDEP — all give same ~60% EX. The selector's bottleneck is not the validator quality.
131
+ 4. **Schema format**: switched from CodeS-style to griffith rich-NL, and from wrapper-tag to paper-format. No change in selector EX.
132
+
133
+ ---
134
+
135
+ ## 4. Bottleneck analysis (numbers, not opinions)
136
+
137
+ - **planner@1 (greedy T=0): 51.54%** — limited by the planner SFT
138
+ - **oracle@8 (K=8 T=1.0): 71.95%** — upper bound for selector
139
+ - **selector picks 60/72 = 83%** of available correct from K=8
140
+ - **fixer adds < 1pp** over planner-only (paper-format)
141
+
142
+ Gap to close = 67 − 60 = **7pp**. Two paths (additive):
143
+
144
+ | Path | Mechanism | What it requires |
145
+ |---|---|---|
146
+ | **A. Better selector** | Pick-rate 83% → 93% with same K=8 candidates | More/better selector training data and/or stronger architecture |
147
+ | **B. Better oracle ceiling** | oracle@8 71% → 80% via more diverse K=8 or stronger planner/fixer | Re-sample K=8 with higher T / better-distilled planner / fixer that actually rescues wrong SQL |
148
+
149
+ A 5pp selector lift OR a 5pp oracle lift both move us to ~65%. Combined gets us past 67%.
150
+
151
+ ---
152
+
153
+ ## 5. Concrete experiment ideas (ranked by expected ROI)
154
+
155
+ ### E1. Train selector on **pairwise preference data** built from existing K=8 rollouts (highest leverage, fastest)
156
+
157
+ Each of the 3 K=8 rollout files has 1524 questions × 8 candidates = ~12k candidates per file. For each question:
158
+ - Pair (correct, wrong) candidates → preference pairs
159
+ - Train a Bradley-Terry-style selector or a binary "is this SQL correct?" classifier
160
+
161
+ Across 3 files = ~36k+ candidate sets. Use both `is_planner_correct` and `is_fixed_correct` for labels.
162
+
163
+ Build script template: `scripts/build_selector_v3_pairwise.py` (exists, not been used).
164
+
165
+ ### E2. Train selector on **execution-result-aware features** (instead of just SQL text)
166
+
167
+ Currently the selector sees `(question, schema, SQL)` and outputs YES/NO. **It does NOT see the execution result**. A selector that sees rows returned by each candidate SQL can directly compare exec outputs against the question, which is much higher-signal than syntactic matching.
168
+
169
+ Field already available in JSONL: per-trajectory exec result is implicitly captured in `is_planner_correct` / `is_fixed_correct` but not stored as serialized rows. Would need a rollout re-run that includes `exec_rows_preview` in each trajectory.
170
+
171
+ ### E3. **Re-sample K=8 with higher T or top_p** to lift oracle@8
172
+
173
+ Current K=8 at T=1.0, top_p=0.9. Try K=8 at T=1.2/top_p=0.95, or mix temperatures: 4 samples at T=0.8 + 4 at T=1.2. Higher diversity → higher oracle@8 ceiling → more headroom.
174
+
175
+ ### E4. **Train a 1B selector** instead of 3B
176
+
177
+ The current selector is Qwen2.5-Coder-**3B** — relatively heavy. A 1B may train faster and be tuned more aggressively. Compare same data, smaller model — see if data is the bottleneck.
178
+
179
+ ### E5. **Distill the planner** (riskiest, biggest upside)
180
+
181
+ Planner is the dominant bottleneck. Re-distill from a stronger teacher (Qwen2.5-72B already cached locally at `/weka/s225250685/Huggingface/hub/models--Qwen--Qwen2.5-72B-Instruct/`). New planner with greedy@1 > 55% would lift everything downstream.
182
+
183
+ This is outside "selector work" but worth flagging — selector improvements above a ceiling won't matter if planner stays at 51.5%.
184
+
185
+ ---
186
+
187
+ ## 6. Reproducing current numbers
188
+
189
+ To re-derive the table in §1 from existing rollouts (no GPU needed for the calc itself, just to host the selector):
190
+
191
+ ```python
192
+ # planner@1 / pipeline@1 from greedy file:
193
+ import json
194
+ for path in ["paper_greedy_PLANNER_ONLY_passAt1_bird_dev.jsonl",
195
+ "paper_greedy_SFT_VF_passAt1_bird_dev.jsonl",
196
+ "paper_greedy_COLLAB_passAt1_bird_dev.jsonl",
197
+ "paper_greedy_INDEP_passAt1_bird_dev.jsonl"]:
198
+ rows = [json.loads(l) for l in open(f"/weka/s225250685/mats-tist/eval_results/{path}")]
199
+ n = len(rows)
200
+ pg = sum(1 for r in rows if r["trajectories"][0]["is_planner_correct"])
201
+ def fin(t): return t["is_fixed_correct"] if not t["planner_exec_ok"] else t["is_planner_correct"]
202
+ pl = sum(1 for r in rows if fin(r["trajectories"][0]))
203
+ print(path, f"planner@1={100*pg/n:.2f}% pipeline@1={100*pl/n:.2f}%")
204
+
205
+ # oracle@8 from K=8 file:
206
+ for path in ["paper_SFT_VF_passAt8_bird_dev.jsonl",
207
+ "paper_COLLAB_par_passAt8_bird_dev.jsonl",
208
+ "paper_INDEP_par_passAt8_bird_dev.jsonl"]:
209
+ rows = [json.loads(l) for l in open(f"/weka/s225250685/mats-tist/eval_results/{path}")]
210
+ n = len(rows)
211
+ o = sum(1 for r in rows if any(
212
+ t["is_fixed_correct"] if not t["planner_exec_ok"] else t["is_planner_correct"]
213
+ for t in r["trajectories"]))
214
+ print(path, f"n={n} oracle@8={100*o/n:.2f}%")
215
+ ```
216
+
217
+ Selector EX numbers are produced by `scripts/compute_bestofn_with_selector.py` against a vLLM-served selector.
218
+
219
+ ---
220
+
221
+ ## 7. Environment + constraints
222
+
223
+ - **K=8 is fixed** (user constraint) — don't try K=16 etc.
224
+ - **Temperature = 1.0 for the K=8 rollouts** — don't change unless you're testing E3.
225
+ - Conda env: `/weka/s225250685/conda-envs/handbook/bin/python`
226
+ - HF_TOKEN at `/weka/s225250685/mats-tist/.env` (source with `set -a; source .env; set +a`)
227
+ - SLURM partition `gpu-large`, QoS `batch-long`, job name MUST be `vl` (ALL CAPS not allowed; lowercase `vl` is required).
228
+ - `PYTHONNOUSERSITE=1` is required to avoid user-site contamination.
229
+ - Don't touch `/weka/s225250685/mats-tist/data/_archived_wrong_format/` — those are the old wrapper-tag datasets, kept for reference.
230
+
231
+ Helper: `free_gpus` command on the login node shows current GPU availability.
232
+
233
+ ---
234
+
235
+ ## 8. Definition of done
236
+
237
+ Final eval: selector v_next on `paper_SFT_VF_passAt8_bird_dev.jsonl` (or any of the 3 paper-format K=8 rollouts) achieves **≥ 67% EX**.
238
+
239
+ Run with:
240
+ ```
241
+ python scripts/compute_bestofn_with_selector.py \
242
+ /weka/s225250685/mats-tist/eval_results/paper_SFT_VF_passAt8_bird_dev.jsonl \
243
+ final_selector_run \
244
+ --selector_host http://localhost:8103 --row_preview
245
+ ```
246
+
247
+ And report:
248
+ - selector EX
249
+ - pick-rate over oracle (EX / oracle@8)
250
+ - any K=8 re-sampling used
code/MATS_SQL_BUNDLE_PROGRESS.md ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MATS-SQL Bundle — Progress Snapshot
2
+
3
+ **Bundle**: `thanhdath/mats-sql-bundle` (HuggingFace)
4
+ **Snapshot date**: 2026-05-13
5
+
6
+ ---
7
+
8
+ ## Original Task
9
+
10
+ Multi-agent Text2SQL pipeline reaching **pass@8 ≥ 67%** (BIRD-dev, EX). Hard constraints from project owner:
11
+
12
+ - Planner ≤ 3B params
13
+ - Selection ≤ 3B params
14
+ - Validator(s) and Fixer ≤ 1B params each (prefer 0.5B)
15
+ - Max ORPO iter-2 (no iter-3+)
16
+ - **No commercial APIs (no GPT teacher)** — collaborative training must be structurally necessary
17
+ - V+F (validators + fixer) must **not hurt** final accuracy and **should contribute** to acc increase
18
+ - Results tables must include per-agent parameter counts
19
+ - Two specialized validators per paper §Combined Validator: **v_s (selection)** and **v_c (condition)**
20
+
21
+ ---
22
+
23
+ ## Current Progress (latest)
24
+
25
+ ### Best result so far (BIRD-dev, K=8)
26
+
27
+ | Config | N | pass@8 (recall, oracle) | Trained selector (real, no leak) | Notes |
28
+ |---|---|---|---|---|
29
+ | 1-stage iter-2 uniform-temp | 1524 | 64.96% | — | leak-pre-patch number was 64.96 |
30
+ | 1-stage iter-2 mixed-temp (0.5/0.7/0.9/1.1) | 1525 | **65.38%** | — | best recall |
31
+ | 3-stage iter-2 + 0.6B v_s/v_c + ORPO fixer iter-1 | 1525 | 65.05% | — | V+F neutral (0 rescues) |
32
+ | 3-stage iter-2 + 0.5B v_s + 0.6B v_c + 0.5B **replanner**-fixer iter-2 | 1525 | 65.11% | **54.30%** | leak-free selector measurement; **fixer iter-2 +0.06pp vs iter-1** |
33
+
34
+ **Critical finding (2026-05-13):** `compute_bestofn_with_selector.py` had `exec_response = "OK" if is_planner_correct else "Error / no rows"` — passed the gold-graded label to the selector → trivially matched oracle. **Patched** to use actual SQL execution result. Real trained-selector accuracy is **54.30%, NOT 65%**. Selector → oracle gap = 10.81pp.
35
+
36
+ ### Two headline gaps to close (target = headline EX ≥ 67%)
37
+
38
+ | Gap | Current | Target | Gap | Lever |
39
+ |---|---|---|---|---|
40
+ | **Oracle pass@8** (recall) | 65.38% (mixed-temp) | ≥70% | +4.6pp | More diverse sampling / better fixer rescues |
41
+ | **Selector → oracle** | 57.25 / 65.38 = 87.6% | ≥95% | +8.13pp | Selector v3 (more data / different arch) |
42
+
43
+ ### Selector v2 results (2026-05-13 — row preview added to prompt)
44
+
45
+ Retrained 3B selector with `OK. Rows preview: <rows>` instead of bare `OK`. Closes ~3-4pp of the ~11pp gap.
46
+
47
+ | Config (BIRD-dev K=8 iter-2 planner) | Oracle | Selector v1 (no rows) | **Selector v2 (rows)** | v2 gain |
48
+ |---|---|---|---|---|
49
+ | 1-stage uniform-temp | 64.96% | 53.94% | 56.43% | +2.49pp |
50
+ | **1-stage mixed-temp** | **65.38%** | 53.64% | **57.25%** ← headline | +3.61pp |
51
+ | 2-stage + ORPO fixer-iter1 | 63.04% | 52.72% | 56.02% | +3.30pp |
52
+ | 3-stage + 0.6B V/V + ORPO fixer-iter1 | 65.05% | 53.11% | 56.98% | +3.87pp |
53
+ | 3-stage + 0.5B V/V + 0.5B replanner-fixer | 65.11% | 53.51% | 56.66% | +3.15pp |
54
+
55
+ **Headline pass@8 post-selector = 57.25%** (1-stage mixed-temp + v2 selector). Still −9.75pp from 67%.
56
+
57
+ ### Per-model status
58
+
59
+ | Agent | Model | Params | Status |
60
+ |---|---|---|---|
61
+ | Planner | Qwen2.5-Coder-3B-Instruct + ORPO iter-2 (collab) | 3B | trained ✓ |
62
+ | Selector | Qwen2.5-Coder-3B-Instruct + SFT (YES/NO binary) | 3B | trained ✓ |
63
+ | Validator-Selection (v_s) | Qwen2.5-Coder-0.5B-Instruct + SFT v3 | 0.5B | trained ✓ |
64
+ | Validator-Condition (v_c) | Qwen3-0.6B-Instruct + SFT v3 | 0.6B | trained ✓ (0.5B variant truncated, retrain pending) |
65
+ | Fixer (re-planner) | Qwen2.5-Coder-0.5B + ORPO iter-2 (replanner data) | 0.5B | trained ✓ |
66
+
67
+ ### V+F contribution diagnostic (mixed-temp iter-2 K=8, 1525 q)
68
+
69
+ - Validators critique 91.6% of trajectories; old fixer ignored 98.6% → 0 rescues at pass@8
70
+ - Replanner fixer (iter-2) currently flipping ~40% of trajectories (winloss=605 at 1360/1534) — net effect being measured
71
+
72
+ ### Key findings
73
+
74
+ - ORPO planner: SFT 64.11% → iter-1 64.26% → iter-2 64.96% (+0.70pp, diminishing returns)
75
+ - Mixed-temp sampling adds +0.42pp over uniform-temp at K=8
76
+ - v3 validator data rebalanced from 8% all-OK (over-critique) to 34.5%/61% all-OK
77
+ - Fixer dataset re-built as "re-planner" objective (1833 pairs): given a failed planner trajectory, produce a correct alternative from same question's K=4 trajectories
78
+ - pass@8 (true recall) is the *upper bound* for trained-selector accuracy; need recall ≥70% to land headline ≥67% after selector picks
79
+
80
+ ---
81
+
82
+ ## What's Next (in priority order)
83
+
84
+ 1. **Phase4 K=8 3-stage eval finishes** (currently 89% done, ETA 30 min) → get pass@8 with replanner-fixer.
85
+ 2. **Apply patched (leak-free) selector** to all K=8 JSONLs → get true selector accuracy (not oracle).
86
+ 3. **If pass@8 selector ≥67%: DONE.** Write results table with per-agent sizes.
87
+ 4. **If pass@8 selector <67%:**
88
+ - Re-mine fixer ORPO data on **iter-2 planner** BIRD-train rollouts (current data was from iter-1 planner → distribution shift).
89
+ - Re-train fixer ORPO iter-2 on fresh data.
90
+ - Consider planner sampling tricks: wider mixed-temp (0.3-1.3), nucleus variation.
91
+ 5. **Make V+F contribute (currently neutral):** the 0.5B replanner fixer's `winloss` is now high (~40%) — need to check if those flips are net+ or net-. If net-, gate fixer to only run on `planner_exec_ok=False` cases.
92
+
93
+ ---
94
+
95
+ ## Repo contents
96
+
97
+ ```
98
+ mats-sql-bundle/
99
+ ├── PROGRESS.md # this file
100
+ ├── models/
101
+ │ ├── planner-iter2-collab-3B/ # 3B ORPO iter-2 planner
102
+ │ ├── selector-3B-sft/ # 3B trained selector
103
+ │ ├── validator-selection-0.5B-v3/ # v_s SFT
104
+ │ ├── validator-condition-0.6B-v3/ # v_c SFT
105
+ │ └── fixer-replanner-0.5B-iter2-orpo/ # ORPO iter-2 re-planner fixer
106
+ ├── data/
107
+ │ ├── sft-validator-selection-v3/ # SFT data for v_s
108
+ │ ├── sft-validator-condition-v3/ # SFT data for v_c
109
+ │ ├── hf_fixer_replanner/ # ORPO data for fixer iter-2
110
+ │ └── hf_planner_collaborative_iter2/ # ORPO data for planner iter-2
111
+ ├── recipes/
112
+ │ ├── orpo-planner-collab-iter2.yaml
113
+ │ ├── orpo-fixer-replanner-0.5b-iter2.yaml
114
+ │ ├── validator-selection-fft-0.5b-v3.yaml
115
+ │ └── validator-condition-fft-0.5b-v3.yaml
116
+ └── scripts/
117
+ ├── run_pipeline_rollouts.py # rollout / 3-stage runner
118
+ ├── compute_bestofn_with_selector.py # selector apply (patched)
119
+ ├── compute_bestofn_metrics.py # oracle/greedy metrics
120
+ ├── build_validator_2agents_v3.py # v_s/v_c data builder
121
+ └── build_fixer_replanner_iter2.py # fixer re-planner data builder
122
+ ```
123
+
124
+ ## How to continue from this bundle
125
+
126
+ ```bash
127
+ # 1. Clone the bundle (~16 GB)
128
+ git clone https://huggingface.co/datasets/thanhdath/mats-sql-bundle
129
+ cd mats-sql-bundle
130
+
131
+ # 2. Symlink to alignment-handbook layout
132
+ ln -s $(pwd)/models /path/to/alignment-handbook/output
133
+ ln -s $(pwd)/data /path/to/mats-sql-tist/data/llm_alignment_imported
134
+
135
+ # 3. Continue from where we left off: BIRD-dev K=8 3-stage with iter-2 planner + 0.5B agents
136
+ bash scripts/run_pipeline_rollouts.py --K 8 --mixed_temp "0.5,0.7,0.9,1.1" ...
137
+
138
+ # 4. To do iter-3 (if needed), re-mine fixer data on iter-2 planner BIRD-train rollouts first.
139
+ ```
140
+
141
+ ---
142
+
143
+ **Maintainer**: thanhdath@gmail.com / thanhdath97@gmail.com
144
+ **Source repo**: /home/datht/mats-sql-tist (private dev machine)
code/PROGRESS.md ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MATS-TIST Rebuttal — Progress Tracker
2
+
3
+ _Last updated: 2026-04-24 — rebuttal plan + full contributor handoff_
4
+
5
+ ---
6
+
7
+ ## Rebuttal goal and stakeholder requests (summary)
8
+
9
+ **Publication:** IEEE TIST journal rebuttal for MATS (multi-agent Text2SQL with small language models and execution feedback).
10
+
11
+ **Requests captured across the project (themes, not verbatim):**
12
+
13
+ 1. **Rebuttal package:** Correct Overleaf/IEEE-style rebuttal workflow; read reviewers in `overleaf-journal-TIST/review.txt`; plan answers, extra experiments, and missing checkpoints; keep rebuttal assets under `MATS-rebuttal/`.
14
+ 2. **Recent baselines:** Compare to FINER-SQL, Arctic-Text2SQL-R1, ExCoT SQL, Alpha-SQL (some use execution feedback). **Baseline accuracies are entered manually** in the paper — no mandatory eval harness for those models in this repo.
15
+ 3. **Accuracy:** Use BIRD `database_description/*.csv` (`column_description`, `value_description`) and **CHESS-style DDL** schema text in prompts for **SFT and ORPO** data prep.
16
+ 4. **BM25 wording:** Reviewer asked about fallback vs “representative example from V_ci”. **Behavior stays** (first indexed doc as fixed representative); **paper + code comment** clarify — no score filter change required.
17
+ 5. **Training code:** **Keep `alignment-handbook`** (custom **ORPO** in `scripts/run_orpo.py`); do **not** replace with TRL-only SFT as the sole stack.
18
+ 6. **Repos:** All edits in **`mats-sql-tist/`** fork only — **not** `/home/datht/mats`. **Do not** use `sql_writer/` for MATS (FINER-SQL area).
19
+ 7. **Compute:** Local dev + **`ssh gf-henry`** for GPU; **edit locally, rsync** to remote (`scripts/sync_code.sh`). Build BM25 indexes locally; sync `mats/data` to remote as needed.
20
+ 8. **Tracked tasks:** Run `build_all_bm25_indexes.py` (done); enriched SFT generation (`scripts/build_sft_data.py` / `prepare_sft_datasets.py`); validator–fixer synthetic data (`scripts/generate_val_fix_sft_data.py`); **1.5B** Qwen recipe for gf-henry; maintain **`PROGRESS.md`**.
21
+ 9. **Ops on gf-henry:** Moved **`mats/data`** (~106 GB) and **`mats/alignment-handbook/output`** (~26 GB) to **`/hdd/datht/mats/...`** with **symlinks**; fixed **Java 11**, **faiss-cpu**, **scipy** (GLIBC), duplicate **`accelerate` dist-info**, **fp16** for Turing GPUs.
22
+
23
+ ---
24
+
25
+ ## Handoff for another contributor (read this first)
26
+
27
+ | Item | Where / what |
28
+ |------|----------------|
29
+ | Paper + review | `mats-sql-tist/overleaf-journal-TIST/` (`review.txt`, main `.tex`) |
30
+ | Point-by-point rebuttal draft | `mats-sql-tist/MATS-rebuttal/response_to_reviewers.md` (numbers still placeholders until eval) |
31
+ | Checkpoint plan | `mats-sql-tist/MATS-rebuttal/checkpoint_tracking.md` |
32
+ | Command cheatsheet | `mats-sql-tist/MATS-rebuttal/scripts/training_commands.sh` |
33
+ | Remote runbook | `mats-sql-tist/WORKFLOW_GF_HENRY.md` |
34
+ | Staged remote script | `mats-sql-tist/scripts/run_training_gf_henry.sh` |
35
+ | **Code edits** | **Only** `mats-sql-tist/` — sync with `scripts/sync_code.sh` to **`gf-henry`** |
36
+ | **Data (local)** | Symlink `mats-sql-tist/data` → `/home/datht/mats/data` |
37
+ | **Data (gf-henry)** | `/home/datht/mats/data` → **`/hdd/datht/mats/data`** (symlink); keep chain intact |
38
+ | **Models (gf-henry)** | `~/huggingface` → **`/hdd/datht/huggingface/`** |
39
+ | **Conda** | `conda activate mats` (see **Conda Environment** below) |
40
+ | **BM25 server** | `db_content_retrieval/lsh_api.py` — **JDK 11+**, heap e.g. `-Xmx6g` |
41
+ | **Training precision** | **fp16** on gf-henry (RTX 2080 Ti / TITAN RTX — no native bf16) |
42
+
43
+ **First actions on pickup:** Read **Resume here** → confirm disk/symlinks on gf-henry → start BM25 API → retry validator–fixer SFT → eval and fill rebuttal numbers.
44
+
45
+ **Source code:** Upstream is `https://github.com/thanhdath/mats-sql` — this workspace uses the **TIST fork folder** `mats-sql-tist/` (not `/home/datht/mats`).
46
+
47
+ **SSH:** Configure a `Host gf-henry` entry in `~/.ssh/config` on your laptop (hostname, user, key) so `ssh gf-henry` matches what the sync scripts expect — or edit `scripts/sync_code.sh` to your target.
48
+
49
+ **Secrets:** Validator–fixer training data was generated **without** paid LLM APIs (heuristic SQL mutations). If you add API-based data generation later, store keys outside git.
50
+
51
+ **Overleaf / IEEE form:** Use the journal’s official rebuttal / response-to-reviewers template from IEEE TIST author instructions or Overleaf; keep the canonical review text at `overleaf-journal-TIST/review.txt`.
52
+
53
+ ---
54
+
55
+ ## Resume here (next session)
56
+
57
+ **Policy:** Edit code only under `mats-sql-tist/` on this machine, then `bash scripts/sync_code.sh` (or your usual `rsync`) to `gf-henry`. Avoid editing project files directly on the remote unless unavoidable.
58
+
59
+ **On gf-henry — do next (in order):**
60
+
61
+ 1. **Confirm env:** `conda activate mats` — `accelerate` should be **0.34.2** only (stale `accelerate-0.23.0.dist-info` was removed; if training still complains, reinstall `accelerate`).
62
+ 2. **BM25 API:** `JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64`, `JAVA_TOOL_OPTIONS=-Xmx6g`, then start `lsh_api.py` as in `WORKFLOW_GF_HENRY.md` / `scripts/run_training_gf_henry.sh`.
63
+ 3. **Retry 1.5B validator–fixer SFT:** recipe `alignment-handbook/recipes/qwen-1.5b-bird/validator-fixer-fft-rebuttal.yaml` + accelerate config `recipes/accelerate_configs/single_gpu.yaml` (**fp16**, Turing GPUs — no bf16).
64
+ 4. After that succeeds: broader SFT/ORPO per `MATS-rebuttal/checkpoint_tracking.md` and `MATS-rebuttal/scripts/training_commands.sh`.
65
+ 5. **Paper / rebuttal:** fill baseline numbers (ExCoT, Arctic, Alpha-SQL, FINER-SQL) yourself; polish `overleaf-journal-TIST/` and `MATS-rebuttal/response_to_reviewers.md`.
66
+
67
+ **Large paths on gf-henry:** `mats/data` and `mats/alignment-handbook/output` live under `/hdd/datht/mats/…` with symlinks from `$HOME` — do not delete the symlinks.
68
+
69
+ ---
70
+
71
+ ## Repository Setup
72
+
73
+ | Task | Status | Notes |
74
+ |---|---|---|
75
+ | Clone `github.com/thanhdath/mats-sql` → `mats-sql-tist/` | ✅ Done | User cloned; all TIST edits live here only |
76
+ | Move `overleaf-journal-TIST/` into `mats-sql-tist/` | ✅ Done | Path: `mats-sql-tist/overleaf-journal-TIST/` |
77
+ | Rename conda env `handbook` → `mats` | ✅ Done | `conda rename -n handbook mats` |
78
+ | Fix broken `more-itertools` in `mats` env | ✅ Done | `pip install more-itertools` |
79
+ | Verify all key libs in `mats` env | ✅ Done | torch 2.2.2, transformers 4.45.0, trl 0.8.6, accelerate 0.34.2, peft 0.6.1, alignment-handbook ✓ |
80
+
81
+ ---
82
+
83
+ ## Code Changes in `mats-sql-tist/` (TIST fork)
84
+
85
+ ### A. BIRD CSV Descriptions (value_description / column_description)
86
+
87
+ **Problem:** MATS was ignoring the rich `database_description/*.csv` files that BIRD provides per-database.
88
+ These contain `column_description` and `value_description` for every column — missing them hurts accuracy.
89
+
90
+ | File | Status | What changed |
91
+ |---|---|---|
92
+ | `utils/bird_csv_utils.py` | ✅ **New file** | CHESS-style CSV loader. `load_db_descriptions(db_dir)` reads all CSVs under `database_description/`; handles UTF-8/CP1252 encodings. Also provides `load_all_db_descriptions(split_dir)` for bulk loading. |
93
+ | `utils/db_utils.py` — `get_db_schema()` | ✅ Done | Added `db_descriptions=None` parameter. When provided, populates `column_descriptions` and `value_descriptions` lists on each schema item from BIRD CSVs. |
94
+ | `utils/db_utils.py` — `get_db_schema_sequence()` | ✅ Done | Rewritten to **CHESS DDL-style format**: `CREATE TABLE … ( col TYPE, -- Example Values: … \| Column Description: … \| Value Description: … )`. Falls back gracefully if fields are absent. |
95
+ | `prepare_sft_datasets.py` | ✅ Done | Imports `load_db_descriptions`; auto-detects BIRD sources and loads CSV descriptions; passes them to `get_db_schema()` per `db_id`. |
96
+ | `evaluate_end2end.py` | ✅ Done | Imports `get_db_schema_sequence`; regenerates `schema_sequence` at load-time for any sample where it is missing — backward-compatible with old JSON inputs. |
97
+
98
+ **Example output from new DDL schema format:**
99
+ ```sql
100
+ CREATE TABLE frpm
101
+ (
102
+ cdscode TEXT, -- Example Values: `01100170` | Column Description: CDSCode identifier | Primary Key
103
+ free_meal_count REAL, -- Example Values: `191.0`, `1.0` | Column Description: Free meal count for K-12 | Value Description: 0 = Not eligible; 1 = Eligible
104
+ );
105
+ ```
106
+
107
+ ### B. BM25 Fallback Clarification
108
+
109
+ | File | Status | What changed |
110
+ |---|---|---|
111
+ | `db_content_retrieval/lsh_api.py` | ✅ Done | Added inline docstring comment on the fallback path (lines ~82–85): when BM25 finds no hits but the column is non-empty, returning `searcher.doc(0)` is a fixed, reproducible, deterministic "representative example from V_ci" — directly addressing Reviewer concern. No behavioral change. |
112
+
113
+ ### C. Training Framework
114
+
115
+ | Decision | Status | Notes |
116
+ |---|---|---|
117
+ | Keep `alignment-handbook` (do NOT switch to TRL SFT) | ✅ Confirmed | `alignment-handbook/scripts/run_orpo.py` contains custom ORPO edits critical to MATS; `train_bird.sh` documents the accelerate launch commands |
118
+
119
+ ---
120
+
121
+ ## BM25 Content Index Status
122
+
123
+ ### Data symlink
124
+ `mats-sql-tist/data` → `/home/datht/mats/data` (symlink created)
125
+
126
+ ### Index build script
127
+ `scripts/build_all_bm25_indexes.py` — builds / symlinks all indexes; run with:
128
+ ```bash
129
+ conda activate mats
130
+ cd mats-sql-tist
131
+ python scripts/build_all_bm25_indexes.py
132
+ ```
133
+
134
+ ### Dataset index status
135
+
136
+ | Dataset | Index path | Status | Notes |
137
+ |---|---|---|---|
138
+ | BIRD dev | `data/bird/dev/db_contents_index` | ✅ Done | 11 dbs |
139
+ | BIRD train | `data/bird/train/db_contents_index` | ✅ Done | 69 dbs |
140
+ | sft_data_collections/bird/dev | symlink → bird/dev | ✅ Done | same 11 dbs |
141
+ | sft_data_collections/bird/train | symlink → bird/train | ✅ Done | same 69 dbs |
142
+ | Spider (dev/test/train) | `data/spider/db_contents_index` | ✅ Done | 169 dbs |
143
+ | Spider-Syn | symlink → spider | ✅ Done | same databases |
144
+ | spider-realistic | symlink → spider | ✅ Done | same databases |
145
+ | Spider-DK | `sft_data_collections/Spider-DK/db_contents_index` | ✅ Done | 3 new dbs |
146
+ | Dr.Spider NLQ\_\* (9 sets) | symlink ��� spider | ✅ Done | same databases |
147
+ | Dr.Spider SQL\_\* (5 sets) | symlink → spider | ✅ Done | same databases |
148
+ | Dr.Spider DB\_schema\_synonym | `…/DB_schema_synonym/db_contents_index` | ✅ Done | 96/96 dbs |
149
+ | Dr.Spider DB\_schema\_abbreviation | `…/DB_schema_abbreviation/db_contents_index` | ✅ Done | 96/96 dbs |
150
+ | Dr.Spider DB\_DBcontent\_equivalence | `…/DB_DBcontent_equivalence/db_contents_index` | ✅ Done | 63/63 dbs |
151
+ | Domain datasets (Bank/Aminer) | `sft_data_collections/domain_datasets/db_contents_index` | ✅ Done | 2/2 dbs |
152
+
153
+ _Full index build finished; `build_all_bm25_indexes.py` is not required to run again unless databases change._
154
+
155
+ ### `lsh_api.py` source paths updated
156
+ All sources now correctly mapped in `db_content_retrieval/lsh_api.py`:
157
+ - BIRD dev/train → `data/bird/{dev,train}/db_contents_index`
158
+ - Spider-train → `data/spider/db_contents_index`
159
+ - Spider-dev/syn/realistic → synonym of spider-train
160
+ - Dr.Spider DB_\* → own index paths
161
+ - Dr.Spider NLQ_\*/SQL_\* → own index paths (symlinked to spider)
162
+ - Bank/Aminer domain datasets → domain_datasets index
163
+ - Startup auto-filters sources whose index dir does not yet exist (no crash on missing dirs)
164
+
165
+ ---
166
+
167
+ ## Completed (local + gf-henry) — since core code landed
168
+
169
+ | Area | Status | Notes |
170
+ |------|--------|------|
171
+ | BM25 indexes (all planned sets) | ✅ | Built locally via `scripts/build_all_bm25_indexes.py`; synced to gf-henry with `mats/data` |
172
+ | Enriched BIRD SFT JSON/JSONL | ✅ Local + synced | `scripts/build_sft_data.py` → e.g. `mats/data/rebuttal_sft_bird_{train,dev}_text2sql.json(l)` (CHESS-style schema + BM25 evidence) |
173
+ | Validator–fixer SFT data (synthetic) | ✅ Local + synced | `scripts/generate_val_fix_sft_data.py` → `data/multi-agents/fixed/sft-validator-fixer-bird_with_evidence/` (HF `DatasetDict`) |
174
+ | gf-henry `mats` env | ✅ | torch 2.2.2+cu121, transformers, trl, peft, pyserini, faiss-cpu, scipy wheel compatible with Ubuntu 20.04 / GLIBC 2.31 |
175
+ | BM25 API on gf-henry | ✅ Was working | Java **11** (`JAVA_HOME`), heap `-Xmx6g`; `lsh_api.py` filters `synonym_sources` when `--db_content_index` limits loaded corpora (fixes `KeyError`) |
176
+ | Qwen2.5-Coder-1.5B-Instruct | ✅ On gf-henry | Under `/home/datht/huggingface/` → `/hdd/datht/huggingface/` (existing symlink layout) |
177
+ | Rebuttal draft doc | ✅ Draft | `MATS-rebuttal/response_to_reviewers.md` — still needs **final numbers** and polish |
178
+ | Training wiring | ✅ | `alignment-handbook/recipes/qwen-1.5b-bird/validator-fixer-fft-rebuttal.yaml` (fp16); `recipes/accelerate_configs/single_gpu.yaml` (fp16); `scripts/run_training_gf_henry.sh`; `WORKFLOW_GF_HENRY.md` |
179
+
180
+ ---
181
+
182
+ ## Pending work (your turn / GPU)
183
+
184
+ ### Training & evaluation on gf-henry
185
+
186
+ | Task | Status | Notes |
187
+ |------|--------|------|
188
+ | Validator–fixer SFT (1.5B Qwen) | ⏳ **Next** | Unblockers applied: disk space, duplicate `accelerate` dist-info removed, fp16 configs — **re-run training** and confirm loss/checkpoint |
189
+ | Full agent SFT + ORPO refresh | ⏳ | After rebuttal data/checkpoints agreed; use `alignment-handbook` + `MATS-rebuttal/checkpoint_tracking.md` |
190
+ | ORPO preference data regen | ⏳ | After refreshed SFT artifacts if you change prompts/schema again |
191
+ | `evaluate_end2end.py` on BIRD dev (new checkpoints) | ⏳ | After models trained |
192
+ | Ablations (no Schema Insight, no Validator, SFT-only, oracle selector, etc.) | ⏳ | Plan in rebuttal docs |
193
+
194
+ ### Paper & rebuttal (no GPU)
195
+
196
+ | Task | Status | Notes |
197
+ |------|--------|------|
198
+ | Baseline table: ExCoT, Arctic-Text2SQL-R1, Alpha-SQL, FINER-SQL | ⏳ | **You add accuracy** — no eval runs required in this repo |
199
+ | Finalize `response_to_reviewers.md` | ⏳ | Merge measured numbers after eval |
200
+ | LaTeX polish + RQ-led experiment narrative | ⏳ | `overleaf-journal-TIST/` |
201
+ | Pipeline overview figure | ⏳ | New diagram for camera-ready |
202
+ | Official hidden-test submission | ⏳ | After final checkpoints |
203
+
204
+ ### Optional code improvements
205
+
206
+ | Task | Status | Notes |
207
+ |------|--------|------|
208
+ | Selector: majority vote / self-consistency on execution | ⏳ | No retraining |
209
+
210
+ ---
211
+
212
+ ## Known issues / gotchas (gf-henry)
213
+
214
+ 1. **Root `/` was full** — mitigated by moving `mats/data` (106G) and `mats/alignment-handbook/output` (26G) to `/hdd/datht/mats/…` with symlinks; **keep** that layout.
215
+ 2. **Turing GPUs** — no bf16: training YAML + accelerate config use **fp16**.
216
+ 3. **Java** — BM25/Lucene needs **JDK 11+**, not default Java 8.
217
+ 4. **Do not use** `sql_writer/` in this repo (reserved for FINER-SQL baseline work).
218
+
219
+ ---
220
+
221
+ ## File Map
222
+
223
+ ```
224
+ mats-sql-tist/
225
+ ├── overleaf-journal-TIST/ ← LaTeX paper + review.txt
226
+ │ ├── main_multiagent.tex
227
+ │ ├── review.txt
228
+ │ └── text/
229
+ ├── MATS-rebuttal/ ← rebuttal plan + drafts + scripts
230
+ │ ├── response_to_reviewers.md
231
+ │ ├── checkpoint_tracking.md
232
+ │ └── scripts/training_commands.sh
233
+ ├── utils/
234
+ │ ├── bird_csv_utils.py ✅ NEW — BIRD CSV description loader
235
+ │ ├── db_utils.py ✅ MODIFIED — CHESS DDL schema format
236
+ │ └── load_sft_dataset.py
237
+ ├── db_content_retrieval/
238
+ │ └── lsh_api.py ✅ MODIFIED — fixed source paths + BM25 fallback comment
239
+ ├── scripts/
240
+ │ ├── build_all_bm25_indexes.py ✅ builds / symlinks all dataset BM25 indexes
241
+ │ ├── build_sft_data.py ✅ enriched BIRD SFT JSONL (calls prepare_sft_datasets)
242
+ │ ├── generate_val_fix_sft_data.py ✅ synthetic validator–fixer SFT from gold SQL
243
+ │ ├── sync_code.sh ✅ rsync mats-sql-tist → gf-henry
244
+ │ ├── setup_env_gf_henry.sh ✅ conda/pip bootstrap for remote
245
+ │ └── run_training_gf_henry.sh ✅ staged BM25 / data / training on gf-henry
246
+ ├── WORKFLOW_GF_HENRY.md ✅ remote runbook
247
+ ├── prepare_sft_datasets.py ✅ MODIFIED — wires BIRD CSV descriptions
248
+ ├── evaluate_end2end.py ✅ MODIFIED — rebuilds schema_sequence
249
+ ├── data -> /home/datht/mats/data ✅ NEW symlink — shared data dir
250
+ ├── alignment-handbook/ ← keep as-is (custom ORPO)
251
+ │ ├── recipes/
252
+ │ │ ├── accelerate_configs/single_gpu.yaml ✅ fp16, single GPU (gf-henry)
253
+ │ │ └── qwen-1.5b-bird/validator-fixer-fft-rebuttal.yaml ✅ rebuttal SFT recipe
254
+ │ └── scripts/
255
+ │ ├── train_bird.sh
256
+ │ ├── run_orpo.py
257
+ │ └── run_sft.py
258
+ └── PROGRESS.md ← this file
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Conda Environment
264
+
265
+ ```
266
+ conda activate mats
267
+ # Key packages:
268
+ # torch 2.2.2+cu121
269
+ # transformers 4.45.0
270
+ # trl 0.8.6
271
+ # accelerate 0.34.2
272
+ # peft 0.6.1
273
+ ```
274
+
275
+ ---
276
+
277
+ ## gf-henry transfer and storage (physical layout)
278
+
279
+ Large trees were moved off the small `/` volume to **`/hdd/datht/`** (symlinks from `$HOME` — **do not remove**):
280
+
281
+ | Logical path on gf-henry | Physical location (approx.) |
282
+ |--------------------------|-------------------------------|
283
+ | `/home/datht/mats/data` | `/hdd/datht/mats/data` (~106 GB: BIRD, Spider, indexes, rebuttal JSON, etc.) |
284
+ | `/home/datht/mats/alignment-handbook/output` | `/hdd/datht/mats/alignment-handbook/output` (~26 GB checkpoints) |
285
+ | `/home/datht/huggingface` | `/hdd/datht/huggingface/` (base models, e.g. Qwen2.5-Coder-1.5B-Instruct) |
286
+
287
+ **Also synced / present:** `mats-sql-tist` tree, `sft_data_collections`, Dr.Spider / domain paths under `mats/data`, schema_insight checkpoints as applicable, synthetic validator–fixer HF dataset under `data/multi-agents/fixed/sft-validator-fixer-bird_with_evidence/`.
288
+
289
+ ## gf-henry Environment (mats conda env)
290
+
291
+ | Package | Version | Status |
292
+ |---------|---------|--------|
293
+ | torch | 2.2.2+cu121 | ✅ CUDA available (2 GPUs) |
294
+ | transformers | 4.45.0 | ✅ |
295
+ | accelerate | 0.34.2 | ✅ |
296
+ | trl | 0.8.6 | ✅ |
297
+ | peft | 0.6.1 | ✅ |
298
+ | pyserini | 0.21.0 | ✅ |
299
+ | numpy | 1.26.4 | ✅ |
300
+ | alignment-handbook | 0.2.0.dev0 | ✅ |
301
+
302
+ **GPUs:** TITAN RTX (23GB VRAM) + RTX 2080 Ti (10GB VRAM)
303
+
304
+ **Note:** bitsandbytes removed (not needed for FFT training; had scipy binary incompatibility).
305
+
306
+ ## MATS-rebuttal/ Contents
307
+
308
+ | File | Status |
309
+ |------|--------|
310
+ | `response_to_reviewers.md` | ✅ Draft complete (placeholders for numbers) |
311
+ | `checkpoint_tracking.md` | ✅ Created |
312
+ | `scripts/training_commands.sh` | ✅ Created |
313
+
314
+ ## Disk space management (gf-henry, Apr 23, 2026)
315
+
316
+ _See also **gf-henry transfer and storage** above._ Moved large directories from `/home` (was 100% full) to `/hdd/datht/` and created symlinks:
317
+
318
+ | Directory | Size | Action |
319
+ |-----------|------|--------|
320
+ | `/home/datht/mats/data` → `/hdd/datht/mats/data` | 106GB | Moved + symlinked ✅ |
321
+ | `/home/datht/mats/alignment-handbook/output` → `/hdd/datht/mats/alignment-handbook/output` | 26GB | Moved + symlinked ✅ |
322
+
323
+ **Result:** Home partition freed from 100% → 87% used (117GB free now)
324
+
325
+ **Fixed:** Removed stale `accelerate-0.23.0.dist-info` from `mats` env (was causing `ImportError` during training)
326
+
327
+ ## Later pipeline (after validator–fixer SFT succeeds)
328
+
329
+ Use **`MATS-rebuttal/checkpoint_tracking.md`** and **`MATS-rebuttal/scripts/training_commands.sh`** as the source of truth. Typical order: broader **SFT** / **ORPO** per agent → **`evaluate_end2end.py`** on BIRD dev → **ablations** (no Schema Insight, no Validator, SFT-only, oracle selector, etc.) → merge metrics into **`response_to_reviewers.md`** and Overleaf tables.
330
+
331
+ **Do not repeat by default:** Full **`build_all_bm25_indexes.py`** and enriched **rebuttal SFT JSON(L)** generation were already run locally and synced; only re-run if database files, index paths, or prompt schema change materially.
332
+
333
+ ## Previous conversation transcript
334
+ [MATS TIST Rebuttal Plan & Setup](a4a8aeb7-1505-431c-9880-59c969998eb0)
code/PROGRESS_bundle.md ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MATS-SQL Bundle — Progress Snapshot
2
+
3
+ **Bundle**: `thanhdath/mats-sql-bundle` (HuggingFace)
4
+ **Snapshot date**: 2026-05-13
5
+
6
+ ---
7
+
8
+ ## Original Task
9
+
10
+ Multi-agent Text2SQL pipeline reaching **pass@8 ≥ 67%** (BIRD-dev, EX). Hard constraints from project owner:
11
+
12
+ - Planner ≤ 3B params
13
+ - Selection ≤ 3B params
14
+ - Validator(s) and Fixer ≤ 1B params each (prefer 0.5B)
15
+ - Max ORPO iter-2 (no iter-3+)
16
+ - **No commercial APIs (no GPT teacher)** — collaborative training must be structurally necessary
17
+ - V+F (validators + fixer) must **not hurt** final accuracy and **should contribute** to acc increase
18
+ - Results tables must include per-agent parameter counts
19
+ - Two specialized validators per paper §Combined Validator: **v_s (selection)** and **v_c (condition)**
20
+
21
+ ---
22
+
23
+ ## Current Progress (latest)
24
+
25
+ ### Best result so far (BIRD-dev, K=8)
26
+
27
+ | Config | N | pass@8 (recall, oracle) | Trained selector (real, no leak) | Notes |
28
+ |---|---|---|---|---|
29
+ | 1-stage iter-2 uniform-temp | 1524 | 64.96% | — | leak-pre-patch number was 64.96 |
30
+ | 1-stage iter-2 mixed-temp (0.5/0.7/0.9/1.1) | 1525 | **65.38%** | — | best recall |
31
+ | 3-stage iter-2 + 0.6B v_s/v_c + ORPO fixer iter-1 | 1525 | 65.05% | — | V+F neutral (0 rescues) |
32
+ | 3-stage iter-2 + 0.5B v_s + 0.6B v_c + 0.5B **replanner**-fixer iter-2 | 1525 | 65.11% | **54.30%** | leak-free selector measurement; **fixer iter-2 +0.06pp vs iter-1** |
33
+
34
+ **Critical finding (2026-05-13):** `compute_bestofn_with_selector.py` had `exec_response = "OK" if is_planner_correct else "Error / no rows"` — passed the gold-graded label to the selector → trivially matched oracle. **Patched** to use actual SQL execution result. Real trained-selector accuracy is **54.30%, NOT 65%**. Selector → oracle gap = 10.81pp.
35
+
36
+ ### Two headline gaps to close (target = headline EX ≥ 67%)
37
+
38
+ | Gap | Current | Target | Gap | Lever |
39
+ |---|---|---|---|---|
40
+ | **Oracle pass@8** (recall) | 65.38% (mixed-temp) | ≥70% | +4.6pp | More diverse sampling / better fixer rescues |
41
+ | **Selector → oracle** | 57.25 / 65.38 = 87.6% | ≥95% | +8.13pp | Selector v3 (more data / different arch) |
42
+
43
+ ### Selector v2 results (2026-05-13 — row preview added to prompt)
44
+
45
+ Retrained 3B selector with `OK. Rows preview: <rows>` instead of bare `OK`. Closes ~3-4pp of the ~11pp gap.
46
+
47
+ | Config (BIRD-dev K=8 iter-2 planner) | Oracle | Selector v1 (no rows) | **Selector v2 (rows)** | v2 gain |
48
+ |---|---|---|---|---|
49
+ | 1-stage uniform-temp | 64.96% | 53.94% | 56.43% | +2.49pp |
50
+ | **1-stage mixed-temp** | **65.38%** | 53.64% | **57.25%** ← headline | +3.61pp |
51
+ | 2-stage + ORPO fixer-iter1 | 63.04% | 52.72% | 56.02% | +3.30pp |
52
+ | 3-stage + 0.6B V/V + ORPO fixer-iter1 | 65.05% | 53.11% | 56.98% | +3.87pp |
53
+ | 3-stage + 0.5B V/V + 0.5B replanner-fixer | 65.11% | 53.51% | 56.66% | +3.15pp |
54
+
55
+ **Headline pass@8 post-selector = 57.25%** (1-stage mixed-temp + v2 selector). Still −9.75pp from 67%.
56
+
57
+ ### Per-model status
58
+
59
+ | Agent | Model | Params | Status |
60
+ |---|---|---|---|
61
+ | Planner | Qwen2.5-Coder-3B-Instruct + ORPO iter-2 (collab) | 3B | trained ✓ |
62
+ | Selector | Qwen2.5-Coder-3B-Instruct + SFT (YES/NO binary) | 3B | trained ✓ |
63
+ | Validator-Selection (v_s) | Qwen2.5-Coder-0.5B-Instruct + SFT v3 | 0.5B | trained ✓ |
64
+ | Validator-Condition (v_c) | Qwen3-0.6B-Instruct + SFT v3 | 0.6B | trained ✓ (0.5B variant truncated, retrain pending) |
65
+ | Fixer (re-planner) | Qwen2.5-Coder-0.5B + ORPO iter-2 (replanner data) | 0.5B | trained ✓ |
66
+
67
+ ### V+F contribution diagnostic (mixed-temp iter-2 K=8, 1525 q)
68
+
69
+ - Validators critique 91.6% of trajectories; old fixer ignored 98.6% → 0 rescues at pass@8
70
+ - Replanner fixer (iter-2) currently flipping ~40% of trajectories (winloss=605 at 1360/1534) — net effect being measured
71
+
72
+ ### Key findings
73
+
74
+ - ORPO planner: SFT 64.11% → iter-1 64.26% → iter-2 64.96% (+0.70pp, diminishing returns)
75
+ - Mixed-temp sampling adds +0.42pp over uniform-temp at K=8
76
+ - v3 validator data rebalanced from 8% all-OK (over-critique) to 34.5%/61% all-OK
77
+ - Fixer dataset re-built as "re-planner" objective (1833 pairs): given a failed planner trajectory, produce a correct alternative from same question's K=4 trajectories
78
+ - pass@8 (true recall) is the *upper bound* for trained-selector accuracy; need recall ≥70% to land headline ≥67% after selector picks
79
+
80
+ ---
81
+
82
+ ## What's Next (in priority order)
83
+
84
+ 1. **Phase4 K=8 3-stage eval finishes** (currently 89% done, ETA 30 min) → get pass@8 with replanner-fixer.
85
+ 2. **Apply patched (leak-free) selector** to all K=8 JSONLs → get true selector accuracy (not oracle).
86
+ 3. **If pass@8 selector ≥67%: DONE.** Write results table with per-agent sizes.
87
+ 4. **If pass@8 selector <67%:**
88
+ - Re-mine fixer ORPO data on **iter-2 planner** BIRD-train rollouts (current data was from iter-1 planner → distribution shift).
89
+ - Re-train fixer ORPO iter-2 on fresh data.
90
+ - Consider planner sampling tricks: wider mixed-temp (0.3-1.3), nucleus variation.
91
+ 5. **Make V+F contribute (currently neutral):** the 0.5B replanner fixer's `winloss` is now high (~40%) — need to check if those flips are net+ or net-. If net-, gate fixer to only run on `planner_exec_ok=False` cases.
92
+
93
+ ---
94
+
95
+ ## Repo contents
96
+
97
+ ```
98
+ mats-sql-bundle/
99
+ ├── PROGRESS.md # this file
100
+ ├── models/
101
+ │ ├── planner-iter2-collab-3B/ # 3B ORPO iter-2 planner
102
+ │ ├── selector-3B-sft/ # 3B trained selector
103
+ │ ├── validator-selection-0.5B-v3/ # v_s SFT
104
+ │ ├── validator-condition-0.6B-v3/ # v_c SFT
105
+ │ └── fixer-replanner-0.5B-iter2-orpo/ # ORPO iter-2 re-planner fixer
106
+ ├── data/
107
+ │ ├── sft-validator-selection-v3/ # SFT data for v_s
108
+ │ ├── sft-validator-condition-v3/ # SFT data for v_c
109
+ │ ├── hf_fixer_replanner/ # ORPO data for fixer iter-2
110
+ │ └── hf_planner_collaborative_iter2/ # ORPO data for planner iter-2
111
+ ├── recipes/
112
+ │ ├── orpo-planner-collab-iter2.yaml
113
+ │ ├── orpo-fixer-replanner-0.5b-iter2.yaml
114
+ │ ├── validator-selection-fft-0.5b-v3.yaml
115
+ │ └── validator-condition-fft-0.5b-v3.yaml
116
+ └── scripts/
117
+ ├── run_pipeline_rollouts.py # rollout / 3-stage runner
118
+ ├── compute_bestofn_with_selector.py # selector apply (patched)
119
+ ├── compute_bestofn_metrics.py # oracle/greedy metrics
120
+ ├── build_validator_2agents_v3.py # v_s/v_c data builder
121
+ └── build_fixer_replanner_iter2.py # fixer re-planner data builder
122
+ ```
123
+
124
+ ## How to continue from this bundle
125
+
126
+ ```bash
127
+ # 1. Clone the bundle (~16 GB)
128
+ git clone https://huggingface.co/datasets/thanhdath/mats-sql-bundle
129
+ cd mats-sql-bundle
130
+
131
+ # 2. Symlink to alignment-handbook layout
132
+ ln -s $(pwd)/models /path/to/alignment-handbook/output
133
+ ln -s $(pwd)/data /path/to/mats-sql-tist/data/llm_alignment_imported
134
+
135
+ # 3. Continue from where we left off: BIRD-dev K=8 3-stage with iter-2 planner + 0.5B agents
136
+ bash scripts/run_pipeline_rollouts.py --K 8 --mixed_temp "0.5,0.7,0.9,1.1" ...
137
+
138
+ # 4. To do iter-3 (if needed), re-mine fixer data on iter-2 planner BIRD-train rollouts first.
139
+ ```
140
+
141
+ ---
142
+
143
+ **Maintainer**: thanhdath@gmail.com / thanhdath97@gmail.com
144
+ **Source repo**: /home/datht/mats-sql-tist (private dev machine)
code/PROGRESS_v3.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # v3 (two-stage labeling) progress — fills in after rollout 90491 completes
2
+
3
+ ## Recipe
4
+
5
+ - Algorithm: `chosen iff (verdict matches planner correctness) AND (fix-with-critique → correct SQL)`,
6
+ rejected otherwise. ALL chosen × ALL rejected pairs (no truncation).
7
+ - Data builder: `scripts/build_orpo_v3_fast.py` + `scripts/merge_v3_chunks.py`
8
+ - Sbatch: `slurm_logs/build_orpo_v3_chunk.sbatch`, launcher `slurm_logs/launch_v3_4chunks.sh`
9
+ - Training: `recipes/iter1-paper/orpo-val-{sel,cond}-v3-paper.yaml`
10
+ - lr=5e-7, beta=0.05, grad_accum=16, warmup=200, max_grad_norm=0.3
11
+ - 2000 max_steps, save_steps=100
12
+ - Eval: `slurm_logs/rollout_v3.sbatch` (gpu-large, 80GB), 6h time limit, BIRD-dev K=8 T=1.0
13
+ - fixer = Qwen-2.5-72B-Instruct-AWQ + smart prompt (SAME as v8 baseline)
14
+ - NO --fixer_gate_exec_ok (fixer always reads critique)
15
+
16
+ ## Dataset stats (CONFIRMED before training)
17
+
18
+ | Side | n_train | n_test | chosen verdict=correct | rejected verdict=correct | verdict gap |
19
+ |---|---:|---:|---:|---:|---:|
20
+ | sel | 64025 | 3371 | 90.65% | 4.10% | **+86.55pp** |
21
+ | cond | 56066 | 2953 | 91.65% | 4.70% | **+86.95pp** |
22
+
23
+ Compared to old iter1 (Llama-1B fixer): −0.3pp (sel), +1.5pp (cond)
24
+ Compared to v8 collab_72b (Qwen-72B fixer, single-stage): −2.9pp (sel), −1.9pp (cond)
25
+ Compared to iter1 INDEP (verdict-heuristic only): +26.6pp (sel), +29.4pp (cond)
26
+
27
+ The +86pp gap is large because **two-stage labeling adds the INDEP verdict-matching gate on top of the COLLAB fix-success gate** — chosen must hit both, rejected misses at least one.
28
+
29
+ ## Training stats
30
+
31
+ | Side | Init from | Steps reached | Final loss | Notes |
32
+ |---|---|---:|---:|---|
33
+ | sel | sft-validator-sel-llama1b-paper-v1 | 1900 (95%) | ~0.13 | hit 4h time limit, ckpt-1900 promoted to root |
34
+ | cond | sft-validator-cond-llama1b-paper-v1 | 1700 (85%) | ~0.15 | hit 4h time limit, ckpt-1700 promoted to root |
35
+
36
+ Loss decreased smoothly (sel: 0.33→0.13, cond: 0.23→0.15). No NaN, no collapse.
37
+
38
+ Final lr=5e-7 / beta=0.05 / grad_clip=0.3 — needed because earlier lr=8e-6 / lr=2e-6 produced NaN at steps 60-500 with bf16 + the strong v3 signal.
39
+
40
+ ## Eval rollout (TODO)
41
+
42
+ job: 90491
43
+
44
+ Comparison vs v8 INDEP iter2 (227MB jsonl, 953/1534 questions):
45
+
46
+ | Config | pass@8 | verdict acc | recall on CORRECT | recall on INCORRECT |
47
+ |---|---:|---:|---:|---:|
48
+ | v8 INDEP iter2 (baseline) | 72.94% | 70.58% | 73.07% | 68.54% |
49
+ | v8 COLLAB iter2 (collapsed) | 73.37% | 56.57% | 6.79% | 97.76% |
50
+ | **v3 (two-stage)** | **TBD** | **TBD** | **TBD** | **TBD** |
51
+
52
+ Bootstrap CI on (v3 − v8_INDEP) gap — TBD.
53
+
54
+ ## Pass criterion
55
+
56
+ - v3 pass@8 ≥ v8 INDEP iter2 pass@8 + 1.0pp at the 2.5%-ile bootstrap bound → SHIP
57
+ - v3 pass@8 ≥ v8 INDEP iter2 pass@8 + 0pp (point) but CI < +1pp → WEAK PASS (more epochs)
58
+ - v3 pass@8 < v8 INDEP iter2 pass@8 → FAIL (escalate to multi-objective COLLAB+INDEP mix)
code/README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## MATS: A Multi-agent Text2SQL Framework using Small Language Models and Execution Feedback
2
+
3
+ [![arXiv](https://img.shields.io/badge/arXiv-2512.18622-b31b1b.svg)](https://arxiv.org/abs/2512.18622)
4
+ ![visitors](https://visitor-badge.laobi.icu/badge?page_id=thanhdath.mats-sql)
5
+ <img src="https://img.shields.io/badge/Contributions-Welcome-278ea5" alt="Contrib"/>
6
+
7
+ MATS is a multi-agent framework for Text2SQL using small language models and execution feedback to improve query accuracy. It employs multiple specialized agents—including schema insight agent, planner, validator, fix agent, and selection agent. Some components of this framework are adapted from [CodeS](https://github.com/RUCKBReasoning/codes) (for schema filtering) and [alignment-handbook](https://github.com/huggingface/alignment-handbook) (for supervised fine-tuning and ORPO training).
8
+
9
+ **1. To set up the environment**
10
+ ```
11
+ conda env create -n mats -f environment.yml
12
+ conda activate mats
13
+ ```
14
+
15
+ **2. Run Evaluation on BIRD**:
16
+
17
+ First serve the models with VLLM.
18
+ ```
19
+ CUDA_VISIBLE_DEVICES=0 vllm serve thanhdathoang/llama-3b-bird-planner --host 0.0.0.0 --port 8003 --dtype bfloat16 --max-model-len 4096 --disable-log-requests --served-model-name planner --gpu-memory-utilization 0.3 --enable-prefix-caching
20
+
21
+ CUDA_VISIBLE_DEVICES=0 vllm serve thanhdathoang/llama-1b-bird-validator --host 0.0.0.0 --port 8004 --dtype bfloat16 --max-model-len 4096 --disable-log-requests --served-model-name validator --gpu-memory-utilization 0.2 --enable-prefix-caching
22
+
23
+ CUDA_VISIBLE_DEVICES=0 vllm serve thanhdathoang/llama-1b-bird-fixed --host 0.0.0.0 --port 8005 --dtype bfloat16 --max-model-len 4096 --disable-log-requests --served-model-name fixed --gpu-memory-utilization 0.2 --enable-prefix-caching
24
+
25
+ CUDA_VISIBLE_DEVICES=0 vllm serve thanhdathoang/llama-3b-bird-selection --host 0.0.0.0 --port 8006 --dtype bfloat16 --max-model-len 4096 --disable-log-requests --served-model-name selection --gpu-memory-utilization 0.3 --enable-prefix-caching
26
+ ```
27
+
28
+ Run evaluation:
29
+ ```
30
+ eval_file=data/evaluate/orpo-llama-3-iter-2-end2end-bird_dev.jsonl
31
+ rm $eval_file
32
+ PYTHONPATH=. python evaluate_end2end.py \
33
+ --input_file data/schema_insight_bird_with_evidence_dev_text2sql.json \
34
+ --output_file $eval_file \
35
+ --model-name llama --mode test --n_return 10 --temperature 1.0 --api_host http://localhost:8003 --n_processes 16
36
+
37
+ python compute_acc.py --pred_file $eval_file
38
+ ```
39
+
40
+
41
+
42
+
43
+ **3. To run evaluation on Spider**:
44
+
45
+ First serve the models with VLLM.
46
+ ```
47
+ CUDA_VISIBLE_DEVICES=0 vllm serve thanhdathoang/llama-3b-spider-planner --host 0.0.0.0 --port 8003 --dtype bfloat16 --max-model-len 4096 --disable-log-requests --served-model-name planner --gpu-memory-utilization 0.3 --enable-prefix-caching
48
+
49
+ CUDA_VISIBLE_DEVICES=0 vllm serve thanhdathoang/llama-1b-spider-validator --host 0.0.0.0 --port 8004 --dtype bfloat16 --max-model-len 4096 --disable-log-requests --served-model-name validator --gpu-memory-utilization 0.2 --enable-prefix-caching
50
+
51
+ CUDA_VISIBLE_DEVICES=0 vllm serve thanhdathoang/llama-1b-spider-fixed --host 0.0.0.0 --port 8005 --dtype bfloat16 --max-model-len 4096 --disable-log-requests --served-model-name fixed --gpu-memory-utilization 0.2 --enable-prefix-caching
52
+
53
+ CUDA_VISIBLE_DEVICES=0 vllm serve thanhdathoang/llama-3b-spider-selection --host 0.0.0.0 --port 8006 --dtype bfloat16 --max-model-len 4096 --disable-log-requests --served-model-name selection --gpu-memory-utilization 0.3 --enable-prefix-caching
54
+ ```
55
+
56
+ Run evaluation:
57
+ ```
58
+ eval_file=data/evaluate/orpo-llama-3-iter-2-end2end-spider_dev.jsonl
59
+ rm $eval_file
60
+ PYTHONPATH=. python evaluate_end2end.py \
61
+ --input_file data/schema_insight_spider_dev_text2sql.json \
62
+ --output_file $eval_file \
63
+ --model-name llama --mode test --n_return 10 --temperature 1.0 --api_host http://localhost:8003 --n_processes 16
64
+
65
+ python compute_acc.py --pred_file $eval_file
66
+ ```
67
+
68
+
69
+ **4. For training agents**
70
+
71
+ The Schema Filtering is inherited from [CodeS](https://github.com/RUCKBReasoning/codes).
72
+
73
+ To train other agents, see the code in ***alignment-handbook/***, here we modified the repository [alignment-handbook](https://github.com/huggingface/alignment-handbook) for supervised-finetuning and ORPO on the completion part only. The config files could be found in **alignment-handbook/recipes/**.
74
+
75
+ **Note**: Currently this work is under review. The model and training dataset will be publicly available upon acceptance.
76
+
77
+ ## Citation:
78
+ ```
79
+ @article{hoang2025multi,
80
+ title={A Multi-agent Text2SQL Framework using Small Language Models and Execution Feedback},
81
+ author={Hoang, Thanh Dat and Huynh, Thanh Trung and Weidlich, Matthias and Nguyen, Thanh Tam and Chen, Tong and Yin, Hongzhi and Nguyen, Quoc Viet Hung},
82
+ journal={arXiv preprint arXiv:2512.18622},
83
+ year={2025}
84
+ }
85
+ ```
86
+
87
+ -----------
88
+ **Backup Statistics**
89
+
90
+ ![Visitors](https://margherita-gustatory-zane.ngrok-free.dev/badge/thanhdath%2Fmats-sql.svg?ngrok-skip-browser-warning=true)
code/WORKFLOW_GF_HENRY.md ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MATS-TIST Workflow on gf-henry
2
+
3
+ ## Machine Info
4
+ - GPUs: RTX 2080 Ti (11GB) + TITAN RTX (24GB)
5
+ - Home: `/home/datht/`
6
+ - Conda env: `mats`
7
+
8
+ ## Code Policy
9
+ > **Never edit code on gf-henry.** Always edit on the dev machine, then sync:
10
+ > ```bash
11
+ > # On dev machine (not gf-henry):
12
+ > bash /home/datht/mats-sql-tist/scripts/sync_code.sh
13
+ > ```
14
+
15
+ ---
16
+
17
+ ## Directory Layout on gf-henry
18
+
19
+ ```
20
+ /home/datht/
21
+ ├── mats-sql-tist/ ← synced code (never edit directly)
22
+ │ ├── data -> /home/datht/mats/data (symlink)
23
+ │ ├── alignment-handbook/
24
+ │ ├── utils/
25
+ │ ├── db_content_retrieval/
26
+ │ ├── scripts/
27
+ │ │ ├── setup_env_gf_henry.sh
28
+ │ │ ├── sync_code.sh
29
+ │ │ ├── build_all_bm25_indexes.py
30
+ │ │ ├── train_bird.sh ← alignment-handbook train commands
31
+ │ │ └── evaluate_bird.sh
32
+ │ ├── prepare_sft_datasets.py
33
+ │ └── evaluate_end2end.py
34
+
35
+ ├── mats/
36
+ │ ├── alignment-handbook/output/ ← Qwen SQL-writer trained models
37
+ │ │ ├── Qwen-2.5-Coder-1.5B-SQL-Writer/
38
+ │ │ ├── Qwen-2.5-Coder-3B-SQL-Writer/
39
+ │ │ └── ...
40
+ │ ├── schema_insight/output/
41
+ │ │ └── grpo_schema_bird-Qwen-Coder-0.5B-phase2/checkpoint-6200/ ← schema agent ckpt
42
+ │ └── data/ ← all datasets + BM25 indexes
43
+ │ ├── bird/dev/ (11 dbs + BM25 indexes)
44
+ │ ├── bird/train/ (69 dbs + BM25 indexes)
45
+ │ ├── spider/ (169 dbs + BM25 indexes)
46
+ │ └── sft_data_collections/ (Spider-DK, Dr.Spider, domain, ...)
47
+
48
+ └── huggingface/ ← trained MATS agent models
49
+ ├── llama-3b-bird-planner-fft/ (6G) Planner SFT
50
+ ├── llama-3b-bird-validator-fft/ (6G) Validator SFT
51
+ ├── llama-3b-bird-fixed-fft/ (6G) Fixer SFT
52
+ ├── orpo-llama-3b-iter-3-bird-planner-no-filter-seed107/ (6.1G) Planner ORPO
53
+ └── Meta-Llama-3.1-8B-Instruct/ (30G) (available if needed)
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Setup (one-time)
59
+
60
+ ```bash
61
+ # 1. Setup conda env (installs torch, transformers, trl, vllm, pyserini, etc.)
62
+ cd /home/datht/mats-sql-tist
63
+ bash scripts/setup_env_gf_henry.sh
64
+
65
+ # 2. Install alignment-handbook (custom ORPO)
66
+ source /home/datht/anaconda3/etc/profile.d/conda.sh
67
+ conda activate mats
68
+ cd /home/datht/mats-sql-tist/alignment-handbook
69
+ pip install -e .
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Base LLaMA Models (for retraining)
75
+
76
+ The recipe YAMLs reference `/home/datht/huggingface/meta-llama/Llama-3.2-{1B,3B}-Instruct`.
77
+ Download them from HuggingFace if not already present:
78
+
79
+ ```bash
80
+ conda activate mats
81
+ python -c "
82
+ from huggingface_hub import snapshot_download
83
+ # LLaMA 3.2 3B (Planner, Selector)
84
+ snapshot_download('meta-llama/Llama-3.2-3B-Instruct',
85
+ local_dir='/home/datht/huggingface/meta-llama/Llama-3.2-3B-Instruct')
86
+ # LLaMA 3.2 1B (Validator, Fixer)
87
+ snapshot_download('meta-llama/Llama-3.2-1B-Instruct',
88
+ local_dir='/home/datht/huggingface/meta-llama/Llama-3.2-1B-Instruct')
89
+ "
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Running Experiments
95
+
96
+ ### Step 1: Start BM25 API (for schema retrieval during SFT data build)
97
+ ```bash
98
+ conda activate mats
99
+ cd /home/datht/mats-sql-tist
100
+ python db_content_retrieval/lsh_api.py --port 8005 &
101
+ ```
102
+
103
+ ### Step 2: Build SFT training data (with CHESS-style DDL + BIRD CSV descriptions)
104
+ ```bash
105
+ conda activate mats
106
+ cd /home/datht/mats-sql-tist
107
+ # BIRD dev
108
+ python prepare_sft_datasets.py
109
+ ```
110
+
111
+ ### Step 3: SFT Training (alignment-handbook)
112
+ ```bash
113
+ conda activate mats
114
+ cd /home/datht/mats-sql-tist/alignment-handbook
115
+ export PYTHONPATH=src/
116
+ # BIRD - planner (LLaMA 3.2 3B)
117
+ ACCELERATE_LOG_LEVEL=info accelerate launch \
118
+ --config_file recipes/accelerate_configs/multi_gpu.yaml \
119
+ --num_processes 1 \
120
+ scripts/run_sft.py recipes/llama-3b-bird/planner-fft.yaml
121
+
122
+ # BIRD - validator + fixer (LLaMA 3.2 1B)
123
+ ACCELERATE_LOG_LEVEL=info accelerate launch \
124
+ --config_file recipes/accelerate_configs/multi_gpu.yaml \
125
+ --num_processes 1 \
126
+ scripts/run_sft.py recipes/llama-3b-bird/validator-fixer-fft.yaml
127
+ ```
128
+
129
+ ### Step 4: ORPO Training (after SFT)
130
+ ```bash
131
+ conda activate mats
132
+ cd /home/datht/mats-sql-tist/alignment-handbook
133
+ export PYTHONPATH=src/
134
+ # See alignment-handbook/scripts/train_bird.sh for full commands
135
+ bash scripts/train_bird.sh
136
+ ```
137
+
138
+ ### Step 5: Evaluation (BIRD dev)
139
+ ```bash
140
+ conda activate mats
141
+ cd /home/datht/mats-sql-tist
142
+
143
+ # Serve agents via vLLM (on TITAN RTX, 24GB)
144
+ CUDA_VISIBLE_DEVICES=1 vllm serve /home/datht/huggingface/orpo-llama-3b-iter-3-bird-planner-no-filter-seed107 \
145
+ --host 0.0.0.0 --port 8003 --served-model-name planner \
146
+ --dtype bfloat16 --max-model-len 4096 --gpu-memory-utilization 0.9 &
147
+
148
+ CUDA_VISIBLE_DEVICES=0 vllm serve /home/datht/huggingface/llama-3b-bird-validator-fft \
149
+ --host 0.0.0.0 --port 8004 --served-model-name validator \
150
+ --dtype bfloat16 --max-model-len 4096 --gpu-memory-utilization 0.8 &
151
+
152
+ CUDA_VISIBLE_DEVICES=0 vllm serve /home/datht/huggingface/llama-3b-bird-fixed-fft \
153
+ --host 0.0.0.0 --port 8005 --served-model-name fixed \
154
+ --dtype bfloat16 --max-model-len 4096 --gpu-memory-utilization 0.8 &
155
+
156
+ # Run evaluation
157
+ python evaluate_end2end.py \
158
+ --input_file data/full_value_matching_sft_bird_062024_with_evidence_dev_text2sql.json \
159
+ --output_file output/bird_dev_results.jsonl \
160
+ --model-name llama \
161
+ --api_host http://localhost:8003 \
162
+ --n_processes 8
163
+ ```
164
+
165
+ ---
166
+
167
+ ## Syncing Code Updates from Dev Machine
168
+
169
+ After editing code on the dev machine:
170
+
171
+ ```bash
172
+ # On DEV machine:
173
+ bash /home/datht/mats-sql-tist/scripts/sync_code.sh gf-henry
174
+
175
+ # On gf-henry (if alignment-handbook changed):
176
+ cd /home/datht/mats-sql-tist/alignment-handbook && pip install -e .
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Notes
182
+
183
+ - **vLLM**: TITAN RTX (24GB, GPU 1) is preferred for planner/selection, RTX 2080 Ti (11GB, GPU 0) for smaller validator/fixer models
184
+ - **BM25 indexes**: already built, stored in `data/*/db_contents_index/`
185
+ - **BIRD CSV descriptions**: automatically loaded during `prepare_sft_datasets.py` via `utils/bird_csv_utils.py`
186
+ - **Schema format**: CHESS-style DDL with inline `-- Column Description | Value Description` (see `utils/db_utils.py`)
code/alignment-handbook/.github/workflows/build_documentation.yml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ build:
10
+ uses: huggingface/doc-builder/.github/workflows/build_main_documentation.yml@main
11
+ with:
12
+ commit_sha: ${{ github.sha }}
13
+ package: alignment-handbook
14
+ path_to_docs: alignment-handbook/chapters/
15
+ additional_args: --not_python_module
16
+ languages: en
17
+ secrets:
18
+ hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}
code/alignment-handbook/.github/workflows/build_pr_documentation.yml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build PR Documentation
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ concurrency:
7
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
8
+ cancel-in-progress: true
9
+
10
+ jobs:
11
+ build:
12
+ uses: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml@main
13
+ with:
14
+ commit_sha: ${{ github.event.pull_request.head.sha }}
15
+ pr_number: ${{ github.event.number }}
16
+ package: alignment-handbook
17
+ path_to_docs: alignment-handbook/chapters/
18
+ additional_args: --not_python_module
19
+ languages: en
code/alignment-handbook/.github/workflows/quality.yml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Quality
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - v*-release
8
+ pull_request:
9
+ branches:
10
+ - main
11
+
12
+ jobs:
13
+
14
+ check_code_quality:
15
+ name: Check code quality
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v2
20
+ - name: Setup Python environment
21
+ uses: actions/setup-python@v2
22
+ with:
23
+ python-version: 3.10.10
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ python -m pip install ".[quality]"
28
+ - name: Code quality
29
+ run: |
30
+ make quality
31
+
code/alignment-handbook/.github/workflows/tests.yml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - v*-release
8
+ pull_request:
9
+ branches:
10
+ - main
11
+
12
+ jobs:
13
+
14
+ unit-tests:
15
+ name: Run unit tests
16
+ env:
17
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - name: Checkout code
21
+ uses: actions/checkout@v2
22
+ - name: Setup Python environment
23
+ uses: actions/setup-python@v2
24
+ with:
25
+ python-version: 3.10.10
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ python -m pip install ".[dev, torch]"
30
+ - name: Run unit tests
31
+ run: HF_TOKEN=$HF_TOKEN pytest -sv tests/
code/alignment-handbook/.github/workflows/upload_pr_documentation.yml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Upload PR Documentation
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows: ["Build PR Documentation"]
6
+ types:
7
+ - completed
8
+
9
+ jobs:
10
+ build:
11
+ uses: huggingface/doc-builder/.github/workflows/upload_pr_documentation.yml@main
12
+ with:
13
+ package_name: alignment-handbook
14
+ secrets:
15
+ hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}
16
+ comment_bot_token: ${{ secrets.COMMENT_BOT_TOKEN }}
code/alignment-handbook/.gitignore ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ .idea/
161
+
162
+ # Temp folders
163
+ data/
164
+ wandb/
165
+ output/
code/alignment-handbook/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
code/alignment-handbook/Makefile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: style quality
2
+
3
+ # make sure to test the local checkout in scripts and not the pre-installed one (don't use quotes!)
4
+ export PYTHONPATH = src
5
+
6
+ check_dirs := src tests scripts
7
+
8
+ style:
9
+ black --line-length 119 --target-version py310 $(check_dirs) setup.py
10
+ isort $(check_dirs) setup.py
11
+
12
+ quality:
13
+ black --check --line-length 119 --target-version py310 $(check_dirs) setup.py
14
+ isort --check-only $(check_dirs) setup.py
15
+ flake8 --max-line-length 119 $(check_dirs) setup.py
16
+
17
+
18
+ # Release stuff
19
+
20
+ pre-release:
21
+ python src/alignment/release.py
22
+
23
+ pre-patch:
24
+ python src/alignment/release.py --patch
25
+
26
+ post-release:
27
+ python src/alignment/release.py --post_release
28
+
29
+ post-patch:
30
+ python src/alignment/release.py --post_release --patch
31
+
32
+ wheels:
33
+ python setup.py bdist_wheel && python setup.py sdist
34
+
35
+ wheels_clean:
36
+ rm -rf build && rm -rf dist
37
+
38
+ pypi_upload:
39
+ python -m pip install twine
40
+ twine upload dist/* -r pypi
41
+
42
+ pypi_test_upload:
43
+ python -m pip install twine
44
+ twine upload dist/* -r pypitest --repository-url=https://test.pypi.org/legacy/
code/alignment-handbook/README.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ To train SFT on TinyLLama, run:
2
+ ```
3
+ bash scripts/train_tinyllama.sh
4
+ ```
5
+
code/alignment-handbook/environment.yml ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: handbook
2
+ channels:
3
+ - defaults
4
+ dependencies:
5
+ - _libgcc_mutex=0.1=main
6
+ - _openmp_mutex=5.1=1_gnu
7
+ - bzip2=1.0.8=h5eee18b_5
8
+ - ca-certificates=2024.3.11=h06a4308_0
9
+ - ld_impl_linux-64=2.38=h1181459_1
10
+ - libffi=3.4.4=h6a678d5_0
11
+ - libgcc-ng=11.2.0=h1234567_1
12
+ - libgomp=11.2.0=h1234567_1
13
+ - libstdcxx-ng=11.2.0=h1234567_1
14
+ - libuuid=1.41.5=h5eee18b_0
15
+ - ncurses=6.4=h6a678d5_0
16
+ - openssl=3.0.13=h7f8727e_0
17
+ - pip=23.3.1=py310h06a4308_0
18
+ - python=3.10.14=h955ad1f_0
19
+ - readline=8.2=h5eee18b_0
20
+ - setuptools=68.2.2=py310h06a4308_0
21
+ - sqlite=3.41.2=h5eee18b_0
22
+ - tk=8.6.12=h1ccaba5_0
23
+ - wheel=0.41.2=py310h06a4308_0
24
+ - xz=5.4.6=h5eee18b_0
25
+ - zlib=1.2.13=h5eee18b_0
26
+ - pip:
27
+ - absl-py==2.1.0
28
+ - accelerate==0.27.2
29
+ - aiohttp==3.9.5
30
+ - aiosignal==1.3.1
31
+ - annotated-types==0.6.0
32
+ - anyio==4.3.0
33
+ - appdirs==1.4.4
34
+ - argon2-cffi==23.1.0
35
+ - argon2-cffi-bindings==21.2.0
36
+ - arrow==1.3.0
37
+ - asttokens==2.4.1
38
+ - async-lru==2.0.4
39
+ - async-timeout==4.0.3
40
+ - attrs==23.2.0
41
+ - babel==2.14.0
42
+ - beautifulsoup4==4.12.3
43
+ - bitsandbytes==0.41.2.post2
44
+ - bleach==6.1.0
45
+ - certifi==2024.2.2
46
+ - cffi==1.16.0
47
+ - charset-normalizer==3.3.2
48
+ - click==8.1.7
49
+ - cloudpickle==3.0.0
50
+ - comm==0.2.2
51
+ - contourpy==1.2.1
52
+ - cycler==0.12.1
53
+ - datasets==2.14.6
54
+ - debugpy==1.8.1
55
+ - decorator==5.1.1
56
+ - deepspeed==0.12.2
57
+ - defusedxml==0.7.1
58
+ - dill==0.3.7
59
+ - distro==1.9.0
60
+ - docker-pycreds==0.4.0
61
+ - docstring-parser==0.16
62
+ - einops==0.7.0
63
+ - evaluate==0.4.0
64
+ - exceptiongroup==1.2.1
65
+ - executing==2.0.1
66
+ - farama-notifications==0.0.4
67
+ - fastjsonschema==2.19.1
68
+ - filelock==3.13.4
69
+ - fonttools==4.51.0
70
+ - fqdn==1.5.1
71
+ - frozenlist==1.4.1
72
+ - fsspec==2023.10.0
73
+ - func-timeout==4.3.5
74
+ - gitdb==4.0.11
75
+ - gitpython==3.1.43
76
+ - grpcio==1.62.2
77
+ - gymnasium==0.29.1
78
+ - h11==0.14.0
79
+ - hjson==3.1.0
80
+ - httpcore==1.0.5
81
+ - httpx==0.27.0
82
+ - huggingface-hub==0.23.3
83
+ - idna==3.7
84
+ - ipykernel==6.29.4
85
+ - ipython==8.24.0
86
+ - ipywidgets==8.1.2
87
+ - isoduration==20.11.0
88
+ - jedi==0.19.1
89
+ - jinja2==3.1.3
90
+ - joblib==1.4.0
91
+ - json5==0.9.25
92
+ - jsonpointer==2.4
93
+ - jsonschema==4.21.1
94
+ - jsonschema-specifications==2023.12.1
95
+ - jupyter==1.0.0
96
+ - jupyter-client==8.6.1
97
+ - jupyter-console==6.6.3
98
+ - jupyter-core==5.7.2
99
+ - jupyter-events==0.10.0
100
+ - jupyter-lsp==2.2.5
101
+ - jupyter-server==2.14.0
102
+ - jupyter-server-terminals==0.5.3
103
+ - jupyterlab==4.1.8
104
+ - jupyterlab-pygments==0.3.0
105
+ - jupyterlab-server==2.27.1
106
+ - jupyterlab-widgets==3.0.10
107
+ - kiwisolver==1.4.5
108
+ - markdown==3.6
109
+ - markdown-it-py==3.0.0
110
+ - markupsafe==2.1.5
111
+ - matplotlib==3.8.4
112
+ - matplotlib-inline==0.1.7
113
+ - mdurl==0.1.2
114
+ - mistune==3.0.2
115
+ - mpmath==1.3.0
116
+ - multidict==6.0.5
117
+ - multiprocess==0.70.15
118
+ - nbclient==0.10.0
119
+ - nbconvert==7.16.3
120
+ - nbformat==5.10.4
121
+ - nest-asyncio==1.6.0
122
+ - networkx==3.3
123
+ - ninja==1.11.1.1
124
+ - nltk==3.8.1
125
+ - notebook==7.1.3
126
+ - notebook-shim==0.2.4
127
+ - numpy==1.26.4
128
+ - nvidia-cublas-cu12==12.1.3.1
129
+ - nvidia-cuda-cupti-cu12==12.1.105
130
+ - nvidia-cuda-nvrtc-cu12==12.1.105
131
+ - nvidia-cuda-runtime-cu12==12.1.105
132
+ - nvidia-cudnn-cu12==8.9.2.26
133
+ - nvidia-cufft-cu12==11.0.2.54
134
+ - nvidia-curand-cu12==10.3.2.106
135
+ - nvidia-cusolver-cu12==11.4.5.107
136
+ - nvidia-cusparse-cu12==12.1.0.106
137
+ - nvidia-nccl-cu12==2.19.3
138
+ - nvidia-nvjitlink-cu12==12.4.127
139
+ - nvidia-nvtx-cu12==12.1.105
140
+ - openai==1.23.6
141
+ - overrides==7.7.0
142
+ - pandas==2.2.2
143
+ - pandocfilters==1.5.1
144
+ - parso==0.8.4
145
+ - peft==0.6.1
146
+ - pexpect==4.9.0
147
+ - pillow==10.3.0
148
+ - platformdirs==4.2.1
149
+ - prometheus-client==0.20.0
150
+ - prompt-toolkit==3.0.43
151
+ - protobuf==3.20.2
152
+ - psutil==5.9.8
153
+ - ptyprocess==0.7.0
154
+ - pure-eval==0.2.2
155
+ - py-cpuinfo==9.0.0
156
+ - pyarrow==16.0.0
157
+ - pycparser==2.22
158
+ - pydantic==2.7.1
159
+ - pydantic-core==2.18.2
160
+ - pygments==2.17.2
161
+ - pynvml==11.5.0
162
+ - pyparsing==3.1.2
163
+ - python-dateutil==2.9.0.post0
164
+ - python-json-logger==2.0.7
165
+ - pytz==2024.1
166
+ - pyyaml==6.0.1
167
+ - pyzmq==26.0.2
168
+ - qtconsole==5.5.1
169
+ - qtpy==2.4.1
170
+ - referencing==0.35.0
171
+ - regex==2024.4.16
172
+ - requests==2.31.0
173
+ - responses==0.18.0
174
+ - rfc3339-validator==0.1.4
175
+ - rfc3986-validator==0.1.1
176
+ - rich==13.7.1
177
+ - rpds-py==0.18.0
178
+ - safetensors==0.4.3
179
+ - scipy==1.13.0
180
+ - send2trash==1.8.3
181
+ - sentencepiece==0.2.0
182
+ - sentry-sdk==2.0.1
183
+ - setproctitle==1.3.3
184
+ - shtab==1.7.1
185
+ - six==1.16.0
186
+ - smmap==5.0.1
187
+ - sniffio==1.3.1
188
+ - soupsieve==2.5
189
+ - sqlglot==23.12.1
190
+ - stable-baselines3==2.3.2
191
+ - stack-data==0.6.3
192
+ - sympy==1.12
193
+ - tensorboard==2.16.2
194
+ - tensorboard-data-server==0.7.2
195
+ - terminado==0.18.1
196
+ - tinycss2==1.3.0
197
+ - tokenizers==0.19.1
198
+ - tomli==2.0.1
199
+ - torch==2.2.2
200
+ - tornado==6.4
201
+ - tqdm==4.66.2
202
+ - traitlets==5.14.3
203
+ - transformers==4.41.2
204
+ - triton==2.2.0
205
+ - trl==0.8.6
206
+ - types-python-dateutil==2.9.0.20240316
207
+ - typing-extensions==4.11.0
208
+ - tyro==0.8.3
209
+ - tzdata==2024.1
210
+ - uri-template==1.3.0
211
+ - urllib3==2.2.1
212
+ - wandb==0.16.6
213
+ - wcwidth==0.2.13
214
+ - webcolors==1.13
215
+ - webencodings==0.5.1
216
+ - websocket-client==1.8.0
217
+ - werkzeug==3.0.2
218
+ - widgetsnbextension==4.0.10
219
+ - xxhash==3.4.1
220
+ - yarl==1.9.4
221
+ prefix: /home/datht/anaconda3/envs/handbook
code/alignment-handbook/recipes/accelerate_configs/deepspeed_dpo.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ debug: false
3
+ deepspeed_config:
4
+ deepspeed_config_file: ./recipes/accelerate_configs/dpo.json
5
+ zero3_init_flag: true
6
+ distributed_type: DEEPSPEED
7
+ downcast_bf16: 'no'
8
+ machine_rank: 0
9
+ main_training_function: main
10
+ num_machines: 1
11
+ num_processes: 2
12
+ rdzv_backend: static
13
+ same_network: true
14
+ tpu_env: []
15
+ tpu_use_cluster: false
16
+ tpu_use_sudo: false
17
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/deepspeed_original.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ debug: false
3
+ deepspeed_config:
4
+ deepspeed_multinode_launcher: standard
5
+ offload_optimizer_device: none
6
+ offload_param_device: none
7
+ zero3_init_flag: true
8
+ zero3_save_16bit_model: true
9
+ zero_stage: 3
10
+ distributed_type: DEEPSPEED
11
+ downcast_bf16: 'no'
12
+ machine_rank: 0
13
+ main_training_function: main
14
+ mixed_precision: bf16
15
+ num_machines: 1
16
+ num_processes: 2
17
+ rdzv_backend: static
18
+ same_network: true
19
+ tpu_env: []
20
+ tpu_use_cluster: false
21
+ tpu_use_sudo: false
22
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/deepspeed_zero3.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ debug: false
3
+ deepspeed_config:
4
+ deepspeed_config_file: ./recipes/accelerate_configs/ds_7b.json
5
+ zero3_init_flag: true
6
+ distributed_type: DEEPSPEED
7
+ downcast_bf16: 'no'
8
+ machine_rank: 0
9
+ main_training_function: main
10
+ num_machines: 1
11
+ num_processes: 2
12
+ rdzv_backend: static
13
+ same_network: true
14
+ tpu_env: []
15
+ tpu_use_cluster: false
16
+ tpu_use_sudo: false
17
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/multi_gpu.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ debug: false
3
+ distributed_type: MULTI_GPU
4
+ downcast_bf16: 'no'
5
+ gpu_ids: all
6
+ machine_rank: 0
7
+ main_training_function: main
8
+ mixed_precision: bf16
9
+ num_machines: 1
10
+ num_processes: 2
11
+ rdzv_backend: static
12
+ same_network: true
13
+ tpu_env: []
14
+ tpu_use_cluster: false
15
+ tpu_use_sudo: false
16
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/no_offload_optimizer.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ debug: false
3
+ deepspeed_config:
4
+ deepspeed_config_file: ./recipes/accelerate_configs/ds_7b.json
5
+ zero3_init_flag: true
6
+ distributed_type: DEEPSPEED
7
+ downcast_bf16: 'no'
8
+ machine_rank: 0
9
+ main_training_function: main
10
+ num_machines: 1
11
+ num_processes: 2
12
+ rdzv_backend: static
13
+ same_network: true
14
+ tpu_env: []
15
+ tpu_use_cluster: false
16
+ tpu_use_sudo: false
17
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/single_gpu.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ debug: false
3
+ distributed_type: 'NO'
4
+ downcast_bf16: 'no'
5
+ gpu_ids: '1'
6
+ machine_rank: 0
7
+ main_training_function: main
8
+ mixed_precision: bf16
9
+ num_machines: 1
10
+ num_processes: 1
11
+ rdzv_backend: static
12
+ same_network: true
13
+ tpu_env: []
14
+ tpu_use_cluster: false
15
+ tpu_use_sudo: false
16
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/single_gpu0_local.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ debug: false
3
+ distributed_type: 'NO'
4
+ downcast_bf16: 'no'
5
+ gpu_ids: '0'
6
+ machine_rank: 0
7
+ main_training_function: main
8
+ mixed_precision: bf16
9
+ num_machines: 1
10
+ num_processes: 1
11
+ rdzv_backend: static
12
+ same_network: true
13
+ tpu_env: []
14
+ tpu_use_cluster: false
15
+ tpu_use_sudo: false
16
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/single_gpu1_local.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ distributed_type: NO
3
+ downcast_bf16: 'no'
4
+ gpu_ids: '1'
5
+ machine_rank: 0
6
+ main_training_function: main
7
+ mixed_precision: bf16
8
+ num_machines: 1
9
+ num_processes: 1
10
+ rdzv_backend: static
11
+ same_network: true
12
+ tpu_env: []
13
+ tpu_use_cluster: false
14
+ tpu_use_sudo: false
15
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/single_gpu_gf_henry.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ debug: false
3
+ distributed_type: 'NO'
4
+ downcast_bf16: 'no'
5
+ gpu_ids: '1'
6
+ machine_rank: 0
7
+ main_training_function: main
8
+ mixed_precision: 'no'
9
+ num_machines: 1
10
+ num_processes: 1
11
+ rdzv_backend: static
12
+ same_network: true
13
+ tpu_env: []
14
+ tpu_use_cluster: false
15
+ tpu_use_sudo: false
16
+ use_cpu: false
code/alignment-handbook/recipes/accelerate_configs/zero2.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ compute_environment: LOCAL_MACHINE
2
+ deepspeed_config:
3
+ offload_optimizer_device: cpu
4
+ offload_param_device: none
5
+ zero3_init_flag: true
6
+ zero_stage: 2
7
+ distributed_type: DEEPSPEED
8
+ fsdp_config: {}
9
+ machine_rank: 0
10
+ main_process_ip: null
11
+ main_process_port: null
12
+ main_training_function: main
13
+ mixed_precision: bf16
14
+ num_machines: 1
15
+ num_processes: 2
16
+ use_cpu: false
code/alignment-handbook/recipes/iter1-paper/orpo-val-cond-collab-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-cond-llama1b-paper-v1
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_cond_paper_iter1_collab: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.1
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 400
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-collab-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter1-paper/orpo-val-cond-indep-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-cond-llama1b-paper-v1
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_cond_paper_iter1_indep: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.1
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 400
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-indep-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter1-paper/orpo-val-cond-v3-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-cond-llama1b-paper-v1
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_cond_v3: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.05
14
+ do_eval: false
15
+ eval_strategy: "no"
16
+ eval_steps: 200
17
+ gradient_accumulation_steps: 16
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 5.0e-7
22
+ log_level: info
23
+ logging_steps: 20
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: 1
28
+ max_steps: 2000
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-v3-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 100
38
+ save_total_limit: 5
39
+ seed: 42
40
+ warmup_ratio: 0.10
41
+ warmup_steps: 200
42
+ max_grad_norm: 0.3
code/alignment-handbook/recipes/iter1-paper/orpo-val-sel-collab-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-sel-llama1b-paper-v1
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_sel_paper_iter1_collab: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.1
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 400
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-collab-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter1-paper/orpo-val-sel-indep-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-sel-llama1b-paper-v1
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_sel_paper_iter1_indep: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.1
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 1.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 200
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-indep-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.1
code/alignment-handbook/recipes/iter1-paper/orpo-val-sel-v3-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-sel-llama1b-paper-v1
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_sel_v3: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.05
14
+ do_eval: false
15
+ eval_strategy: "no"
16
+ eval_steps: 200
17
+ gradient_accumulation_steps: 16
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 5.0e-7
22
+ log_level: info
23
+ logging_steps: 20
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: 1
28
+ max_steps: 2000
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-v3-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 100
38
+ save_total_limit: 5
39
+ seed: 42
40
+ warmup_ratio: 0.10
41
+ warmup_steps: 200
42
+ max_grad_norm: 0.3
code/alignment-handbook/recipes/iter1/orpo-fixer-iter1.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-fixer-llama1b-griffith-v5
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_fixer_iter1: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 1.0
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 400
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-fixer-iter1
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter1/orpo-planner-iter1.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-planner-3B-griffith-v4
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_planner_iter1: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|im_start|>user\n' + messages['prompt'] + '<|im_end|>\n'}}{{'<|im_start|>assistant\n' + messages['completion'] + '<|im_end|>\n'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 1.0
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 16
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 2.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 4000
26
+ max_prompt_length: 3500
27
+ num_train_epochs: -1
28
+ max_steps: 200
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-planner-iter1
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 200
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter1/orpo-val-cond-collab-iter1.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-cond-llama1b-griffith-v5
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_validator_cond_iter1_collab: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 1.0
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 400
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-collab-iter1
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter1/orpo-val-cond-indep-iter1.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-cond-llama1b-griffith-v5
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_validator_cond_iter1_indep: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 1.0
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 400
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-indep-iter1
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter1/orpo-val-sel-collab-iter1.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-sel-llama1b-griffith-v5
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_validator_sel_iter1_collab: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 1.0
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 400
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-collab-iter1
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter1/orpo-val-sel-indep-iter1.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/sft-validator-sel-llama1b-griffith-v5
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_validator_sel_iter1_indep: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 1.0
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 400
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-indep-iter1
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 400
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 50
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter2-paper/orpo-val-cond-collab-iter2-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-collab-paper
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_cond_paper_iter2_collab: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.1
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: 2
28
+ max_steps: 100
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-iter2-collab-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 300
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 30
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter2-paper/orpo-val-cond-indep-iter2-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-indep-paper
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_cond_paper_iter2_indep: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.1
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 300
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-cond-iter2-indep-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 300
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 30
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter2-paper/orpo-val-sel-collab-iter2-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-collab-paper
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_sel_paper_iter2_collab: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.1
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: 2
28
+ max_steps: 200
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-iter2-collab-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 300
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 30
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/iter2-paper/orpo-val-sel-indep-iter2-paper.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_name_or_path: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-indep-paper
2
+ torch_dtype: bfloat16
3
+ use_flash_attention_2: false
4
+ dataset_mixer:
5
+ /weka/s225250685/mats-tist/data/hf_orpo_val_sel_paper_iter2_indep: 1.0
6
+ dataset_splits:
7
+ - train_dpo
8
+ - test_dpo
9
+ preprocessing_num_workers: 12
10
+ chat_template: "{{'<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n' + messages['prompt'] + '<|eot_id|>'}}{{'<|start_header_id|>assistant<|end_header_id|>\n\n' + messages['completion'] + '<|eot_id|>'}}"
11
+ report_to: ["tensorboard"]
12
+ bf16: true
13
+ beta: 0.1
14
+ do_eval: true
15
+ eval_strategy: "steps"
16
+ eval_steps: 100
17
+ gradient_accumulation_steps: 8
18
+ gradient_checkpointing: true
19
+ gradient_checkpointing_kwargs:
20
+ use_reentrant: False
21
+ learning_rate: 8.0e-6
22
+ log_level: info
23
+ logging_steps: 10
24
+ lr_scheduler_type: inverse_sqrt
25
+ max_length: 3000
26
+ max_prompt_length: 2700
27
+ num_train_epochs: -1
28
+ max_steps: 300
29
+ optim: adamw_torch
30
+ output_dir: /weka/s225250685/mats-tist/alignment-handbook/output/orpo-val-sel-iter2-indep-paper
31
+ overwrite_output_dir: true
32
+ per_device_train_batch_size: 1
33
+ per_device_eval_batch_size: 1
34
+ push_to_hub: false
35
+ remove_unused_columns: false
36
+ save_strategy: "steps"
37
+ save_steps: 300
38
+ save_total_limit: 1
39
+ seed: 42
40
+ warmup_ratio: 0.1
41
+ warmup_steps: 30
42
+ max_grad_norm: 0.5
code/alignment-handbook/recipes/llama-1b-bird/fixed-fft.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model arguments:
2
+ model_name_or_path: /home/datht/huggingface/meta-llama/Llama-3.2-1B-Instruct
3
+ torch_dtype: bfloat16
4
+ use_flash_attention_2: true
5
+ response_template: "<|start_header_id|>assistant<|end_header_id|>"
6
+
7
+ # Data training arguments
8
+ dataset_mixer:
9
+ /home/datht/codes/data/multi-agents/fixed/sft-fixed-bird_with_evidence: 1
10
+ dataset_splits:
11
+ - train
12
+ - test
13
+ preprocessing_num_workers: 24
14
+ chat_template: "{{'<|start_header_id|>user<|end_header_id|>\n' + messages['prompt'] + '<|eot_id|>\n'}}{{'<|start_header_id|>assistant<|end_header_id|>\n' + messages['completion'] + '<|eot_id|>\n'}}"
15
+
16
+ # SFT trainer config
17
+ bf16: true
18
+ do_eval: false
19
+ evaluation_strategy: "no"
20
+ gradient_accumulation_steps: 64
21
+ gradient_checkpointing: true
22
+ hub_strategy: every_save
23
+ learning_rate: 2.0e-05
24
+ log_level: info
25
+ logging_steps: 5
26
+ logging_strategy: steps
27
+ lr_scheduler_type: cosine
28
+ max_seq_length: 4096
29
+ max_steps: -1
30
+ num_train_epochs: 4
31
+ output_dir: output/llama-1b-bird-fixed-fft
32
+ overwrite_output_dir: true
33
+ per_device_eval_batch_size: 2
34
+ per_device_train_batch_size: 1
35
+ push_to_hub: false
36
+ remove_unused_columns: true
37
+ report_to:
38
+ - tensorboard
39
+ save_strategy: "no"
40
+ save_total_limit: 1
41
+ seed: 42
42
+ tf32: true
code/alignment-handbook/recipes/llama-1b-bird/llama-3-bird-planner-fft.yaml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model arguments:
2
+ model_name_or_path: /home/datht/huggingface/meta-llama/Llama-3.2-1B-Instruct
3
+ model_revision: main
4
+ torch_dtype: bfloat16
5
+ use_flash_attention_2: true
6
+ response_template: "<|start_header_id|>assistant<|end_header_id|>"
7
+
8
+ # Data training arguments
9
+ dataset_mixer:
10
+ /home/datht/codes/data/multi-agents/planner/sft-gpt-4o-mini-planner_combine_with_true_sql_bird_062024_with_evidence_train/: 1.0
11
+ dataset_splits:
12
+ - train
13
+ - test
14
+ preprocessing_num_workers: 24
15
+ chat_template: "{{'<|start_header_id|>user<|end_header_id|>\n' + messages['prompt'] + '<|eot_id|>\n'}}{{'<|start_header_id|>assistant<|end_header_id|>\n' + messages['completion'] + '<|eot_id|>\n'}}"
16
+
17
+ # SFT trainer config
18
+ bf16: true
19
+ do_eval: true
20
+ evaluation_strategy: "no"
21
+ gradient_accumulation_steps: 32
22
+ gradient_checkpointing: true
23
+ hub_model_id: griffith-bigdata/llama-1b-bird-planner-fft
24
+ hub_strategy: every_save
25
+ learning_rate: 2.0e-05
26
+ log_level: info
27
+ logging_steps: 5
28
+ logging_strategy: steps
29
+ lr_scheduler_type: cosine
30
+ max_seq_length: 8192
31
+ max_steps: -1
32
+ num_train_epochs: 4
33
+ output_dir: output/llama-1b-bird-planner-fft
34
+ overwrite_output_dir: true
35
+ per_device_eval_batch_size: 4
36
+ per_device_train_batch_size: 2
37
+ push_to_hub: false
38
+ remove_unused_columns: true
39
+ report_to:
40
+ - tensorboard
41
+ save_strategy: "no"
42
+ save_total_limit: 1
43
+ seed: 42
44
+ tf32: true