What this is about
When you download a model to run at home, you usually get one file that ends in .gguf. It is a container. Inside are two kinds of things: the weights, which are the model's numbers, and a list of facts about the model, called metadata. The facts tell a program what it is looking at: the name, the architecture, how long a chat it supports, how the text is cut into tokens, and more.
One file, everything needed. That is why the format caught on.
Why it matters
Before containers like this, a model could arrive as many loose files. A program had to guess which belonged together and how to read them. If a number was missing, the model ran wrongly, or not at all.
With GGUF, the program opens one file and asks it questions. It is also easy to check: if the file is complete, the facts are there. This makes model downloads shareable and makes tools easier to write.
How it works
A GGUF file has three parts, one after another.
- A header. It says "this is a GGUF file" and gives the version and the counts of the other two parts.
- Key-value facts. A list of named entries. A name might be
general.architectureorgeneral.name. The value might be text or a number. A tool finds what it needs by name. - A table of tensors, then the tensor data. A tensor is one block of weights, like one table in one layer. The table lists each one's name, shape, number format and where its bytes start. The data follows.
Because the table says exactly where each block starts, a program does not have to read everything to use a model. It can look at the header and the table, and fetch only the bytes it needs.
We lean on this. Our reader maps the file into memory instead of copying it. A 20 GB model opens in 36 milliseconds at 29 MB of memory use, because only the small front part is parsed and the weights are views into the mapping. The whole reader is 360 lines with no dependencies. We checked it against the standard Python tool, gguf-py, which writes the same bytes.
Looking inside one
You do not need a special program to see what a GGUF file holds. Our mojo-gguf library has a few lines that open a file and print its summary. From its README:
from ggufx import Gguf
def main() raises:
var g = Gguf("model.gguf")
print(g.summary())
That reads only the header and the table. It does not touch the weights. The README's example output is kv 22 tensors 11 alignment 32 data_offset 1472, which is from a tiny test file: 22 facts, 11 blocks of weights. A real model has many more.
The same library ships four small tools that mirror the standard ones: dump to list a file, hash, set-metadata to change a fact, and convert-endian. It also has a converter from the safetensors format to GGUF, and quantizers. For the details of each, see the README.
A file that carries its proof
Here is something we added that you will not find in a plain GGUF. Our "bakes" put more inside. They carry the exact source files the engine was built from, the git commit those sources came from, and, for some, the prompt tokens and the answer a check should produce.
Why? So a stranger can test the file by itself. A tool called gguf-verify.sh rebuilds the engine from the file's own sources, runs it on the file's own test prompt, and says whether the result matches. It needs no checkout and no folder of test data.
That last point went wrong once, and we want to be honest about it. One of our bakes passed its check, but the check had silently fallen back to a local test folder on our machine, instead of reading the evidence in the file. It said PASS while testing nothing the file carried. An audit found it. We fixed the check, rebuilt nine bakes clean, and kept the bad one in our records, labeled "fixture-assisted". The lesson: a check that can quietly use a stand-in will keep passing.
Even a good check proves only so much. A file that rebuilds itself is not the same as a model that gives good answers. We track those two things separately.
What goes wrong for beginners
- Wrong architecture. A program that knows only some architectures will refuse a file from another family. Our engine, for instance, is built for one model shape and refuses a pack for a different shape.
- Wrong tokenizer. If the text cutter is wrong, the model sees nonsense. One of our models is blocked because we have no matching text-splitting pattern for its tokenizer family yet.
- Mixed-up sizes. Q4 and Q8 files of the same model are different files. The name tells you which.
Words you may not know
- GGUF: a file format that holds a model's weights and facts in one file.
- Metadata: facts about the model, stored as named entries.
- Tensor: one block of weights with a name and a shape.
- Header: the first bytes of a file, saying what it is and how to read the rest.
- Memory map: letting a program treat a file as if it were already in memory.
- Bake: our name for a GGUF with our sources and test proof added inside.
- Architecture: the model's design family, such as Qwen or Llama.
Try it
- Open a GGUF file with mojo-gguf-core, our small reader and writer. The README has a short program that writes a tiny file and reads it back, so you can see the parts. Like the other libraries, it has moved into our
mojo-libscollection. - Use mojo-gguf for the summary, the tools above and the converters.
- Pick any model you have and look at its key-value list. Find the architecture and the context length.
Read next
- A Model File That Carries Its Own Kernels, the full audit story and the list of what counts as a self-contained bake.

Komentarze
Brak komentarzy.
Zaloguj się aby skomentować.