# GGUF

GGUF（最初为 GPT-Generated Unified Format，即“GPT 生成统一格式”）是一种用于量化机器学习模型的单文件二进制容器格式，由[格奥尔基·格尔加诺夫](https://www.edgepedia.org/zh/georgi-gerganov)（Georgi Gerganov）于 2023 年 8 月 21 日推出，用以取代 llama.cpp 所使用的旧版 GGML 格式。<sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup> 它以量化形式存储模型权重，并连同运行该模型所需的全部元数据一并保存，如今已成为分发开放权重模型、供本地推理使用的事实标准。<sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup>

| 关键事实 | 内容 |
|---|---|
| 推出时间 | 2023 年 8 月 21 日，作为 GGML 的向后不兼容后继者<sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup> |
| 当前格式版本 | 版本 3；版本 1 和版本 2 属旧版<sup>[2](https://ggml-org-llama-cpp.mintlify.app/concepts/gguf-format)</sup><sup> • </sup><sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup> |
| 起源 | 源自 llama.cpp，后者由格奥尔基·格尔加诺夫于 2023 年 3 月发布<sup>[3](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)</sup> |
| 标志性体积 | Llama 风格 8B 模型：F16 下为 32.1 GB → Q4_K_M 下为 4.9 GB（厂商报告）<sup>[4](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/quantize/README.md)</sup> |
| 采用情况 | Hugging Face 上已有逾 18 万个 GGUF 模型<sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup> |
| 生态 | Ollama、LM Studio、KoboldCpp、GPT4All、Jan 等均构建于 llama.cpp 与 GGUF 之上<sup>[5](https://zeroentropy.dev/concepts/gguf/)</sup> |

## 为何必须取代 GGML

本地 LLM 推理运动可追溯至 2023 年 3 月——就在 Meta 的 LLaMA 权重在网上泄露数日之后，格奥尔基·格尔加诺夫发布了 llama.cpp，这是一个完全在 CPU 上运行的 LLaMA 推理 C 实现。<sup>[3](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)</sup> 它的文件格式 GGML 将模型超参数作为硬编码字段携带，并要求针对每种架构编写加载代码。随着 2023 年间新架构与新量化方案不断涌现，这种做法难以为继，于是到 2023 年 8 月，GGUF 作为向后不兼容的后继者被推出。<sup>[3](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)</sup>

过渡历时数月，两种格式一度并行流传，之后 llama.cpp 才彻底放弃对 GGML 的支持。如今 [Hugging Face](https://www.edgepedia.org/zh/hugging-face) 上几乎每一个主流开放权重模型都会有一个 GGUF 版本，通常在其发布后数小时内就会出现。<sup>[3](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)</sup>

## 格式如何运作

GGUF 文件是自包含的：它在一个文件中保存配置属性、完整的分词器词表、特殊 token 定义以及全部模型张量，因此权重旁边不再需要单独的 `tokenizer.model` 或 `config.json`。<sup>[6](https://huggingface.co/docs/transformers/v4.42.0/gguf)</sup><sup> • </sup><sup>[3](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)</sup> 官方文档将该结构描述为：以键值对形式存储的元数据、带有形状与类型信息的张量描述符，以及为高效内存访问而设的可选对齐。<sup>[2](https://ggml-org-llama-cpp.mintlify.app/concepts/gguf-format)</sup>

两项设计选择解释了该格式的持久生命力。第一，读取器若看不懂某个特定的元数据键，可以直接跳过——规范将此作为其前向兼容机制，使格式得以演进而不致破坏旧的加载器。<sup>[3](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)</sup><sup> • </sup><sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup> 第二，内存映射允许通过虚拟内存使用大于可用内存的模型，由操作系统按需将张量数据分页调入。<sup>[3](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)</sup> 规范是有版本号的：版本 1 和版本 2 的文件属旧版，当前几乎所有文件都是版本 3；合规的加载器遇到旧版本会记录一条警告，但通常仍能读取它们。<sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup>

## GGUF 内部的量化

llama.cpp 官方的 quantize 文档列出了该格式仅权重量化的各个系列：最初的组方案（Q4_0、Q4_1、Q5_0、Q5_1、Q8_0）、K 系列量化（Q2_K、Q3_K*、Q4_K*、Q5_K*、Q6_K）以及 I 系列量化（IQ1_S 至 IQ4_NL）。<sup>[4](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/quantize/README.md)</sup> 官方格式文档还列出了 F32/F16/BF16 以及实验性类型 TQ1_0、TQ2_0 和 MXFP4。<sup>[2](https://ggml-org-llama-cpp.mintlify.app/concepts/gguf-format)</sup>

**K 系列量化与 i 系列量化。** K 系列量化已趋成熟；当前活跃的开发前沿是基于 imatrix 的量化——其重要性矩阵权重在校准集上计算（思路上类似 [AWQ](https://www.edgepedia.org/zh/awq) 的显著性分析）——以及诸如 IQ2_XXS 和 IQ3_XS 之类的 i 系列量化，它们在相同比特预算下，困惑度表现优于最初的 Q2_K 和 Q3_K_S，并在 4 比特以下、可部署于 CPU 的格式上，基本弥合了与学术前沿方法（AQLM、QuIP#）之间的质量差距。<sup>[5](https://zeroentropy.dev/concepts/gguf/)</sup>

**多模态模型。** 多模态组件被保存在一个名为 mmproj（即“多媒体投影器”，multimedia projector）的独立 GGUF 文件中；除投影层外，它还可能包含视觉或音频编码器，通常采用 bf16 或 q8，因为更低比特的量化会显著损害这些组件的质量，而保持较大体积对速度和内存的影响则可忽略不计。<sup>[4](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/quantize/README.md)</sup>

## 用数字说话

来自 llama.cpp 的厂商报告体积表展示了 Q4_K_M 在 Llama 系列上的表现：<sup>[4](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/quantize/README.md)</sup>

| 模型规模 | F16 | Q4_K_M |
|---|---|---|
| 8B | 32.1 GB | 4.9 GB |
| 70B | 280.9 GB | 43.1 GB |
| 405B | 1,625.1 GB | 249.1 GB |

对于一个 7B 模型，一份专门的体积阶梯从 F16 下约 14 GB 起，依次为 Q8_0 下 7.5 GB、Q6_K 下 5.5 GB、Q5_K_M 下 4.8 GB、Q4_K_M 下 4.1 GB、Q4_0 下 3.8 GB、Q3_K_M 下 3.3 GB、Q2_K 下 2.9 GB，直至 IQ2_M 下 2.3 GB。<sup>[3](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)</sup>

官方表格给出的每权重比特数为：IQ1_S 为 2.0042，IQ1_M 为 2.1460，IQ2_XXS 为 2.3824，IQ2_XS 为 2.5882，IQ2_S 为 2.7403；Q4_K_S 为 4.6672，Q4_K_M 为 4.8944，Q6_K 为 6.5633，Q8_0 为 8.5008，F16 为 16.0005。同一张表还报告了生成吞吐：Q8_0 为每秒 50.93 个 token，而 F16 为每秒 29.17 个 token。<sup>[4](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/quantize/README.md)</sup> 这些表中的体积指的是磁盘上的模型文件，而非常驻内存——后者在运行时可能更低，因为内存映射会按需将张量数据分页调入。<sup>[4](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/quantize/README.md)</sup>

**独立的质量发现。** 一项学术评估（arXiv，2026）发现，名义比特宽度、下游准确率与内在语言建模质量之间存在清晰但非单调的关系：压缩最强的点 Q3_K_S 实现了最大的体积缩减，却在未加权基准均值上造成最大跌幅，并在 WikiText-2 上造成最大困惑度上升；而改用 3 比特系列中的其他方案（Q3_K_M、Q3_K_L），则能大幅减轻损失。<sup>[7](https://arxiv.org/pdf/2601.14277)</sup> 该论文的结论是：量化格式的实现细节——例如缩放粒度与块结构——至少与“3 比特”这一标志性标签同等重要。<sup>[7](https://arxiv.org/pdf/2601.14277)</sup> 同一研究将 GGUF 的各个量化系列列为正式研究对象，印证了该格式在 llama.cpp 之外的研究价值。<sup>[7](https://arxiv.org/pdf/2601.14277)</sup>

## 与其他格式的比较

三种格式主导着模型生命周期的版图：SafeTensors 作为训练与模型中心的标准，PyTorch 的 `.bin` 作为旧版格式，而 GGUF 作为本地推理的标准。<sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup> 在量化服务一侧，GPTQ 和 AWQ 是面向数据中心 GPU、依托 vLLM 和 [TensorRT-LLM](https://www.edgepedia.org/zh/tensorrt-llm) 等技术栈的服务器端生产用量化，而 GGUF 则是面向消费者与研究者的量化；如果目标是笔记本电脑、Mac、消费级 GPU 或 CPU 服务器，GGUF 就是合适之选，而聪明的开放权重发布则会两种都打包。<sup>[5](https://zeroentropy.dev/concepts/gguf/)</sup>

Hugging Face 的 Transformers 库加入了探索性的 GGUF 加载功能（记录于 v4.42，2024 年年中），它在将权重加载进 PyTorch 之前先反量化至 fp32，最初支持 F32、Q2_K、Q3_K、Q4_0、Q4_K、Q5_K、Q6_K 和 Q8_0；Hugging Face 将该支持标注为“仍非常具有探索性”，并推荐使用 llama.cpp 的 convert-hf-to-gguf.py 进行反向转换。<sup>[6](https://huggingface.co/docs/transformers/v4.42.0/gguf)</sup>

## 生态与近期进展

截至 2024–2025 年，GGUF 生态包括 Ollama（一个 Go 服务，捆绑了固定版本的 llama.cpp，并带有一个从注册表拉取 GGUF 的模型拉取层）、[LM Studio](https://www.edgepedia.org/zh/lm-studio)（llama.cpp 之上的桌面图形界面），以及 Jan、GPT4All、KoboldCpp 和 text-generation-webui——它们全都构建于 llama.cpp 加 GGUF 之上。Hugging Face 上最受欢迎的模型系列（LLaMA、Mistral、Qwen、Gemma、Phi）都带有 GGUF 标签页，列出社区量化版本。<sup>[5](https://zeroentropy.dev/concepts/gguf/)</sup>

自 2023 年以来，该格式本身也在成长：i 系列量化与基于 imatrix 的量化相继问世，实验性的 TQ1_0/TQ2_0 与 MXFP4 类型被加入，多模态组件则获得了 mmproj 文件约定。<sup>[5](https://zeroentropy.dev/concepts/gguf/)</sup><sup> • </sup><sup>[2](https://ggml-org-llama-cpp.mintlify.app/concepts/gguf-format)</sup><sup> • </sup><sup>[4](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/quantize/README.md)</sup> 采用规模已扩大至 Hugging Face 上逾 18 万个 GGUF 模型。<sup>[1](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)</sup>

## References

1. [What Is GGUF? The Local Model File Format Explained | AI/TLDR](https://ai-tldr.dev/learn/local-open-models/quantization-and-formats/what-is-gguf/)
2. [GGUF format — llama.cpp official docs (Mintlify)](https://ggml-org-llama-cpp.mintlify.app/concepts/gguf-format)
3. [GGUF: Storage and Inference for Quantized LLMs — Michael Brenndoerfer](https://mbrenndoerfer.com/writing/gguf-format-quantized-llm-storage-inference)
4. [llama.cpp quantize README (ggml-org GitHub)](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/quantize/README.md)
5. [GGUF format and k-quants: local LLM inference, explained — ZeroEntropy](https://zeroentropy.dev/concepts/gguf/)
6. [GGUF and interaction with Transformers · Hugging Face Docs](https://huggingface.co/docs/transformers/v4.42.0/gguf)
7. [arXiv paper on GGUF weight-only quantization formats (2601.14277)](https://arxiv.org/pdf/2601.14277)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026; Oct 11, 2026; Oct 15, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Foundation-model methods and training › Inference, serving, and efficiency of foundation models

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/gguf

English original: https://www.edgepedia.org/gguf
