diff --git a/docs/source/convert-weights.md b/docs/source/convert-weights.md index a3594c6e..65c42f0d 100644 --- a/docs/source/convert-weights.md +++ b/docs/source/convert-weights.md @@ -2,22 +2,12 @@ PyTorch model weights are commonly saved and stored as `.bin` files with Python's [`pickle`](https://docs.python.org/3/library/pickle.html) utility. To save and store your model weights in the more secure `safetensor` format, we recommend converting your weights to `.safetensors`. -The easiest way to convert your model weights is to use the [Convert Space](https://huggingface.co/spaces/diffusers/convert), given your model weights are already stored on the Hub. The Convert Space downloads the pickled weights, converts them, and opens a Pull Request to upload the newly converted `.safetensors` file to your repository. Merge the Pull Request to upload the weights, but if you can't wait to try it out, you can also use the `.safetensors` immediately by specifying the reference to the Pull Request in the revision parameter: +The easiest way to convert your model weights is to use the [Convert Space](https://huggingface.co/spaces/diffusers/convert), given your model weights are already stored on the Hub. The Convert Space downloads the pickled weights, converts them, and opens a Pull Request to upload the newly converted `.safetensors` file to your repository. -```py -from transformers import AutoModel + -model = AutoModel.from_pretrained( - "my-safe-model", revision="refs/pr/1", use_safetensors=True -) -``` +For larger models, the Space may be a bit slower because its resources are tied up in converting other models. You can also try running the [convert.py](https://github.com/huggingface/safetensors/blob/main/bindings/python/convert.py) script (this is what the Space is running) locally to convert your weights. -Another way to convert your `.bin` files is to use the [`~safetensors.torch.save_model`] function: +Feel free to ping [@Narsil](https://huggingface.co/Narsil) for any issues with the Space. -```py -from transformers import AutoModel -from safetensors.torch import save_model - -unsafe_model = AutoModel.from_pretrained("my-unsafe-model") -save_model(unsafe_model, "model.safetensors") -``` +