Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Update rl.py

Daniel Han780e02656b5e
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index 149846ca23c..2facd3ccb05 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}",