From 9e4b1ef70c710811c97cb599d3689562e6b2112a Mon Sep 17 00:00:00 2001 From: Mathew Mathew Date: Fri, 2 May 2025 21:40:15 -0500 Subject: [PATCH] the pixtral vision notebook fails during inferenc with unused kwargs token_type_ids. This fixes the error --- unsloth/models/vision.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py index d212c224be..cadfed9430 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