更新模型版本的详细信息 - Amazon SageMaker

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

更新模型版本的详细信息

您可以使用 AWS SDK for Python (Boto3) 或 Amazon SageMaker Studio 控制台查看和更新特定型号版本的详细信息。

重要

Amazon 将模型卡 SageMaker 集成到模型注册表中。在模型注册表中注册的模型包包括简化的模型卡作为模型包的组成部分。有关更多信息,请参阅 模型包模型卡片架构 (Studio)

查看和更新模型版本的详细信息 (Boto3)

要使用 Boto3 查看模型版本的详细信息,请完成以下步骤。

  1. 调用该list_model_packagesAPI操作以查看模型组中的模型版本。

    sm_client.list_model_packages(ModelPackageGroupName="ModelGroup1")

    响应是模型包摘要列表。您可以从此列表中获取模型版本的 Amazon 资源名称 (ARN)。

    {'ModelPackageSummaryList': [{'ModelPackageGroupName': 'AbaloneMPG-16039329888329896', 'ModelPackageVersion': 1, 'ModelPackageArn': 'arn:aws:sagemaker:us-east-2:123456789012:model-package/ModelGroup1/1', 'ModelPackageDescription': 'TestMe', 'CreationTime': datetime.datetime(2020, 10, 29, 1, 27, 46, 46000, tzinfo=tzlocal()), 'ModelPackageStatus': 'Completed', 'ModelApprovalStatus': 'Approved'}], 'ResponseMetadata': {'RequestId': '12345678-abcd-1234-abcd-aabbccddeeff', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': '12345678-abcd-1234-abcd-aabbccddeeff', 'content-type': 'application/x-amz-json-1.1', 'content-length': '349', 'date': 'Mon, 23 Nov 2020 04:56:50 GMT'}, 'RetryAttempts': 0}}
  2. 调用 describe_model_package 以查看模型版本的详细信息。你传入ARN在调用的输出中得到的模型版本list_model_packages

    sm_client.describe_model_package(ModelPackageName="arn:aws:sagemaker:us-east-2:123456789012:model-package/ModelGroup1/1")

    此调用的输出是一个包含模型版本详细信息的JSON对象。

    {'ModelPackageGroupName': 'ModelGroup1', 'ModelPackageVersion': 1, 'ModelPackageArn': 'arn:aws:sagemaker:us-east-2:123456789012:model-package/ModelGroup/1', 'ModelPackageDescription': 'Test Model', 'CreationTime': datetime.datetime(2020, 10, 29, 1, 27, 46, 46000, tzinfo=tzlocal()), 'InferenceSpecification': {'Containers': [{'Image': '257758044811.dkr.ecr.us-east-2.amazonaws.com/sagemaker-xgboost:1.0-1-cpu-py3', 'ImageDigest': 'sha256:99fa602cff19aee33297a5926f8497ca7bcd2a391b7d600300204eef803bca66', 'ModelDataUrl': 's3://sagemaker-us-east-2-123456789012/ModelGroup1/pipelines-0gdonccek7o9-AbaloneTrain-stmiylhtIR/output/model.tar.gz'}], 'SupportedTransformInstanceTypes': ['ml.m5.xlarge'], 'SupportedRealtimeInferenceInstanceTypes': ['ml.t2.medium', 'ml.m5.xlarge'], 'SupportedContentTypes': ['text/csv'], 'SupportedResponseMIMETypes': ['text/csv']}, 'ModelPackageStatus': 'Completed', 'ModelPackageStatusDetails': {'ValidationStatuses': [], 'ImageScanStatuses': []}, 'CertifyForMarketplace': False, 'ModelApprovalStatus': 'PendingManualApproval', 'LastModifiedTime': datetime.datetime(2020, 10, 29, 1, 28, 0, 438000, tzinfo=tzlocal()), 'ResponseMetadata': {'RequestId': '12345678-abcd-1234-abcd-aabbccddeeff', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': '212345678-abcd-1234-abcd-aabbccddeeff', 'content-type': 'application/x-amz-json-1.1', 'content-length': '1038', 'date': 'Mon, 23 Nov 2020 04:59:38 GMT'}, 'RetryAttempts': 0}}

模型包模型卡片架构 (Studio)

与模型版本相关的所有细节都封装在模型包的模型卡片中。模型包的模型卡是 Amazon SageMaker 模型卡的特殊用法,其架构得到了简化。模型包模型卡片架构显示在以下可扩展下拉列表中。

{ "title": "SageMakerModelCardSchema", "description": "Schema of a model package’s model card.", "version": "0.1.0", "type": "object", "additionalProperties": false, "properties": { "model_overview": { "description": "Overview about the model.", "type": "object", "additionalProperties": false, "properties": { "model_creator": { "description": "Creator of model.", "type": "string", "maxLength": 1024 }, "model_artifact": { "description": "Location of the model artifact.", "type": "array", "maxContains": 15, "items": { "type": "string", "maxLength": 1024 } } } }, "intended_uses": { "description": "Intended usage of model.", "type": "object", "additionalProperties": false, "properties": { "purpose_of_model": { "description": "Reason the model was developed.", "type": "string", "maxLength": 2048 }, "intended_uses": { "description": "Intended use cases.", "type": "string", "maxLength": 2048 }, "factors_affecting_model_efficiency": { "type": "string", "maxLength": 2048 }, "risk_rating": { "description": "Risk rating for model card.", "$ref": "#/definitions/risk_rating" }, "explanations_for_risk_rating": { "type": "string", "maxLength": 2048 } } }, "business_details": { "description": "Business details of model.", "type": "object", "additionalProperties": false, "properties": { "business_problem": { "description": "Business problem solved by the model.", "type": "string", "maxLength": 2048 }, "business_stakeholders": { "description": "Business stakeholders.", "type": "string", "maxLength": 2048 }, "line_of_business": { "type": "string", "maxLength": 2048 } } }, "training_details": { "description": "Overview about the training.", "type": "object", "additionalProperties": false, "properties": { "objective_function": { "description": "The objective function for which the model is optimized.", "function": { "$ref": "#/definitions/objective_function" }, "notes": { "type": "string", "maxLength": 1024 } }, "training_observations": { "type": "string", "maxLength": 1024 }, "training_job_details": { "type": "object", "additionalProperties": false, "properties": { "training_arn": { "description": "SageMaker Training job ARN.", "type": "string", "maxLength": 1024 }, "training_datasets": { "description": "Location of the model datasets.", "type": "array", "maxContains": 15, "items": { "type": "string", "maxLength": 1024 } }, "training_environment": { "type": "object", "additionalProperties": false, "properties": { "container_image": { "description": "SageMaker training image URI.", "type": "array", "maxContains": 15, "items": { "type": "string", "maxLength": 1024 } } } }, "training_metrics": { "type": "array", "items": { "maxItems": 50, "$ref": "#/definitions/training_metric" } }, "user_provided_training_metrics": { "type": "array", "items": { "maxItems": 50, "$ref": "#/definitions/training_metric" } }, "hyper_parameters": { "type": "array", "items": { "maxItems": 100, "$ref": "#/definitions/training_hyper_parameter" } }, "user_provided_hyper_parameters": { "type": "array", "items": { "maxItems": 100, "$ref": "#/definitions/training_hyper_parameter" } } } } } }, "evaluation_details": { "type": "array", "default": [], "items": { "type": "object", "required": [ "name" ], "additionalProperties": false, "properties": { "name": { "type": "string", "pattern": ".{1,63}" }, "evaluation_observation": { "type": "string", "maxLength": 2096 }, "evaluation_job_arn": { "type": "string", "maxLength": 256 }, "datasets": { "type": "array", "items": { "type": "string", "maxLength": 1024 }, "maxItems": 10 }, "metadata": { "description": "Additional attributes associated with the evaluation results.", "type": "object", "additionalProperties": { "type": "string", "maxLength": 1024 } }, "metric_groups": { "type": "array", "default": [], "items": { "type": "object", "required": [ "name", "metric_data" ], "properties": { "name": { "type": "string", "pattern": ".{1,63}" }, "metric_data": { "type": "array", "items": { "anyOf": [ { "$ref": "#/definitions/simple_metric" }, { "$ref": "#/definitions/linear_graph_metric" }, { "$ref": "#/definitions/bar_chart_metric" }, { "$ref": "#/definitions/matrix_metric" } ] } } } } } } } }, "additional_information": { "additionalProperties": false, "type": "object", "properties": { "ethical_considerations": { "description": "Ethical considerations for model users.", "type": "string", "maxLength": 2048 }, "caveats_and_recommendations": { "description": "Caveats and recommendations for model users.", "type": "string", "maxLength": 2048 }, "custom_details": { "type": "object", "additionalProperties": { "$ref": "#/definitions/custom_property" } } } } }, "definitions": { "source_algorithms": { "type": "array", "minContains": 1, "maxContains": 1, "items": { "type": "object", "additionalProperties": false, "required": [ "algorithm_name" ], "properties": { "algorithm_name": { "description": "The name of the algorithm used to create the model package. The algorithm must be either an algorithm resource in your SageMaker account or an algorithm in AWS Marketplace that you are subscribed to.", "type": "string", "maxLength": 170 }, "model_data_url": { "description": "Amazon S3 path where the model artifacts, which result from model training, are stored.", "type": "string", "maxLength": 1024 } } } }, "inference_specification": { "type": "object", "additionalProperties": false, "required": [ "containers" ], "properties": { "containers": { "description": "Contains inference related information used to create model package.", "type": "array", "minContains": 1, "maxContains": 15, "items": { "type": "object", "additionalProperties": false, "required": [ "image" ], "properties": { "model_data_url": { "description": "Amazon S3 path where the model artifacts, which result from model training, are stored.", "type": "string", "maxLength": 1024 }, "image": { "description": "Inference environment path. The Amazon Elastic Container Registry (Amazon ECR) path where inference code is stored.", "type": "string", "maxLength": 255 }, "nearest_model_name": { "description": "The name of a pre-trained machine learning benchmarked by an Amazon SageMaker Inference Recommender model that matches your model.", "type": "string" } } } } } }, "risk_rating": { "description": "Risk rating of model.", "type": "string", "enum": [ "High", "Medium", "Low", "Unknown" ] }, "custom_property": { "description": "Additional property.", "type": "string", "maxLength": 1024 }, "objective_function": { "description": "Objective function for which the training job is optimized.", "additionalProperties": false, "properties": { "function": { "type": "string", "enum": [ "Maximize", "Minimize" ] }, "facet": { "type": "string", "maxLength": 63 }, "condition": { "type": "string", "maxLength": 63 } } }, "training_metric": { "description": "Training metric data.", "type": "object", "required": [ "name", "value" ], "additionalProperties": false, "properties": { "name": { "type": "string", "pattern": ".{1,255}" }, "notes": { "type": "string", "maxLength": 1024 }, "value": { "type": "number" } } }, "training_hyper_parameter": { "description": "Training hyperparameter.", "type": "object", "required": [ "name", "value" ], "additionalProperties": false, "properties": { "name": { "type": "string", "pattern": ".{1,255}" }, "value": { "type": "string", "pattern": ".{1,255}" } } }, "linear_graph_metric": { "type": "object", "required": [ "name", "type", "value" ], "additionalProperties": false, "properties": { "name": { "type": "string", "pattern": ".{1,255}" }, "notes": { "type": "string", "maxLength": 1024 }, "type": { "type": "string", "enum": [ "linear_graph" ] }, "value": { "anyOf": [ { "type": "array", "items": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 2 }, "minItems": 1 } ] }, "x_axis_name": { "$ref": "#/definitions/axis_name_string" }, "y_axis_name": { "$ref": "#/definitions/axis_name_string" } } }, "bar_chart_metric": { "type": "object", "required": [ "name", "type", "value" ], "additionalProperties": false, "properties": { "name": { "type": "string", "pattern": ".{1,255}" }, "notes": { "type": "string", "maxLength": 1024 }, "type": { "type": "string", "enum": [ "bar_chart" ] }, "value": { "anyOf": [ { "type": "array", "items": { "type": "number" }, "minItems": 1 } ] }, "x_axis_name": { "$ref": "#/definitions/axis_name_array" }, "y_axis_name": { "$ref": "#/definitions/axis_name_string" } } }, "matrix_metric": { "type": "object", "required": [ "name", "type", "value" ], "additionalProperties": false, "properties": { "name": { "type": "string", "pattern": ".{1,255}" }, "notes": { "type": "string", "maxLength": 1024 }, "type": { "type": "string", "enum": [ "matrix" ] }, "value": { "anyOf": [ { "type": "array", "items": { "type": "array", "items": { "type": "number" }, "minItems": 1, "maxItems": 20 }, "minItems": 1, "maxItems": 20 } ] }, "x_axis_name": { "$ref": "#/definitions/axis_name_array" }, "y_axis_name": { "$ref": "#/definitions/axis_name_array" } } }, "simple_metric": { "description": "Metric data.", "type": "object", "required": [ "name", "type", "value" ], "additionalProperties": false, "properties": { "name": { "type": "string", "pattern": ".{1,255}" }, "notes": { "type": "string", "maxLength": 1024 }, "type": { "type": "string", "enum": [ "number", "string", "boolean" ] }, "value": { "anyOf": [ { "type": "number" }, { "type": "string", "maxLength": 63 }, { "type": "boolean" } ] }, "x_axis_name": { "$ref": "#/definitions/axis_name_string" }, "y_axis_name": { "$ref": "#/definitions/axis_name_string" } } }, "axis_name_array": { "type": "array", "items": { "type": "string", "maxLength": 63 } }, "axis_name_string": { "type": "string", "maxLength": 63 } } }

查看和更新模型版本(Studio 或 Studio Classic)的详细信息

要查看和更新模型版本的详细信息,请根据您使用的是 Studio 还是 Studio Classic 完成以下步骤。在 Studio Classic 中,您可以更新模型版本的批准状态。有关详细信息,请参阅更新模型的批准状态。另一方面,在 Studio 中,为模型包 SageMaker 创建模型卡,模型版本用户界面提供了更新模型卡片中详细信息的选项。

Studio
  1. 按照启动 Amazon SageMaker Studio 中的说明打开 SageMaker Studio 控制台。

  2. 在左侧导航窗格中,从菜单中选择模型

  3. 如果尚未选择,请选择已注册的模型选项卡。

  4. 已注册模型选项卡标签的正下方,选择模型组(如果尚未选择)。

  5. 选择包含要查看的模型版本的模型组的名称。

  6. 在模型版本列表中,选择要查看的模型版本。

  7. 选择以下选项卡之一。

    • 训练:查看或编辑与您的训练作业相关的详细信息,包括绩效指标、构件、IAM角色和加密以及容器。有关更多信息,请参阅 添加训练作业 (Studio)

    • 评估:查看或编辑与您的训练作业相关的详细信息,例如绩效指标、评估数据集和安全性。有关更多信息,请参阅 添加评估作业 (Studio)

    • 审计:查看或编辑与模型的业务目的、用法、风险以及算法和性能限制等技术细节相关的高级细节。有关更多信息,请参阅 更新审计(治理)信息(Studio)

    • 部署:查看或编辑您的推理图像容器和构成终端节点的实例的位置。有关更多信息,请参阅 更新部署信息 (Studio)

Studio Classic
  1. 登录亚马逊 SageMaker Studio 经典版。有关更多信息,请参阅启动 Amazon SageMaker Studio 经典版

  2. 在左侧导航窗格中,选择主页图标 ( Black square icon representing a placeholder or empty image. )。

  3. 选择模型,然后选择模型注册表

  4. 从模型组列表中,选择要查看的模型组的名称。

  5. 此时将出现一个新选项卡,其中列出了模型组中的模型版本。

  6. 在模型版本列表中,选择您要查看其详细信息的模型版本的名称。

  7. 在打开的模型版本选项卡上,选择以下选项之一,以查看有关模型版本的详细信息:

    • 活动:显示模型版本的事件,例如批准状态更新。

    • 模型质量:报告与 Model Monitor 模型质量检查相关的指标,这些指标将模型预测与 Ground Truth 进行比较。有关 Model Monitor 模型质量检查的更多信息,请参阅模型质量

    • 可解释性:报告与 Model Monitor 特征归因检查相关的指标,这些指标比较训练数据与实时数据中特征的相对排名。有关 Model Monitor 可解释性检查的更多信息,请参阅生产中模型的特征归因漂移

    • 偏差:报告与 Model Monitor 偏差偏移检查相关的指标,这些指标将比较实时数据与训练数据的分布情况。有关 Model Monitor 偏差偏移检查的更多信息,请参阅量产模型的偏差漂移

    • Inference Recommender:根据您的模型和示例负载提供初始实例建议,以实现出色性能。

    • 负载测试:当您提供特定的生产要求(如延迟和吞吐量约束)时,针对您选择的实例类型运行负载测试。

    • 推理规范:显示实时推理和转换任务的实例类型,以及有关您的 Ama ECR zon 容器的信息。

    • 信息:显示模型版本关联的项目、生成模型的管道、模型组以及模型在 Amazon S3 中的位置等信息。