module

Semtrace::GGUF

Minimal GGUF parser for extracting tensor data from Ollama model files.

GGUF format: header โ†’ metadata KV pairs โ†’ tensor infos โ†’ aligned tensor data. Reference: https://github.com/ggerganov/ggml/blob/master/docs/gguf.md

Constants

MAGIC = 1179993927_u32

Class methods

read_info(path : String) : NamedTuple(header: Header, metadata: Hash(String, String | Int64 | UInt64 | Float64 | Bool), tensors: Array(TensorInfo), data_offset: Int64)

Reads the GGUF header, metadata, and tensor info without loading tensor data.

Source
read_tensor_f32(path : String, tensor : TensorInfo, data_offset : Int64) : Slice(Float32)

Reads a tensor's data and dequantizes to Float32.

Source

Nested types