Method: projects.locations.tuningJobs.create

Creates a TuningJob. A created TuningJob right away will be attempted to be run.

Endpoint

post https://{service-endpoint}/v1beta1/{parent}/tuningJobs

Where {service-endpoint} is one of the supported service endpoints.

Path parameters

parent string

Required. The resource name of the Location to create the TuningJob in. Format: projects/{project}/locations/{location}

Request body

The request body contains an instance of TuningJob.

Example request

Minimal

Python


import time

import vertexai
from vertexai.preview.tuning import sft

# TODO(developer): Update project
vertexai.init(project=PROJECT_ID, location="us-central1")

sft_tuning_job = sft.train(
    source_model="gemini-1.0-pro-002",
    train_dataset="gs://cloud-samples-data/ai-platform/generative_ai/sft_train_data.jsonl",
)

# Polling for job completion
while not sft_tuning_job.has_ended:
    time.sleep(60)
    sft_tuning_job.refresh()

print(sft_tuning_job.tuned_model_name)
print(sft_tuning_job.tuned_model_endpoint_name)
print(sft_tuning_job.experiment)

Advanced

Python


import time

import vertexai
from vertexai.preview.tuning import sft

# TODO(developer): Update project
vertexai.init(project=PROJECT_ID, location="us-central1")

sft_tuning_job = sft.train(
    source_model="gemini-1.0-pro-002",
    train_dataset="gs://cloud-samples-data/ai-platform/generative_ai/sft_train_data.jsonl",
    # The following parameters are optional
    validation_dataset="gs://cloud-samples-data/ai-platform/generative_ai/sft_validation_data.jsonl",
    epochs=4,
    adapter_size=4,
    learning_rate_multiplier=1.0,
    tuned_model_display_name="tuned_gemini_pro",
)

# Polling for job completion
while not sft_tuning_job.has_ended:
    time.sleep(60)
    sft_tuning_job.refresh()

print(sft_tuning_job.tuned_model_name)
print(sft_tuning_job.tuned_model_endpoint_name)
print(sft_tuning_job.experiment)

Response body

If successful, the response body contains a newly created instance of TuningJob.