Skip to main content

read_metadata

Function read_metadata 

Source
pub fn read_metadata(path: &Path) -> Result<HashMap<String, String>>
Expand description

Reads a .safetensors file’s __metadata__ string map (e.g. the embedded quantization_config – see crate::format) directly from path.

safetensors::SafeTensors (the type teeny_data::safetensors::SafeTensors::tensors hands back) doesn’t expose this map publicly – only the crate-internal Metadata header type does, via SafeTensors::read_metadata. That function insists the buffer’s total length exactly match the header-declared data length, but doesn’t care about the data bytes themselves for metadata extraction – so this reads the real header off disk but only zero-pads out to the real file length for the (unread) tensor payload, avoiding an I/O read of the potentially multi-GB data section just to reach a handful of metadata strings.