GGUF ファイル形式とは?
.gguf ファイルは GGML Universal Format ファイルであり、llama.cpp が大規模言語モデルを保存するために使用するバイナリコンテナです。Georgi Gerganov 氏と ggml コミュニティによって、旧式の GGML、GGMF、GGJT フォーマットの後継として 2023年8月に導入されました。単一の .gguf ファイルにモデルの重み、トークナイザー、およびすべてのハイパーパラメータが型付きのキー・バリュー形式のメタデータとして保持されているため、モデルをロードして実行するために個別の設定ファイルは必要ありません。
このフォーマットは、自己完結型で拡張性があり、メモリマップ(memory-mappable)が可能なように構築されています。メタデータは固定リストではなく名前空間付きのキー・バリューペアとして保存されるため、古いリーダーを壊すことなく新しいフィールドを追加できます。重みは通常、2ビットから8ビットまで量子化されており、Q4_K_M などの K-quants も含まれます。これにより、かなりの規模のモデルをコンシューマー向けの CPU や GPU で実行できるようになります。すべてのファイルは 4バイトのマジック文字列 GGUF で始まり、その後にバージョン番号が続きます。現在のバージョンは 3 です。
セキュリティと安全性
リスク: LOWGGUF is a data container for model weights and metadata, not an executable, so opening one does not run code by itself. The main practical risks are large file sizes and downloading models from untrusted sources; a malformed file could in theory exploit a bug in the loader, so use up-to-date inference tools and reputable model repositories.
形式の詳細
概要- Genome Graphical User Format - Rarely, .gguf has been used ad hoc by hobby projects for GUI layout data, unrelated to the machine-learning format described here.
GGUF ファイルを開くプログラム
.gguf models through a desktop GUI, with per-model quantization choices. .gguf file via a Modelfile and serve it for chat or API use with one command. .gguf model with llama-cli or llama-server, the reference implementation of the format. .gguf model for text generation and roleplay with a self-contained executable. .gguf models with Apple Silicon acceleration through a desktop GUI. .gguf model via a Modelfile using Metal acceleration on Apple hardware. .gguf models with CUDA, ROCm or CPU backends via llama-cli and llama-server. .gguf models through the llama.cpp loader in a browser-based interface. .gguf file's metadata, tensor list and quantization in the browser without downloading it. 技術的詳細
詳細仕様| Encoding | Binary |
| Byte order | Little-endian by default; big-endian supported since version 3 |
| Container | Single-file container holding header, metadata key-value block, tensor info block and raw tensor data |
| Compression | None as a container; weights are stored using GGUF quantization schemes (Q2 through Q8, K-quants such as Q4_K_M, IQ variants, plus F16/BF16/F32) |
| Typical size | Roughly 0.5 GB to over 100 GB depending on parameter count and quantization level |
| Structure | Header (magic, version, tensor count, metadata count) then namespaced key-value metadata, then per-tensor info (name, dimensions, type, offset), then aligned raw tensor data. Default alignment is 32 bytes and must be a multiple of 8. |
| Integrity | No built-in checksum; the metadata block is self-describing and validated at load time |
| Platforms | Windows, macOS, Linux |
| Notes | A GGUF file is self-contained: it bundles the model weights, tokenizer and all hyperparameters as typed metadata, so no separate config files are needed. Metadata keys use lower_snake_case with period-separated namespaces and keys can be up to 65,535 bytes. Over 40 quantization types are supported. Large models can be sharded across multiple .gguf files with llama-gguf-split. |
| リリース日 | August 2023 |
| 最新バージョン | Version 3 |
| オープンスタンダード | はい · ロイヤリティフリー |
| 仕様書 | github.com |
GGUF の変換
コミュニティ Q&A
ユーザーからの質問まだ質問はありません。GGUF ファイルについて最初の質問をしてみましょう。
よくある質問
GGUF ファイルを開くにはどうすればよいですか?
llama.cpp で直接ロードしてください。これらのツールは .gguf ファイルを読み取り、モデルとチャットできるようにします。ファイルをダブルクリックしても、それだけでは何も実行されません。どのプログラムが GGUF ファイルを作成しますか?
llama.cpp の変換スクリプト、主に Hugging Face モデルを .gguf に変換する convert_hf_to_gguf.py によって生成されます。その後、オプションで llama-quantize を使用して Q4_K_M などのより小さな量子化サイズに縮小されます。GGUF ファイル名にある Q4_K_M とはどういう意味ですか?
GGUF ファイルを元のモデルに戻すことはできますか?
.safetensors や PyTorch の重みにデ量子化できますが、ほとんどの GGUF ファイルは量子化されているため、変換は不可逆であり、元の正確な重みは復元されません。なぜ GGUF ファイルはこんなに大きいのですか?
.gguf はすべてのモデルの重みを 1つのファイルに保持します。ファイルサイズはパラメータ数と量子化レベルに比例するため、高精度の大型モデルは簡単に数十ギガバイトを超えることがあります。