From bc0688623d937b6c4c05814b7c1113c50ec74f90 Mon Sep 17 00:00:00 2001 From: Mishig Date: Mon, 22 May 2023 16:00:54 +0200 Subject: [PATCH] [docs] Safetensors format (#248) * [docs] Safetensors format * More text * Add format illustration --- docs/source/index.mdx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/source/index.mdx b/docs/source/index.mdx index 7e6089c..1907250 100644 --- a/docs/source/index.mdx +++ b/docs/source/index.mdx @@ -21,7 +21,9 @@ with conda: conda install -c huggingface safetensors ``` -## Load tensors +## Usage + +### Load tensors ```python from safetensors import safe_open @@ -44,7 +46,7 @@ with safe_open("model.safetensors", framework="pt", device=0) as f: tensor = tensor_slice[:, :hidden_dim] ``` -## Save tensors +### Save tensors ```python import torch @@ -57,6 +59,14 @@ tensors = { save_file(tensors, "model.safetensors") ``` +## Format + +Let's say you have safetensors file named `model.safetensors`, then `model.safetensors` will have the following internal format: + +
+ +
+ ## Featured Projects Safetensors is being used widely at leading AI enterprises, such as [Hugging Face](https://huggingface.co/), [EleutherAI](https://www.eleuther.ai/), and [StabilityAI](https://stability.ai/). Here is a non-exhaustive list of projects that are using safetensors: @@ -77,4 +87,4 @@ Safetensors is being used widely at leading AI enterprises, such as [Hugging Fac * [AIGC-Audio/AudioGPT](https://github.com/AIGC-Audio/AudioGPT) * [brycedrennan/imaginAIry](https://github.com/brycedrennan/imaginAIry) * [comfyanonymous/ComfyUI](https://github.com/comfyanonymous/ComfyUI) -* [LianjiaTech/BELLE](https://github.com/LianjiaTech/BELLE) \ No newline at end of file +* [LianjiaTech/BELLE](https://github.com/LianjiaTech/BELLE) -- 2.43.0