AI Concepts

Published 2026-09-25

GGUF - Model File Format

Learn about GGUF, a common LLM model file format in the GGML ecosystem, frequently used for local inference, quantization, and uncensored scenarios.

Official Introduction

  • GGUF is a file format for storing models for inference with GGML and executors based on GGML.

  • GGUF is a binary format that is designed for fast loading and saving of models, and for ease of reading. Models are traditionally developed using PyTorch or another framework, and then converted to GGUF for use in GGML.

  • It is a successor file format to GGML, GGMF and GGJT, and is designed to be unambiguous by containing all the information needed to load a model.

  • It is also designed to be extensible, so that new information can be added to models without breaking compatibility.

Understanding

  • GGUF is a binary file format used for storing machine learning models, optimized for fast loading and saving, making it highly efficient for inference scenarios.

  • It saves the model's Tensors (weight and other tensor data) and Metadata (model architecture, Tokenizer, parameters, etc.) in a single file, and is designed for fast loading and saving of model data. Taking Qwen3.8 as an example, comparing the Qwen3.8-27B ModelScope BadgeQwen3.8-27B standard model repository with the Qwen3.8-27B-GGUF ModelScope BadgeQwen3.8-27B-GGUF GGUF repository:

    • The file structure of the standard model repository is as follows, mainly serving inference frameworks like Transformers, vLLM, SGLang, TokenSpeed, etc. When Transformers loads a model, it needs to read files like config.json to learn about the model architecture, the number of layers, hidden_size, etc., which is part of the HF / Transformers model directory protocol;
Plain text
Qwen3.8-27B/
├── config.json
├── generation_config.json
├── tokenizer.json
├── tokenizer_config.json
├── preprocessor_config.json
├── model-00001-of-xxxxx.safetensors
├── model-00002-of-xxxxx.safetensors
└── ...
  • The core design goal of GGUF is: a single-file format. Besides tensor weights, it can also contain configuration properties, Tokenizer vocabulary, and other model properties. It is mostly used for inference with llama.cpp (a popular C/C++ LLM inference framework), as shown below, where files like config.json and tokenizer.json do not appear;
Plain text
unsloth/Qwen3.8-27B-GGUF/
├── Qwen3.8-27B-Uncensored-Q5_K_M.gguf
├── Qwen3.8-27B-Uncensored-draft-Q4_0.gguf
├── Qwen3.8-27B-Uncensored-draft-Q8_0.gguf
└── mmproj-Qwen3.8-27B-Uncensored-F16.gguf
└── ...
  • Rough understanding of the file structure:
Plain text
Transformers Model
─────────────────────────────
config.json
tokenizer.json
tokenizer_config.json
generation_config.json
*.safetensors
...
 
        ↓ Convert to GGUF
 
GGUF
─────────────────────────────
Qwen3.8-27B-Uncensored-Q5_K_M.gguf
 
Internal:
├── metadata
│   ├── architecture
│   ├── context length
│   ├── embedding size
│   ├── attention heads
│   ├── RoPE parameters
│   └── ...
│
├── tokenizer
│   ├── vocabulary
│   ├── token types
│   ├── special tokens
│   └── ...
│
└── tensors
    ├── embedding
    ├── attention weights
    ├── FFN weights
    └── ...
  • GGUF is specifically designed to work with GGML and other execution engines. It was developed by ggerganov, who is also the developer of llama.cpp.

  • GGML is a tensor library for machine learning that emphasizes C/C++, cross-platform support, low dependencies, and highly efficient local inference. It supports multiple backends like CPU and GPU, as well as quantization types from 2 to 8-bit. Projects like llama.cpp commonly use the GGML ecosystem.

  • It often appears alongside quantization, but GGUF itself is not a quantization method. However, it is highly suitable for saving and distributing quantized models. It is common to see quantized models like Q4_K_M, Q5_K_M, and Q8_0 provided as .gguf files.

  • It has become a very common model format in the local LLM inference ecosystem and can be directly used by tools like llama.cpp, Ollama, and LM Studio;

GGML/llama.cpp ecosystem → GGUF file format → Tensor + Metadata → Commonly used for quantized models → .gguf → Filenames usually directly reflect model size, fine-tuning type, quantization Encoding, and shards.

About the Full Name

The official documentation does not actually provide a full name expansion for GGUF. GGML Unified Format is currently the most reasonable and widely accepted expansion by the community; however, it is not a formal full name explicitly defined in the official GGML specification.

The source code gguf.h also simply refers to it as: "GGUF" files, the binary file format used by ggml. It does not explain what each of the four letters stands for.

In the original materials from when GGUF was created, the Issue #220 proposing the new format in 2023 was simply titled: GGJTv4/GGUF.

The author stated that he wanted to propose a new universal format to solve the fragmentation issues of the previous GGML/GGMF/GGJT file formats, while retaining single-file deployment.

The currently common expansions are as follows:

ExpansionVerdict
GPT-Generated Unified Format❌ Can basically be ruled out
GGML Universal File⚠️ Has some semantic basis, but no official naming evidence found
Georgi Gerganov Universal Format⚠️ Community interpretation, not officially confirmed
GGML Unified Format✅ Most suitable as the agreed expansion in knowledge bases, but should be noted as unofficially confirmed

There is also a Reddit post ranting about this matter, which you can check out if you are interested.

GGUF Naming Convention

The greatest value of the Naming Convention is that you can obtain the core information of the model just from the filename without opening the model card. For example: Qwen3-8B-Instruct-Q4_K_M.gguf, quickly leads to the following conclusion:

Qwen3 series → 8 Billion parameter scale → Instruction fine-tuned model → Q4_K_M quantization/encoding → GGUF format.

Rule: [<Sidecar>]<BaseName><SizeLabel><FineTune><Version><Encoding><Type><Shard>.gguf, each part is usually separated by -:

Plain text
[Sidecar]-BaseName-SizeLabel-FineTune-Version-Encoding-Type-Shard.gguf

This convention describes the standard writing of each field in the GGUF filename, designed for human readability. It does not guarantee that all real-world GGUF filenames can be strictly parsed according to this rule.

In practice, many files released by the community follow "conventions" rather than strictly copying the official specification, and variant naming styles are frequently seen.

Plain text
Qwen3-8B-Instruct-Q4_K_M.gguf
│     │  │        │       └─ GGUF file format
│     │  │        └───────── Q4_K_M encoding/quantization
│     │  └────────────────── Instruct fine-tuning
│     └───────────────────── 8B parameter size
└─────────────────────────── Model name
MarkerPurposeNotes
1SidecarSidecar module prefixOptional
mmproj: Multimodal projector;
mtp: Multi-Token Prediction heads;
2BaseNameModel nameFor example: Qwen3
3SizeLabelModel parameter scale8B, 14B, 32B, 70B, etc.;

K = Thousand
M = Million
B = Billion
T = Trillion
Q = Quadrillion
4FineTuneIndicates the type/purpose of fine-tuning applied to the modelNo fixed enumeration values; the following are the most common, conventionally accepted writings in the community:

Dialogue/Instruction

- Instruct: Instruction fine-tuning, excels at following single-turn instructions
- Chat: Chat fine-tuning, optimized for multi-turn dialogue
- RP / Roleplay: Roleplay fine-tuning

Reasoning/Chain-of-Thought

- Reasoning: Fine-tuning for enhanced reasoning
- Thinking: Fine-tuning with explicit chain-of-thought output

Code/Domain-Specific

- Coder / Code: Code generation fine-tuning
- Math: Math capability fine-tuning

Content Style

- Uncensored: Fine-tuning to remove censorship/content restrictions (as in your previous example)
- Abliterated: A specific "de-refusal" technique processing (not exactly equivalent to regular fine-tuning, but often labeled in this position)

Base/Untuned

- Base: Indicates the base model without instruction/chat fine-tuning (sometimes this field is omitted entirely, meaning it's a base model)
5VersionVersion numberOptional;
Indicates the model's version number, formatted as v<major>.<minor>;
This field can be derived from the general.version in the gguf metadata;
6EncodingHow the model weights are saved in terms of encoding/quantization;
Indicates the weight encoding scheme used by the model;
However, the specific content, type mixing, and combination methods are determined by the user's code and vary based on project needs;
The most core field, common ones: F16, BF16, Q8_0, Q6_K, Q5_K_M, Q4_K_M, Q4_K_S, Q3_K_M;

Q4, Q5, and Q8 describe approximately how many bits are used to represent the model weights after quantization. The smaller the number, the smaller the model usually is, the lower the RAM/VRAM requirement, but the greater the information loss.

See Encoding Explanation for details
7TypeWhat type of GGUF file it is and its purpose- Omitted: Represents a normal, complete GGUF tensor model file (the most common case);
- LoRA: Indicates this GGUF file is a LoRA adapter, not a complete model, and needs to be loaded with a base model;
- vocab: Indicates this GGUF file only contains vocabulary data and metadata, without weight tensors;
8ShardShardOptional
Indicates that the model has been split into multiple shard files, formatted as <ShardNum>-of-<ShardTotal>;
- ShardNum: The position of the shard in the entire model. Must be zero-padded to 5 digits.
- Shard numbering always starts from 00001 (e.g., the first shard is always 00001-of-XXXXX, not 00000-of-XXXXX).
- ShardTotal: The total number of shards for the model. Must be zero-padded to 5 digits.

Encoding Explanation

Assume a model has 8B = 8 Billion parameters, and each parameter weight uses FP16, then:

8B×16bitRough estimate: 8×109×2 bytes≈16GBWeights approx: 16GBAt 8 bit: 8B×1 byte≈8GBAt 4 bit: 8B×0.5 byte≈4GBWe can establish a very useful rough estimation formula: Weight Size≈Parameter Count×bits8\begin{aligned} &8B \times 16bit \\[1em] &\text{Rough estimate: } 8\times10^9\times2\ bytes \approx16GB \\[1em] &\text{Weights approx: } 16GB \\[1em] &\text{At 8 bit: } 8B\times1\ byte\approx8GB \\ &\text{At 4 bit: } 8B\times0.5\ byte\approx4GB \\[1em] &\text{We can establish a very useful rough estimation formula: } \\[1em] &\text{Weight Size} \approx &\text{Parameter Count}\times\frac{\text{bits}}{8} \end{aligned}
ModelFP168 bit4 bit
7B~14 GB~7 GB~3.5 GB
14B~28 GB~14 GB~7 GB
32B~64 GB~32 GB~16 GB

Q = Quantization.

Plain text
High Precision / Large Size
        ↑
FP16
Q8
Q6
Q5
Q4      ← Very common
Q3
Q2
        ↓
Low Precision / Small Size

Generally:

Higher bit

→ Larger file size
→ Higher RAM/VRAM usage
→ Usually preserves more model quality

Lower bit

→ Smaller file size
→ Lower RAM/VRAM usage
→ Easier to run large models
→ Usually increases quantization loss

Q4 is approximately the 4-bit quantization level;

Q4_K_M uses the GGML K-quant series scheme, primarily based on 4-bit, and adopts the tensor-type mixture corresponding to M.

K represents a K-quant (K-quants) quantization system later introduced by GGML/llama.cpp. K-quants use more complex block, scale, and other quantization representations, and allow different tensors in the model to use different quantization types.

S/M/L reflects: what combination of quantization types (quantization mix) is used for different Tensors in the model.

Plain text
Q4_K_M
│  │ │
│  │ └── M: A medium/mixed quantization configuration
│  │
│  └──── K: K-quant quantization system
│
└─────── Q4: Primarily quantized at the 4-bit level
Plain text
              Model Quality
                 ↑
 
Q8_0         Higher
Q6_K
Q5_K_M
Q5_K_S
Q4_K_M       ← Common balance point
Q4_K_S
Q3_K_M
Q3_K_S
Q2_K
 
                 ↓
          File Size / Memory Requirement Decreases

gguf.md

GGUF - Wikipedia

Hugging Face GGUF Documentation

Transformer GGUF Documentation