Введение в MLOps
🎯 Цель
После прочтения этой главы:
- Знаете, что такое MLOps и его отличие от DevOps
- Знаете полную картину ML lifecycle
- Сможете оценить MLOps maturity levels и уровень компании
- Знаете самую важную экосистему tool
Что нужно изучить
- Понятие MLOpsи его появление
- ML Lifecycle — data → train → deploy → monitor
- DevOps vs DataOps vs MLOps
- ML Maturity Levels(Google MLOps levels 0-2)
- MLOps challenges — reproducibility, drift, scaling
- Tool landscape — open source vs managed services
- Team structure — Data Engineer, ML Engineer, Data Scientist
MLOps — что и зачем?
Классический жизненный цикл ML проекта
Data Scientist в Jupyter notebook:
1. Получает данные через Pandas
2. Тренирует модель
3. Сохраняет "model.pkl"
4. Говорит: "Поставьте в Production"
Backend Engineer:
1. Загружает .pkl
2. Добавляет в FastAPI
3. Делает deploy
4. Всё хорошо... несколько недель
Через два месяца:
- Accuracy модели упала (drift!)
- Data scientist присылает новую модель (новый формат)
- Никто не может воспроизвести исходный результат
- Audit logs нет
- A/B test тоже нет
- Если в production ошибка, никто не замечает
MLOps решает эти проблемы.
DevOps vs MLOps
DevOps:
Code → Test → Build → Deploy → Monitor
MLOps:
Data → Validate → Train → Test → Register → Deploy → Monitor → Retrain
↑ ↓
└──────────────── Feedback loop ────────────────────────────────────┘
Основные различия:
- Dataтоже нужен versioning (как и код)
- Model — это artifact, новый при каждом retraining
- Performanceсо временем подвергается деградации(drift)
- Reproducibility — сложно воспроизвести одинаковый результат (randomness, изменение data)
- Testing — accuracy или business metric
Google MLOps Maturity Levels
Level 0 — Manual
Data scientist: kompyuterda manual
Production: oddiy script, manual deploy
Monitoring: yo'q yoki kam
✅ Новые проекты, MVP, маленькие компании ❌ Не production-grade
Level 1 — ML pipeline automation
Training pipeline avtomatik (Airflow yoki shunga o'xshash)
Data validation, model validation, automated retraining
Hali deployment manual yoki semi-automatic
✅ Средние компании ✅ Большинство real-world ML проектов на этом уровне
Level 2 — CI/CD pipeline
Hammasi avtomatik:
- Code/data CI: validation, testing
- ML pipeline CD: yangi model avtomatik deploy
- Monitoring orqali retraining trigger
- A/B testing infrastructure
✅ Зрелая культура MLOps (Google, Netflix, Uber)
MLOps Tool Ecosystem (2024-2026)
Experiment Tracking
- MLflow ⭐⭐⭐⭐⭐ — open source, самый распространённый
- Weights & Biases — managed, отличный UI
- Neptune.ai — managed alternative
- Comet — alternative
Data Versioning
- DVC ⭐⭐⭐⭐⭐ — Git for data
- LakeFS — data warehouse
- Pachyderm — kubernetes-native
- Delta Lake — экосистема Databricks
Feature Store
- Feast ⭐⭐⭐⭐ — open source
- Tecton — managed (вышла из Feast)
- Hopsworks — alternative
Model Serving
- FastAPI+ custom — простой, гибкий
- TorchServe — PyTorch native
- TensorFlow Serving — TF native
- BentoML ⭐⭐⭐⭐ — Python-friendly, гибкий
- Ray Serve — distributed
- Triton (NVIDIA) — production-grade GPU serving
- vLLM — LLM-specific, очень быстрый
Workflow Orchestration
- Apache Airflow ⭐⭐⭐⭐⭐ — библия
- Prefect — modern, Pythonic
- Dagster — data-aware
- Kubeflow Pipelines — k8s-native
- Metaflow — от Netflix
Monitoring
- Prometheus + Grafana — infrastructure
- Evidently AI ⭐⭐⭐⭐⭐ — data/model drift
- WhyLabs — managed alternative
- Arize, Fiddler — enterprise
Deployment Platforms
- Kubernetes+ custom — flexibility
- AWS SageMaker — managed
- GCP Vertex AI — managed
- Azure ML — managed
- Databricks — unified analytics
LLMOps (specific to LLM)
- Langfuse ⭐⭐⭐⭐⭐ — open source observability
- LangSmith — экосистема LangChain
- Helicone — proxy + analytics
- Phoenix(Arize) — open source
ML Lifecycle подробно
1. PROBLEM DEFINITION
- Business problem → ML problem
- Success metrics (online + offline)
2. DATA COLLECTION
- Source identification
- Sampling strategy
- Privacy/compliance
3. DATA PREPARATION
- Cleaning, transformation
- Feature engineering
- Train/val/test split
- Data versioning (DVC)
4. MODEL DEVELOPMENT
- Algorithm selection
- Hyperparameter tuning
- Experiment tracking (MLflow)
- Reproducibility
5. MODEL EVALUATION
- Offline metrics
- Bias/fairness analysis
- Edge cases testing
- Stakeholder review
6. MODEL DEPLOYMENT
- Containerization (Docker)
- Orchestration (K8s)
- Serving framework (FastAPI/BentoML)
- API design
7. MODEL MONITORING
- Performance metrics
- Data drift detection
- Concept drift detection
- Business KPIs
8. CONTINUOUS IMPROVEMENT
- A/B testing
- Shadow deployment
- Champion-challenger
- Automated retraining
Типичная структура MLOps проекта
ml_project/
├── data/ # Raw data (DVC tracked, not git)
│ ├── raw/
│ ├── interim/
│ └── processed/
├── notebooks/ # Exploration
│ └── 01_eda.ipynb
├── src/ # Source code
│ ├── data/
│ │ ├── make_dataset.py
│ │ └── validate.py
│ ├── features/
│ │ └── build_features.py
│ ├── models/
│ │ ├── train.py
│ │ ├── predict.py
│ │ └── evaluate.py
│ └── api/
│ └── main.py # FastAPI
├── tests/
│ ├── test_data.py
│ ├── test_features.py
│ └── test_model.py
├── configs/
│ ├── config.yaml
│ └── model_v1.yaml
├── dvc.yaml # DVC pipeline
├── params.yaml # Hyperparameters
├── Dockerfile
├── docker-compose.yml
├── .github/workflows/
│ ├── ci.yml
│ ├── train.yml
│ └── deploy.yml
├── k8s/ # Kubernetes manifests
│ ├── deployment.yaml
│ └── service.yaml
├── airflow/dags/ # Workflow orchestration
│ └── retrain_dag.py
├── monitoring/
│ ├── prometheus.yml
│ └── grafana_dashboard.json
├── requirements.txt
├── pyproject.toml
├── README.md
└── Makefile # Common commands
Backend dev → MLOps Engineer: skill mapping
У вас уже есть:
- ✅ REST API (FastAPI, DRF)
- ✅ Docker, docker-compose
- ✅ PostgreSQL, Redis
- ✅ Celery (async tasks)
- ✅ CI/CD (GitHub Actions / GitLab CI)
- ✅ Linux, basic Kubernetes
- ✅ Monitoring (Prometheus/Grafana)
- ✅ Git workflow
- ✅ Testing (pytest)
Нужно изучить новое:
- ML lifecycle thinking
- Experiment tracking (MLflow)
- Data versioning (DVC)
- Model serving frameworks (BentoML)
- Drift detection (Evidently)
- Workflow orchestration (Airflow)
- Feature stores (Feast)
Изучение этих 6 вещей за 4 недели реалистично.
Ресурсы
Книги (must)
- “Designing Machine Learning Systems” — Chip Huyen (лучшая книга по MLOps)
- “Machine Learning Engineering” — Andriy Burkov
- “Building Machine Learning Pipelines” — Hannes Hapke & Catherine Nelson
- “Practical MLOps” — Noah Gift
Online курсы (must)
- MLOps Zoomcamp — DataTalks.Club (github.com/DataTalksClub/mlops-zoomcamp) — MUST DO, бесплатно
- Made With ML — Goku Mohandas (бесплатно)
- Full Stack Deep Learning — Berkeley course
- DeepLearning.AI MLOps Specialization — Andrew Ng
Блоги
- Chip Huyen’s blog — huyenchip.com/blog
- Eugene Yan’s blog — eugeneyan.com
- Neptune.ai blog — MLOps articles
- Towards Data Science — MLOps section
Communities
- MLOps Community Slack — mlops.community
- DataTalks.Club Slack
- Reddit r/MachineLearning, r/MLOps
🏋️ Упражнения
🟢 Easy
- Погуглите 10 tool из tool landscape выше, напишите краткое описание каждого.
- Оцените, на каком MLOps maturity level находится ваша компания/проект.
- Объясните 8 этапов ML Lifecycle своими словами.
🟡 Medium
- Напишите план ML интеграции для существующего Django/FastAPI проекта (где, как, какие tool).
- Диалог с ChatGPT или Claude — “20 вопросов и ответов на интервью MLOps Engineer”.
- Проанализируйте 5 вакансий “MLOps Engineer” с сайтов работы, какие tool требуются.
🔴 Hard
- Plan template: создайте полный ML Engineering Document для ML проекта (problem statement → success metrics → architecture).
- Tool comparison: BentoML vs TorchServe vs Triton — сравнение через POC.
Capstone
notebooks/month-06/01_mlops_intro.ipynb:
- Один простой классический ML проект (например, churn prediction)
- Создайте полную структуру (по структуре выше)
- Пока нет tool, но в последующих разделах каждый добавим
✅ Чек-лист
- Знаю разницу MLOps и DevOps
- Знаю 8 этапов ML Lifecycle
- MLOps Maturity Levels (0, 1, 2)
- Знаю основной tool landscape
- Знаю типичную структуру MLOps проекта
- Увидел, как мой существующий backend опыт даст преимущество в MLOps
Переходим к MLflow — Experiment tracking.