]> khamidou — GitHub mirrors - safetensors.git/commitdiff
Superseed #279 (#285)
authorNicolas Patry <patry.nicolas@protonmail.com>
Fri, 30 Jun 2023 08:32:00 +0000 (10:32 +0200)
committerGitHub <noreply@github.com>
Fri, 30 Jun 2023 08:32:00 +0000 (10:32 +0200)
* Update README.md

Add note about arbitrary JSON not allowed in __metadata__.

* Update README.md

Co-authored-by: Julien Chaumond <julien@huggingface.co>
* Update other readmes.

---------

Co-authored-by: by321 <by321@hotmail.com>
Co-authored-by: Julien Chaumond <julien@huggingface.co>
README.md
safetensors/README.md
safetensors/src/lib.rs

index 169c7ace69c9061e0b99400d0e9f60e3a290c3aa..697cef188758e489ada1b39bff19b6dfd5dd9e97 100644 (file)
--- a/README.md
+++ b/README.md
@@ -78,7 +78,7 @@ with safe_open("model.safetensors", framework="pt", device="cpu") as f:
 - 8 bytes: `N`, a u64 int, containing the size of the header
 - N bytes: a JSON utf-8 string representing the header.
   - The header is a dict like `{"TENSOR_NAME": {"dtype": "F16", "shape": [1, 16, 256], "data_offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}`, where offsets point to the tensor data relative to the beginning of the byte buffer, with `BEGIN` as the starting offset and `END` as the one-past offset (so total tensor byte size = `END - BEGIN`).
-  - A special key `__metadata__` is allowed to contain free form text-to-text map.
+  - A special key `__metadata__` is allowed to contain free form string-to-string map. Arbitrary JSON is not allowed, all values must be strings.
 - Rest of the file: byte-buffer.
 
 Notes:
index 169c7ace69c9061e0b99400d0e9f60e3a290c3aa..697cef188758e489ada1b39bff19b6dfd5dd9e97 100644 (file)
@@ -78,7 +78,7 @@ with safe_open("model.safetensors", framework="pt", device="cpu") as f:
 - 8 bytes: `N`, a u64 int, containing the size of the header
 - N bytes: a JSON utf-8 string representing the header.
   - The header is a dict like `{"TENSOR_NAME": {"dtype": "F16", "shape": [1, 16, 256], "data_offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}`, where offsets point to the tensor data relative to the beginning of the byte buffer, with `BEGIN` as the starting offset and `END` as the one-past offset (so total tensor byte size = `END - BEGIN`).
-  - A special key `__metadata__` is allowed to contain free form text-to-text map.
+  - A special key `__metadata__` is allowed to contain free form string-to-string map. Arbitrary JSON is not allowed, all values must be strings.
 - Rest of the file: byte-buffer.
 
 Notes:
index f3dcf867474adb178a1b795b47bf772f81832fc3..a66b1e7ab39d2e1c03824145a15d3d4a709d0b7a 100644 (file)
@@ -55,7 +55,7 @@
 //! - 8 bytes: `N`, a u64 int, containing the size of the header
 //! - N bytes: a JSON utf-8 string representing the header.
 //!   - The header is a dict like `{"TENSOR_NAME": {"dtype": "F16", "shape": [1, 16, 256], "data_offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}`, where offsets point to the tensor data relative to the beginning of the byte buffer, with `BEGIN` as the starting offset and `END` as the one-past offset (so total tensor byte size = `END - BEGIN`).
-//!   - A special key `__metadata__` is allowed to contain free form text-to-text map.
+//!   - A special key `__metadata__` is allowed to contain free form string-to-string map. Arbitrary JSON is not allowed, all values must be strings.
 //! - Rest of the file: byte-buffer.
 //!
 //! Notes: