跳到正文

MLflow 教程

MLflow tutorial: experiment tracking, logging parameters, metrics and artifacts, models, the model registry, evaluation, tracing for LLM apps and deployment.

Getting Started

  1. 1 What Is MLflow? Learn what MLflow is, which problems it solves for machine learning and LLM projects, what you need to know first, and how this tutorial is organized.
  2. 2 Install MLflow and Log Your First Run Install MLflow in a virtual environment, log a first run, open the web UI, and understand where your tracking data is saved on your own computer.
  3. 3 Runs, Experiments and Stores Understand MLflow experiments, runs, logged models, the backend store and the artifact store, and see how a tracking client connects to each of them.

Experiment Tracking

  1. 4 Log Parameters and Metrics Log parameters and metrics in MLflow one at a time or in batches, record training curves with steps, and avoid common naming and logging mistakes.
  2. 5 Artifacts, Tags and Datasets Save plots, reports and files as MLflow artifacts, organize runs with tags and notes, and record which dataset each run used so you can trace results.
  3. 6 Search and Query Runs Filter and sort MLflow runs with the search syntax, quote values correctly, order results, and load runs into a table for your own analysis.

Autologging and Comparison

  1. 7 Autologging Use MLflow autologging to capture parameters, metrics, signatures and models with one line, and learn what it records, what it misses and how to control it.
  2. 8 Compare Runs and Choose a Winner Compare MLflow runs in the UI and in code, set a selection rule before looking, handle trade-offs between metrics and check whether a difference is real.
  3. 9 Nested Runs and Hyperparameter Tuning Group tuning trials with MLflow parent and child runs, track every trial of a search, mark the best one and enable system metrics logging when needed.

Models and Signatures

  1. 10 The MLflow Model Format See what is inside an MLflow Model folder, how the MLmodel file and flavors work, how to log and load a model, and why loading untrusted models is risky.
  2. 11 Signatures and Input Examples Define what a model accepts and returns with MLflow signatures, add input examples and parameters, and learn the main schema enforcement rules.
  3. 12 Custom PyFunc Models Wrap preprocessing, business rules or an LLM chain in a custom MLflow PythonModel, and use models from code to log readable Python files.

Model Registry

  1. 13 Model Registry Basics Register models in the MLflow Model Registry, understand registered models and versions, load them by URI, and record where each version came from.
  2. 14 Aliases, Tags and Promotion Move model versions to production safely with MLflow aliases and validation tags, plan rollbacks and understand why the old stage system is deprecated.

Evaluation

  1. 15 Evaluate Machine Learning Models Use mlflow.models.evaluate for classifiers and regressors, add your own metric, check quality thresholds before release and study results by group.
  2. 16 Evaluate LLM Apps Evaluate LLM applications with mlflow.genai.evaluate: build test records, connect your app, choose scorers, manage datasets and read the results.
  3. 17 Scorers and Judges Choose MLflow scorers: built-in judges, code-based custom scorers and make_judge LLM judges. Learn to calibrate judges against human labels.

Tracing and LLM Apps

  1. 18 Tracing Basics Understand MLflow traces and spans, add manual tracing with decorators and context managers, set span types and read a trace tree to debug an app.
  2. 19 Auto Tracing, Feedback and Production Turn on MLflow auto tracing for LLM libraries, group traces by user and session, attach feedback, redact data and control sampling in production.
  3. 20 Version Prompts in the Prompt Registry Store prompt templates in the MLflow Prompt Registry, create versions, use aliases to release and roll back, and evaluate a prompt change before shipping.

Servers, Deployment and Teams

  1. 21 Run a Tracking Server Run a shared MLflow tracking server with a database backend and artifact storage, understand the key command flags, protect it and upgrade it safely.
  2. 22 Serve and Deploy Models Serve MLflow models over a REST API, send correctly shaped requests to the invocations endpoint, build Docker images and test before you deploy.
  3. 23 Teams, Security and Reproducibility Share MLflow safely with authentication and permissions, clean up deleted runs, package code as MLflow Projects and use MLflow in a CI pipeline.

Projects and Reference

  1. 24 Project: A Tracked Model Release Build an end-to-end MLflow project: track a parameter search, choose a model by a written rule, register it, gate the release and plan a rollback.
  2. 25 Project: Trace and Evaluate a Support Bot Build a small support bot workflow, trace its steps, score it against a test set, fix a retrieval bug and compare two versions before releasing one.
  3. 26 MLflow Glossary and Cheat Sheet A quick MLflow reference: key terms, Python calls for tracking, models, registry, evaluation and tracing, common commands, URIs and a release checklist.