.GGUF
GGUF model file
Introduction
GGUF is the model format of the ggml machine learning library and of llama.cpp, which runs large language models on ordinary computers. It was introduced in August 2023 to replace the earlier GGML files. One GGUF file holds everything needed to run a model: its weights, often quantised to 8, 5 or 4 bits per value to save memory, and metadata such as the architecture, the context length and the tokenizer’s vocabulary.
Software
- llama.cpp (Windows, macOS, Linux)
- Ollama (Windows, macOS, Linux)
- LM Studio (Windows, macOS, Linux)
- GPT4All (Windows, macOS, Linux)
- Hugging Face, which hosts GGUF models and shows their metadata on each model page
Structure
Numbers are little-endian. A string is a 64-bit length followed by that many bytes of UTF-8.
0Magic the four bytesGGUF4 bytes4Version currently 34 bytes8Tensor count8 bytes16Metadata count8 bytes24Metadata key, value type, value; keys such asgeneral.architecturerepeated…Tensor info name, number of dimensions, dimensions, type, offsetrepeated…Padding to the alignment, 32 bytes unlessgeneral.alignmentsays otherwisevaries…Tensor data each tensor at its offset from heremost of the file
The type of each tensor names its encoding: plain floats such as F32 and F16, or one of the quantised block formats such as Q8_0 and Q4_K, which store small groups of values with a shared scale.