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_replacements.py

Daniel Han1013ab5891ec
diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.py
index 5da57c44bfc..4d7a4dbe09a 100644
--- a/unsloth/models/rl_replacements.py
+++ b/unsloth/models/rl_replacements.py
@@ -116,6 +116,8 @@ def sft_trainer_compute_loss(function_name, function):
function = inspect.getsource(_sft_trainer_compute_loss)
function = function.replace("def _sft_trainer_compute_loss", "def compute_loss")
+ function = function.split("\n")
+ function = "\n".join(" "*4+x for x in function)
return function
pass
RL_FUNCTIONS["sft_trainer"].append(sft_trainer_compute_loss)