CLI (v2) 模型 YAML 架构

适用于:Azure CLI ml 扩展 v2(当前)

源 JSON 架构可在 https://azuremlschemas.azureedge.net/latest/model.schema.json 中找到。

注意

本文档中详细介绍的 YAML 语法基于最新版本的 ML CLI v2 扩展的 JSON 架构。 此语法必定仅适用于最新版本的 ML CLI v2 扩展。 可以在 https://azuremlschemasprod.azureedge.net/ 上查找早期扩展版本的架构。

YAML 语法

密钥 类型 说明 允许的值
$schema 字符串 YAML 架构。
name 字符串 必需。 模型的名称。
version int 模型的版本。 如果省略,Azure 机器学习将自动生成一个版本。
description 字符串 模型的说明。
tags 对象 模型的标记字典。
path 字符串 模型文件的本地路径或模型文件的云路径的 URI。 它可指向文件或目录。
type 字符串 模型的存储格式类型。 适用于无代码部署方案。 custom_modelmlflow_modeltriton_model
flavors 对象 模型风格。 每种模型存储格式类型可能具有一种或多种受支持的风格。 适用于无代码部署方案。
default_deployment_template 对象 模型的默认部署模板。 仅适用于注册表范围的模型。 设置时,引用此模型的部署默认使用部署模板的设置(例如 environmentinstance_type和探测)。
default_deployment_template.asset_id 字符串 部署模板的资产 ID。 格式: azureml://registries/<registry-name>/deploymenttemplates/<template-name>/versions/<version>.
allowed_deployment_templates 对象列表 作者指南列出了使用者在部署此模型时建议用作替代的部署模板,这是一组精选的已验证模板。 不强制实施:部署时指定的替代不需要在此列表中。
allowed_deployment_templates[].asset_id 字符串 允许的部署模板的资产 ID。 格式: azureml://registries/<registry-name>/deploymenttemplates/<template-name>/labels/latest.

备注

az ml model 命令可用于管理 Azure 机器学习模型。

示例

示例 GitHub 存储库中提供了示例。 下面显示了几个示例。

YAML:本地文件

$schema: https://azuremlschemas.azureedge.net/latest/model.schema.json
name: local-file-example
path: mlflow-model/model.pkl
description: Model created from local file.

YAML:MLflow 格式的本地文件夹

$schema: https://azuremlschemas.azureedge.net/latest/model.schema.json
name: local-mlflow-example
path: mlflow-model
type: mlflow_model
description: Model created from local MLflow model directory.

YAML:默认部署模板

$schema: https://azuremlschemas.azureedge.net/latest/model.schema.json
name: my-model
version: 1
path: ./model
default_deployment_template:
  asset_id: azureml://registries/my-registry/deploymenttemplates/my-template/versions/1

YAML:默认部署模板和允许的部署模板

$schema: https://azuremlschemas.azureedge.net/latest/model.schema.json
name: my-model
version: 1
type: custom_model
path: ./model
default_deployment_template:
  asset_id: azureml://registries/my-registry/deploymenttemplates/my-template/versions/1
allowed_deployment_templates:
  - asset_id: azureml://registries/my-registry/deploymenttemplates/my-template/labels/latest
  - asset_id: azureml://registries/my-registry/deploymenttemplates/my-template2/labels/latest

后续步骤