liveBook · Manning

Safetensors

As explained in AI Governance

SafeTensors is a tensor-serialization format that stores numerical tensor data without embedding executable code.

Loading external model weights can introduce code-execution risk when the serialization format permits executable code. SafeTensors stores numeric tensor data without embedding executable code, making it an alternative to pickle-based model files. section 4.4.4 section 4.4.4

A safer file format does not secure the entire supply chain. In April 2024, researchers found that Hugging Face’s SafeTensor conversion service could be exploited to inject malicious code. An attacker who compromised the conversion bot’s credentials could push modified files under a trusted account. Hugging Face addressed the vulnerability. section 4.3.3

Before loading an external model, use the format as one control within a broader workflow:

  • Check the publisher, review the model card and configuration files, and verify the file hash against the official release. section 4.4.4
  • Require SafeTensors or a similar numeric-weights format, and record the downloaded file, its source, and its approver. section 4.4.4
  • Test model behavior after introduction or updates; for stronger containment, use a restricted runtime and control model versions. section 4.4.4

Policy for external weights

An internal tool requires SafeTensors, verifies weights cryptographically against the publisher’s release, and runs them in a sandbox with network egress disabled by default. section 4.9

How AI Governance covers it

How deep it goes
Explains the security rationale and surrounding verification workflow, without specifying format internals.
Examples
Illustrates a conversion-service vulnerability and an internal-tool policy for external weights.
What you can do after
Apply it when selecting external model files and combining format requirements with provenance checks and containment.
How it connects
Connects safe serialization with supply-chain security, hash verification, sandboxing, and behavioral testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Governance. The section links point to the parts of the book it draws on.