From: KOLANICH Date: Tue, 17 Jan 2023 16:39:47 +0000 (+0000) Subject: Added JSONSchema of the header. (#151) X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2a5cac88d9ee4af7f4430a0db09000945924b4e7;p=safetensors.git Added JSONSchema of the header. (#151) --- diff --git a/docs/safetensors.schema.json b/docs/safetensors.schema.json new file mode 100644 index 0000000..23e1a37 --- /dev/null +++ b/docs/safetensors.schema.json @@ -0,0 +1,66 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "safetensors format header", + "description": "Describes the structure of all the tensors and their metadata", + "$defs": { + "size_t": { + "type": "integer", + "minimum": 0, + "maximum": 281474976710655, + "description": "A natural integer no more than 48 bits (current CPU limitation, not all 64 bits are used)" + }, + "Tensor": { + "title": "Tensor", + "description": "Describes the structure of one tensor", + "type": "object", + "additionalProperties": false, + "properties": { + "dtype": { + "type": "string", + "pattern": "([UIF])(8|16|32|64|128|256)", + "description": "Type of the array. U - unsigned int, I - signed int, F - IEEE 754 floating-point. Number is the count of bits." + }, + "shape": { + "type": "array", + "items": { + "$ref": "#/$defs/size_t", + "description": "Size of each dimension." + } + }, + "data_offsets": { + "type": "array", + "prefixItems": [ + { + "$ref": "#/$defs/size_t", + "description": "Start offset of the array. " + }, + { + "$ref": "#/$defs/size_t", + "description": "End offset of the array. Equal to the previous item + array size." + } + ] + } + }, + "required": [ + "data_offsets", + "dtype", + "shape" + ] + }, + "Metadata": { + "type": "object", + "additionalProperties": {"type": "string"}, + "title": "Metadata" + } + }, + "type": "object", + "properties": { + "__metadata__": { + "description": "Arbitrary metadata", + "$ref": "#/$defs/Metadata" + } + }, + "additionalProperties": { + "$ref": "#/$defs/Tensor" + } +}