使用 JumpStart 进行 Sagemaker 端点调用

问题描述 投票:0回答:1

我在 sagemaker 端点后面部署了一个经过微调的模型。当我遵循官方教程时(here),我尝试使用以下代码调用端点:

response = client.invoke_endpoint(EndpointName=endpoint_name, 
                                  ContentType='application/x-text', 
                                  Body=encoded_text, 
                                  Accept='application/json',
                                  InferenceComponentName=inf_comp_name
                                  )

这返回了以下错误:

ParamValidationError:参数验证失败: 输入中的未知参数:“InferenceComponentName”,必须是以下之一:EndpointName、Body、ContentType、Accept、CustomAttributes、TargetModel、TargetVariant、TargetContainerHostname、InferenceId、EnableExplanations

这表明“invoke_endpoint”函数不接受“nferenceComponentName”作为输入。接下来,我尝试将“InferenceComponentName”添加为自定义属性,如下所示:


response = client.invoke_endpoint(EndpointName=endpoint_name, 
                                  ContentType='application/x-text', 
                                  Body=encoded_text, 
                                  Accept='application/json',
                                  CustomAttributes="InferenceComponentName=[NAME]")

这会产生以下错误:

您计划部署推理组件的端点需要推理组件名称标头。请包含推理组件名称标题。

基于此,我需要添加“nferenceComponentName”作为输入,但是当我这样做时,它会抛出一个错误,指出它无效。这个问题的可能解决方案是什么?我正在通过使用 Python 3.10 和 boto3 1.28.64 的 sagemaker 笔记本查询端点。

我尝试按照官方教程中的描述查询端点。所发生的情况是,按照文档中所述查询端点会导致由于传递无效参数而导致的错误。此外,当调用中省略所述参数时,会抛出另一个错误,这表明所述参数是必要的。

python amazon-web-services amazon-sagemaker
1个回答
0
投票

请将您的 python SDK 更新到最新版本,以便包含 InferenceComponent(IC)。有关如何配置 IC 的一些示例可以在此处找到 - https://aws.amazon.com/blogs/machine-learning/reduce-model-deployment-costs-by-50-on-average-using-sagemakers -最新功能/

© www.soinside.com 2019 - 2024. All rights reserved.