

# 사용자 지정 모델 온디맨드 추론용 배포
<a name="deploy-custom-model"></a>

모델 사용자 지정 작업(미세 조정, 증류, 또는 지속적 사전 학습)을 통해 사용자 지정 모델을 성공적으로 생성한 후, 해당 모델에 대해 온디맨드 추론을 설정할 수 있습니다.

사용자 지정 모델의 온디맨드 추론을 설정하려면, 사용자 지정 모델 배포를 통해 모델을 배포해야 합니다. 모델을 배포한 후에는 배포된 모델의 Amazon 리소스 이름(ARN)을 `InvokeModel` 또는 `Converse` API 작업에서 `modelId` 파라미터로 사용합니다. 배포된 모델은 Amazon Bedrock의 플레이그라운드, 에이전트, 지식 베이스 등의 기능에서 온디맨드 추론용으로 활용할 수 있습니다.

**Topics**
+ [지원되는 모델](#custom-model-inference-supported-models)
+ [사용자 지정 모델 배포](deploying-custom-model.md)
+ [온디맨드 추론용 배포 사용](use-custom-model-on-demand.md)
+ [사용자 지정 모델 배포 삭제](delete-custom-model-deployment.md)

## 지원되는 모델
<a name="custom-model-inference-supported-models"></a>

다음 모델에 대해 온디맨드 추론을 설정할 수 있습니다.
+ Amazon Nova Canvas
+ Amazon Nova Lite
+ Amazon Nova Micro
+ Amazon Nova Pro

# 사용자 지정 모델 배포
<a name="deploying-custom-model"></a>

사용자 지정 모델은 Amazon Bedrock 콘솔, AWS Command Line Interface 또는 AWS를 사용하여 배포할 수 있습니다. 배포를 추론에 활용하는 방법에 대한 자세한 내용은 [온디맨드 추론용 배포 사용](https://docs.aws.amazon.com/bedrock/latest/userguide/use-custom-model-on-demand.html)을 참조하세요.

**Topics**
+ [사용자 지정 모델 배포(콘솔)](#deploy-custom-model-console)
+ [사용자 지정 모델 배포(AWS Command Line Interface)](#deploy-custom-model-cli)
+ [사용자 지정 모델 배포(AWS SDK)](#deploy-custom-model-sdk)

## 사용자 지정 모델 배포(콘솔)
<a name="deploy-custom-model-console"></a>

사용자 지정 모델은 **사용자 지정 모델** 페이지에서 다음과 같이 배포할 수 있습니다. 동일한 필드를 사용하여 **온디맨드 사용자 지정 모델** 페이지에서도 모델을 배포할 수 있습니다. 이 페이지를 찾으려면 탐색 창에서 **추론 및 평가** 아래의 **온디맨드 사용자 지정 모델**을 선택합니다.

**사용자 지정 모델 배포 방법**

1. [Amazon Bedrock 권한이 있는 IAM 역할](https://docs.aws.amazon.com//bedrock/latest/userguide/getting-started.html)을 사용하여 AWS Management Console에 로그인하고 [https://console.aws.amazon.com/nova/](https://console.aws.amazon.com/nova/)에서 Amazon Bedrock 콘솔을 엽니다.

1. 왼쪽 탐색 창의 **파운데이션 모델**에서 **사용자 지정 모델**을 선택합니다.

1. **모델** 탭에서 배포할 모델의 라디오 버튼을 선택합니다.

1. **추론 설정**과 **온디맨드 배포**를 차례로 선택합니다.

1. **배포 세부 정보**에서 다음 정보를 입력합니다.
   + **배포 이름**(필수) – 배포의 고유 이름을 입력합니다.
   + **설명**(선택 사항) – 배포에 대한 설명을 입력합니다.
   + **태그**(선택 사항) - 비용 할당 및 리소스 관리를 위해 태그를 추가합니다.

1. **생성(Create)**을 선택합니다. 배포 상태가 `Completed`가 되면, 사용자 지정 모델을 온디맨드 추론에 사용할 준비가 완료된 것입니다. 사용자 지정 모델 사용 방법에 대한 자세한 내용은 [온디맨드 추론용 배포 사용](https://docs.aws.amazon.com/bedrock/latest/userguide/use-custom-model-on-demand.html)을 참조하세요.

## 사용자 지정 모델 배포(AWS Command Line Interface)
<a name="deploy-custom-model-cli"></a>

AWS Command Line Interface를 사용하여 사용자 지정 모델을 온디맨드 추론용으로 배포하려면, 사용자 지정 모델의 Amazon 리소스 이름(ARN)을 사용하여 `create-custom-model-deployment` 명령어를 실행합니다. 이 명령은 [CreateCustomModelDeployment](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_CreateCustomModelDeployment.html) API 작업을 사용합니다. 실행 결과로 반환되는 배포의 ARN을 추론 요청 시 `modelId`로 사용할 수 있습니다. 배포를 추론에 활용하는 방법에 대한 자세한 내용은 [온디맨드 추론용 배포 사용](https://docs.aws.amazon.com/bedrock/latest/userguide/use-custom-model-on-demand.html)을 참조하세요.

```
aws bedrock create-custom-model-deployment \
--model-deployment-name "Unique name" \
--model-arn "Custom Model ARN" \
--description "Deployment description" \
--tags '[
    {
        "key": "Environment",
        "value": "Production"
    },
    {
        "key": "Team",
        "value": "ML-Engineering"
    },
    {
        "key": "Project",
        "value": "CustomerSupport"
    }
]' \
--client-request-token "unique-deployment-token" \
--region region
```

## 사용자 지정 모델 배포(AWS SDK)
<a name="deploy-custom-model-sdk"></a>

온디맨드 추론을 위해 사용자 지정 모델을 배포하려면, 사용자 지정 모델의 Amazon 리소스 이름(ARN)과 함께 [CreateCustomModelDeployment](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_CreateCustomModelDeployment.html) API 작업을 사용합니다. 실행 결과로 반환되는 배포의 ARN을 추론 요청 시 `modelId`로 사용할 수 있습니다. 배포를 추론에 활용하는 방법에 대한 자세한 내용은 [온디맨드 추론용 배포 사용](https://docs.aws.amazon.com/bedrock/latest/userguide/use-custom-model-on-demand.html)을 참조하세요.

다음 코드는 Python용 SDK(Boto3)를 사용하여 사용자 지정 모델을 배포하는 방법을 보여줍니다.

```
def create_custom_model_deployment(bedrock_client):
    """Create a custom model deployment
    Args:
        bedrock_client: A boto3 Bedrock client for making API calls
 
    Returns:
        str: The ARN of the created custom model deployment
 
    Raises:
        Exception: If there is an error creating the deployment
    """
 
    try:
        response = bedrock_client.create_custom_model_deployment(
            modelDeploymentName="Unique deployment name",
            modelArn="Custom Model ARN",
            description="Deployment description",
            tags=[
                {'key': 'Environment', 'value': 'Production'},
                {'key': 'Team', 'value': 'ML-Engineering'},
                {'key': 'Project', 'value': 'CustomerSupport'}
            ],
            clientRequestToken=f"deployment-{uuid.uuid4()}"
        )
 
        deployment_arn = response['customModelDeploymentArn']
        print(f"Deployment created: {deployment_arn}")
        return deployment_arn
 
    except Exception as e:
        print(f"Error creating deployment: {str(e)}")
        raise
```

# 온디맨드 추론용 배포 사용
<a name="use-custom-model-on-demand"></a>

사용자 지정 모델을 온디맨드 추론용으로 배포한 후에는 추론 요청을 보내 응답을 생성할 수 있습니다. `InvokeModel` 또는 `Converse` 작업을 사용할 때는 배포된 모델의 Amazon 리소스 이름(ARN)을 `modelId`로 지정합니다.

추론 요청 방법에 대한 자세한 내용은 다음 주제를 참조하세요.
+ [모델 추론을 사용하여 프롬프트 제출 및 응답 생성](https://docs.aws.amazon.com/bedrock/latest/userguide/inference.html)
+ [모델 추론 실행을 위한 사전 조건](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html)
+ [API를 사용하여 프롬프트 제출 및 응답 생성](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-api.html)

# 사용자 지정 모델 배포 삭제
<a name="delete-custom-model-deployment"></a>

온디맨드 추론에 모델 사용을 마친 후에는 배포를 삭제할 수 있습니다. 배포를 삭제하면 해당 배포를 온디맨드 추론에 사용할 수 없지만, 기본 사용자 지정 모델 자체가 삭제되지는 않습니다.

사용자 지정 모델은 Amazon Bedrock 콘솔, AWS Command Line Interface 또는 AWS SDK를 사용하여 삭제할 수 있습니다.

**중요**  
사용자 지정 모델 배포 삭제는 되돌릴 수 없는 작업입니다. 삭제를 진행하기 전에 해당 배포가 더 이상 필요하지 않은지 반드시 확인합니다. 동일한 사용자 지정 모델을 다시 온디맨드 추론에 사용하려면, 새로운 배포를 생성해야 합니다.

**Topics**
+ [사용자 지정 모델 배포 삭제(콘솔)](#delete-deployment-console)
+ [사용자 지정 모델 배포 삭제(AWS Command Line Interface)](#delete-deployment-cli)
+ [사용자 지정 모델 배포 삭제(AWS SDK)](#delete-deployment-sdk)

## 사용자 지정 모델 배포 삭제(콘솔)
<a name="delete-deployment-console"></a>

**사용자 지정 모델 배포를 삭제하려면 다음 단계를 수행합니다.**

1. 탐색 창에서 **추론 및 평가** 아래의 **온디맨드 사용자 지정 모델**을 선택합니다.

1. 삭제하려는 사용자 지정 모델 배포를 선택합니다.

1. **삭제**를 선택합니다.

1. 확인 대화 상자에서 삭제를 확인하기 위해 배포 이름을 입력합니다.

1. [**삭제**]를 선택하여 확인합니다.

삭제가 진행되는 동안 배포 상태가 `Deleting`로 변경됩니다. 삭제가 완료되면 해당 배포는 목록에서 제거됩니다.

## 사용자 지정 모델 배포 삭제(AWS Command Line Interface)
<a name="delete-deployment-cli"></a>

AWS Command Line Interface를 사용하여 사용자 지정 모델 배포를 삭제하려면, `delete-custom-model-deployment` 명령어와 배포 식별자를 사용합니다.

```
aws bedrock delete-custom-model-deployment \
--custom-model-deployment-identifier "deployment-arn-or-name" \
--region region
```

## 사용자 지정 모델 배포 삭제(AWS SDK)
<a name="delete-deployment-sdk"></a>

프로그래밍 방식으로 사용자 지정 모델 배포를 삭제하려면, 배포의 Amazon 리소스 이름(ARN) 또는 이름을 사용하여 [DeleteCustomModelDeployment](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_DeleteCustomModelDeployment.html) API 작업을 호출합니다. 다음 코드는 Python용 SDK(Boto3)를 사용하여 사용자 지정 모델 배포를 삭제하는 방법을 보여줍니다.

```
def delete_custom_model_deployment(bedrock_client):
    """Delete a custom model deployment
 
    Args:
        bedrock_client: A boto3 Bedrock client for making API calls
 
    Returns:
        dict: The response from the delete operation
 
    Raises:
        Exception: If there is an error deleting the deployment
    """
 
    try:
        response = bedrock_client.delete_custom_model_deployment(
            customModelDeploymentIdentifier="Deployment identifier"
        )
 
        print(f"Deployment deletion initiated")
        return response
 
    except Exception as e:
        print(f"Error deleting deployment: {str(e)}")
        raise
```