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.

the pixtral vision notebook fails during inferenc with unused kwargs token_type_ids. This fixes the error

Mathew Mathewbbe5e2a22186
diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py
index d212c224be5..cadfed94300 100644
--- a/unsloth/models/vision.py
+++ b/unsloth/models/vision.py
@@ -112,6 +112,11 @@ def unsloth_base_fast_generate(
arch = self.config.architectures[0]
# Remove token_type_ids - WRONG for Gemma 3 since bidirectional attention
+ if hasattr(self, "generate") and hasattr(self, "forward"):
+ # did not combine with below since self might not have model
+ keys = inspect.signature(self.forward).parameters.keys()
+ if "token_type_ids" not in keys:
+ kwargs.pop("token_type_ids", None)
# kwargs.pop("token_type_ids", None)
# VLMs do not allow logits_to_keep