Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nb/HuggingFace Course-Llama3.1_(8B)-GRPO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -693,14 +693,14 @@
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"^<reasoning>\\n.*?\\n</reasoning>\\n<answer>\\n.*?\\n</answer>\\n$\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def soft_format_reward_func(completions, **kwargs) -> list[float]:\n",
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"<reasoning>.*?</reasoning>\\s*<answer>.*?</answer>\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def count_xml(text) -> float:\n",
Expand Down
4 changes: 2 additions & 2 deletions nb/HuggingFace Course-Mistral_v0.3_(7B)-GRPO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,14 @@
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"^<reasoning>\\n.*?\\n</reasoning>\\n<answer>\\n.*?\\n</answer>\\n$\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def soft_format_reward_func(completions, **kwargs) -> list[float]:\n",
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"<reasoning>.*?</reasoning>\\s*<answer>.*?</answer>\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def count_xml(text) -> float:\n",
Expand Down
4 changes: 2 additions & 2 deletions nb/HuggingFace Course-Phi_4_(14B)-GRPO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,14 @@
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"^<reasoning>\\n.*?\\n</reasoning>\\n<answer>\\n.*?\\n</answer>\\n$\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def soft_format_reward_func(completions, **kwargs) -> list[float]:\n",
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"<reasoning>.*?</reasoning>\\s*<answer>.*?</answer>\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def count_xml(text) -> float:\n",
Expand Down
4 changes: 2 additions & 2 deletions nb/HuggingFace Course-Qwen2.5_(3B)-GRPO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -834,14 +834,14 @@
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"^<reasoning>\\n.*?\\n</reasoning>\\n<answer>\\n.*?\\n</answer>\\n$\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def soft_format_reward_func(completions, **kwargs) -> list[float]:\n",
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"<reasoning>.*?</reasoning>\\s*<answer>.*?</answer>\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def count_xml(text) -> float:\n",
Expand Down
228 changes: 120 additions & 108 deletions nb/Kaggle-Llama3.1_(8B)-GRPO.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions nb/Kaggle-Mistral_v0.3_(7B)-GRPO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,14 @@
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"^<reasoning>\\n.*?\\n</reasoning>\\n<answer>\\n.*?\\n</answer>\\n$\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def soft_format_reward_func(completions, **kwargs) -> list[float]:\n",
" \"\"\"Reward function that checks if the completion has a specific format.\"\"\"\n",
" pattern = r\"<reasoning>.*?</reasoning>\\s*<answer>.*?</answer>\"\n",
" responses = [completion[0][\"content\"] for completion in completions]\n",
" matches = [re.match(pattern, r) for r in responses]\n",
" matches = [re.match(pattern, r, flags=re.DOTALL) for r in responses]\n",
" return [0.5 if match else 0.0 for match in matches]\n",
"\n",
"def count_xml(text) -> float:\n",
Expand Down
Loading