From: Nicolas Patry Date: Fri, 30 Jun 2023 08:32:00 +0000 (+0200) Subject: Superseed #279 (#285) X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=eca6cf10c3a782147c73569edd18649b62e3a840;p=safetensors.git Superseed #279 (#285) * Update README.md Add note about arbitrary JSON not allowed in __metadata__. * Update README.md Co-authored-by: Julien Chaumond * Update other readmes. --------- Co-authored-by: by321 Co-authored-by: Julien Chaumond --- diff --git a/README.md b/README.md index 169c7ac..697cef1 100644 --- 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: diff --git a/safetensors/README.md b/safetensors/README.md index 169c7ac..697cef1 100644 --- a/safetensors/README.md +++ b/safetensors/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: diff --git a/safetensors/src/lib.rs b/safetensors/src/lib.rs index f3dcf86..a66b1e7 100644 --- a/safetensors/src/lib.rs +++ b/safetensors/src/lib.rs @@ -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: