מחיקת מודל מ-Gemini Enterprise Agent Platform מרשם המודלים

כאן מוסבר איך למחוק מודל שכבר לא צריך ממרשם המודלים של Gemini Enterprise Agent Platform.

כדי למחוק מודל של BigQuery ML ממרשם המודלים ב-Gemini Enterprise Agent Platform, צריך קודם למחוק אותו מ-BigQuery ML. מידע נוסף זמין במאמר BigQuery ML ומרשם המודלים של Gemini Enterprise Agent Platform.

כדי למחוק מודל שנפרס בנקודת קצה, צריך קודם לבטל את הפריסה שלו. אחרת, לא תוכלו למחוק את המודל.

מחיקת מודל

המסוף

  1. במסוף Google Cloud , בקטע Agent Platform, נכנסים לדף Model Registry.

    כניסה לדף Model Registry

  2. במודל שרוצים למחוק, לוחצים על פעולות נוספות.

  3. לוחצים על מחיקת המודל. כשמוחקים את המודל, כל הגרסאות וההערכות שמשויכות אליו נמחקות מהפרויקט ב- Google Cloud .

  4. לוחצים על מחיקה במסך האישור.

gcloud

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫MODEL_ID: מזהה המודל.
  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
  • ‫LOCATION: האזור של הפרויקט. לדוגמה, us-central1. אם האזור בכתובת ה-URL של נקודת הקצה ל-API מתנגש עם המיקום בנתיב המשאב, המערכת מתעלמת מהמיקום בנתיב.

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או Cloud Shell

gcloud ai models delete MODEL_ID \
    --project=PROJECT_ID \
    --region=LOCATION

‏Windows (PowerShell)

gcloud ai models delete MODEL_ID `
    --project=PROJECT_ID `
    --region=LOCATION

Windows‏ (cmd.exe)

gcloud ai models delete MODEL_ID ^
    --project=PROJECT_ID ^
    --region=LOCATION

API

איך מוחקים מודל באמצעות Agent Platform SDK ל-Python.

Python


from google.cloud import aiplatform


def delete_model_sample(model_id: str, project: str, location: str):
    """
    Delete a Model resource.
    Args:
        model_id: The ID of the model to delete. Parent resource name of the model is also accepted.
        project: The project.
        location: The region name.
    Returns
        None.
    """
    # Initialize the client.
    aiplatform.init(project=project, location=location)

    # Get the model 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(model_name=model_id)

    # Delete the model.
    model.delete()

מחיקת גרסה של מודל

המסוף

  1. במסוף Google Cloud , בקטע Agent Platform, נכנסים לדף Model Registry.

    כניסה לדף Model Registry

  2. מרחיבים את המודל כדי לראות את הגרסאות שלו. בוחרים את הגרסה שרוצים למחוק.

  3. בתפריט של גרסת המודל, לוחצים על More actions.

  4. לוחצים על מחיקת הגרסה. כשמוחקים גרסה, כל הערכות המודל שמשויכות אליה נמחקות.

gcloud

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫MODEL_VERSION_ID: המזהה של גרסת המודל שרוצים למחוק.
  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
  • ‫LOCATION: האזור של הפרויקט. לדוגמה, us-central1. אם האזור בכתובת ה-URL של נקודת הקצה ל-API מתנגש עם המיקום בנתיב המשאב, המערכת מתעלמת מהמיקום בנתיב.

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או Cloud Shell

gcloud ai models delete-version MODEL_VERSION_ID \
    --project=PROJECT_ID \
    --region=LOCATION

‏Windows (PowerShell)

gcloud ai models delete-version MODEL_VERSION_ID `
    --project=PROJECT_ID `
    --region=LOCATION

Windows‏ (cmd.exe)

gcloud ai models delete-version MODEL_VERSION_ID ^
    --project=PROJECT_ID ^
    --region=LOCATION

API

Python


from google.cloud import aiplatform


def delete_model_version_sample(
    model_id: str, version_id: str, project: str, location: str
):
    """
    Delete a Model version.
    Args:
        model_id: The ID of the model to delete. Parent resource name of the model is also accepted.
        version_id: The version ID or version alias of the model to delete.
        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)

    # Delete the model version with the version 'version'.
    model_registry.delete_version(version=version_id)

מחיקת גרסת מודל עם השם הסודי שמוגדר כברירת מחדל

המסוף

  1. במרשם המודלים, בוחרים את שם המודל שרוצים לראות את הגרסאות שלו.
  2. בוחרים את הגרסה הרצויה ולוחצים על Delete בכפתור Actions . תיפתח אזהרה כי ניסיתם למחוק את גרסת ברירת המחדל של השם החלופי. קודם צריך להגדיר גרסה אחרת כברירת מחדל.
  3. בתפריט הנפתח, בוחרים את הגרסה שרוצים להגדיר כברירת המחדל של המודל.
  4. במסך האישור, לוחצים על הגדרה ומחיקה.

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
    )