]> khamidou — GitHub mirrors - safetensors.git/commitdiff
[docs] Safetensors format (#248)
authorMishig <dmishig@gmail.com>
Mon, 22 May 2023 14:00:54 +0000 (16:00 +0200)
committerGitHub <noreply@github.com>
Mon, 22 May 2023 14:00:54 +0000 (16:00 +0200)
* [docs] Safetensors format

* More text

* Add format illustration

docs/source/index.mdx

index 7e6089c8f2b2490b004f0c42fe04f33f66c42639..190725008bc6d6c83ea1fe2db8e02849080f9131 100644 (file)
@@ -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:
+
+<div class="flex justify-center">
+    <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/safetensors/safetensors-format.svg"/>
+</div>
+
 ## 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)