gizlang:gguf
GGUF files, llama.cpp's model format. A file is the magic "GGUF", a version (2 or 3), the counts of tensors and of metadata values, the metadata (typed key-value pairs: the architecture, its sizes, the tokenizer), the tensors' names, shapes, GGML types and offsets, then their data from an aligned start. A reader takes the header alone; the tensors are Stored (gizlang:safetensors), whose reads decode the GGML block types. The Hugging Face view (config, tokenizer, tensors by their Hugging Face names) lets a model converter take a GGUF file as it takes a model folder.
import * as Gguf from "gizlang:gguf";Types
Gguf
type Gguf = { path: string; values: Map<string, JsonValue>; tensors: Vec<Stored>; }A GGUF file's header: its metadata values by key and its tensors (GGUF names, shapes row-major as Hugging Face writes them, dtypes by GGML type name: "F32", "F16", "BF16", "Q8_0", "Q4_K", ...).
path:stringvalues:_gizlang_sdk_collections.Map<string, gizlang_json.Json>tensors:Vec<gizlang_safetensors.Stored>
Functions
read
function read(sys: System, path: string): Gguf throws stringThe header of the GGUF file at path.
Effects: fail, io.
Methods
Gguf.value
function Gguf.value(self: Gguf, key: string): JsonValueThe metadata value key (null when the file has none).
Effects: fail.
Gguf.arch
function Gguf.arch(self: Gguf): stringgeneral.architecture: "llama", "qwen2", "qwen3", ...
Effects: fail.
Gguf.hfNamed
function Gguf.hfNamed(self: Gguf): boolWhether the file keeps the Hugging Face names of its tensors (DeepBeepMeep's files): none has a GGML name. Its config and tokenizer are then not in its metadata.
Effects: fail.
Gguf.hfTensors
function Gguf.hfTensors(self: Gguf): Vec<Stored> throws stringThe tensors with the Hugging Face names of the architecture's model (Qwen2, Qwen3, Llama), in the Hugging Face row order: llama.cpp writes the q and k rows of a Llama head in pairs of rotary partners, which a read takes back to the head's two halves (Stored.interleaved).
Effects: fail.
Gguf.config
function Gguf.config(self: Gguf, sys: System): JsonValue throws stringThe model's config.json: the architecture's sizes from the metadata. rope_freqs.weight (Llama 3's rotary factors)
becomes rope_factors, each inverse frequency's divisor.
Effects: fail, io.
Gguf.tokenizer
function Gguf.tokenizer(self: Gguf): JsonValue throws stringThe tokenizer.json of a byte-level BPE vocabulary (tokenizer.ggml.model "gpt2") as Hugging Face writes it for the pre-tokenizer named: "qwen2" (NFC first) or "llama-bpe" (Llama 3: the begin-of-text token first). Control and user-defined tokens are added tokens; control ones are special.
Effects: fail.
Gguf.tokenizerConfig
function Gguf.tokenizerConfig(self: Gguf): JsonValuetokenizer_config.json: the chat template and the end-of-text and begin-of-text tokens.
Effects: fail.
Gguf.generationConfig
function Gguf.generationConfig(self: Gguf): JsonValuegeneration_config.json: the end-of-text token.
Effects: fail.