From 6c52a215485eb7164b6e6b7fd63200bfb5eede9e Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sat, 15 Feb 2025 18:03:57 -0800 Subject: [PATCH] Update rl.py --- unsloth/models/rl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py index 149846ca23..2facd3ccb0 100644 --- a/unsloth/models/rl.py +++ b/unsloth/models/rl.py @@ -464,6 +464,9 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"): RLTrainer_source = RLTrainer_source.replace(__RLTrainer_doc__, "", 1) pass + # Remove multiple newlines + RLTrainer_source = re.sub(r"[\n]{3,}", "\n", RLTrainer_source) + # Create new function created_module = create_new_function( f"Unsloth{RLTrainer_name}",