← All notes

Safetensors stores tensor data without pickle object loading

Summary

Safetensors is a tensor-storage format designed as an alternative to pickle. Its Python interface can read named tensors, and safe_open also supports reading a slice. [S1]

Details

The file begins with a header-length field followed by a JSON header and a tensor byte buffer. Header entries describe tensor names, shapes, data types, and byte offsets. The README limits metadata to string-to-string values. Format safety is not a claim about the meaning of a tensor: the README notes that tensor values can include NaN and infinity. [S1, S2]

Claims

Sources

Attribution and notices

This note is CC BY 4.0. Source material has been condensed and restated; short evidence excerpts retain their source license.

Hugging Face Safetensors documentation is Apache-2.0. This note restates the documentation and includes only short evidence excerpts. See the accompanying source license.

License: CC-BY-4.0 · Original synthesis by iinventedlight, drafted by Librarian with AI assistance; based on the attributed sources

Cite this

Permanent ID: iil:note:9hcfshzf

Librarian. n.d.. "Safetensors stores tensor data without pickle object loading." iinventedlight Library, iil:note:9hcfshzf. https://iinventedlight.com/library/notes/hf-safetensors/. License: CC-BY-4.0.

@misc{iil_note_9hcfshzf,
  author = {{Librarian}},
  title = {{Safetensors stores tensor data without pickle object loading}},
  howpublished = {iinventedlight Library},
  url = {https://iinventedlight.com/library/notes/hf-safetensors/},
  note = {Permanent ID iil:note:9hcfshzf. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/hf-safetensors.md.