Examples
End-to-end ML pipeline examples covering training, recommendation systems, inference, workflow orchestration, evaluation, and model packaging. Each example is a complete, working workflow you can run locally or on a Michelangelo AI cluster.
Most examples live in python/examples/. Heavier examples with their own dependency footprint (the California Housing pipelines, GPT fine-tuning, Nomic AI and MovieLens) live in the separate michelangelo-examples repo instead, to keep this core repo's dependencies lean.
By Use Case
Training & Fine-tuning
| Example | Description | Runtime | Difficulty |
|---|---|---|---|
| California Housing (XGBoost) | Full pipeline — feature prep, Spark preprocessing, distributed XGBoost training, and pusher step that exports model + eval report to storage and registry. Lives in michelangelo-examples. | Ray + Spark | Beginner |
| California Housing (PyTorch Lightning) | Same California Housing use case as the XGBoost variant, using tabular_trainer's train_tabular() for distributed Ray Train instead. Also has a local-only runner for a quick, sandbox-free trial. Lives in michelangelo-examples. | Ray + Spark | Beginner |
| BERT Text Classification | Fine-tune BERT (bert-base-cased) on a GLUE task: the CoLA linguistic acceptability benchmark, with SST-2 selected in the shipped entrypoint. Uses HuggingFace Transformers on Ray, then assembles and pushes the model. Runs as a one-epoch smoke test on a 1% data sample. | Ray | Intermediate |
| GPT Fine-tuning with LoRA | Parameter-efficient fine-tuning using LoRA (1.29% trainable params) on the Stanford Alpaca instruction-following dataset. Includes perplexity and generation quality evaluation. Lives in michelangelo-examples. | Ray | Advanced |
| Nomic AI Embedding Training | Train a long-context Nomic BERT model (2048 tokens) on WikiText using PyTorch Lightning with distributed Ray execution. Lives in michelangelo-examples. | Ray | Intermediate |
| MovieLens Collaborative Filtering | Neural Collaborative Filtering on MovieLens-100k. Minimal smoke test for the LightningTrainer SDK — trains on CPU with a single Ray Train worker. Lives in michelangelo-examples. | Ray | Beginner |
Recommendation Systems
| Example | Description | Runtime | Difficulty |
|---|---|---|---|
| Amazon Books Recommendation | Dual-encoder recommendation system using Qwen-based architecture for Amazon Books. Demonstrates Chronon feature engineering on Spark and distributed Ray training. Lives in michelangelo-examples. | Ray + Spark | Advanced |
Inference
| Example | Description | Runtime | Difficulty |
|---|---|---|---|
| HuggingFace Batch Inference | Batch inference with two backends: HuggingFace Transformers (CPU/GPU) and vLLM (requires a CUDA GPU; tensor parallelism). Configurable sampling parameters (temperature, top-p, max tokens). | Ray | Intermediate |
Workflow Orchestration
| Example | Description | Runtime | Difficulty |
|---|---|---|---|
| Uniflow Workflow Patterns | One runnable file covering every core orchestration pattern: sequential tasks, if/else branching, for loops, concurrent_run fan-out and fan-in, concurrent_batch_run, and DatasetVariable hand-offs between tasks. Its README lists the Starlark restrictions that apply to workflow bodies in remote runs. Companion to Workflow Patterns. | Ray | Beginner |
| Retry and Cache Test | Four-task workflow (task_a/task_b then task_c/task_d, run concurrently) for checking manual-retry cache behavior: retrying task_a invalidates the cache of tasks that consume its result, while the independent task_b keeps its cache hit. Companion to Uniflow caching and pipeline run resume. | Ray | Intermediate |
| Scala Spark Task | Minimal end-to-end example of the ScalaSparkTask plugin: runs a pre-compiled Scala Spark JAR as a single-task workflow. Needs Scala 2.13 and Java 17 to build the JAR. | Spark | Advanced |
Evaluation
| Example | Description | Runtime | Difficulty |
|---|---|---|---|
| Evaluator Workflow | Runs the evaluator task on synthetic predictions: metrics declared in config (torchmetrics), results split per segment, and a SanityCheck threshold that fails the run when one segment regresses even though the aggregate passes. Set BREAK_IT=1 to see the failure. Install with the example and evaluator extras. See Evaluate Models and Read Reports for the full walkthrough. | Ray | Intermediate |
Model Packaging
| Example | Description | Runtime | Difficulty |
|---|---|---|---|
| Custom Model Packaging | Package a custom model with CustomTritonPackager for Triton Inference Server. Demonstrates the Model interface (save/load/predict) with raw and deployable packaging modes. | — | Advanced |
| Custom PyTorch Model Packaging | Package a PyTorch model (TorchLinearModel) with CustomTritonPackager. Uses numpy arrays for I/O (as required by the Model interface) with internal torch conversion. | — | Advanced |
Running Examples
Most examples follow the same pattern:
cd python
poetry install --extras "example"
PYTHONPATH=. poetry run python examples/<example_dir>/<script>.py
For remote execution on a Michelangelo AI cluster, append remote-run:
# From the michelangelo-examples repo (https://github.com/michelangelo-ai/michelangelo-examples):
pip install "michelangelo-examples[california-housing]"
python -m michelangelo_examples.california_housing.pipelines.xgb_train.pipeline \
remote-run \
--image ghcr.io/michelangelo-ai/michelangelo-examples:california-housing \
--storage-url s3://michelangelo/workflows \
--environ AWS_ENDPOINT_URL=http://objectstore:9091 \
--environ AWS_ACCESS_KEY_ID=michelangeloadmin \
--environ AWS_SECRET_ACCESS_KEY=michelangeloadmin \
--environ REGISTRY_ENDPOINT=michelangelo-apiserver:15566 \
--yes
See each example's README for specific prerequisites and run instructions.
What's Next?
- New to Michelangelo AI? Start with California Housing (XGBoost) in the michelangelo-examples repo — it covers the full pipeline end-to-end
- Want to understand the framework? Read Getting Started with Pipelines for a guided walkthrough
- Ready to deploy? See Deploy a Model after training