pub struct ModelMetadata {Show 15 fields
pub architecture: Option<String>,
pub name: Option<String>,
pub n_layers: Option<u64>,
pub n_heads: Option<u64>,
pub n_kv_heads: Option<u64>,
pub embedding_length: Option<u64>,
pub feed_forward_length: Option<u64>,
pub context_length: Option<u64>,
pub vocab_size: Option<u64>,
pub rope_theta: Option<f32>,
pub rope_dimension_count: Option<u64>,
pub norm_epsilon: Option<f32>,
pub quantization_version: Option<u32>,
pub file_type: Option<u32>,
pub raw: GgufMetadata,
}Expand description
Model-level hyperparameters, promoted out of the raw metadata bag into named fields where the two supported formats (or at least GGUF, which is the only one of the two with a standardized hyperparameter vocabulary) agree on a concept.
§Why Option everywhere
Every field is optional because this struct has to represent both a
fully-specified GGUF LLM export and a bare SafeTensors weight dump that
carries no architecture metadata at all — SafeTensors’ __metadata__ is
a free-form string -> string map with no standardized keys. Refusing
to load a SafeTensors file just because it lacks n_heads would be
wrong: the tensors are still perfectly loadable, and it is the
architecture-specific consumer (in kopitiam-runtime, not here) that
knows whether a missing field is fatal for the model it is trying to
build.
§Why these fields specifically
This is the intersection of GGUF’s [llm].* standardized keys (see
crates/kopitiam-ai/vendor/ggml/docs/gguf.md) that essentially every
dense transformer architecture needs to reconstruct its shape: layer
count, head counts (including the separate KV head count for grouped-
query attention), embedding/feed-forward widths, context length,
vocabulary size, RoPE parameters, and normalization epsilon. Anything
architecture-specific (MoE expert counts, SSM state sizes, ALiBi bias)
is deliberately not promoted here — it stays reachable through raw
so this struct does not have to grow a field for every architecture
GGUF has ever described.
Fields§
§architecture: Option<String>general.architecture — e.g. "llama", "qwen2", "gptneox".
None for formats or files that do not record one.
name: Option<String>general.name, if present.
n_layers: Option<u64>[arch].block_count — number of transformer blocks.
n_heads: Option<u64>[arch].attention.head_count.
n_kv_heads: Option<u64>[arch].attention.head_count_kv. Distinct from n_heads only under
grouped-query or multi-query attention; None means “not recorded”,
which the GGUF spec says should be read as “equal to n_heads” —
that fallback is a modeling decision for the consumer, not this
loader, so it is left as None rather than silently copied here.
embedding_length: Option<u64>[arch].embedding_length — the model’s hidden/embedding width.
feed_forward_length: Option<u64>[arch].feed_forward_length.
context_length: Option<u64>[arch].context_length — the context window the model was trained
for.
vocab_size: Option<u64>Vocabulary size. GGUF has no dedicated key for this; it is derived
from the length of tokenizer.ggml.tokens when present.
rope_theta: Option<f32>[arch].rope.freq_base — the RoPE base frequency (theta).
rope_dimension_count: Option<u64>[arch].rope.dimension_count.
norm_epsilon: Option<f32>Normalization epsilon, from whichever of
[arch].attention.layer_norm_rms_epsilon or
[arch].attention.layer_norm_epsilon is present (RMS-norm is tried
first, since it is what every current GGUF LLM architecture uses).
quantization_version: Option<u32>general.quantization_version, present when any tensor is
quantized.
file_type: Option<u32>general.file_type — the GGUF enum describing the majority tensor
encoding. Left as the raw u32 rather than decoded, since it is
advisory (“can be inferred from the tensor types”) and this crate
already reports each tensor’s real kopitiam_core::DType.
raw: GgufMetadataEvery metadata key as found in the file, verbatim. This is the
escape hatch for everything not promoted to a named field above:
tokenizer vocabularies, chat templates, MoE/SSM parameters,
community-namespaced keys, and SafeTensors’ free-form
__metadata__ strings.
Trait Implementations§
Source§impl Clone for ModelMetadata
impl Clone for ModelMetadata
Source§fn clone(&self) -> ModelMetadata
fn clone(&self) -> ModelMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more