whisper icon indicating copy to clipboard operation
whisper copied to clipboard

Fix/torch load weights only warning

Open Ultr4Dev opened this issue 1 year ago • 2 comments
trafficstars

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

Ultr4Dev avatar Aug 13 '24 01:08 Ultr4Dev

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 https://github.com/pytorch/pytorch/issues/52181

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

glangford avatar Aug 13 '24 13:08 glangford

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!

Ultr4Dev avatar Aug 20 '24 10:08 Ultr4Dev

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

vblazenka avatar Nov 09 '24 09:11 vblazenka

thanks! #2451 fixed this

jongwook avatar Jun 26 '25 00:06 jongwook