Anatomy · a sample file, read by this library
A file, at the scale of its bytes.
Every byte belongs to one of four parts. Drag the head along the lane and the panel says what you are standing on — which pair, which tensor, which block of weights.
drag · arrow keys · shift moves 256 bytes drag it, or pick a part
The price of a weight.
An encoding fixes how many values share a block and how many bytes that block takes. Divide one by the other and you have the bits each weight costs — the number that decides whether a model fits.
Thirteen kinds of value.
A metadata value is typed, and the type is in the file. Arrays carry the kind of their entries, and an array of arrays carries the kind again at each level, so a vocabulary and a per-layer table are both just pairs.
The number is what the file stores before the value. A reader that meets a number it does not know refuses the file rather than guessing, and so does a reader that meets a value whose kind contradicts the one its array declared.
What a reader refuses.
A corrupt file is not a puzzle to be solved generously. Each of these ends the read with a named reason and the position it happened at, so a caller can say which byte is wrong instead of which model failed to load.
- Bytes that do not begin with
GGUF. - A version outside 1 to 3, or a version 1 header read with 64-bit counts.
- A key that is empty, or present twice.
- Text that is not UTF-8 — refused, not repaired.
- A tensor whose row is not a whole number of blocks.
- An offset that is not where the tensor before it ended, rounded up to the alignment.
- More than four dimensions, or a count of values past 64 bits.
- A ceiling on pairs, tensors, text and array entries, and on how deeply arrays nest.
- Each refusal names the ceiling it hit and the number that passed it.
- Fewer bytes than a field needs, with the position the field starts at.
- A tensor asked for by a name the file does not have.
- A shard that starts past the end of the tensor it belongs to.