Skip to main content

Sharing and export

Save local folders with save_pretrained, publish with push_to_hub, and export when a production runtime needs ONNX, ExecuTorch or another format.

Adapted for this playbook from the πŸ€— Transformers documentation by Hugging Face. Official page: https://huggingface.co/docs/transformers/model_sharing. Images Β© Hugging Face (documentation-images) unless noted. This is not a substitute for the upstream docs β€” verify against the current version.

Covers Hugging Face pages: model_sharing, serialization

Creating a model repository on the Hub β€” Source: Hugging Face

Source: Hugging Face documentation images.

Save locally​

model.save_pretrained("./my-model")
tokenizer.save_pretrained("./my-model")

Push to the Hub​

model.push_to_hub("org/my-model")
tokenizer.push_to_hub("org/my-model")

Authenticate with huggingface-cli login or HF_TOKEN. Add a model card (README.md) covering intended use, limitations and evaluation.

Uploading files to a Hub repo β€” Source: Hugging Face

Source: Hugging Face documentation images.

Exporting for production​

Transformers documents exporters and serialisation paths for moving beyond eager PyTorch β€” see Exporting to production and the Exporters guide. Typical targets:

  • ONNX / Optimum for portable graphs
  • Runtime-specific formats (TensorRT, ExecuTorch, llama.cpp GGUF via conversion tools)
  • Serve with engines that load HF definitions directly (vLLM)

Enterprise checklist​

  • Licence compatible with redistribution
  • Model card and eval evidence attached
  • Secrets and training data not accidentally uploaded
  • Revision tag created for the release

Discussion

Comments​

Share feedback or questions about this page. No account required.

Loading comments…