You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'unsloth/llava-v1.6-mistral-7b-hf' model inference ValueError: Image features and image tokens do not match: tokens: 1175, features 1176 #2225
Thanks @shimmyshimmer the old issue seems fixed. But now I get this new error: "ValueError: Image features and image tokens do not match: tokens: 1175, features 1176"
Looks similar to this: huggingface/transformers#36002 and they solved by updating the model. The fix is the processor_config.json file. Let me know if I need to open a new issue with it. Thanks
changed the title [-]Llava-Next - ValueError: Image features and image tokens do not match: tokens: 1175, features 1176[/-][+]'unsloth/llava-v1.6-mistral-7b-hf' model inference ValueError: Image features and image tokens do not match: tokens: 1175, features 1176[/+]on Mar 28, 2025
@pritamdeka@joydeb28 Could you share the unsloth example where you see this error? Usually if this happens there are examples in the dataset that are longer than max seq len after you tokenize the image and text.
@alessiodecastro a workaround is the set tokenizer.num_additional_image_tokens = 1 before training.
@shimmyshimmer alessiodecastro's error is a missing value in the processor config.
unsloth/llava-1.5-7b-hf and unsloth/llava-v1.6-mistral-7b-hf are missing an attribute in the processor_config.json: "num_additional_image_tokens": 1,
Fixed! Sorry on the delay. The unsloth/llava-v1.6-mistral-7b-hf and unsloth/llava-1.5-7b-hf processors were saved without num_additional_image_tokens, so each image got one placeholder token too few for the CLIP vision tower and both inference and training raised Image features and image tokens do not match. #13091 now sets it to 1 at load time whenever a LLaVA processor has it at 0 with a CLIP vision tower, so these checkpoints and any fine-tunes saved from them work without the tokenizer.num_additional_image_tokens = 1 workaround.
To update: uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir (if it's not in the current release yet it'll be in the next one). Reopen if it still happens.
Activity
[-]Llava-Next - ValueError: Image features and image tokens do not match: tokens: 1175, features 1176[/-][+]'unsloth/llava-v1.6-mistral-7b-hf' model inference ValueError: Image features and image tokens do not match: tokens: 1175, features 1176[/+]joydeb28 commentedon Apr 29, 2025
same issue with pixtra-12b. Any idea to solve it?
pritamdeka commentedon Apr 29, 2025
@joydeb28 I had a similar problem few days ago. If you are using the Unsloth Pixtral model, it will give you that error but if you use the Mistral Community Pixtral model there is no such error. This is the model I am talking about https://huggingface.co/mistral-community/pixtral-12b . Just make sure to follow the prompt format they have given. Hope this helps.
mmathew23 commentedon May 2, 2025
@pritamdeka @joydeb28 Could you share the unsloth example where you see this error? Usually if this happens there are examples in the dataset that are longer than max seq len after you tokenize the image and text.
@alessiodecastro a workaround is the set
tokenizer.num_additional_image_tokens = 1before training.@shimmyshimmer alessiodecastro's error is a missing value in the processor config.
unsloth/llava-1.5-7b-hf and unsloth/llava-v1.6-mistral-7b-hf are missing an attribute in the processor_config.json:
"num_additional_image_tokens": 1,The official llava-hf uploads have it. https://huggingface.co/llava-hf/llava-v1.6-mistral-7b-hf/blob/main/processor_config.json
if you can add this the workaround won't be needed.
danielhanchen commentedon Oct 9, 2026
Fixed! Sorry on the delay. The
unsloth/llava-v1.6-mistral-7b-hfandunsloth/llava-1.5-7b-hfprocessors were saved withoutnum_additional_image_tokens, so each image got one placeholder token too few for the CLIP vision tower and both inference and training raisedImage features and image tokens do not match. #13091 now sets it to 1 at load time whenever a LLaVA processor has it at 0 with a CLIP vision tower, so these checkpoints and any fine-tunes saved from them work without thetokenizer.num_additional_image_tokens = 1workaround.To update:
uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir(if it's not in the current release yet it'll be in the next one). Reopen if it still happens.