커스텀 가중치로 모델을 배포하는 것은 프리뷰로 제공됩니다. 사전 정의된 기본 모델 세트를 기반으로 모델을 미세 조정하고 맞춤설정된 모델을 Vertex AI Model Garden에 배포할 수 있습니다. Vertex AI에서 클릭 한 번으로 모델 아티팩트를 프로젝트의 Cloud Storage 버킷에 업로드하여 커스텀 가중치 가져오기를 사용해 커스텀 모델을 배포할 수 있습니다.
지원되는 모델
커스텀 가중치로 모델 배포 공개 프리뷰는 다음 기본 모델에서 지원됩니다.
모델 이름 | 버전 |
---|---|
Llama |
|
Gemma |
|
Qwen |
|
Deepseek |
|
Mistral 및 Mixtral |
|
Phi-4 |
|
OpenAI OSS |
|
제한사항
커스텀 가중치는 양자화된 모델의 가져오기를 지원하지 않습니다.
모델 파일
Hugging Face 가중치 형식으로 모델 파일을 제공해야 합니다. Hugging Face 가중치 형식에 관한 자세한 내용은 Hugging Face 모델 사용을 참조하세요.
필수 파일이 제공되지 않으면 모델 배포가 실패할 수 있습니다.
이 표에는 모델 아키텍처에 따라 달라지는 모델 파일 유형이 나와 있습니다.
모델 파일 콘텐츠 | 파일 형식 |
---|---|
모델 구성 |
|
모델 가중치 |
|
가중치 색인 |
|
토크나이저 파일 |
|
위치
Model Garden 서비스에서 모든 리전에 커스텀 모델을 배포할 수 있습니다.
기본 요건
이 섹션에서는 커스텀 모델을 배포하는 방법을 보여줍니다.
시작하기 전에
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
- REGION: 사용자의 리전. 예를 들면
uscentral1
입니다. - MODEL_GCS: Google Cloud 모델. 예를 들면
gs://custom-weights-fishfooding/meta-llama/Llama-3.2-1B-Instruct
입니다. - PROJECT_ID: 프로젝트 ID.
- MODEL_ID: 모델 ID
- MACHINE_TYPE: 머신 유형. 예를 들면
g2-standard-12
입니다. - ACCELERATOR_TYPE: 가속기 유형. 예를 들면
NVIDIA_L4
입니다. - ACCELERATOR_COUNT: 가속기 수
PROMPT: 텍스트 프롬프트
Google Cloud 콘솔에서 Model Garden 페이지로 이동합니다.
커스텀 가중치로 모델 배포를 클릭합니다. Vertex AI에서 커스텀 가중치로 모델 배포 창이 표시됩니다.
모델 소스 섹션에서 다음을 수행합니다.
찾아보기를 클릭하고 모델이 저장된 버킷을 선택한 다음 선택을 클릭합니다.
선택사항: 모델 이름 필드에 모델 이름을 입력합니다.
대상 설정 섹션에서 다음을 수행합니다.
리전 필드에서 리전을 선택하고 확인을 클릭합니다.
머신 사양 필드에서 모델을 배포하는 데 사용되는 머신 사양을 선택합니다.
선택사항: 엔드포인트 이름 필드에 모델의 엔드포인트가 기본적으로 표시됩니다. 하지만 필드에 다른 엔드포인트 이름을 입력할 수 있습니다.
커스텀 가중치로 모델 배포를 클릭합니다.
- 자체 배포된 모델에 대한 자세한 내용은 자체 배포된 모델 개요를 참조하세요.
- Model Garden에 대한 자세한 내용은 Model Garden 개요를 참조하세요.
- 모델 배포에 관한 자세한 내용은 Model Garden에서 모델 사용을 참고하세요.
- Gemma 개방형 모델 사용
- Llama 개방형 모델 사용
- Hugging Face 개방형 모델 사용
이 튜토리얼에서는 Cloud Shell을 사용하여 Google Cloud와 상호작용한다고 가정합니다. Cloud Shell 대신 다른 셸을 사용하려면 다음 추가 구성을 수행하세요.
커스텀 모델 배포
이 섹션에서는 커스텀 모델을 배포하는 방법을 보여줍니다.
명령줄 인터페이스(CLI), Python 또는 JavaScript를 사용하는 경우 다음 변수를 코드 샘플이 작동하는 값으로 바꿉니다.
콘솔
다음 단계에서는 Google Cloud 콘솔을 사용하여 커스텀 가중치로 모델을 배포하는 방법을 보여줍니다.
gcloud CLI
이 명령어는 특정 리전에 모델을 배포하는 방법을 보여줍니다.
gcloud ai model-garden models deploy --model=${MODEL_GCS} --region ${REGION}
이 명령어는 머신 유형, 가속기 유형, 가속기 수를 사용하여 특정 리전에 모델을 배포하는 방법을 보여줍니다. 특정 머신 구성을 선택하려면 세 필드를 모두 설정해야 합니다.
gcloud ai model-garden models deploy --model=${MODEL_GCS} --machine-type=${MACHINE_TYE} --accelerator-type=${ACCELERATOR_TYPE} --accelerator-count=${ACCELERATOR_COUNT} --region ${REGION}
Python
import vertexai
from google.cloud import aiplatform
from vertexai.preview import model_garden
vertexai.init(project=${PROJECT_ID}, location=${REGION})
custom_model = model_garden.CustomModel(
gcs_uri=GCS_URI,
)
endpoint = custom_model.deploy(
machine_type="${MACHINE_TYPE}",
accelerator_type="${ACCELERATOR_TYPE}",
accelerator_count="${ACCELERATOR_COUNT}",
model_display_name="custom-model",
endpoint_display_name="custom-model-endpoint")
endpoint.predict(instances=[{"prompt": "${PROMPT}"}], use_dedicated_endpoint=True)
또는 custom_model.deploy()
메서드에 파라미터를 전달하지 않아도 됩니다.
import vertexai
from google.cloud import aiplatform
from vertexai.preview import model_garden
vertexai.init(project=${PROJECT_ID}, location=${REGION})
custom_model = model_garden.CustomModel(
gcs_uri=GCS_URI,
)
endpoint = custom_model.deploy()
endpoint.predict(instances=[{"prompt": "${PROMPT}"}], use_dedicated_endpoint=True)
curl
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${REGION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${REGION}:deploy" \
-d '{
"custom_model": {
"gcs_uri": "'"${MODEL_GCS}"'"
},
"destination": "projects/'"${PROJECT_ID}"'/locations/'"${REGION}"'",
"model_config": {
"model_user_id": "'"${MODEL_ID}"'",
},
}'
또는 API를 사용하여 머신 유형을 명시적으로 설정할 수 있습니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${REGION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${REGION}:deploy" \
-d '{
"custom_model": {
"gcs_uri": "'"${MODEL_GCS}"'"
},
"destination": "projects/'"${PROJECT_ID}"'/locations/'"${REGION}"'",
"model_config": {
"model_user_id": "'"${MODEL_ID}"'",
},
"deploy_config": {
"dedicated_resources": {
"machine_spec": {
"machine_type": "'"${MACHINE_TYPE}"'",
"accelerator_type": "'"${ACCELERATOR_TYPE}"'",
"accelerator_count": '"${ACCELERATOR_COUNT}"'
},
"min_replica_count": 1
}
}
}'