Skip to content

Conversation

@openvino-dev-samples
Copy link
Contributor

@openvino-dev-samples openvino-dev-samples commented Aug 7, 2025

@openvino-dev-samples openvino-dev-samples changed the title add support for minicpm4v [OpenVINO]add support for minicpm4v Aug 7, 2025
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@openvino-dev-samples
Copy link
Contributor Author

openvino-dev-samples commented Aug 8, 2025

@IlyasMoutawwakil could help to take a look ?

@IlyasMoutawwakil
Copy link
Member

Thanks for the fix ! let's create a tiny random model with llama as the decoder to test this 🤗 tell me you need help with that !

@openvino-dev-samples
Copy link
Contributor Author

Thanks for the fix ! let's create a tiny random model with llama as the decoder to test this 🤗 tell me you need help with that !

But i guess we need merge this PR first ? otherwise test case will not work

@IlyasMoutawwakil
Copy link
Member

@openvino-dev-samples no need to merge it now, you can simply pin that PR in setup.py so that the tests would run with it 🤗
We will merge both PRs once everything works together.

@openvino-dev-samples
Copy link
Contributor Author

@openvino-dev-samples no need to merge it now, you can simply pin that PR in setup.py so that the tests would run with it 🤗 We will merge both PRs once everything works together.

Hi since minicpmv4 and minicpmv share a same model type, but different LLM. It is possible to add both of them in utils_tests.py ?

@IlyasMoutawwakil
Copy link
Member

@openvino-dev-samples yes, you can name it minicpmv4 in utils_tests.py

@IlyasMoutawwakil
Copy link
Member

IlyasMoutawwakil commented Aug 18, 2025

Hi @openvino-dev-samples it would be faster if you made sure the minicpmv4 tests pass locally, the ci is slow and shouldn't be used as a testing mechanism, only use it for validating when local tests are already passing.

@openvino-dev-samples
Copy link
Contributor Author

Hi @openvino-dev-samples it would be faster if you made sure the minicpmv4 tests pass locally, the ci is slow and shouldn't be used as a testing mechanism, only use it for validating when local tests are already passing.

Sorry for that, and i fully understand, but i always met connection issue in local test case, e.g

huggingface_hub.errors.HfHubHTTPError: 429 Client Error: Too Many Requests for url: https://huggingface.co/api/models/katuni4ka/tiny-random-qwen2.5-vl/tree/main?recursive=True&expand=False

@IlyasMoutawwakil
Copy link
Member

but i always met connection issue in local test case

you can target minicpmv tests specifically to avoid this issue with pytest -k "minicpmv"

@openvino-dev-samples openvino-dev-samples changed the title [OpenVINO]add support for minicpm4v [OpenVINO]add support for minicpmv4/4_5 Aug 27, 2025
"minicpm3": "katuni4ka/tiny-random-minicpm3",
"minicpmv": "katuni4ka/tiny-random-minicpmv-2_6",
"minicpmv4": "snake7gun/minicpm-v-4-tiny",
"minicpmv4_5": "snake7gun/tiny-minicpmv-4_5",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

158M model size, it makes sense to try to reduce the size

Copy link
Collaborator

@rkazants rkazants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add tests for inference to test generate() method and compare with transformers

@openvino-dev-samples
Copy link
Contributor Author

@IlyasMoutawwakil could you help to trigger CI, thanks

if isinstance(behavior, str) and not isinstance(behavior, MiniCPMVConfigBehavior):
behavior = MiniCPMVConfigBehavior(behavior)

model_mapping = {2.6: "llama", 4.0: "qwen2", 4.5: "qwen3"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use str for versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may i understand why?the version in model's config is a number:
https://huggingface.co/openbmb/MiniCPM-V-4_5/blob/main/config.json#L3

Copy link
Member

@IlyasMoutawwakil IlyasMoutawwakil Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah okay I see ! thanks for the clarification.
(it's generally a bad idea to use numbers for versions: 4.0 becomes 4 and 4.10 and 4.1 are the same version 😅)

if isinstance(behavior, str) and not isinstance(behavior, MiniCPMVConfigBehavior):
behavior = MiniCPMVConfigBehavior(behavior)

model_mapping = {2.6: "llama", 4.0: "qwen2", 4.5: "qwen3"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a bad idea to make decision about architecture based on model version in general.
I think you should parse class model object and use isinstance for inner objects to make decision.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, its a better approach in this case, but I dont know if we can access the modeling file at this stage.

Comment on lines +850 to +852
# skip the temporal_ids which makes the number of loop inconstant:
# https://huggingface.co/openbmb/MiniCPM-V-4_5/blob/main/resampler.py#L261
inputs.pop("temporal_ids", None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't quite understand. To me it degrades user experience that we make users to skip this parameter after preprocessing to have matched results with the reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will impact the user experience in some cases. I think its one of the limitation for torchscipt. I will try to find a better solution handle this parameter if possible.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants