pub struct ModelCard {Show 16 fields
pub model_id: String,
pub name: String,
pub version: String,
pub author: Option<String>,
pub created_at: String,
pub framework_version: String,
pub rust_version: Option<String>,
pub description: Option<String>,
pub license: Option<String>,
pub training_data: Option<TrainingDataInfo>,
pub hyperparameters: HashMap<String, Value>,
pub metrics: HashMap<String, Value>,
pub architecture: Option<String>,
pub param_count: Option<u64>,
pub target_hardware: Vec<String>,
pub extra: HashMap<String, Value>,
}Expand description
Model card metadata embedded in .apr files.
Designed for dual compatibility:
- APR sovereign format (full control)
- Hugging Face ecosystem (interoperability)
§Example
use apr_format::model_card::{ModelCard, TrainingDataInfo};
let card = ModelCard::new("my-model", "1.0.0")
.with_author("user@host")
.with_description("A test model");
assert_eq!(card.version, "1.0.0");Fields§
§model_id: StringUnique model identifier (e.g., “aprender-shell-markov-3gram-20251127”)
name: StringHuman-readable model name
version: StringSemantic version (e.g., “1.2.3”)
Model author or organization
created_at: StringCreation timestamp (ISO 8601)
framework_version: StringTraining framework version (e.g., “aprender 0.10.0”)
rust_version: Option<String>Rust toolchain used (e.g., “1.82.0”)
description: Option<String>Short description (one line)
license: Option<String>License (SPDX identifier)
training_data: Option<TrainingDataInfo>Training dataset description
hyperparameters: HashMap<String, Value>Hyperparameters used
metrics: HashMap<String, Value>Training/evaluation metrics
architecture: Option<String>Model architecture type (e.g., “MarkovModel”, “LinearRegression”)
param_count: Option<u64>Number of parameters (for complexity estimation)
target_hardware: Vec<String>Target hardware platforms
extra: HashMap<String, Value>Custom metadata (extensible)
Implementations§
Source§impl ModelCard
impl ModelCard
Sourcepub fn new(model_id: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(model_id: impl Into<String>, version: impl Into<String>) -> Self
Create a new model card with required fields.
Set the author.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set the description.
Sourcepub fn with_license(self, license: impl Into<String>) -> Self
pub fn with_license(self, license: impl Into<String>) -> Self
Set the license (SPDX identifier).
Sourcepub fn with_architecture(self, arch: impl Into<String>) -> Self
pub fn with_architecture(self, arch: impl Into<String>) -> Self
Set the architecture type.
Sourcepub fn with_param_count(self, count: u64) -> Self
pub fn with_param_count(self, count: u64) -> Self
Set the parameter count.
Sourcepub fn with_training_data(self, data: TrainingDataInfo) -> Self
pub fn with_training_data(self, data: TrainingDataInfo) -> Self
Set training data info.
Sourcepub fn with_hyperparameter(
self,
key: impl Into<String>,
value: impl Into<Value>,
) -> Self
pub fn with_hyperparameter( self, key: impl Into<String>, value: impl Into<Value>, ) -> Self
Add a hyperparameter.
Sourcepub fn with_metric(
self,
key: impl Into<String>,
value: impl Into<Value>,
) -> Self
pub fn with_metric( self, key: impl Into<String>, value: impl Into<Value>, ) -> Self
Add a metric.
Sourcepub fn to_huggingface(&self) -> String
pub fn to_huggingface(&self) -> String
Export to Hugging Face model card format (YAML front matter + Markdown).