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

Daniel Hanb28b7fa364fe
diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py
index f0d5a0930cc..180c2cefec3 100644
--- a/unsloth/models/vision.py
+++ b/unsloth/models/vision.py
@@ -275,10 +275,19 @@ class FastBaseModel:
padding_side = "right",
token = token,
)
- # Add padding side as well
if hasattr(tokenizer, "tokenizer"):
- tokenizer.tokenizer.padding_side = "right"
-
+ __tokenizer = tokenizer.tokenizer
+ # Add padding side as well
+ __tokenizer.padding_side = "right"
+ # Check bos, eos, pad, unk tokens
+ tokens = ["bos_token", "eos_toke", "pad_toke", "unk_toke"]
+ for token in tokens:
+ if hasattr(__tokenizer, token) and not hasattr(tokenizer, token):
+ exec(f"tokenizer.{token} = __tokenizer.{token}")
+ exec(f"tokenizer.{token}_id = __tokenizer.{token}_id")
+ pass
+ pass
+ pass
model, tokenizer = patch_tokenizer(model, tokenizer)
model = post_patch_loss_function(model)
# Fix other stuff like BnB compute data types