23f2002275 commited on
Commit ·
e85f766
1
Parent(s): 9c646f0
fix(notebook): correct reward weights, fix compose_reward_single signature + tuple unpack, add model hint
Browse files- notebooks/fathom_train.ipynb +34 -8
notebooks/fathom_train.ipynb
CHANGED
|
@@ -87,16 +87,39 @@
|
|
| 87 |
"source": [
|
| 88 |
"from rewards.compose import compose_reward_single\n",
|
| 89 |
"import types\n",
|
| 90 |
-
"cfg = types.SimpleNamespace(alpha=0.2, weights=types.SimpleNamespace(correctness=0.75, token_budget=0.2, recursion_efficiency=0.05), token_budget_variant='capped_linear', answer_regex='<answer>(.*?)</answer>')\n",
|
| 91 |
"\n",
|
| 92 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
"format_only_wrong = '<answer>Berlin</answer>'\n",
|
| 94 |
-
"no_format
|
| 95 |
-
"padded
|
| 96 |
"\n",
|
| 97 |
-
"for label, completion in [
|
| 98 |
-
"
|
| 99 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
]
|
| 101 |
},
|
| 102 |
{
|
|
@@ -136,7 +159,10 @@
|
|
| 136 |
"# with initialize(config_path='configs', version_base='1.3'):\n",
|
| 137 |
"# cfg = compose(config_name='config', overrides=['model=qwen_1_5b','train=grpo','train.max_steps=50'])\n",
|
| 138 |
"# m, t = load_model_and_tokenizer(cfg)\n",
|
| 139 |
-
"# run_grpo(cfg, m, t, make_reward_fn(cfg.reward), 'https://Pratham-math-fathom-env.hf.space')"
|
|
|
|
|
|
|
|
|
|
| 140 |
]
|
| 141 |
},
|
| 142 |
{
|
|
|
|
| 87 |
"source": [
|
| 88 |
"from rewards.compose import compose_reward_single\n",
|
| 89 |
"import types\n",
|
|
|
|
| 90 |
"\n",
|
| 91 |
+
"# Weights match configs/reward/v1.yaml exactly (REW-02 v3)\n",
|
| 92 |
+
"cfg = types.SimpleNamespace(\n",
|
| 93 |
+
" alpha=0.2,\n",
|
| 94 |
+
" weights=types.SimpleNamespace(\n",
|
| 95 |
+
" correctness=0.70,\n",
|
| 96 |
+
" token_budget=0.15,\n",
|
| 97 |
+
" recursion_efficiency=0.15\n",
|
| 98 |
+
" ),\n",
|
| 99 |
+
" token_budget_variant='capped_linear',\n",
|
| 100 |
+
" answer_regex='<answer>(.*?)</answer>'\n",
|
| 101 |
+
")\n",
|
| 102 |
+
"\n",
|
| 103 |
+
"good = '<answer>Paris</answer>'\n",
|
| 104 |
"format_only_wrong = '<answer>Berlin</answer>'\n",
|
| 105 |
+
"no_format = 'Paris'\n",
|
| 106 |
+
"padded = '<answer>Paris</answer>' + ' '*5000\n",
|
| 107 |
"\n",
|
| 108 |
+
"for label, completion in [\n",
|
| 109 |
+
" ('correct', good),\n",
|
| 110 |
+
" ('wrong-but-formatted', format_only_wrong),\n",
|
| 111 |
+
" ('no-format', no_format),\n",
|
| 112 |
+
" ('length-padded', padded),\n",
|
| 113 |
+
"]:\n",
|
| 114 |
+
" # compose_reward_single returns (composite_score, metrics_dict)\n",
|
| 115 |
+
" score, metrics = compose_reward_single(\n",
|
| 116 |
+
" completion=completion,\n",
|
| 117 |
+
" gold_answer='Paris',\n",
|
| 118 |
+
" prompt_token_count=512,\n",
|
| 119 |
+
" cfg_reward=cfg,\n",
|
| 120 |
+
" llm_call_count=0,\n",
|
| 121 |
+
" )\n",
|
| 122 |
+
" print(f'{label:25s} -> reward = {score:.4f} (correctness={metrics[\"correctness\"]:.2f})')"
|
| 123 |
]
|
| 124 |
},
|
| 125 |
{
|
|
|
|
| 159 |
"# with initialize(config_path='configs', version_base='1.3'):\n",
|
| 160 |
"# cfg = compose(config_name='config', overrides=['model=qwen_1_5b','train=grpo','train.max_steps=50'])\n",
|
| 161 |
"# m, t = load_model_and_tokenizer(cfg)\n",
|
| 162 |
+
"# run_grpo(cfg, m, t, make_reward_fn(cfg.reward), 'https://Pratham-math-fathom-env.hf.space')\n",
|
| 163 |
+
"#\n",
|
| 164 |
+
"# NOTE: Default config uses qwen_1_5b (1.5B Qwen2.5-Coder-Instruct-bnb-4bit).\n",
|
| 165 |
+
"# For a faster smoke run on smaller GPU, override with model=qwen_0_5b_smoke."
|
| 166 |
]
|
| 167 |
},
|
| 168 |
{
|