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 Han1623c3242bb0
diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py
index 6e9c061fad7..d7af61a0908 100644
--- a/unsloth/tokenizer_utils.py
+++ b/unsloth/tokenizer_utils.py
@@ -914,6 +914,7 @@ def patch_sft_trainer_tokenizer():
check_text = \
"\n"\
+ "if 'tokenizer' not in locals(): tokenizer = processing_class\n"\
"test_text = dataset[0][dataset_text_field] if (formatting_func is not None and dataset_text_field is None) else formatting_func(dataset[0])[0]\n"\
"chat_template = getattr(tokenizer, 'chat_template', None)\n"\
"chat_template = '' if chat_template is None else chat_template\n"\