You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A pure Rust machine learning library with SIMD acceleration, GPU
inference, and the APR v2 model format. No Python dependencies, no C
bindings -- memory-safe, thread-safe, and WebAssembly-ready.
Aprender is a production-ready machine learning library written entirely
in Rust. It provides classical and modern ML algorithms -- from linear
regression and k-means to neural networks and transformers -- with SIMD
acceleration via trueno and GPU
inference via realizar. Models
serialize to the APR v2 format with LZ4/ZSTD compression, zero-copy
loading, and optional AES-256-GCM encryption.
Aprender is the ML foundation of the PAIML Sovereign AI Stack.
Features
Pure Rust -- Zero C/C++ dependencies, memory-safe and thread-safe
by default.
SIMD Acceleration -- Vectorized operations via
trueno 0.16 (AVX2/AVX-512/NEON).
GPU Inference -- CUDA-accelerated inference via
realizar (67.8 tok/s 7B, 851
tok/s 1.5B batched on RTX 4090).
APR v2 Format -- Native model serialization with LZ4/ZSTD
compression, zero-copy loading, and Int4/Int8 quantization.
[dependencies]
aprender = { version = "0.27", features = ["format-encryption", "hf-hub-integration"] }
Feature
Description
format-encryption
AES-256-GCM encryption for model files
format-signing
Ed25519 digital signatures
format-compression
Zstd compression
hf-hub-integration
Hugging Face Hub push/pull support
gpu
GPU acceleration via wgpu
Quick Start
use aprender::prelude::*;fnmain() -> Result<(),Box<dyn std::error::Error>>{// Training datalet x = Matrix::from_vec(4,2,vec![1.0,2.0,2.0,3.0,3.0,4.0,4.0,5.0,])?;let y = Vector::from_slice(&[3.0,5.0,7.0,9.0]);// Train modelletmut model = LinearRegression::new();
model.fit(&x,&y)?;// Evaluateprintln!("R-squared = {:.4}", model.score(&x,&y));Ok(())}
Algorithms
Linear Models
Algorithm
Module
LinearRegression
linear_model
LogisticRegression
linear_model
LinearSVM
classification
Clustering
Algorithm
Module
KMeans
cluster
DBSCAN
cluster
Classification
Algorithm
Module
NaiveBayes
classification
KNeighborsClassifier
classification
RandomForestClassifier
ensemble
GradientBoostingClassifier
ensemble
Decision Trees
Algorithm
Module
DecisionTreeClassifier
tree
NLP and Text
Capability
Module
Tokenization (BPE, WordPiece)
text
TF-IDF vectorization
text
Stemming
text
Chat templates (ChatML, Llama2, Mistral, Phi)
text
Time Series
Capability
Module
ARIMA forecasting
time_series
Graph Analysis
Capability
Module
PageRank
graph
Betweenness centrality
graph
Community detection
graph
Bayesian Inference
Capability
Module
Gaussian Naive Bayes
bayesian
Neural Networks
Capability
Module
Sequential models
nn
Transformer layers
nn
Mixture of Experts
nn
Decomposition
Algorithm
Module
PCA
decomposition
Model Serialization (APR v2)
Capability
Module
Save/load with encryption
format
LZ4/ZSTD compression
format
Zero-copy memory-mapped loading
format
Ed25519 signatures
format
Online Learning
Capability
Module
Incremental model updates
online
Recommendation Systems
Capability
Module
Collaborative filtering
recommend
APR Format
The .apr format provides secure, efficient model serialization:
use aprender::format::{save, load,ModelType,SaveOptions};// Save with encryptionsave(&model,ModelType::LinearRegression,"model.apr",SaveOptions::default().with_encryption("password").with_compression(true))?;// Loadlet model:LinearRegression = load("model.apr",ModelType::LinearRegression)?;
Feature
APR v1
APR v2
Tensor Compression
None
LZ4/ZSTD
Index Format
JSON
Binary
Zero-Copy Loading
Partial
Full
Quantization
Int8
Int4/Int8
Streaming
No
Yes
Architecture
aprender
primitives/ Core tensor types (Matrix, Vector)
linear_model/ Linear and logistic regression
cluster/ KMeans, DBSCAN
classification/ SVM, Naive Bayes, KNN
tree/ Decision trees
ensemble/ Random forest, gradient boosting
text/ Tokenization, TF-IDF, chat templates
time_series/ ARIMA
graph/ PageRank, centrality, community detection
bayesian/ Bayesian inference
glm/ Generalized linear models
decomposition/ PCA, dimensionality reduction
nn/ Neural networks, transformers, MoE
online/ Online / incremental learning
recommend/ Recommendation systems
synthetic/ Synthetic data generation
format/ APR v2 serialization (encryption, compression)
serialization/ Legacy serialization
prelude/ Convenient re-exports
Key dependency: trueno provides the
SIMD-accelerated compute primitives (AVX2/AVX-512/NEON).