Skip to content

Conversation

eaidova
Copy link
Contributor

@eaidova eaidova commented May 26, 2025

General huggingface recommendation is to use trust_remote_code only if it is necessary, andthe model requires it, as potentially remote code may try to run arbitrary insecure code.
Besides that some models (e.g. phi-3) may have outdated remote code version kept for backward compatibility and non-maintained by its authors as the model is already integrated into transformers.

Suggestion is try to load model without remote code and only if it is failed use remote code for resolve such issues

CVS-168307

@eaidova eaidova requested a review from andreyanufr May 26, 2025 15:29
@github-actions github-actions bot added the category: WWB PR changes WWB label May 26, 2025
model_id, device=device, ov_config=ov_config, safety_checker=None,
)
except ValueError:
config = AutoConfig.from_pretrained(model_id, trust_remote_code=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andreyanufr I do not know if this code branch can be reached at all for diffusers models, but loading config in such way does not work for diffusion models:

>>> from transformers import AutoConfig
>>> config = AutoConfig.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", trust_remote_code=True)

transformers/models/auto/configuration_auto.py", line 1151, in from_pretrained
    raise ValueError(
ValueError: Unrecognized model in stable-diffusion-v1-5/stable-diffusion-v1-5. Should have a `model_type` key in its config.json

That is why I removed this line.

@eaidova eaidova merged commit 662c6b9 into openvinotoolkit:master May 28, 2025
66 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jun 17, 2025
This fixes a regression introduced in
#2270

Ticket: 169203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: WWB PR changes WWB
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants