What Is GGUF and Why Local LLMs Use It

JS
Jai Singh
02 Dec, 2026 3 min read 4 views

GGUF is a single-file format for storing a language model so that llama.cpp and the tools built on it can load it quickly. One GGUF file holds the weights, the tokenizer and the configuration, and it usually stores the weights in a quantized form. That is why it became the standard way to share local models.

What is inside a GGUF file

A GGUF file has two main parts. The first is a block of metadata: key-value pairs describing the model architecture, the number of layers, the context length it was trained for, the tokenizer vocabulary, and often the chat template. The second part is the tensors, which are the actual weight arrays, each with a name, shape and data type. Because everything needed is in one file, you can copy a model to another machine and run it without any extra downloads.

Why a new format?

GGUF replaced an earlier format called GGML. The older format had no good way to add new information, so adding a model or a new field often broke compatibility. GGUF is extensible: new metadata keys can be added without breaking old readers. It is also designed for fast loading using memory mapping. With memory mapping the operating system maps the file into memory pages as they are needed, so a model starts quickly and several processes can share the same cached pages.

GGUF compared with safetensors

FeatureGGUFSafetensors
Typical usellama.cpp, Ollama, LM Studiotransformers, vLLM, training
Files per modelOneOften several shards plus config files
QuantizationMany built-in typesUsually full or half precision
Tokenizer insideYesSeparate files
Good on CPU and Apple SiliconYesLess so

Both formats avoid executing code when loaded, which is an important safety property compared with older pickle-based files. Post 89 returns to that topic.

Types of weights in a GGUF

The data type of the tensors determines the size. Full precision variants are F16 and BF16, which use 16 bits per weight. Quantized variants use fewer bits, with names like Q8_0, Q6_K, Q5_K_M and Q4_K_M. The next post explains what those labels mean. A GGUF at 16 bits is rarely what you want for everyday use, since it is four times larger than a 4-bit one.

Inspect a GGUF from Python

The gguf package, maintained alongside llama.cpp, can read the header of a file. Install it with pip install gguf. This script lists the metadata keys and the first tensors:

import sys
from gguf import GGUFReader

path = sys.argv[1]
reader = GGUFReader(path)

print("Metadata keys:")
for name in list(reader.fields)[:15]:
    print("  ", name)

print("Tensors:", len(reader.tensors))
for t in reader.tensors[:5]:
    print("  ", t.name, list(t.shape), t.tensor_type.name)

Run it as python inspect_gguf.py model.gguf. You will see keys like general.architecture and tokenizer fields, then tensor names with their shapes and a type such as Q4_K or F32. Small tensors such as normalisation weights are often kept at higher precision even in a 4-bit file, which is normal. If your installed version of the package differs and an attribute is missing, check its documentation; the idea stays the same.

Where chat templates fit

Many GGUF files embed the chat template, the pattern of special tokens that marks system, user and assistant turns. Engines can read it and format your messages correctly. If a GGUF lacks a template or has a wrong one, the model may produce odd output, which is a common source of problems that post 38 covers.

Practical points

  • Download GGUF files from the model creator or a well-known conversion publisher, and check the license on the page.
  • File size is a good estimate of the memory the model will need, plus room for context.
  • A GGUF file is not tied to one tool. LM Studio's downloads can be loaded by llama.cpp, and Ollama can import a GGUF with a Modelfile (post 39).
  • Split files named like -00001-of-00003.gguf are one model in several parts; keep them in the same folder and point the engine at the first part.
Was this article helpful?

Comments

No comments yet. Have a question or a tip? Be the first to share it.

Leave a comment

Comments are reviewed before they appear.