Why convert GGUF to SAFETENSORS?
Converting .gguf to .safetensors lets you load a model back into Hugging Face Transformers or diffusers, fine-tune it, or re-quantize it differently. GGUF is optimized for llama.cpp inference, while .safetensors is the standard, pickle-free format for the PyTorch/HF ecosystem. Note that very recent GGUF format revisions are not always convertible.
How to convert GGUF to SAFETENSORS
gguf_to_safetensors OPEN-SOURCE
Run python gguf_to_safetensors.py --input model.gguf --output model.safetensors. It defaults to F16; add --bf16 for BF16 output.
GGUF2Safetensors OPEN-SOURCE
Upcasts GGUF weights to PyTorch tensors in memory and writes a Hugging Face folder of .safetensors shards, usable directly with Transformers.
gguf library + safetensors FREE
Load with GGUFReader, call gguf.quants.dequantize() per tensor, then safetensors.torch.save_file(). Full control over dtype and sharding.
About these formats
A .gguf file is a GGML Universal Format File, the binary container used by llama.cpp and related tools to store a large language model as a single file. It holds the model weights,…
Open .GGUF details →A .SAFETENSORS file is a data file used by specific software.
Open .SAFETENSORS details →Quality & what to watch
- Dequantizing a quantized GGUF (Q4/Q5/etc.) is lossy - the
.safetensorswill not match the original model bit-for-bit. - Newer GGUF format versions may fail to convert because tooling lags behind llama.cpp changes.
- Output is F16/BF16 (or F32), so file size grows significantly versus the compact quantized GGUF.
Frequently asked questions
Is GGUF-to-safetensors lossless?
Why did my recent GGUF fail to convert?
Can I load the result in Hugging Face Transformers?
.safetensors), which GGUF2Safetensors targets.