Summary
Add ability to publish trained ML models to Hugging Face Hub directly from aprender, with automatic model card generation.
Motivation
Users of aprender (including renacer) need to:
- Share trained models - Push .apr files to HF Hub for team collaboration
- Version models - Track model iterations with HF Hub's versioning
- Auto-generate model cards - Include training metadata, hyperparameters, metrics
Requested API
use aprender::hf_hub::{HfHubClient, ModelCard, PushOptions};
// Push model to HF Hub
let client = HfHubClient::new()?; // Uses HF_TOKEN env var
client.push_to_hub(
"org/model-name",
&model,
PushOptions::default()
.with_model_card(ModelCard::auto_generate(&metadata))
.with_commit_message("Add v1.0.0 trained model")
)?;
// Pull model from HF Hub
let model: KMeansModel = client.pull_from_hub("org/model-name")?;
Model Card Auto-Generation
Should include:
- Model type (KMeans, IsolationForest, etc.)
- Training timestamp
- Hyperparameters used
- Training sample count
- Silhouette score / other metrics
- aprender version
Example Model Card Output
---
library_name: aprender
tags:
- anomaly-detection
- syscall-analysis
- rust
---
# Model Card: syscall-anomaly-detector
## Model Details
- **Type:** KMeans Clustering
- **Clusters:** 5
- **Features:** 3 (count, total_time, avg_time)
- **Trained:** 2024-01-15T10:30:00Z
- **aprender version:** 0.10.0
## Training Data
- **Samples:** 15,234 syscall records
- **Source:** renacer trace of `cargo build`
## Metrics
- **Silhouette Score:** 0.847
- **Inertia:** 1234.56
## Usage
\`\`\`rust
use aprender::hf_hub::HfHubClient;
let model = HfHubClient::new()?.pull_from_hub("paiml/syscall-anomaly")?;
\`\`\`
Downstream Consumer
renacer will add CLI flags:
--push-model hub:org/repo - Push trained model to HF Hub
--load-model hub:org/repo - Load model from HF Hub
References
🤖 Generated with Claude Code
Summary
Add ability to publish trained ML models to Hugging Face Hub directly from aprender, with automatic model card generation.
Motivation
Users of aprender (including renacer) need to:
Requested API
Model Card Auto-Generation
Should include:
Example Model Card Output
Downstream Consumer
renacer will add CLI flags:
--push-model hub:org/repo- Push trained model to HF Hub--load-model hub:org/repo- Load model from HF HubReferences
🤖 Generated with Claude Code