Model Registry를 사용하여 모델 버전 관리

모델 버전 관리를 사용하면 같은 모델의 버전을 여러 개 만들 수 있습니다. 모델 버전 관리를 사용하면 어떤 변경 사항이 모델에 어떤 영향을 미쳤는지 탐색하고 이해하는 데 도움이 되는 방식으로 모델을 구성할 수 있습니다. Model Registry를 사용하면 모델과 모든 모델 버전을 단일 뷰에서 볼 수 있습니다. 특정 모델 버전을 상세히 살펴보고 그 성능을 정확하게 확인할 수 있습니다.

새 모델 버전 가져오기

Model Registry에서 모델을 기존 모델의 새 버전으로 가져올 수 있습니다.

콘솔

  1. Google Cloud 콘솔에서 Model Registry 페이지로 이동합니다.
    Model Registry로 이동
  2. 페이지 상단에서 가져오기를 선택합니다.
  3. 새 버전으로 가져오기를 선택합니다.
  4. 드롭다운에서 이 모델을 새 버전으로 선택합니다. 선택적인 버전 설명을 추가합니다.
  5. 선택적으로 이 모델을 기본 버전으로 설정합니다. 예측에 모델을 사용할 때마다 기본 버전이 미리 선택되지만, 다른 버전도 선택할 수 있습니다.
  6. 리전을 선택합니다.
  7. 계속을 선택합니다.
  8. 모델 설정에서 사용할 컨테이너를 정의합니다. 모델 아티팩트를 사전 빌드된 새 컨테이너로 가져오거나 기존 커스텀 컨테이너로 가져오도록 선택할 수 있습니다. 컨테이너에 대한 자세한 내용은 Vertex AI로 모델 가져오기를 참조하세요.
  9. 계속을 선택합니다.
  10. 선택사항: 모델에 설명 기능 지원을 추가합니다.
  11. 가져오기를 선택합니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID입니다.
  • LOCATION: 위치입니다.
  • MODEL_DISPLAY_NAME: 모델 이름입니다.
  • ARTIFACT_URI: 모델 아티팩트 및 지원 파일이 포함된 디렉터리의 경로입니다.
  • IMAGE_URI: 예측 제공을 위해 커스텀 컨테이너로 사용할 Docker 이미지입니다.
  • PARENT_MODEL: 버전을 업로드할 모델의 리소스 이름입니다.

HTTP 메서드 및 URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/models:upload

JSON 요청 본문:

{

  "model": {
    "displayName": "MODEL_DISPLAY_NAME",
    "artifactUri": "ARTIFACT_URI",
    "containerSpec": {
       "imageUri": "IMAGE_URI"
    }
   },
 "parentModel": "PARENT_MODEL"
}

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

성공 상태 코드(2xx)와 빈 응답을 받게 됩니다.

Python

Python


from typing import List

from google.cloud import aiplatform

def upload_new_model_version_using_custom_training_pipeline(
    display_name: str,
    script_path: str,
    container_uri,
    model_serving_container_image_uri: str,
    dataset_id: str,
    replica_count: int,
    machine_type: str,
    accelerator_type: str,
    accelerator_count: int,
    parent_model: str,
    args: List[str],
    model_version_aliases: List[str],
    model_version_description: str,
    is_default_version: bool,
    project: str,
    location: str,
):
    """
    Uploads a new model version using a custom training pipeline.
    Args:
        display_name: The display name of the model version.
        script_path: The path to the Python script that trains the model.
        container_uri: The URI of the container to use for training.
        model_serving_container_image_uri: The URI of the serving container image to use.
        dataset_id: The ID of the dataset to use for training.
        replica_count: The number of replicas to use for training.
        machine_type: The machine type to use for training.
        accelerator_type: The accelerator type to use for training.
        accelerator_count: The number of accelerators to use for training.
        parent_model: The parent resource name of an existing model.
        args: A list of arguments to pass to the training script.
        model_version_aliases: The aliases of the model version to create.
        model_version_description: The description of the model version.
        is_default_version: Whether the model version is the default version.
        project: The project ID.
        location: The region name.
    Returns:
        The new version of the model.
    """
    # Initialize the client.
    aiplatform.init(project=project, location=location)

    # Create the training job.
    # This job will upload a new, non-default version of the my-training-job model
    job = aiplatform.CustomTrainingJob(
        display_name=display_name,
        script_path=script_path,
        container_uri=container_uri,
        model_serving_container_image_uri=model_serving_container_image_uri,
    )

    # Create dataset
    # This examples uses a TabularDataset, but you can use any dataset type.
    dataset = aiplatform.TabularDataset(dataset_id) if dataset_id else None

    # Run the training job.
    model = job.run(
        dataset=dataset,
        args=args,
        replica_count=replica_count,
        machine_type=machine_type,
        accelerator_type=accelerator_type,
        accelerator_count=accelerator_count,
        parent_model=parent_model,
        model_version_aliases=model_version_aliases,
        model_version_description=model_version_description,
        is_default_version=is_default_version,
    )

    return model

새 모델 버전 학습

Model Registry에서 모델의 새 버전을 학습시킬 수 있습니다.

콘솔

Model Registry에서 기존 모델의 버전을 만들 수 있습니다. 학습 파이프라인에서 모델 버전을 추가하거나 만드는 방법은 CustomJob 및 모델 업로드를 참조하세요.

  1. Google Cloud 콘솔에서 Model Registry 페이지로 이동합니다.
    <a{: class="button button-primary" l10n-attrs-original-order="href,target,class,track-name,track-type" l10n-encrypted-href="eE471CdLRMtrJ6UgOX6O4ltigmNHgUGOXn/QVSGplOheMVJU/yDyZ/OoAbOtzTXtQQdc2CaGxVtVGC/5S+Yj6A==" target="console" track-name="consoleLink" track-type="tasks" }="">Model Registry로 이동 </a{:>
  2. 페이지 상단에서 만들기를 선택합니다. 학습 방법 세부정보를 입력하고 모델 학습 방법을 선택합니다.
  3. 계속을 클릭합니다.
  4. 모델 세부정보에서 새 버전 학습 옵션을 선택합니다. 드롭다운에서 새 버전을 추가할 모델을 선택합니다. 버전에 대한 설명을 추가합니다. 계속을 클릭합니다.
  5. 컴퓨팅 및 가격 책정 섹션에서 예산을 입력하고 준비되면 학습 시작을 선택합니다. 모델 학습이 완료되면 새 버전이 Model Registry에서 표시됩니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • TRAINING_PIPELINE_NAME: trainingPipeline의 표시 이름입니다.
  • TRAINING_TASK_INPUT: 학습 태스크의 매개변수입니다.
  • PARENT_MODEL: 버전을 업로드할 모델의 리소스 이름입니다.

HTTP 메서드 및 URL:

POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/trainingPipelines

JSON 요청 본문:

{
  "displayName": "TRAINING_PIPELINE_NAME",
  "trainingTaskDefinition": "gs://google-cloud-aiplatform/schema/trainingjob/definition/custom_task_1.0.0.yaml",
  "trainingTaskInputs":"TRAINING_TASK_INPUT"
  },
  "modelToUpload": {
    "displayName": "MODEL_DISPLAY_NAME",
    "containerSpec": {
       "imageUri": "IMAGE_URI"
    },
  },
  "parentModel": "PARENT_MODEL",

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

성공 상태 코드(2xx)와 빈 응답을 받게 됩니다.

Python

Python


from google.cloud import aiplatform

def create_default_model_sample(model_id: str, project: str, location: str):
    """
    Initialize a Model resource to represent an existing model version with alias 'default'.
    Args:
        model_id: The ID of the model to initialize. Parent resource name of the model is also accepted.
        project: The project ID.
        location: The region name.
    Returns:
        Model resource.
    """
    # Initialize the client.
    aiplatform.init(project=project, location=location)

    # Initialize the Model resource with the ID 'model_id'. The parent_name of the Model resource can be also
    # 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
    default_model = aiplatform.Model(model_name=model_id)

    return default_model

모델의 모든 버전 목록을 보는 방법

모델 버전의 세부정보 페이지에서 모델을 배포 및 테스트하고 일괄 예측을 설정하고 모델 유형에 따라 평가할 수 있습니다. 버전 세부정보 페이지에서 모델 버전을 학습시키는 데 사용된 데이터 세트도 직접 볼 수 있습니다.

콘솔

Model Registry에서 모델의 모든 버전 목록을 볼 수 있습니다. 이를 통해 통계 개요를 얻고 모델 구성을 지원할 수 있습니다.

  1. Google Cloud 콘솔에서 Model Registry 페이지로 이동합니다.
    <a{: class="button button-primary" l10n-attrs-original-order="href,target,class,track-name,track-type" l10n-encrypted-href="eE471CdLRMtrJ6UgOX6O4ltigmNHgUGOXn/QVSGplOheMVJU/yDyZ/OoAbOtzTXtQQdc2CaGxVtVGC/5S+Yj6A==" target="console" track-name="consoleLink" track-type="tasks" }="">Model Registry로 이동 </a{:>
  2. 이름 열에서 버전이 여러 개인 모델의 이름을 선택합니다. 버전 페이지가 열립니다.
  3. 모든 버전과 연결된 버전 ID의 목록이 표시됩니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 이 모델과 연결된 프로젝트 ID입니다.
  • LOCATION: Vertex AI를 사용하는 리전입니다.
  • MODEL_ID: 특정 모델과 연결된 ID입니다.

HTTP 메서드 및 URL:

GET https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/models/MODEL_ID

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

성공 상태 코드(2xx)와 빈 응답을 받게 됩니다.

Python

Python


from google.cloud import aiplatform

def list_model_versions_sample(model_id: str, project: str, location: str):
    """
    List all model versions of a model.
    Args:
        model_id: The ID of the model to list. Parent resource name of the model is also accepted.
        project: The project ID.
        location: The region name.
    Returns:
        versions: List of model versions.
    """
    # Initialize the client.
    aiplatform.init(project=project, location=location)

    # Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
    # 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
    model_registry = aiplatform.models.ModelRegistry(model=model_id)

    # List all model versions of the model.
    versions = model_registry.list_versions()

    return versions

모델 버전 세부정보를 확인하는 방법

Model Registry에서 모델과 모든 모델 버전을 확인할 수 있습니다. Model Registry에서 모델을 선택하면 세부정보 페이지에 모델 세부정보와 특정 모델 버전 세부정보가 표시됩니다. 세부정보 화면에서 모델 버전을 평가하고 테스트하거나, 일괄 예측을 실행하거나, 온라인 예측을 위해 모델을 엔드포인트에 배포할 수 있습니다.

콘솔

모델 세부정보 페이지를 보려면 다음 안내를 수행합니다. 버전 세부정보를 보려면 버전 이름을 클릭합니다.

  1. Google Cloud 콘솔에서 Model Registry 페이지로 이동합니다.
    <a{: class="button button-primary" l10n-attrs-original-order="href,target,class,track-name,track-type" l10n-encrypted-href="eE471CdLRMtrJ6UgOX6O4ltigmNHgUGOXn/QVSGplOheMVJU/yDyZ/OoAbOtzTXtQQdc2CaGxVtVGC/5S+Yj6A==" target="console" track-name="consoleLink" track-type="tasks" }="">Model Registry로 이동 </a{:>
  2. Vertex AI Model Registry에서 모델 이름을 클릭하여 모델 세부정보 페이지를 엽니다.
  3. 모든 버전과 연결된 버전 ID의 목록이 표시됩니다. 행으로 구분된 모델 버전이 표시됩니다. 모델 버전 세부정보에는 버전 ID, 모델 별칭, 상태, 설명, 라벨이 포함됩니다.
  4. 모델 버전 중 하나의 세부정보를 보려면 버전 ID를 선택합니다. 모델 세부정보 페이지가 열립니다.
  5. 세부정보 페이지에서 평가, 배포, 테스트하고 일괄 예측을 사용하며 버전 세부정보를 자세히 살펴볼 수 있습니다. 또한 이 페이지에서 Vertex AI 모델 평가를 사용하여 모델 버전을 비교할 수 있습니다.

Python

Python


from google.cloud import aiplatform

def get_model_version_info_sample(
    model_id: str, version_id: str, project: str, location: str
):
    """
    Get model version info.
    Args:
        model_id: The ID of the model.
        version_id: The version ID of the model version.
        project: The project ID.
        location: The region name.
    Returns:
        VersionInfo resource.
    """

    # Initialize the client.
    aiplatform.init(project=project, location=location)

    # Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
    # 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
    model_registry = aiplatform.models.ModelRegistry(model=model_id)

    # Get model version info with the version 'version_id'.
    model_version_info = model_registry.get_version_info(version=version_id)

    return model_version_info