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

Daniel Han-Chenfaa66d209d85
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 69e570dc9a5..8864ebab4b2 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -148,7 +148,7 @@ def patch_tokenizer(model, tokenizer):
model.config.update({"unsloth_version" : __version__})
if not hasattr(tokenizer, "pad_token") or tokenizer.pad_token is None:
# Fixes https://github.com/unslothai/unsloth/issues/5
- if hasattr(tokenizer, "unk_token"):
+ if hasattr(tokenizer, "unk_token") and tokenizer.unk_token is not None:
tokenizer.add_special_tokens({"pad_token" : tokenizer.unk_token})
tokenizer.pad_token = tokenizer.unk_token
else: