모델 별칭은 모델 리소스 내에서 고유한 모델 버전에 대한 이름이 지정된 참조로서 변경이 가능합니다. 별칭은 한 모델 버전에서 다른 모델 버전으로 이동할 수 있기 때문에 "변경이 가능"하며 사용자가 정의하는 임의의 문자열이므로 "이름을 지정"할 수 있습니다. 모델 별칭은 특정 버전의 ID를 파악할 필요 없이 참조로 특정 모델 버전을 가져오거나 배포할 수 있어서 유용합니다. 이러한 점에서 모델 별칭은 Git의 Docker 태그 또는 브랜치 참조와 비슷하게 작동합니다.
모델 레지스트리에서 새 모델을 만들면 첫 번째 버전에 기본 별칭이 자동으로 할당됩니다. 기본 별칭은 사용자가 특정 버전을 지정하지 않은 채 모델에서 명령어를 실행하는 경우에 사용되는 모델 버전을 참조합니다. 한 버전의 모델에서는 항상 기본 별칭을 전달해야 합니다. 그렇지 않으면 기본 별칭이 다른 사용자 정의 별칭처럼 작동합니다.
Google Cloud 콘솔에서 별칭 마커는 배포 준비가 된 안정적인 버전의 모델을 이해관계자가 한 눈에 파악할 수 있도록 도와줍니다. 기본 별칭 외에도 고유한 커스텀 별칭을 만들어 모델 레지스트리의 모델에 할당할 수 있습니다.
모델 레지스트리에서 별칭 열을 보면 기본 별칭이 있는 모델 버전을 한눈에 확인할 수 있습니다.
별칭을 다른 모델 버전에 다시 할당하려는 경우 별칭을 다른 버전으로 쉽게 이동할 수 있습니다.
fromtypingimportListfromgoogle.cloudimportaiplatformdefupload_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,):
"""
UploadsanewaliasedversionofamodelwithID 'model_id'.Args:parent_name:Theparentresourcenameofanexistingmodel.artifact_uri:TheURIofthemodelartifacttoupload.serving_container_image:Thenameoftheservingcontainerimagetouse.is_default_version:Whetherthisversionisthedefaultversionofthemodel.version_aliases:Thealiasesofthemodelversion.version_description:Thedescriptionofthemodelversion.project:TheprojectID.location:Theregionname.Returns:Thenewversionofthemodel.
"""
# 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,)returnmodel
모델 별칭 삭제
기본 별칭이 할당된 모델 버전을 삭제하면 별칭이 자동으로 다음 최신 버전에 할당됩니다.
콘솔
Google Cloud 콘솔에서 Vertex AI Model Registry 페이지로 이동합니다.
모델 버전에 연결된 별칭 목록이 표시됩니다. 라벨의 별칭 텍스트 상자 오른쪽으로 커서를 가져가면 삭제 아이콘이 표시됩니다.
삭제할 별칭의 삭제 아이콘을 클릭합니다.
저장을 클릭합니다.
API
Python
fromtypingimportListfromgoogle.cloudimportaiplatformdefdelete_aliases_model_version_sample(model_id:str,version_aliases:List[str],version_id:str,project:str,location:str,):
"""
Deletealiasestoamodelversion.Args:model_id:TheIDofthemodel.version_aliases:Theversionaliasestoassign.version_id:TheversionIDofthemodeltoassignthealiasesto.project:TheprojectID.location:Theregionname.ReturnsNone.
"""
# 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)