-
Notifications
You must be signed in to change notification settings - Fork 284
[wwb]: load transformers model first, then only trust_remote_code #2270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eaidova
merged 7 commits into
openvinotoolkit:master
from
eaidova:ea/wwb_trust_remote_code_prior
May 28, 2025
Merged
[wwb]: load transformers model first, then only trust_remote_code #2270
eaidova
merged 7 commits into
openvinotoolkit:master
from
eaidova:ea/wwb_trust_remote_code_prior
May 28, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eaidova
commented
May 28, 2025
eaidova
commented
May 28, 2025
model_id, device=device, ov_config=ov_config, safety_checker=None, | ||
) | ||
except ValueError: | ||
config = AutoConfig.from_pretrained(model_id, trust_remote_code=True) |
There was a problem hiding this comment.
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.
andreyanufr
reviewed
May 28, 2025
Co-authored-by: andreyanufr <[email protected]>
andreyanufr
approved these changes
May 28, 2025
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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