Safetensors documentation

将权重转换为 safetensors

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.5.0-rc.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

将权重转换为 safetensors

PyTorch 模型权重通常使用 Python 的 pickle 工具保存和存储为 .bin 文件。为了以更安全、更可靠的 safetensor 格式保存和存储模型权重,我们建议将权重转换为 .safetensors 格式。

转换模型权重最简单的方法是使用 Convert Space,前提是你的模型权重已经存储在 Hub 上。Convert Space 会下载 pickle 格式的权重,将其转换,并创建一个 Pull Request,以将新转换的 .safetensors 文件上传到你的仓库。

对于更大的模型,由于 Space 的资源正忙于转换其他模型,其速度可能会稍慢。你也可以尝试在本地运行 convert.py 脚本(Space 运行的正是该脚本)来转换你的权重。

如果在使用该 Space 时遇到任何问题,请随时联系 @Narsil。

Update on GitHub