pub struct AprV2Metadata {Show 36 fields
pub model_type: String,
pub name: Option<String>,
pub description: Option<String>,
pub author: Option<String>,
pub license: Option<String>,
pub data_source: Option<String>,
pub data_license: Option<String>,
pub version: Option<String>,
pub source: Option<String>,
pub original_format: Option<String>,
pub created_at: Option<String>,
pub total_size: u64,
pub param_count: u64,
pub quantization: Option<QuantizationMetadata>,
pub sharding: Option<ShardingMetadata>,
pub chat_template: Option<String>,
pub chat_format: Option<String>,
pub special_tokens: Option<ChatSpecialTokens>,
pub architecture: Option<String>,
pub hf_architecture: Option<String>,
pub hf_model_type: Option<String>,
pub hidden_size: Option<usize>,
pub num_layers: Option<usize>,
pub num_heads: Option<usize>,
pub num_kv_heads: Option<usize>,
pub vocab_size: Option<usize>,
pub intermediate_size: Option<usize>,
pub max_position_embeddings: Option<usize>,
pub rope_theta: Option<f32>,
pub rope_type: Option<u32>,
pub rms_norm_eps: Option<f32>,
pub head_dim: Option<usize>,
pub num_experts: Option<usize>,
pub num_experts_per_tok: Option<usize>,
pub moe_intermediate_size: Option<usize>,
pub custom: HashMap<String, Value>,
}Expand description
APR v2 JSON metadata section
Fields§
§model_type: StringModel type identifier
name: Option<String>Model name
description: Option<String>Model description
Model author/organization
license: Option<String>Model license (SPDX identifier; governed by C-APR-PROVENANCE).
NO skip_serializing_if here: FALSIFY-SHIP-022 requires provenance
keys to serialize as explicit null (FM-APR-PROV-SILENT-SKIP) —
and license is not a realizar alias-group member, so the null
cannot trigger the duplicate-field poison (C-APR-MERGE-RUNNABLE).
data_source: Option<String>Training-data source (dataset identifier or “teacher-only”;
governed by C-APR-PROVENANCE / AC-SHIP2-012 / FALSIFY-SHIP-022).
Explicit-null serialization required — see license.
data_license: Option<String>SPDX license for data_source (governed by C-APR-PROVENANCE /
AC-SHIP2-012 / FALSIFY-SHIP-022).
Explicit-null serialization required — see license.
version: Option<String>Model version string
source: Option<String>Source/provenance URI (DD6: Model provenance tracking) Examples: “hf://openai/whisper-tiny”, “local://path/to/model.safetensors”
original_format: Option<String>Original format before conversion Examples: “safetensors”, “gguf”, “pytorch”
created_at: Option<String>Creation timestamp (ISO 8601)
total_size: u64Total model size in bytes
param_count: u64Parameter count
quantization: Option<QuantizationMetadata>Quantization info
sharding: Option<ShardingMetadata>Shard info (for multi-file models)
chat_template: Option<String>Chat template (Jinja2 format, from tokenizer_config.json) Per spec: chat-template-improvement-spec.md CTA-01
chat_format: Option<String>Detected chat template format Per spec: chat-template-improvement-spec.md CTA-03 Values: “chatml”, “llama2”, “mistral”, “phi”, “alpaca”, “custom”, “raw”
special_tokens: Option<ChatSpecialTokens>Special tokens for chat templates Per spec: chat-template-improvement-spec.md CTA-04
architecture: Option<String>Model architecture family (e.g., “llama”, “qwen2”, “phi”)
hf_architecture: Option<String>HuggingFace class name from config.json::architectures[0]
(e.g., “Qwen2ForCausalLM”, “LlamaForCausalLM”). Distinct from
architecture (family) and model_type. PMAT-690 P0-K stamps
this so downstream apr pretrain --init can propagate it into
the trained checkpoint’s metadata.
hf_model_type: Option<String>HuggingFace config.json::model_type (e.g., “qwen2”, “llama”).
PMAT-690 P0-K stamps this alongside hf_architecture so the
import→pretrain→export chain has a single source of truth.
Hidden dimension size
num_layers: Option<usize>Number of transformer layers
num_heads: Option<usize>Number of attention heads
num_kv_heads: Option<usize>Number of key-value heads (for GQA, defaults to num_heads)
vocab_size: Option<usize>Vocabulary size
intermediate_size: Option<usize>FFN intermediate dimension
max_position_embeddings: Option<usize>Maximum context/sequence length
rope_theta: Option<f32>RoPE theta for position encoding
rope_type: Option<u32>RoPE type: 0=NORM (adjacent pairs), 2=NEOX (split halves) CORRECTNESS-011: Qwen2.5 models require rope_type=2 (NEOX style)
rms_norm_eps: Option<f32>Layer norm epsilon
head_dim: Option<usize>Explicit head dimension (overrides hidden_size / num_heads for Qwen3+)
num_experts: Option<usize>Number of MoE experts
num_experts_per_tok: Option<usize>Number of experts selected per token
moe_intermediate_size: Option<usize>MoE expert intermediate/FFN dimension
custom: HashMap<String, Value>Custom key-value pairs
Implementations§
Source§impl AprV2Metadata
impl AprV2Metadata
Sourcepub fn to_json_pretty(&self) -> Result<String, V2FormatError>
pub fn to_json_pretty(&self) -> Result<String, V2FormatError>
Sourcepub fn canonicalize_hf_aliases(&mut self)
pub fn canonicalize_hf_aliases(&mut self)
Canonicalize HF/GGUF-style alias keys into typed struct fields (C-APR-MERGE-RUNNABLE / FALSIFY-APR-MERGE-RUNNABLE-001).
Import-produced APR files carry HuggingFace-style dimension keys
(num_hidden_layers, num_attention_heads, num_key_value_heads, …)
which land in custom because this struct has no serde aliases.
Realizar’s AprMetadata deserializer DOES alias them — so a file
containing BOTH the canonical field (even as an explicit null)
AND an alias key makes serde fail with “duplicate field”, which
realizar’s mmap loader swallows via unwrap_or_default() —
silently dropping ALL metadata (architecture, dims, embedded
tokenizer) and producing C-01 / “no tokenizer in APR metadata”
failures on a file that physically contains everything.
This method promotes alias values into the typed fields (when the
field is unset) and REMOVES the alias keys from custom, so a
re-serialized container has exactly one spelling per dimension.
Trait Implementations§
Source§impl Clone for AprV2Metadata
impl Clone for AprV2Metadata
Source§fn clone(&self) -> AprV2Metadata
fn clone(&self) -> AprV2Metadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more