Documentation
¶
Index ¶
- Constants
- type Header
- type Model
- func (m *Model) Config() (types.Config, error)
- func (m *Model) ConfigFile() (*v1.ConfigFile, error)
- func (m *Model) ConfigName() (v1.Hash, error)
- func (m *Model) Descriptor() (types.Descriptor, error)
- func (m *Model) Digest() (v1.Hash, error)
- func (m *Model) ID() (string, error)
- func (m *Model) LayerByDiffID(hash v1.Hash) (v1.Layer, error)
- func (m *Model) LayerByDigest(hash v1.Hash) (v1.Layer, error)
- func (m *Model) Layers() ([]v1.Layer, error)
- func (m *Model) Manifest() (*v1.Manifest, error)
- func (m *Model) MediaType() (ggcr.MediaType, error)
- func (m *Model) RawConfigFile() ([]byte, error)
- func (m *Model) RawManifest() ([]byte, error)
- func (m *Model) Size() (int64, error)
- type TensorInfo
Constants ¶
const ( QuantizationUnknown = "unknown" QuantizationMixed = "mixed" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct {
Metadata map[string]interface{}
Tensors map[string]TensorInfo
}
Header represents the JSON header in a safetensors file
func ParseSafetensorsHeader ¶
ParseSafetensorsHeader reads only the header from a safetensors file without loading the entire file. This is memory-efficient for large model files (which can be many GB).
Safetensors format:
[8 bytes: header length (uint64, little-endian)] [N bytes: JSON header] [remaining: tensor data]
func (*Header) CalculateParameters ¶
CalculateParameters sums up all tensor parameters
func (*Header) ExtractMetadata ¶
ExtractMetadata converts header to string map (similar to GGUF)
func (*Header) GetQuantization ¶
GetQuantization determines the quantization type from tensor dtypes
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func NewModel ¶
NewModel creates a new safetensors model from one or more safetensors files If a sharded model pattern is detected (e.g., model-00001-of-00002.safetensors), it will auto-discover all related shards
func (*Model) ConfigFile ¶
func (m *Model) ConfigFile() (*v1.ConfigFile, error)
func (*Model) Descriptor ¶
func (m *Model) Descriptor() (types.Descriptor, error)
func (*Model) RawConfigFile ¶
func (*Model) RawManifest ¶
type TensorInfo ¶
TensorInfo contains information about a tensor