Men-deploy model dengan bobot kustom adalah penawaran Pratinjau. Anda dapat menyetel model berdasarkan serangkaian model dasar yang telah ditentukan sebelumnya, dan men-deploy model yang telah disesuaikan di Vertex AI Model Garden. Anda dapat men-deploy model kustom menggunakan impor bobot kustom dengan mengupload artefak model ke bucket Cloud Storage di project Anda, yang merupakan pengalaman sekali klik di Vertex AI.
Model yang didukung
Pratinjau publik Deploy model dengan bobot kustom didukung oleh model dasar berikut:
Nama model | Version |
---|---|
Llama |
|
Gemma |
|
Qwen |
|
Deepseek |
|
Mistral dan Mixtral |
|
Phi-4 |
|
OSS OpenAI |
|
Batasan
Bobot kustom tidak mendukung impor model terkuantisasi.
File model
Anda harus menyediakan file model dalam format bobot Hugging Face. Untuk mengetahui informasi selengkapnya tentang format bobot Hugging Face, lihat Menggunakan Model Hugging Face.
Jika file yang diperlukan tidak disediakan, deployment model mungkin gagal.
Tabel ini mencantumkan jenis file model, yang bergantung pada arsitektur model:
Konten file model | Jenis file |
---|---|
Konfigurasi model |
|
Bobot model |
|
Indeks berat |
|
File tokenizer |
|
Lokasi
Anda dapat men-deploy model kustom di semua region dari layanan Model Garden.
Prasyarat
Bagian ini menunjukkan cara men-deploy model kustom Anda.
Sebelum memulai
- 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.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
-
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: Region Anda. Misalnya,
uscentral1
. - MODEL_GCS: Model Google Cloud Anda. Contohnya,
gs://custom-weights-fishfooding/meta-llama/Llama-3.2-1B-Instruct
- PROJECT_ID: Project ID Anda.
- MODEL_ID: ID model Anda.
- MACHINE_TYPE: Jenis mesin Anda. Contohnya,
g2-standard-12
. - ACCELERATOR_TYPE: Jenis akselerator Anda. Contohnya,
NVIDIA_L4
. - ACCELERATOR_COUNT: Jumlah akselerator Anda.
PROMPT: Perintah teks Anda.
Di konsol Google Cloud , buka halaman Model Garden.
Klik Deploy model dengan bobot kustom. Panel Deploy model with custom weights on Vertex AI akan muncul.
Di bagian Sumber model, lakukan hal berikut:
Klik Telusuri, lalu pilih bucket tempat model Anda disimpan, dan klik Pilih.
Opsional: Masukkan nama model Anda di kolom Model name.
Di bagian Deployment settings, lakukan hal berikut:
Dari kolom Region, pilih region Anda, lalu klik OK.
Di kolom Spesifikasi Mesin, pilih spesifikasi mesin Anda, yang digunakan untuk men-deploy model Anda.
Opsional: Di kolom Endpoint name, endpoint model Anda akan muncul secara default. Namun, Anda dapat memasukkan nama endpoint yang berbeda di kolom.
Klik Deploy model dengan bobot kustom.
- Untuk mengetahui informasi selengkapnya tentang model yang di-deploy sendiri, lihat Ringkasan model yang di-deploy sendiri.
- Untuk mengetahui informasi selengkapnya tentang Model Garden, lihat Ringkasan Model Garden.
- Untuk mengetahui informasi selengkapnya tentang men-deploy model, lihat Menggunakan model di Model Garden.
- Menggunakan model terbuka Gemma
- Menggunakan model terbuka Llama
- Menggunakan model terbuka Hugging Face
Tutorial ini mengasumsikan bahwa Anda menggunakan Cloud Shell untuk berinteraksi dengan Google Cloud. Jika Anda ingin menggunakan shell lain, bukan Cloud Shell, lakukan konfigurasi tambahan berikut:
Men-deploy model kustom
Bagian ini menunjukkan cara men-deploy model kustom Anda.
Jika Anda menggunakan antarmuka command line (CLI), Python, atau JavaScript, ganti variabel berikut dengan nilai agar contoh kode Anda berfungsi:
Konsol
Langkah-langkah berikut menunjukkan cara menggunakan konsol Google Cloud untuk men-deploy model dengan bobot kustom.
gcloud CLI
Perintah ini menunjukkan cara men-deploy model ke region tertentu.
gcloud ai model-garden models deploy --model=${MODEL_GCS} --region ${REGION}
Perintah ini menunjukkan cara men-deploy model ke region tertentu dengan jenis mesin, jenis akselerator, dan jumlah akseleratornya. Jika ingin memilih konfigurasi mesin tertentu, Anda harus menyetel ketiga kolom.
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)
Atau, Anda tidak perlu meneruskan parameter ke
metode 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}"'",
},
}'
Atau, Anda dapat menggunakan API untuk menetapkan jenis mesin secara eksplisit.
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
}
}
}'