使用 AWS sagemaker 执行 A/B 测试时如何设置推理调用的百分比?
How to set the percentage of inference calls when performing A/B testing using AWS sagemaker?
我是 sagemaker 的新手。我正在尝试弄清楚如何使用 AWS sagemaker 执行 A/B 测试。我知道设置 train_instance_count 会在两个实例之间分配训练。但是我如何指定设置每个模型将处理和执行 A/B 测试的推理调用百分比?
这是我能从文档中找到的所有内容
"Amazon SageMaker can also manage model A/B testing for you. You can
configure the endpoint to spread traffic across as many as five
different models and set the percentage of inference calls you want
each one to handle. You can change all of this on the fly, giving you
a lot of flexibility to run experiments and determine which model
produces the most accurate results in the real world."
您可以在一个 Amazon SageMaker 端点后面有多个生产变体。每个生产变体都有一个初始变体权重,并且根据每个变体权重与权重总和的比率,SageMaker 可以将调用分配给每个模型。例如,如果您只有一个权重为 1 的生产变体,则所有流量都将流向该变体。如果您添加另一个初始权重为 2 的生产变体,则新变体将获得 2/3 的流量,而第一个变体将获得 1/3。
您可以在此处的 Amazon SageMaker 文档中查看有关 ProductionVariant 的更多详细信息:https://docs.aws.amazon.com/sagemaker/latest/dg/API_ProductionVariant.html
当您 "Create Endpoint Configuration" 时,您可以提供 ProductionVariants 数组:https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpointConfig.html , and you can update the variants with "Update Endpoint Weights and Capacities" call: https://docs.aws.amazon.com/sagemaker/latest/dg/API_UpdateEndpointWeightsAndCapacities.html
你可以使用这样的东西,我刚刚创建了一个函数,它使用一些用户输入来实现 AWS SDK 库。该示例根据以下代码中的 InitialVariantWeight 参数,以 1:1 的比例为 model1 和 model2 分配流量。有关 SageMaker 库的详细信息,请参见此处:https://boto3.readthedocs.io/en/latest/reference/services/sagemaker.html
def custom_create_endpoint_config(model1,model2,endpoint_config_name,instancetype= 'm1.t2.medium'):
response = client.create_endpoint_config(
EndpointConfigName=endpoint_config_name,
ProductionVariants= [
{
'VariantName': 'variant1',
'ModelName': model1,
'InitialInstanceCount': 1,
'InstanceType': instancetype,
'InitialVariantWeight': 1
},
{
'VariantName': 'variant2',
'ModelName': model2,
'InitialInstanceCount': 1,
'InstanceType': instancetype,
'InitialVariantWeight': 1
},],
Tags=[
{
'Key': str(endpoint_config_name +'_key'),
'Value': str(endpoint_config_value +'_value')
},]
)
def custom_delete_endpoint_config(endpoint_config_name):
client.delete_endpoint_config(\
EndpointConfigName=config_name)
我是 sagemaker 的新手。我正在尝试弄清楚如何使用 AWS sagemaker 执行 A/B 测试。我知道设置 train_instance_count 会在两个实例之间分配训练。但是我如何指定设置每个模型将处理和执行 A/B 测试的推理调用百分比? 这是我能从文档中找到的所有内容
"Amazon SageMaker can also manage model A/B testing for you. You can configure the endpoint to spread traffic across as many as five different models and set the percentage of inference calls you want each one to handle. You can change all of this on the fly, giving you a lot of flexibility to run experiments and determine which model produces the most accurate results in the real world."
您可以在一个 Amazon SageMaker 端点后面有多个生产变体。每个生产变体都有一个初始变体权重,并且根据每个变体权重与权重总和的比率,SageMaker 可以将调用分配给每个模型。例如,如果您只有一个权重为 1 的生产变体,则所有流量都将流向该变体。如果您添加另一个初始权重为 2 的生产变体,则新变体将获得 2/3 的流量,而第一个变体将获得 1/3。
您可以在此处的 Amazon SageMaker 文档中查看有关 ProductionVariant 的更多详细信息:https://docs.aws.amazon.com/sagemaker/latest/dg/API_ProductionVariant.html
当您 "Create Endpoint Configuration" 时,您可以提供 ProductionVariants 数组:https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpointConfig.html , and you can update the variants with "Update Endpoint Weights and Capacities" call: https://docs.aws.amazon.com/sagemaker/latest/dg/API_UpdateEndpointWeightsAndCapacities.html
你可以使用这样的东西,我刚刚创建了一个函数,它使用一些用户输入来实现 AWS SDK 库。该示例根据以下代码中的 InitialVariantWeight 参数,以 1:1 的比例为 model1 和 model2 分配流量。有关 SageMaker 库的详细信息,请参见此处:https://boto3.readthedocs.io/en/latest/reference/services/sagemaker.html
def custom_create_endpoint_config(model1,model2,endpoint_config_name,instancetype= 'm1.t2.medium'):
response = client.create_endpoint_config(
EndpointConfigName=endpoint_config_name,
ProductionVariants= [
{
'VariantName': 'variant1',
'ModelName': model1,
'InitialInstanceCount': 1,
'InstanceType': instancetype,
'InitialVariantWeight': 1
},
{
'VariantName': 'variant2',
'ModelName': model2,
'InitialInstanceCount': 1,
'InstanceType': instancetype,
'InitialVariantWeight': 1
},],
Tags=[
{
'Key': str(endpoint_config_name +'_key'),
'Value': str(endpoint_config_value +'_value')
},]
)
def custom_delete_endpoint_config(endpoint_config_name):
client.delete_endpoint_config(\
EndpointConfigName=config_name)