The header
Four bytes of magic, the version, and two counts. Twenty-four bytes that say how much is coming.
fn is_gguf(bytes)GGUF · version 3 · MoonBit
The header, the metadata table, the tensor index, and the quantised blocks behind them — read from bytes, written back byte for byte, and handed over without a copy.
reading…
A GGUF file is a small directory followed by a lot of weights. The directory holds everything a reader needs to answer questions about a model without touching a single weight.
Four bytes of magic, the version, and two counts. Twenty-four bytes that say how much is coming.
fn is_gguf(bytes)Key–value pairs the format types: architecture, layer count, the vocabulary. Thirteen kinds, arrays and arrays of arrays among them.
file.meta().text("general.architecture")
One entry per tensor: its name, its shape in ggml's
order, its encoding, and where its bytes begin.
The weights, block after block, each row a whole number of blocks. Read as a view into the bytes you already have.
file.data("token_embd.weight")
Paste the hex of a file, or drop a .gguf from your disk. The
library on this page is this repository compiled to JavaScript: the same
parser, the same refusals, the same numbers.
A tensor's bytes are blocks: so many values, so many bytes. The library
carries the whole table, from F32 to F8_E4M3,
and uses it to check that a row is a whole number of blocks.
The library deals in bytes, never in files: whatever read the file — a disk, a range request, a mapped buffer — hands the bytes over.
let file = @moongguf.File::parse(bytes[:])
let arch = file.meta().text("general.architecture")
let extent = file.extent("token_embd.weight")
let weight = file.data("token_embd.weight")