언어 기반 모델 조정(생성형 AI)
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
미세 조정 데이터 세트로 언어 기반 모델을 미세 조정합니다.
코드 샘플
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],[],[],[],null,["Tune language foundation models with a tuning dataset.\n\nCode sample \n\nJava\n\n\nBefore trying this sample, follow the Java setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Java API\nreference documentation](/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.CreatePipelineJobRequest.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.LocationName.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.html.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.RuntimeConfig.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineServiceClient.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineServiceSettings.html;\n import com.google.protobuf.https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Value.html;\n import java.io.IOException;\n import java.util.HashMap;\n import java.util.Map;\n\n public class CreatePipelineJobModelTuningSample {\n\n public static void main(String[] args) throws IOException {\n // TODO(developer): Replace these variables before running the sample.\n String project = \"PROJECT\";\n String location = \"europe-west4\"; // europe-west4 and us-central1 are the supported regions\n String pipelineJobDisplayName = \"PIPELINE_JOB_DISPLAY_NAME\";\n String modelDisplayName = \"MODEL_DISPLAY_NAME\";\n String outputDir = \"OUTPUT_DIR\";\n String datasetUri = \"DATASET_URI\";\n int trainingSteps = 300;\n\n createPipelineJobModelTuningSample(\n project,\n location,\n pipelineJobDisplayName,\n modelDisplayName,\n outputDir,\n datasetUri,\n trainingSteps);\n }\n\n // Create a model tuning job\n public static void createPipelineJobModelTuningSample(\n String project,\n String location,\n String pipelineJobDisplayName,\n String modelDisplayName,\n String outputDir,\n String datasetUri,\n int trainingSteps)\n throws IOException {\n final String endpoint = String.format(\"%s-aiplatform.googleapis.com:443\", location);\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineServiceSettings.html pipelineServiceSettings =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineServiceSettings.html.newBuilder().setEndpoint(endpoint).build();\n\n // Initialize client that will be used to send requests. This client only needs to be created\n // once, and can be reused for multiple requests.\n try (https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineServiceClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineServiceClient.html.create(pipelineServiceSettings)) {\n Map\u003cString, Value\u003e parameterValues = new HashMap\u003c\u003e();\n parameterValues.put(\"project\", stringToValue(project));\n parameterValues.put(\"model_display_name\", stringToValue(modelDisplayName));\n parameterValues.put(\"dataset_uri\", stringToValue(datasetUri));\n parameterValues.put(\n \"location\",\n stringToValue(\n \"us-central1\")); // Deployment is only supported in us-central1 for Public Preview\n parameterValues.put(\"large_model_reference\", stringToValue(\"text-bison@001\"));\n parameterValues.put(\"train_steps\", numberToValue(trainingSteps));\n parameterValues.put(\"accelerator_type\", stringToValue(\"GPU\")); // Optional: GPU or TPU\n\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.RuntimeConfig.html runtimeConfig =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.RuntimeConfig.html.newBuilder()\n .setGcsOutputDirectory(outputDir)\n .https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.RuntimeConfig.Builder.html#com_google_cloud_aiplatform_v1_PipelineJob_RuntimeConfig_Builder_putAllParameterValues_java_util_Map_java_lang_String_com_google_protobuf_Value__(parameterValues)\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.html pipelineJob =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.html.newBuilder()\n .https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.Builder.html#com_google_cloud_aiplatform_v1_PipelineJob_Builder_setTemplateUri_java_lang_String_(\n \"https://us-kfp.pkg.dev/ml-pipeline/large-language-model-pipelines/tune-large-model/v2.0.0\")\n .setDisplayName(pipelineJobDisplayName)\n .https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.Builder.html#com_google_cloud_aiplatform_v1_PipelineJob_Builder_setRuntimeConfig_com_google_cloud_aiplatform_v1_PipelineJob_RuntimeConfig_(runtimeConfig)\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.LocationName.html parent = https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.LocationName.html.of(project, location);\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.CreatePipelineJobRequest.html request =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.CreatePipelineJobRequest.html.newBuilder()\n .setParent(parent.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.LocationName.html#com_google_cloud_aiplatform_v1_LocationName_toString__())\n .setPipelineJob(pipelineJob)\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.html response = client.createPipelineJob(request);\n System.out.format(\"response: %s\\n\", response);\n System.out.format(\"Name: %s\\n\", response.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.PipelineJob.html#com_google_cloud_aiplatform_v1_PipelineJob_getName__());\n }\n }\n\n static https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Value.html stringToValue(String str) {\n return https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Value.html.newBuilder().setStringValue(str).build();\n }\n\n static https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Value.html numberToValue(int n) {\n return https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Value.html.newBuilder().setNumberValue(n).build();\n }\n }\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=aiplatform)."]]