Skip to content

'unsloth/llava-v1.6-mistral-7b-hf' model inference ValueError: Image features and image tokens do not match: tokens: 1175, features 1176 #2225

Closed

Description

@alessiodecastro

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

Image

Originally posted by @alessiodecastro in #1847

Activity

  1. 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
  2. joydeb28 commented on Apr 29, 2025

    @joydeb28

    same issue with pixtra-12b. Any idea to solve it?

  3. pritamdeka commented on Apr 29, 2025

    @pritamdeka

    @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.

  4. mmathew23 commented on May 2, 2025

    @mmathew23
    Contributor

    @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,

    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.

  5. self-assigned this
    on Oct 8, 2026
  6. danielhanchen commented on Oct 9, 2026

    @danielhanchen
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions