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

Daniel Han0288ca825fe1
diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py
index 78494f8efa7..5f904ad7ddb 100644
--- a/unsloth/tokenizer_utils.py
+++ b/unsloth/tokenizer_utils.py
@@ -917,7 +917,7 @@ def patch_sft_trainer_tokenizer():
return
all_imports = dir(trl.trainer.sft_trainer)
- for function_name, replacer in (
+ for (function_name, replacer,) in (
("_prepare_non_packed_dataloader", "def tokenize(element):",),
("_prepare_dataset", None,),
# ("_prepare_packed_dataloader", "if dataset_text_field is not None",),
@@ -962,12 +962,12 @@ def patch_sft_trainer_tokenizer():
else:
function = function.replace(replacer, check_text + replacer)
pass
+ print(function)
x = [x for x in all_imports if x in function]
exec(f"from trl.trainer.sft_trainer import ({','.join(x)})", locals())
exec(function, locals(), globals())
exec(f"trl.trainer.sft_trainer.SFTTrainer.{function_name} = {function_name}", globals())
- print("Patched")
pass
# Patch train with fix_untrained_tokens