Skip to main content

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​

ExampleDescriptionRuntimeDifficulty
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 + SparkBeginner
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 + SparkBeginner
BERT Text ClassificationFine-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.RayIntermediate
GPT Fine-tuning with LoRAParameter-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.RayAdvanced
Nomic AI Embedding TrainingTrain a long-context Nomic BERT model (2048 tokens) on WikiText using PyTorch Lightning with distributed Ray execution. Lives in michelangelo-examples.RayIntermediate
MovieLens Collaborative FilteringNeural 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.RayBeginner

Recommendation Systems​

ExampleDescriptionRuntimeDifficulty
Amazon Books RecommendationDual-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 + SparkAdvanced

Inference​

ExampleDescriptionRuntimeDifficulty
HuggingFace Batch InferenceBatch inference with two backends: HuggingFace Transformers (CPU/GPU) and vLLM (requires a CUDA GPU; tensor parallelism). Configurable sampling parameters (temperature, top-p, max tokens).RayIntermediate

Workflow Orchestration​

ExampleDescriptionRuntimeDifficulty
Uniflow Workflow PatternsOne 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.RayBeginner
Retry and Cache TestFour-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.RayIntermediate
Scala Spark TaskMinimal 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.SparkAdvanced

Evaluation​

ExampleDescriptionRuntimeDifficulty
Evaluator WorkflowRuns 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.RayIntermediate

Model Packaging​

ExampleDescriptionRuntimeDifficulty
Custom Model PackagingPackage 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 PackagingPackage 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?​