§product-os-models
A unified machine learning library providing LLM inference, classical ML training,
deep learning (Burn), custom computational graph building, and
ML tooling – all behind feature flags for minimal dependency footprint.
§Architecture
This crate uses a unified trait hierarchy where all model types implement
the base ModelKind trait, with extension traits for specific capabilities:
Trainable – models that can be trained on data
- LlmCapable – large language models with generation capabilities (behind
llm)
Educatable – models with educational content
PretrainedLoadable – models that can load pre-trained weights
§Feature Flags
§Core
| Feature | Description |
core | Lightweight traits, types, and errors (no heavy dependencies) |
std | Standard library support (enabled by default) |
§LLM Inference
| Feature | Description |
llm | Local LLM inference via Candle (enables candle-core, candle-nn, etc.) |
llm-api | Remote LLM backends shared plumbing (requires product-os-request) |
llm-ollama | Ollama API backend (implies llm-api) |
llm-vllm | vLLM API backend (implies llm-api) |
llm-sglang | SGLang API backend (implies llm-api) |
llm-max | MAX API backend (implies llm-api) |
§Hardware Acceleration (require llm)
| Feature | Description |
metal | Apple Metal GPU backend for Candle (macOS / Apple Silicon) |
accelerate | Apple Accelerate framework for BLAS on macOS |
cuda | NVIDIA CUDA GPU backend for Candle |
§Deep Learning & Burn
| Feature | Description |
dl-core | Deep learning foundation via Burn |
dl-mlp | Multi-layer perceptron architecture (implies dl-core) |
dl-cnn | Convolutional neural network architecture (implies dl-core) |
dl-rnn | Recurrent neural network architecture (implies dl-core) |
dl-transformer | Transformer architecture (implies dl-core) |
burn-backend | Burn with Candle compute backend (implies llm) |
| Feature | Description |
classical | Classical ML (linear regression, SVM, k-means, decision trees, etc.) |
data | Data loading, schema inference, and dataset management |
preprocessing | Feature engineering and data transformation pipelines |
experiments | Experiment tracking, run comparison, and metric logging |
tuning | Hyperparameter optimisation (grid, random, Bayesian) |
custom-graph | Custom computational graph builder for research models |
inference | Inference runtime for trained models |
onnx | ONNX model export and import (implies inference) |
Moved to product-os-ml-tooling: eda, interpretability, registry
§Other
| Feature | Description |
remote | Download models from Hugging Face Hub (hf-hub) |
§Bundles
| Feature | Description |
ml-full | All ML toolkit modules (classical + DL + data + preprocessing + …) |
all | Everything: ml-full + llm + all API backends |
§Quick Start
§Using the unified trait hierarchy (core only)
use product_os_models::core::traits::{ModelKind, ModelCategory};
§Using an Ollama backend (requires llm + llm-api features)
ⓘuse product_os_models::llm::parameters::Parameters;
use product_os_models::llm::model::ModelDefinition;
use product_os_models::llm::backends::ollama::Ollama;
let model_def = ModelDefinition {
name: "llama3".to_string(),
external_model_name: "llama3:8b".to_string(),
..Default::default()
};
let mut params = Parameters::new(model_def);
params.root_url = Some("http://localhost:11434".to_string());
let backend = Ollama::new(params);