Skip to content
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

Fix/torch load weights only warning #2301

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Ultr4Dev
Copy link

@Ultr4Dev Ultr4Dev commented Aug 13, 2024

This pull request updates the load_model function of the Whisper ASR model, enhancing documentation and incorporating a weights_only parameter for more flexible model weight handling. The update addresses a FutureWarning regarding the use of torch.load with weights_only=False, recommending a safer loading method to mitigate security risks associated with loading untrusted model data. This change is designed to improve both the functionality and security of the model loading process.

Relevant info Untrusted models

@glangford
Copy link

glangford commented Aug 13, 2024

Just to add to the documentation of this issue, the default for torch.load() is weights_only=False back to at least 2.0. So the default behaviour is that torch.load

... uses (the) pickle module implicitly, which is known to be insecure. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling

(from https://pytorch.org/docs/2.4/generated/torch.load.html#torch-load)

Related
pytorch/pytorch#52181

HuggingFace on Pickle
https://huggingface.co/docs/hub/en/security-pickle

@Ultr4Dev
Copy link
Author

Just to add to the documentation of this issue, the default for torch.load() is weights_only=False back to at least 2.0. So the default behaviour is that torch.load

... uses (the) pickle module implicitly, which is known to be insecure. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling

(from https://pytorch.org/docs/2.4/generated/torch.load.html#torch-load)

Related pytorch/pytorch#52181

HuggingFace on Pickle https://huggingface.co/docs/hub/en/security-pickle

Thank you for the addition!

@vblazenka
Copy link

Hey @Ultr4Dev thanks for creating this PR. Do you plan to move it forward? 🙏

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