What MLflow does

MLflow · Essentials · 8 min

Knowing the components tells you which part solves your current problem, from comparing runs to deploying models.

MLflow organizes ML work around a few concepts:

  • Tracking records each training attempt as a run inside an experiment: parameters, metrics over time, tags and files (artifacts).
  • Models are saved in a standard format with a flavor (sklearn, pytorch, transformers...) plus a generic pyfunc interface, so any logged model can be loaded and called with predict the same way.
  • The Model Registry gives models names, versions and aliases such as champion, which deployment code refers to.
  • Serving turns a logged model into a REST endpoint or Docker image.
  • GenAI features add tracing of LLM and agent calls, evaluation with LLM judges, and a prompt registry.

Install with pip install mlflow. With no configuration, MLflow 3 stores runs in a local SQLite database mlflow.db in the working directory and artifacts in a local folder. Start the web UI with:

mlflow ui --port 5000

then open http://localhost:5000 to browse experiments, compare runs and charts, and inspect models.

For teams, a shared tracking server backed by a database and object storage replaces the local file (covered later). The same Python code works against either; only the tracking URI changes.

Example

import mlflow

print(mlflow.__version__)          # 3.x
print(mlflow.get_tracking_uri())   # sqlite:///.../mlflow.db  (local default)

mlflow.set_experiment("hello-mlflow")
with mlflow.start_run():
    mlflow.log_param("model", "baseline")
    mlflow.log_metric("accuracy", 0.81)

# Then, in a terminal in the same directory:
#   mlflow ui --port 5000      -> open http://localhost:5000

Remember

  • Runs inside experiments record params, metrics, tags and artifacts
  • Models get a flavor plus a generic pyfunc interface; the registry versions them
  • Local default: SQLite mlflow.db; mlflow ui browses it

Watch out for

  • Running mlflow ui from a different directory than your scripts and seeing no runs, because the local store is relative to the working directory.

Check yourself

  1. Which MLflow component lets deployment code refer to 'the current production model' by a stable name?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: mlflow.org/docs/latest/ml/

Builds on

Nothing: this is a foundation.

Unlocks