모델 버전 별칭 사용 방법

모델 별칭은 모델 리소스 내에서 고유한 모델 버전에 대한 이름이 지정된 참조로서 변경이 가능합니다. 별칭은 한 모델 버전에서 다른 모델 버전으로 이동할 수 있기 때문에 "변경이 가능"하며 사용자가 정의하는 임의의 문자열이므로 "이름을 지정"할 수 있습니다. 모델 별칭은 특정 버전의 ID를 파악할 필요 없이 참조로 특정 모델 버전을 가져오거나 배포할 수 있어서 유용합니다. 이러한 점에서 모델 별칭은 Git의 Docker 태그 또는 브랜치 참조와 비슷하게 작동합니다.

모델 레지스트리에서 새 모델을 만들면 첫 번째 버전에 기본 별칭이 자동으로 할당됩니다. 기본 별칭은 사용자가 특정 버전을 지정하지 않은 채 모델에서 명령어를 실행하는 경우에 사용되는 모델 버전을 참조합니다. 한 버전의 모델에서는 항상 기본 별칭을 전달해야 합니다. 그렇지 않으면 기본 별칭이 다른 사용자 정의 별칭처럼 작동합니다.

Google Cloud 콘솔에서 별칭 마커는 배포 준비가 된 안정적인 버전의 모델을 이해관계자가 한 눈에 파악할 수 있도록 도와줍니다. 기본 별칭 외에도 고유한 커스텀 별칭을 만들어 모델 레지스트리의 모델에 할당할 수 있습니다.

모델 레지스트리에서 별칭 열을 보면 기본 별칭이 있는 모델 버전을 한눈에 확인할 수 있습니다.

별칭 열과 기본 별칭 태그

별칭을 다른 모델 버전에 다시 할당하려는 경우 별칭을 다른 버전으로 쉽게 이동할 수 있습니다.

별칭 사용 고려사항:

  • 버전 별칭은 고유해야 하며 별칭은 모델별로 한 번에 버전 하나에만 할당될 수 있습니다.
  • 버전 별칭은 숫자가 아니어야 합니다.
  • 프로덕션용 모델 버전을 지정하지 않으면 기본 모델이 사용됩니다.
  • 별칭은 라벨과 다릅니다. 여기에서 모델 라벨에 대해 자세히 알아보세요.
  • 다른 모델 버전에서 사용되는 기존 별칭을 적용하면 해당 버전에서 별칭이 삭제됩니다.

모델 버전을 기본값으로 설정

  1. Google Cloud 콘솔에서 Vertex AI Model Registry 페이지로 이동합니다.

    Model Registry 페이지로 이동

  2. 모델 레지스트리에서 수정할 모델의 이름을 선택합니다. 모델 세부정보 창이 열립니다. 모든 모델 버전이 나열됩니다. 모델 버전 중 하나에 기본 별칭이 있습니다.

  3. 기본 버전을 할당할 모델 버전의 작업 버튼을 선택합니다.

  4. 기본값으로 설정을 클릭합니다.

모델 버전에 별칭 추가

  1. Google Cloud 콘솔에서 Vertex AI Model Registry 페이지로 이동합니다.

    Model Registry 페이지로 이동

  2. 모델 레지스트리에서 수정할 모델의 이름을 선택합니다. 모델 세부정보 창이 열립니다.

  3. 세부정보 페이지에서 원하는 모델 버전을 선택하고 더보기를 클릭합니다.

  4. 별칭 수정을 클릭합니다. 새로 추가를 선택합니다.

  5. 별칭 수정: 별칭 추가를 클릭하고 모델 버전에 추가할 별칭의 이름을 입력합니다.

  6. 저장을 클릭합니다.

별칭이 지정된 새 모델 버전 업로드

API

Python


from typing import List

from google.cloud import aiplatform

def upload_new_aliased_model_version_sample(
    parent_name: str,
    artifact_uri: str,
    serving_container_image: str,
    is_default_version: bool,
    version_aliases: List[str],
    version_description: str,
    project: str,
    location: str,
):
    """
    Uploads a new aliased version of a model with ID 'model_id'.
    Args:
        parent_name: The parent resource name of an existing model.
        artifact_uri: The URI of the model artifact to upload.
        serving_container_image: The name of the serving container image to use.
        is_default_version: Whether this version is the default version of the model.
        version_aliases: The aliases of the model version.
        version_description: The description of the model 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)

    # Upload a new aliased version of the Model 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 = aiplatform.Model.upload(
        artifact_uri=artifact_uri,
        serving_container_image=serving_container_image,
        parent_name=parent_name,
        is_default_version=is_default_version,
        version_aliases=version_aliases,
        version_description=version_description,
    )

    return model

모델 별칭 삭제

기본 별칭이 할당된 모델 버전을 삭제하면 별칭이 자동으로 다음 최신 버전에 할당됩니다.

콘솔

  1. Google Cloud 콘솔에서 Vertex AI Model Registry 페이지로 이동합니다.

    Model Registry 페이지로 이동

  2. 모델 레지스트리에서 수정할 모델의 이름을 선택합니다. 모델 세부정보 창이 열립니다.

  3. 세부정보 페이지에서 모델 버전의 작업 버튼을 클릭합니다.

  4. 별칭 수정을 클릭합니다.

  5. 모델 버전에 연결된 별칭 목록이 표시됩니다. 라벨의 별칭 텍스트 상자 오른쪽으로 커서를 가져가면 삭제 아이콘이 표시됩니다.

  6. 삭제할 별칭의 삭제 아이콘을 클릭합니다.

  7. 저장을 클릭합니다.

API

Python


from typing import List

from google.cloud import aiplatform

def delete_aliases_model_version_sample(
    model_id: str,
    version_aliases: List[str],
    version_id: str,
    project: str,
    location: str,
):
    """
    Delete aliases to a model version.
    Args:
        model_id: The ID of the model.
        version_aliases: The version aliases to assign.
        version_id: The version ID of the model to assign the aliases to.
        project: The project ID.
        location: The region name.
    Returns
        None.
    """
    # 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)

    # Remove the version aliases to the model version with the version 'version'.
    model_registry.remove_version_aliases(
        target_aliases=version_aliases, version=version_id
    )