Mlops

From williamzujkowski/standards · View interactive version

Mlops is an AI agent skill from the GitHub repository williamzujkowski/standards. MLOps engineering covering ML pipeline design, model versioning, experiment tracking, deployment strategies, drift detection, and monitoring for production ML systems with tools like MLflow, Kubeflow, and model registries

How to use this skill

Skill file

MLOps (Machine Learning Operations)

Overview

MLOps brings DevOps principles to machine learning workflows, enabling reliable, scalable, and reproducible ML systems in production. It covers the entire ML lifecycle from experimentation to deployment and monitoring.

Core Principles:


Level 1: Quick Reference

ML Lifecycle Stages

┌─────────────┐     ┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Data      │────▶│  Training   │────▶│ Deployment  │────▶│ Monitoring  │
│ Collection  │     │ & Experiment│     │  & Serving  │     │ & Retraining│
└─────────────┘     └─────────────┘     └─────────────┘     └─────────────┘
      │                    │                    │                    │
      │                    │                    │                    │
      ▼                    ▼                    ▼                    ▼
  Versioning        Tracking             Inference          Drift Detection
  Validation        Reproducibility      Scalability        Performance Decay
  Feature Eng.      Hyperparameters      A/B Testing        Alerts & Triggers

MLOps vs Traditional DevOps

| Aspect | Traditional DevOps | MLOps |

|--------|-------------------|-------|

| Artifacts | Code, binaries | Code + Data + Models + Features |

| Testing | Unit, integration tests | Data validation + Model evaluation + Inference tests |

| Deployment | Deploy once, stable | Continuous retraining, model decay |

| Monitoring | Logs, metrics, traces | + Data drift, concept drift, model performance |

| Versioning | Git for code | Git + DVC for data + Model registry |

| Reproducibility | Dockerfile, env vars | + Data versions, random seeds, feature pipelines |

Essential MLOps Checklist

Experimentation & Development:

Training Pipelines:

Deployment & Serving:

Monitoring & Maintenance:

Quick Commands

# MLflow - Track experiments
mlflow ui --host 0.0.0.0 --port 5000
mlflow run . -P alpha=0.5

# Kubeflow - Deploy pipeline
kfp pipeline create --pipeline-name my_pipeline pipeline.yaml
kfp run submit --experiment-name exp1 --pipeline-id <id>

# DVC - Version data
dvc add data/train.csv
dvc push
dvc pull

# Model serving - TorchServe
torch-model-archiver --model-name my_model --version 1.0 --serialized-file model.pt
torchserve --start --model-store ./model_store
curl -X POST http://localhost:8080/predictions/my_model -T input.json

# Feature store - Feast
feast apply
feast materialize-incremental $(date -u +"%Y-%m-%dT%H:%M:%S")

Common Patterns

1. Experiment Tracking

import mlflow

with mlflow.start_run():
    mlflow.log_param("learning_rate", 0.01)
    mlflow.log_metric("accuracy", 0.95)
    mlflow.sklearn.log_model(model, "model")

2. Model Versioning

from mlflow.tracking import MlflowClient

client = MlflowClient()
result = client.create_model_version(
    name="my_model",
    source="runs:/abc123/model",
    run_id="abc123"
)

3. Model Serving

# Load model from registry
model = mlflow.pyfunc.load_model(f"models:/my_model/production")

# Inference
predictions = model.predict(input_data)

4. Drift Detection

from scipy.stats import ks_2samp

# Compare training and production distributions
statistic, p_value = ks_2samp(train_distribution, production_distribution)
if p_value < 0.05:
    trigger_alert("Data drift detected")

Level 2:

📚 Full Examples: See REFERENCE.md for complete code samples, detailed configurations, and production-ready implementations.

Implementation Guide

1. ML Model Lifecycle Management

Training Phase

Reproducible Training Environment:

See REFERENCE.md for complete implementation.

Hyperparameter Optimization:

See REFERENCE.md for complete implementation.

Model Versioning

Model Registry Pattern:

See REFERENCE.md for complete implementation.

2. Feature Engineering & Feature Stores

Feature Store with Feast:

See REFERENCE.md for complete implementation.

Feature Retrieval in Training:

See REFERENCE.md for complete implementation.

3. Model Serving Strategies

Batch Prediction Pipeline

Apache Airflow DAG:

See REFERENCE.md for complete implementation.

Real-Time Inference API

FastAPI Model Serving:

See REFERENCE.md for complete implementation.

Streaming Inference

Kafka Consumer with Model:

See REFERENCE.md for complete implementation.

4. Model Monitoring & Drift Detection

Data Drift Detection

Statistical Testing Approach:

See REFERENCE.md for complete implementation.

Concept Drift Detection

Performance-Based Monitoring:

See REFERENCE.md for complete implementation.

Production Monitoring Dashboard

Prometheus Metrics + Grafana:

See REFERENCE.md for complete implementation.

5. ML Pipelines & Orchestration

Kubeflow Pipelines

Pipeline Definition:

See REFERENCE.md for complete implementation.

6. A/B Testing & Canary Deployments

Multi-Armed Bandit for Model Selection:

See REFERENCE.md for complete implementation.

7. Production Best Practices

Model Governance

Model Card Documentation:

See REFERENCE.md for complete implementation.

CI/CD for ML

GitHub Actions Workflow:

See REFERENCE.md for complete implementation.


Level 3: Deep Dive Resources

Advanced Topics

  1. Distributed Training
  1. Advanced Monitoring
  1. AutoML & Meta-Learning
  1. Edge ML & Model Optimization

Official Documentation

Books

Courses

Tools & Platforms

Community Resources


Practice Exercises

Exercise 1: End-to-End Pipeline

Build a complete MLOps pipeline:

  1. Version dataset with DVC
  2. Train model with MLflow tracking
  3. Register model in MLflow Model Registry
  4. Create Kubeflow pipeline for retraining
  5. Deploy with FastAPI + Docker
  6. Monitor with Prometheus + Grafana

Exercise 2: Drift Detection System

Implement comprehensive drift detection:

  1. Collect baseline statistics from training data
  2. Implement KS test for numerical features
  3. Implement Chi-square test for categorical features
  4. Create concept drift detector tracking model performance
  5. Set up alerts for drift detection
  6. Build automated retraining trigger

Exercise 3: A/B Testing Framework

Build an A/B testing system for models:

  1. Deploy two model versions
  2. Implement Thompson Sampling for traffic routing
  3. Collect feedback and update reward statistics
  4. Create dashboard showing model performance comparison
  5. Implement automated winner selection
  6. Gradual rollout of winning model

Exercise 4: Feature Store

Set up a production feature store:

  1. Define entities and feature views in Feast
  2. Materialize historical features for training
  3. Set up online feature serving
  4. Implement feature freshness monitoring
  5. Create feature lineage tracking
  6. Build feature validation pipeline

Examples

Basic Usage

// TODO: Add basic example for mlops
// This example demonstrates core functionality

Advanced Usage

// TODO: Add advanced example for mlops
// This example shows production-ready patterns

Integration Example

// TODO: Add integration example showing how mlops
// works with other systems and services

See examples/mlops/ for complete working examples.

Integration Points

This skill integrates with:

Upstream Dependencies

Downstream Consumers

Related Skills

Common Integration Patterns

  1. Development Workflow: How this skill fits into daily development
  2. Production Deployment: Integration with production systems
  3. Monitoring & Alerting: Observability integration points

Common Pitfalls

Pitfall 1: Insufficient Testing

Problem: Not testing edge cases and error conditions leads to production bugs

Solution: Implement comprehensive test coverage including:

Prevention: Enforce minimum code coverage (80%+) in CI/CD pipeline

Pitfall 2: Hardcoded Configuration

Problem: Hardcoding values makes applications inflexible and environment-dependent

Solution: Use environment variables and configuration management:

Prevention: Use tools like dotenv, config validators, and secret scanners

Pitfall 3: Ignoring Security Best Practices

Problem: Security vulnerabilities from not following established security patterns

Solution: Follow security guidelines:

Prevention: Use security linters, SAST tools, and regular dependency updates

Best Practices:


Next Steps: Explore data-engineering for upstream data pipelines or observability for production monitoring integration.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.