--- id: safetensors version: "0.8.0" license: unclear license_treatment: permissive maintenance: active --- # safetensors License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install safetensors uv add safetensors poetry add safetensors ## Description ## Installation ``` pip install safetensors ``` ## Usage ### Numpy ```python from safetensors.numpy import save_file, load_file import numpy as np tensors = { "a": np.zeros((2, 2)), "b": np.zeros((2, 3), dtype=np.uint8) } save_file(tensors, "./model.safetensors") # Now loading loaded = load_file("./model.safetensors") ``` ### Torch ```python from safetensors.torch import save_file, load_file import torch tensors = { "a": torch.zeros((2, 2)), "b": torch.zeros((2, 3), dtype=torch.uint8) } save_file(tensors, "./model.safetensors") # Now loading loaded = load_file("./model.safetensors") ``` ### Developing ``` # inside ./safetensors/bindings/python pip install .[dev] ``` Should be enough to install this library locally. ### Testing ``` # inside ./safetensors/bindings/python pip install .[dev] pytest -sv tests/ ``` ## AI interpretation — verify before relying Serializes and deserializes tensors to a safe, language-agnostic binary format designed for secure model storage and transfer across frameworks. Verdict: A production-stable, actively maintained serialization library with no known vulnerabilities, zero runtime dependencies, and broad platform support. Medium install friction is offset by pre-built wheels and permissive licensing, making it a low-risk choice for model persistence. [View on SkillFed](https://skillfed.io/packages/safetensors) · [View on PyPI](https://pypi.org/project/safetensors/)