Expand description
Aprender Model Format (.apr)
Binary format for ML model serialization with built-in quality (Jidoka):
- CRC32 checksum (integrity)
- Ed25519 signatures (provenance)
- AES-256-GCM encryption (confidentiality)
- Zstd compression (efficiency)
- Quantization (Q8_0, Q4_0, Q4_1 - GGUF compatible)
- Streaming/mmap (JIT loading)
§Format Structure
┌─────────────────────────────────────────┐
│ Header (32 bytes, fixed) │
├─────────────────────────────────────────┤
│ Metadata (variable, MessagePack) │
├─────────────────────────────────────────┤
│ Chunk Index (if STREAMING flag) │
├─────────────────────────────────────────┤
│ Salt + Nonce (if ENCRYPTED flag) │
├─────────────────────────────────────────┤
│ Payload (variable, compressed) │
├─────────────────────────────────────────┤
│ Signature Block (if SIGNED flag) │
├─────────────────────────────────────────┤
│ Checksum (4 bytes, CRC32) │
└─────────────────────────────────────────┘§Example
ⓘ
use aprender::format::{save, load, ModelType, SaveOptions};
use aprender::linear_model::LinearRegression;
let model = LinearRegression::new();
// ... train model ...
// Save with compression
save(&model, ModelType::LinearRegression, "model.apr", SaveOptions::default())?;
// Load with verification
let loaded: LinearRegression = load("model.apr", ModelType::LinearRegression)?;Re-exports§
pub use model_card::ModelCard;pub use model_card::TrainingDataInfo;
Modules§
- gguf
- GGUF Export (spec §7.2)
- model_
card - Model Card for .apr format (spec §11)
Structs§
- Distillation
Info - Complete distillation provenance (spec §6.3.2)
- Distillation
Params - Distillation hyperparameters (spec §6.3.2)
- Flags
- Feature flags (bitmask) - spec §3.2
- Header
- File header (32 bytes)
- Layer
Mapping - Layer mapping for progressive distillation (spec §6.3.2)
- License
Info - Commercial license information (spec §9.1)
- Metadata
- Model metadata (MessagePack-encoded)
- Model
Info - Model information (from inspection)
- Save
Options - Options for saving models
- Teacher
Provenance - Teacher model provenance for audit trails (spec §6.3.2)
- Training
Info - Training information
Enums§
- Compression
- Compression algorithm
- Distill
Method - Distillation method used (spec §6.3.1)
- License
Tier - License tier levels (spec §9.1)
- Model
Type - Model type identifiers
Constants§
- FORMAT_
VERSION - Current format version (1.0)
- HEADER_
SIZE - Header size in bytes
- MAGIC
- Magic number: “APRN” in ASCII (0x4150524E)
- MAX_
UNCOMPRESSED_ SIZE - Maximum uncompressed size (1GB safety limit)
- MMAP_
THRESHOLD - Threshold for switching to mmap loading (1MB)
Functions§
- inspect
- Inspect a model file without loading the payload
- inspect_
bytes - Inspect model data without loading the payload (spec §1.1)
- load
- Load a model from .apr format
- load_
auto - Load a model with automatic strategy selection based on file size
- load_
from_ bytes - Load a model from a byte slice (spec §1.1 - Single Binary Deployment)
- load_
mmap - Load a model using memory-mapped I/O (zero-copy where possible)
- save
- Save a model to .apr format