GgufFile
Models & Types · AiDotNet.Agentic.Models.Local
A parsed GGUF file: its version, the metadata key/value store (hyperparameters, tokenizer config, etc.), the tensor directory, and access to F32/F16 tensor values. This is the structural loading primitive for GGUF (the llama.cpp weight format).
Implements: INamedTensorSource
For Beginners
The opened GGUF file. Ask it for the model’s settings (metadata), which weight tensors it has, and read the float ones as numbers.
How It Works
Metadata values are exposed as .NET objects (numbers, strings, bools, or arrays). F32 and F16 tensors can
be read as Double; quantized tensors (Q4_K, Q8_0, …) are listed with their type/offset but
dequantization is a follow-up — their raw bytes are still available.
Properties
| Property | Summary |
|---|---|
IReadOnlyCollection<string> TensorNames { get; } |
|
IReadOnlyDictionary<string, object> Metadata { get; } |
Gets the metadata key/value store. |
IReadOnlyList<GgufTensorInfo> Tensors { get; } |
Gets the tensor directory. |
int Alignment { get; } |
Gets the tensor-data alignment. |
uint Version { get; } |
Gets the GGUF format version. |
Methods
| Method | Summary |
|---|---|
GgufTensorInfo Get(string name) |
Returns the tensor info for a name, or null when not present. |
bool TryReadQ8_0Raw(string name, sbyte[] qs, float[] scales) |
Reads a Q8_0 tensor’s raw quantized blocks WITHOUT dequantizing: the int8 quants (qs, length = element count) and one fp32 scale per 32-value block (scales, length = count/32). |
double[] ReadAsDouble(string name) |
Reads an F32 or F16 tensor’s values as Double. |
object GetMetadata(string key) |
Gets a metadata value, or null when the key is absent. |