GGUF is a single-file binary format for storing the weights, tokenizer and configuration of a machine learning model, designed for fast loading and local inference with the llama.cpp ecosystem. In edge AI, it has become the most common way to distribute quantized large language models that run on laptops, desktops, phones and small servers without a cloud connection.
The format was introduced in 2023 by the developers of the ggml tensor library as the successor to the older GGML and GGJT files. Its main improvement is an extensible key-value metadata section, which lets one file describe the model architecture, context length, tokenizer and quantization scheme, so a runtime needs no separate configuration files.
How the GGUF file is structured
A GGUF file is laid out as a header, a metadata block, a tensor index and a data region, written in little-endian byte order by default. The runtime reads the small header and index, then memory-maps the data region, so the operating system loads weights on demand instead of copying the whole file into memory.
The table below describes each part of the file in the order it appears.
| Part | Contents | Purpose |
|---|---|---|
| Magic and version | The bytes GGUF and a format version number | Identifies the file and its revision |
| Counts | Number of tensors and number of metadata pairs | Lets the reader parse the rest |
| Metadata pairs | Typed keys such as general.architecture | Describes model, tokenizer and settings |
| Tensor infos | Name, shape, data type and offset of each tensor | Locates every weight in the file |
| Padding | Bytes up to the alignment boundary, usually 32 | Enables efficient memory mapping |
| Tensor data | Raw or quantized weight blocks | The model parameters themselves |
Metadata keys follow namespaced conventions: general keys for name and license, architecture-specific keys such as attention head counts and rotary embedding settings, and tokenizer keys holding the vocabulary, merges and special tokens. Because unknown keys are simply ignored, new fields can be added without breaking older readers.
Quantization types stored in GGUF
GGUF stores weights in block-based quantization formats defined by ggml. Weights are grouped into small blocks, and each block keeps low-bit integers plus one or more scale factors. The newer k-quants organize blocks into super-blocks of 256 weights with quantized scales, which improves accuracy at the same size.
Typical variants differ in bits per weight, file size and quality loss, as the table shows for a model of roughly 7 to 8 billion parameters.
| Type | Approximate bits per weight | Approximate size for 8B model | Quality impact |
|---|---|---|---|
| F16 | 16 | About 16 GB | Reference quality |
| Q8_0 | About 8.5 | About 8.5 GB | Nearly indistinguishable |
| Q6_K | About 6.6 | About 6.6 GB | Very small loss |
| Q5_K_M | About 5.7 | About 5.7 GB | Small loss |
| Q4_K_M | About 4.8 | About 4.9 GB | Moderate, widely accepted default |
| IQ2_XS | About 2.3 | About 2.5 GB | Noticeable degradation |
The lowest-bit i-quants rely on an importance matrix computed from calibration text, which tells the quantizer which weights matter most. Suffixes such as M and S indicate mixed precision: sensitive tensors, such as attention output or embedding layers, receive more bits than the rest.
GGUF compared with other model formats
GGUF is an inference-oriented container, whereas most other formats target training or general interchange. The key differences concern self-containment, quantization support and loading speed.
| Format | Main use | Quantization | Self-contained |
|---|---|---|---|
| GGUF | Local inference with llama.cpp and derived tools | Built-in block formats from 1.5 to 8 bits | Yes, includes tokenizer and configuration |
| Safetensors | Safe sharing of training checkpoints | Depends on external libraries | No, configuration files are separate |
| PyTorch pickle | Legacy checkpoints | Not standardized | No, and loading can execute code |
| ONNX | Cross-runtime graph exchange | INT8 and some 4-bit operators | Graph and weights, tokenizer separate |
| GGML (legacy) | Predecessor of GGUF | Early block formats | Partly, with fragile versioning |
Unlike pickle files, GGUF contains no executable code, which removes a common attack path. It still relies on a parser written in native code, so files from untrusted sources should be handled with an up-to-date runtime.
Using GGUF for local inference
The usual workflow is conversion, quantization and loading. A conversion script reads a Hugging Face checkpoint and writes an F16 or BF16 GGUF file; the quantize tool then produces smaller variants; finally a runtime such as llama.cpp, Ollama or LM Studio loads the file and optionally offloads some layers to a GPU.
| Situation | Recommended choice | Reason |
|---|---|---|
| Laptop with 16 GB of shared memory | Q4_K_M of a 7B to 8B model | Leaves room for context and the system |
| Workstation with a 24 GB GPU | Q5_K_M or Q6_K, all layers offloaded | Higher quality at full GPU speed |
| Phone or single-board computer | Q4_0 or IQ4 of a 1B to 3B model | Fits tight memory and simple kernels |
| Quality-critical evaluation | Q8_0 or F16 | Minimizes quantization error |
| Very long context | Smaller weights plus quantized KV cache | Context memory grows with length |
Memory needs are roughly file size plus the KV cache plus runtime overhead. A 4.9 GB model with an 8,000-token context typically needs 6 to 7 GB in total, depending on architecture and cache precision.
Limitations and common mistakes
GGUF is tied closely to the ggml and llama.cpp ecosystem. Support for a new architecture appears only after developers implement it in the runtime, so a freshly released model may not be convertible immediately.
- Wrong chat template: an outdated or missing template in metadata produces rambling or malformed answers.
- Over-aggressive quantization: 2-bit and 3-bit variants of small models lose reasoning and coding ability quickly.
- Ignoring the KV cache: users size memory for the file alone and run out at long contexts.
- Version mismatch: older runtimes may reject files that use newer quantization types.
- Training expectations: GGUF targets inference; fine-tuning normally happens on the original checkpoint.
A plain-language summary
An AI language model is a huge collection of numbers. GGUF is a way to pack those numbers into one tidy file. The file also holds the instructions a program needs to use them.
Think of a flat-pack furniture box. Everything is inside: the parts, the screws and the manual. GGUF works the same way. It also lets the numbers be stored in a compressed, rounded form. That makes the file small enough for an ordinary computer. The model can then run privately on your own device, without sending anything to the cloud.
An example from practice
A small law office wants an assistant that summarizes contracts, but its policy forbids sending client documents to external services. The office has a desktop with 32 GB of RAM and a GPU with 12 GB of video memory. An IT consultant downloads an 8-billion-parameter instruction model in Q5_K_M GGUF format, about 5.7 GB, and serves it with llama.cpp on the local network.
All layers fit on the GPU, and the assistant produces summaries at roughly 40 to 50 tokens per second with an 8,000-token context. Tests on twenty past contracts show summaries close to those of the F16 version. The office gains a fully offline tool that keeps confidential documents on its own hardware, at the cost of reviewing every summary before use.