From 34c66f0327c1ebed39b73d76d2251ca270b7b13c Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Thu, 17 Jul 2025 06:25:21 -0700 Subject: [PATCH] Update rl_replacements.py --- unsloth/models/rl_replacements.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.py index eca236cac9..760bb336b1 100644 --- a/unsloth/models/rl_replacements.py +++ b/unsloth/models/rl_replacements.py @@ -256,11 +256,10 @@ def grpo_trainer__generate_and_score_completions(function_name, function): replace_part, spacing = found[0] removed_comments = re.sub(r"\#[^\n]{1,}", "", replace_part) splits = removed_comments.split("\n") - if sum(re.search(rf"^{spacing}[^\s]", x) is not None for x in splits) == 2 and \ - len(spacing) == 8: - replace_part + if sum(re.search(rf"^{spacing}[^\s]", x) is not None for x in splits) == 2 and len(spacing) == 8: - new_replacement = spacing + """if self.max_prompt_length is not None: + new_replacement = spacing + \ + """if self.max_prompt_length is not None: # If max_prompt_length is set, we trim the prompt to keep only the last `max_prompt_length` tokens. # Then we decode those tokens back into text. We manually remove leading pad tokens from the decoded text, # because we can't use `skip_special_tokens=True` (some special tokens are still needed for generation). @@ -282,7 +281,7 @@ def grpo_trainer__generate_and_score_completions(function_name, function): # Generate completions using either vLLM or regular generation if self.use_vllm:""" - function = function.replace(replace_part, new_replacement) + function = function.replace(replace_part, new_replacement) pass return function pass