load(file: str, /, format: str | None = None, return_metadata: bool = False, *, stream: None | Stream | Device = None) array | Dict[str, array]#

Load array(s) from a binary file.

The supported formats are .npy, .npz, .safetensors, and .gguf.

  • file (file, str) – File in which the array is saved.

  • format (str, optional) – Format of the file. If None, the

  • format – is inferred from the file extension. Supported formats: npy, npz, and safetensors. Default: None.

  • return_metadata (bool, optional) – Load the metadata for formats

  • which – support matadata. The metadata will be returned as an additional dictionary.


A single array if loading from a .npy file or a dict mapping names to arrays if loading from a .npz or .safetensors file. If return_metadata` is ``True an additional dictionary of metadata will be returned.

Return type:

result (array, dict)


When loading unsupported quantization formats from GGUF, tensors will automatically cast to mx.float16