ניהול גרסאות של מודלים באמצעות מרשם המודלים

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

ייבוא גרסה חדשה של מודל

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

המסוף

  1. במסוף Google Cloud , עוברים לדף מרשם המודלים.
    כניסה ל-Model Registry
  2. בחלק העליון של הדף, לוחצים על ייבוא.
  3. בוחרים באפשרות ייבוא כגרסה חדשה.
  4. בתפריט הנפתח, בוחרים את המודל שהגרסה החדשה הזו מבוססת עליו. מוסיפים תיאור אופציונלי לגרסה.
  5. אם רוצים, מגדירים את המודל הזה כגרסת ברירת המחדל. גרסת ברירת המחדל נבחרת מראש בכל פעם שמשתמשים במודל לחיזוי (אבל עדיין אפשר לבחור גרסאות אחרות).
  6. בוחרים את האזור.
  7. לוחצים על המשך.
  8. בהגדרות המודל, מגדירים את מאגר התגים שבו רוצים להשתמש. אתם יכולים לבחור אם לייבא פריטי מידע שנוצרו במודל למאגר חדש שנוצר מראש או למאגר קיים בהתאמה אישית. מידע נוסף על קונטיינרים זמין במאמר ייבוא מודלים ל-Agent Platform.
  9. לוחצים על המשך.
  10. אופציונלי: מוסיפים למודל תמיכה בהסברתיות.
  11. לוחצים על ייבוא.

REST

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

  • ‫PROJECT_ID: מזהה הפרויקט.
  • ‫LOCATION: המיקום.
  • ‫MODEL_DISPLAY_NAME: שם המודל.
  • ‫ARTIFACT_URI: הנתיב לספרייה שמכילה את פריט המידע שנוצר מהמודל ואת כל הקבצים התומכים שלו.
  • ‫IMAGE_URI: קובץ אימג' של Docker שישמש כקונטיינר בהתאמה אישית להצגת חיזויים.
  • ‫PARENT_MODEL: שם המשאב של המודל שאליו רוצים להעלות את הגרסה.

ה-method של ה-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

אימון גרסה חדשה של המודל

ממרשם המודלים, אפשר לאמן גרסה חדשה של מודל.

המסוף

ממרשם המודלים, אתם יכולים ליצור גרסה של מודל קיים. במאמר הזה מוסבר איך מוסיפים או יוצרים גרסת מודל בצינור עיבוד הנתונים לאימון.

  1. במסוף Google Cloud , עוברים לדף מרשם המודלים.
    כניסה ל-Model Registry
  2. בחלק העליון של הדף, לוחצים על יצירה. מזינים את פרטי שיטת האימון ובוחרים את שיטת האימון של המודל.
  3. לוחצים על Continue.
  4. בקטע "פרטי המודל", בוחרים באפשרות אימון גרסה חדשה. בתפריט הנפתח, בוחרים את המודל שרוצים להוסיף לו גרסה חדשה. מוסיפים תיאור של הגרסה. לוחצים על Continue.
  5. בקטע Compute and pricing, מזינים את התקציב ולוחצים על Start training כשמוכנים. בסיום אימון המודל, הגרסה החדשה מופיעה ב-מרשם המודלים.

REST

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

  • ‫TRAINING_PIPELINE_NAME: השם המוצג של trainingPipeline
  • ‫TRAINING_TASK_INPUT: הפרמטרים של משימת האימון.
  • ‫PARENT_MODEL: שם המשאב של המודל שאליו רוצים להעלות את הגרסה.

ה-method של ה-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

איך רואים רשימה של כל הגרסאות של מודל מסוים

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

המסוף

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

  1. במסוף Google Cloud , עוברים לדף מרשם המודלים.
    כניסה ל-Model Registry
  2. בעמודה "שם", בוחרים את השם של מודל שיש לו כמה גרסאות. הדף Versions נפתח.
  3. מוצגת רשימה של כל הגרסאות ומזהי הגרסאות שמשויכים אליהן.

REST

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

  • ‫PROJECT_ID: מזהה הפרויקט שמשויך למודל הזה
  • ‫LOCATION: האזור שבו אתם משתמשים ב-Agent Platform.
  • ‫MODEL_ID: המזהה שמשויך למודל ספציפי.

ה-method של ה-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, בדף הפרטים מוצגים פרטי המודל ופרטי הגרסה הספציפית של המודל. במסך הפרטים אפשר להעריך ולבדוק את גרסת המודל, להריץ הסקת אצווה או לפרוס את המודל בנקודת קצה להסקה אונליין.

המסוף

כדי לראות את דף הפרטים של המודל: כדי לראות את פרטי הגרסה, לוחצים על שם הגרסה.

  1. במסוף Google Cloud , עוברים לדף מרשם המודלים.
    כניסה ל-Model Registry
  2. ב-Gemini Enterprise Agent Platform Model Registry, לוחצים על שם המודל כדי לפתוח את דף הפרטים שלו.
  3. תוצג רשימה של כל הגרסאות ומזהי הגרסאות שמשויכים אליהן. גרסאות המודל מוצגות בשורות נפרדות. פרטי גרסת המודל כוללים את מזהה הגרסה, הכינוי של המודל, הסטטוס, התיאור והתוויות.
  4. כדי לראות את הפרטים של אחת מגרסאות המודל, בוחרים מזהה גרסה. דף פרטי המודל נפתח.
  5. בדף הפרטים אפשר להעריך, לפרוס ולבדוק, להשתמש בחיזוי באצווה ולבחון מקרוב את פרטי הגרסה. בנוסף, בדף הזה אתם יכולים להשתמש בהערכת המודל של Agent Platform כדי להשוות בין גרסאות המודל.

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