View a markdown version of this page

部署模型 - Amazon Bedrock

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

部署模型

訂閱模型後,您可以將其部署到 SageMaker AI 端點。您對端點進行推論呼叫。此模型由 SageMaker AI 託管。在部署過程中,您提供下列資訊:

  • SageMaker AI 端點的名稱

  • 對端點進行推論呼叫的執行個體數量

  • 端點的執行個體類型

您也可以設定選用的進階選項,例如標籤。

SageMaker AI 服務角色會自動建立,供 SageMaker AI 擔任該角色和代表您執行動作。如需 Amazon SageMaker AI 許可的詳細資訊,請參閱如何使用 SageMaker AI 執行角色

或者,您可以選擇現有的角色或新建角色。若要了解如何部署 Amazon Bedrock 市集模型,請選取與您所選方法對應的索引標籤,然後依照步驟操作。

部署模型
  1. AWS 管理主控台 使用具有 Amazon Bedrock 許可的 IAM 角色登入 。

  2. 在搜尋列中指定「Amazon Bedrock」,然後從下拉式清單中選擇 Amazon Bedrock

  3. 從導覽窗格選擇模型目錄

  4. 選擇您要部署之模型的模型卡。

  5. 選擇部署

  6. 端點名稱,指定端點的名稱。

  7. 選擇執行個體數量,以及選取執行個體類型。

  8. 進階設定下,您可以選用:

    1. 設定 VPC

    2. 設定服務存取角色

    3. 自訂加密設定

    4. 新增標籤

  9. 選擇部署,將 Amazon Bedrock 市集模型部署到 SageMaker AI 端點。此程序通常需要 10-15 分鐘。

使用 CreateMarketplaceModelEndpoint 操作來建立端點。某些模型具有最終使用者授權協議 (EULA)。若要接受 EULA,請將 AcceptEula 設為 True

下列範例使用範例 AWS Command Line Interface 命令來建立端點:

aws bedrock create-marketplace-model-endpoint --model-source-identifier HubContentArn --endpoint-config "{\"sageMaker\":{\"initialInstanceCount\":1,\"instanceType\":\"ml.g5.xlarge\",\"executionRole\":\"arn:aws:iam::111122223333:role/example-IAM-role\"}}" --endpoint-name "example-endpoint-name"
注意

CreateMarketplaceModelEndpointUpdateMarketplaceModelEndpointRegisterMarketplaceModelEndpoint 操作的回應都是相同的。

{"marketplaceModelEndpoint":{"createdAt":"2024-11-12T02:31:58.201474085Z","endpoint":{"sageMaker":{"executionRole":"arn:aws:iam::111122223333:role/service-role/amazon-sagemaker-execution-role","initialInstanceCount":1,"instanceType":"ml.g5.2xlarge","kmsEncryptionKey":null,"vpc":null}},"endpointArn":"arn:aws:sagemaker:region:555555555555:endpoint/example-endpoint-name","endpointStatus":"Creating","endpointStatusMessage":"","modelSourceIdentifier":"arn:aws:sagemaker:region:aws:hub-content/SageMakerPublicHub/Model/example-model-name/1.2.2","status":"ACTIVE","statusMessage":"","updatedAt":"2024-11-12T02:31:58.201474085Z"}}

您可以同時在 Amazon Bedrock 市集和 Amazon SageMaker AI 中修改端點。我們建議只在 Amazon Bedrock 中修改端點。如果您在 SageMaker AI 中修改端點,則可能無法在 Amazon Bedrock 中使用端點。以下是可能導致 Amazon Bedrock 內端點失敗的修改:

若要讓端點運作,該端點必須為已註冊且服務中的狀態。您可以使用下列 AWS Command Line Interface 命令來檢查端點的狀態。

aws bedrock get-marketplace-model-endpoint --endpoint-arn arn:aws:sagemaker:region:111122223333:endpoint/example-endpoint-name

端點必須具有下列狀態,才能與 Amazon Bedrock 搭配使用:

endpointStatus: InService status: REGISTERED

如果所做的修改導致端點失敗,您可以取消註冊並重新註冊端點。使用 DeregisterEndpoint 操作取消註冊端點。使用 RegisterEndpoint 操作重新註冊端點。

aws bedrock deregister-marketplace-model-endpoint --endpoint-arn arn:aws:sagemaker:region:111122223333:endpoint/example-endpoint-name
aws bedrock register-marketplace-model-endpoint --endpoint-identifier arn:aws:sagemaker:region:111122223333:endpoint/example-endpoint-name --model-source-identifier HubContentArn