MLflow 模型注册表简介

MLflow 入门

Weston Bassler

Senior MLOps Engineer

模型生命周期

开发、预发布的示意图

MLflow 入门

MLflow 模型注册表

  • 集中式存储位置

  • 生命周期管理

    • Web UI
    • MLflow Client 模块
    • 模型版本
    • 模型阶段

模型注册表

MLflow 入门

MLflow 模型注册表

  • 模型

    • 已记录到 MLflow Tracking
  • 已注册模型

    • 获得版本
    • 可分配阶段
MLflow 入门

MLflow 模型注册表

  • 模型版本

    • 每次新注册都会递增
  • 模型阶段

    • 可设置为:
      • None
      • Staging
      • Production
      • Archived

阶段

MLflow 入门

使用模型注册表

模型

MLflow 入门

MLflow Client 模块

  • 实验

  • 运行

  • 模型版本

  • 已注册模型

机器学习

1 Flaticon.com
MLflow 入门

使用 MLflow Client 模块

# 从 MLflow 模块导入
from mlflow import MlflowClient


# 创建实例 client = MlflowClient()
# 打印对象 client
<mlflow.tracking.client.MlflowClient object at 0x101d55f30>
MLflow 入门

注册模型

# 创建名为 "Unicorn" 的模型
client.create_registered_model(name="Unicorn")
<RegisteredModel: creation_timestamp=1679404160448, description=None, 
last_updated_timestamp=1679404160448, latest_versions=[], name='Unicorn', 
tags={}>
MLflow 入门

模型 UI

create-model

MLflow 入门

搜索已注册模型

搜索模型

MLflow 入门

搜索已注册模型

# 搜索已注册模型
client.search_registered_models(filter_string=MY_FILTER_STRING)
  • 标识符
    • name - 模型名称
    • tags - 与模型关联的标签
  • 比较符
    • = - 等于
    • != - 不等于
    • LIKE - 区分大小写的模式匹配
    • ILIKE - 不区分大小写的模式匹配
MLflow 入门

搜索示例

# 过滤字符串
unicorn_filter_string = "name LIKE 'Unicorn%'"


# 搜索模型 client.search_registered_models(filter_string=unicorn_filter_string)
[<RegisteredModel: creation_timestamp=1679404160448, description=None, 
last_updated_timestamp=1679404160448, latest_versions=[], name='Unicorn', 
tags={}>, 
<RegisteredModel: creation_timestamp=1679404276745, description=None, 
last_updated_timestamp=1679404276745, latest_versions=[], name='Unicorn 2.0', 
tags={}>]
MLflow 入门

Passons à la pratique !

MLflow 入门

Preparing Video For Download...