Skip to main content

ModelMetadata

Struct ModelMetadata 

Source
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: GgufMetadata

Every 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

Source§

fn clone(&self) -> ModelMetadata

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModelMetadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ModelMetadata

Source§

fn default() -> ModelMetadata

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ModelMetadata

Source§

fn eq(&self, other: &ModelMetadata) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ModelMetadata

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.