מערכי נתונים מולטי-מודאליים בפלטפורמת הסוכנים מאפשרים לכם ליצור, לנהל, לשתף ולהשתמש במערכי נתונים מולטי-מודאליים ל-AI גנרטיבי. מערכי נתונים מולטימודאליים מספקים את התכונות העיקריות הבאות:
אפשר לטעון מערכי נתונים מ-BigQuery, מ-DataFrames או מקובצי JSONL ב-Cloud Storage.
יוצרים את מערך הנתונים פעם אחת ומשתמשים בו בסוגים שונים של משימות, כמו כוונון עדין מפוקח וחיזוי באצווה. כך נמנעים משכפול נתונים ומבעיות בעיצוב.
שומרים את כל מערכי הנתונים של ה-AI הגנרטיבי במקום אחד מנוהל.
האימות של הסכימה והמבנה מאפשר לכם לכמת את המשאבים שנדרשים למשימות בהמשך, וכך לזהות שגיאות ולהעריך את העלות לפני שמתחילים משימה.
אפשר להשתמש במערכי נתונים מולטימודאליים באמצעות Agent Platform SDK או REST API.
מערכי נתונים מולטימודאליים הם סוג של מערכי נתונים מנוהלים בפלטפורמת הסוכנים. הם שונים מסוגים אחרים של מערכי נתונים מנוהלים בדרכים הבאות:
- מערכי נתונים מולטי-מודאליים יכולים לכלול נתונים מכל מודאליות (טקסט, תמונה, אודיו, וידאו). סוגים אחרים של מערכי נתונים מנוהלים מיועדים רק למודאליות אחת.
- אפשר להשתמש במערכי נתונים מולטימודאליים רק בשירותי AI גנרטיבי בפלטפורמת הסוכנים, כמו כוונון וחיזוי אצווה באמצעות מודלים גנרטיביים. סוגים אחרים של מערכי נתונים מנוהלים יכולים לשמש רק למודלים חיזויים של Agent Platform.
- מערכי נתונים מולטימודאליים תומכים בשיטות נוספות, כמו
assembleו-assess, שמשמשות לתצוגה מקדימה של נתונים, לאימות בקשות ולאומדן עלויות. - מערכי נתונים מולטימודאליים מאוחסנים ב-BigQuery, שמותאם למערכי נתונים גדולים.
לפני שמתחילים
- נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Agent Platform, BigQuery, and Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Agent Platform, BigQuery, and Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.- התקנה ואתחול של Agent Platform SDK ל-Python
- מייבאים את הספריות הבאות ויוצרים לקוח:
import agentplatform from agentplatform.types import ( GeminiExample, GeminiRequestReadConfig, GeminiTemplateConfig, ) # To use related features, such as tuning and batch prediction, you may also # need to import the Google Gen AI SDK: from google import genai from google.genai.types import Content, Part # Create a client for multimodal dataset operations. client = agentplatform.Client(project="PROJECT_ID", location="LOCATION")
יצירת מערך נתונים
אפשר ליצור dataset מולטימודאלי ממקורות שונים:
מ-Pandas DataFrame
my_dataset = client.datasets.create_from_pandas( dataframe=my_dataframe, target_table_id=table_id # optional )-
my_dataset = client.datasets.create_from_bigframes( dataframe=my_dataframe, target_table_id=table_id # optional ) מטבלה ב-BigQuery
my_dataset_from_bigquery = client.datasets.create_from_bigquery( bigquery_uri="bq://projectId.datasetId.tableId" )מטבלת BigQuery, באמצעות REST API
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT/locations/LOCATION/datasets" \ -d '{ "display_name": "TestDataset", "metadataSchemaUri": "gs://google-cloud-aiplatform/schema/dataset/metadata/multimodal_1.0.0.yaml", "metadata": { "inputConfig": { "bigquery_source": { "uri": "bq://projectId.datasetId.tableId" } } } }'מקובץ JSONL ב-Cloud Storage. בדוגמה הבאה, קובץ ה-JSONL מכיל בקשות שכבר עברו עיצוב ל-Gemini, כך שלא נדרש הרכבה.
my_dataset = client.datasets.create_from_gemini_request_jsonl( gcs_uri = gcs_uri_of_jsonl_file, )ממערך נתונים קיים של נתונים מרובי-אופנים
# Load dataset based on its name. This accepts a full resource name or a # dataset ID. same_dataset = client.datasets.get_multimodal_dataset(name=dataset_name)
יצירה וצירוף של הגדרות קריאה
הגדרת קריאה (GeminiRequestReadConfig) מגדירה איך להמיר את מערך הנתונים הרב-אופני לפורמט שאפשר להעביר למודל. הוא מכיל תבנית עם placeholders שמוחלפים בערכים של העמודות התואמות במערך הנתונים במהלך ההרכבה. השלב הזה נדרש כדי להריץ עבודת כוונון או עבודת חיזוי באצווה.
Agent Platform SDK
יוצרים הגדרות קריאה. יש שתי דרכים ליצור אותה:
- משתמשים בשיטת העזר
GeminiRequestReadConfig.single_turn_template:
read_config = GeminiRequestReadConfig.single_turn_template( prompt="This is the image: {image_uris}", response="{labels}", system_instruction='You are a botanical image classifier. Analyze the provided image ' 'and determine the most accurate classification of the flower.' 'These are the only flower categories: [\'daisy\', \'dandelion\', \'roses\', \'sunflowers\', \'tulips\'].' 'Return only one category per image.' )- ליצור באופן ידני הגדרת קריאה מ-
GeminiExample, שמאפשרת רמת פירוט גבוהה יותר, כמו שיחות מרובות תפניות. דוגמת הקוד הבאה כוללת גם קוד אופציונלי עם הערות לציוןfield_mapping, שמאפשר להשתמש בשם placeholder ששונה משם העמודה של מערך הנתונים. לדוגמה:
# Define a GeminiExample gemini_example = GeminiExample( contents=[ Content(role="user", parts=[Part.from_text(text="This is the image: {image_uris}")]), Content(role="model", parts=[Part.from_text(text="This is the flower class: {label}.")]), Content(role="user", parts=[Part.from_text(text="Your response should only contain the class label.")]), Content(role="model", parts=[Part.from_text(text="{label}")]), # Optional: If you specify a field_mapping, you can use different placeholder values. For example: # Content(role="user", parts=[Part.from_text(text="This is the image: {uri_placeholder}")]), # Content(role="model", parts=[Part.from_text(text="This is the flower class: {flower_placeholder}.")]), # Content(role="user", parts=[Part.from_text(text="Your response should only contain the class label.")]), # Content(role="model", parts=[Part.from_text(text="{flower_placeholder}")]), ], system_instruction=Content( parts=[ Part.from_text( text='You are a botanical image classifier. Analyze the provided image ' 'and determine the most accurate classification of the flower.' 'These are the only flower categories: [\'daisy\', \'dandelion\', \'roses\', \'sunflowers\', \'tulips\'].' 'Return only one category per image.' ) ] ), ) # Construct the read config, specifying a map for the placeholders. read_config = GeminiRequestReadConfig( template_config=GeminiTemplateConfig( gemini_example=gemini_example, # Optional: Map the template placeholders to the column names of your dataset. # Not required if the template placeholders are column names of the dataset. # field_mapping={"uri_placeholder": "image_uris", "flower_placeholder": "labels"}, ), )- משתמשים בשיטת העזר
מצרפים אותו למערך הנתונים ושומרים את השינוי:
my_dataset.set_read_config(read_config=read_config) my_dataset = client.datasets.update_multimodal_dataset(multimodal_dataset=my_dataset)
REST
מבצעים קריאה ל-patch ומעדכנים את השדה metadata עם הערכים הבאים:
- ה-URI של הטבלה ב-BigQuery. במערכי נתונים שנוצרו מטבלה ב-BigQuery, זהו המקור
bigquery_uri. במערכי נתונים שנוצרו ממקורות אחרים, כמו JSONL או DataFrame, זו הטבלה ב-BigQuery שאליה הועתקו הנתונים. gemini_template_config.
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-d $'{
"metadata": {
"input_config": {
"bigquery_source": {
"uri": "bq://projectId.datasetId.tableId"
}
},
"gemini_template_config_source": {
"gemini_template_config": {
"gemini_example": {
"contents": [
{
"role": "user",
"parts": [
{
"text": "This is the image: {image_uris}"
}
]
},
{
"role": "model",
"parts": [
{
"text": "response"
}
]
}
]
"systemInstruction": {
"parts": [
{
"text": "You are a botanical image classifier."
}
]
}
}
}
}
}
}' \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID?updateMask=metadata"
(אופציונלי) הרכבת מערך הנתונים
השיטה assemble מחילה את הגדרת הקריאה כדי לשנות את מערך הנתונים, ושומרת את הפלט בטבלה חדשה ב-BigQuery. כך אפשר לראות תצוגה מקדימה של הנתונים לפני שהם מועברים למודל.
כברירת מחדל, נעשה שימוש בהגדרת הקריאה המצורפת למערך הנתונים, אבל אפשר להעביר gemini_request_read_config כדי לשנות את התנהגות ברירת המחדל.
Agent Platform SDK
השיטה assemble מחזירה n-יה סדורה (tuple) מסוג (table_id, dataframe). מעבירים את load_dataframe=True כדי לטעון גם את הטבלה המורכבת כ-DataFrame לבדיקה.
table_id, assembly = client.datasets.assemble(
name=my_dataset.name,
gemini_request_read_config=read_config, # optional if attached to the dataset
load_dataframe=True,
)
# Inspect the results
assembly.head()
REST
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID:assemble" \
-d '{}'
לדוגמה, נניח שמערך הנתונים הרב-אופני שלכם מכיל את הנתונים הבאים:
| Row | image_uris | labels |
|---|---|---|
| 1 | gs://cloud-samples-data/ai-platform/flowers/daisy/1396526833_fb867165be_n.jpg | חיננית |
לאחר מכן, הפונקציה assemble יוצרת טבלה חדשה ב-BigQuery בשם table_id, שכל שורה בה מכילה את גוף הבקשה. לדוגמה:
{
"contents": [
{
"parts": [
{
"text": "This is the image: "
},
{
"fileData": {
"fileUri": "gs://cloud-samples-data/ai-platform/flowers/daisy/1396526833_fb867165be_n.jpg",
"mimeType": "image/jpeg"
}
}
],
"role": "user"
},
{
"parts": [
{
"text": "daisy"
}
],
"role": "model"
}
],
"systemInstruction": {
"parts": [
{
"text": "You are a botanical image classifier. Analyze the provided image and determine the most accurate classification of the flower.These are the only flower categories: ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips'].Return only one category per image."
}
]
}
}
כוונון המודל
אתם יכולים לכוונן את המודלים של Gemini באמצעות מערך נתונים מולטימודאלי.
(אופציונלי) אימות מערך הנתונים
בודקים את מערך הנתונים כדי לראות אם הוא מכיל שגיאות, כמו שגיאות בפורמט של מערך הנתונים או שגיאות במודל.
Agent Platform SDK
התקשרות אל assess_tuning_validity() כברירת מחדל, נעשה שימוש בהגדרת הקריאה המצורפת למערך הנתונים, אבל אפשר להעביר gemini_request_read_config כדי לשנות את התנהגות ברירת המחדל.
# Attach the read configuration to the dataset.
my_dataset.set_read_config(read_config=read_config)
my_dataset = client.datasets.update_multimodal_dataset(multimodal_dataset=my_dataset)
# Validation for tuning
validation = client.datasets.assess_tuning_validity(
dataset_name=my_dataset.name,
model_name="gemini-2.5-flash",
dataset_usage="SFT_TRAINING"
)
# Inspect validation result
validation.errors
REST
מבצעים קריאה ל-assess ומספקים TuningValidationAssessmentConfig.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID:assess" \
-d '{
"tuningValidationAssessmentConfig": {
"modelName": "projects/PROJECT_ID/locations/LOCATION/models/gemini-2.5-flash",
"datasetUsage": "SFT_TRAINING"
}
}'
(אופציונלי) הערכת השימוש במשאבים
כדי לקבל את הטוקן ואת מספר התווים לחיוב של משימת ההתאמה, צריך להעריך את מערך הנתונים.
Agent Platform SDK
התקשרות אל assess_tuning_resources()
# Resource estimation for tuning.
tuning_resources = client.datasets.assess_tuning_resources(
dataset_name=my_dataset.name,
model_name="gemini-2.5-flash"
)
print(tuning_resources)
# For example, TuningResourceUsageAssessmentResult(token_count=362688, billable_character_count=122000)
REST
מבצעים קריאה ל-method assess ומספקים TuningResourceUsageAssessmentConfig.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID:assess" \
-d '{
"tuningResourceUsageAssessmentConfig": {
"modelName": "projects/PROJECT_ID/locations/LOCATION/models/gemini-2.5-flash"
}
}'
הפעלת משימת ההתאמה
משתמשים ב-Google Gen AI SDK כדי להתחיל משימת התאמה, ומעבירים את שם המשאב של מערך הנתונים המולטימודאלי. למערך הנתונים צריך להיות מצורף קובץ הגדרות לקריאה.
Google Gen AI SDK
from google import genai
from google.genai.types import HttpOptions, CreateTuningJobConfig
genai_client = genai.Client(http_options=HttpOptions(api_version="v1"))
tuning_job = genai_client.tunings.tune(
base_model="gemini-2.5-flash",
# Pass the resource name of the Multimodal Dataset, not the dataset object
training_dataset={
"vertex_dataset_resource": my_multimodal_dataset.name
},
# Optional
config=CreateTuningJobConfig(
validation_dataset={
"vertex_dataset_resource": my_multimodal_validation_dataset.name
},
tuned_model_display_name="Example tuning job"),
)
מידע נוסף מופיע במאמר יצירת משימת התאמה.
תחזית באצווה
אפשר לקבל תחזיות אצווה באמצעות מערך נתונים מולטי-מודאלי.
(אופציונלי) אימות מערך הנתונים
בודקים את מערך הנתונים כדי לראות אם הוא מכיל שגיאות, כמו שגיאות בפורמט של מערך הנתונים או שגיאות במודל.
Agent Platform SDK
התקשרות אל assess_batch_prediction_validity() כברירת מחדל, נעשה שימוש בהגדרת הקריאה המצורפת למערך הנתונים, אבל אפשר להעביר gemini_request_read_config כדי לשנות את התנהגות ברירת המחדל.
# Attach the read configuration to the dataset.
my_dataset.set_read_config(read_config=read_config)
my_dataset = client.datasets.update_multimodal_dataset(multimodal_dataset=my_dataset)
# Validation for batch prediction
validation = client.datasets.assess_batch_prediction_validity(
dataset_name=my_dataset.name,
model_name="gemini-2.5-flash"
)
# Inspect validation result
validation.errors
REST
מבצעים קריאה ל-assess ומספקים batchPredictionValidationAssessmentConfig.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID:assess" \
-d '{
"batchPredictionValidationAssessmentConfig": {
"modelName": "projects/PROJECT_ID/locations/LOCATION/models/gemini-2.5-flash",
}
}'
(אופציונלי) הערכת השימוש במשאבים
בודקים את מערך הנתונים כדי לראות כמה טוקנים יש בעבודה.
Agent Platform SDK
התקשרות אל assess_batch_prediction_resources()
batch_prediction_resources = client.datasets.assess_batch_prediction_resources(
dataset_name=my_dataset.name,
model_name="gemini-2.5-flash"
)
print(batch_prediction_resources)
# For example, BatchPredictionResourceUsageAssessmentResult(token_count=362688, audio_token_count=122000)
REST
מבצעים קריאה ל-assess ומספקים batchPredictionResourceUsageAssessmentConfig.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID:assess" \
-d '{
"batchPredictionResourceUsageAssessmentConfig": {
"modelName": "projects/PROJECT_ID/locations/LOCATION/models/gemini-2.5-flash"
}
}'
הפעלת משימת חיזוי באצווה
אפשר להשתמש במערך הנתונים הרב-אופני כדי לבצע חיזוי באצווה על ידי העברת ה-BigQuerytable_id של הפלט המורכב:
Google Gen AI SDK
from google import genai
from google.genai.types import HttpOptions
# Attach the read configuration to the dataset.
my_dataset.set_read_config(read_config=read_config)
my_dataset = client.datasets.update_multimodal_dataset(multimodal_dataset=my_dataset)
# Assemble the dataset to get the assembled BigQuery table.
table_id, _ = client.datasets.assemble(name=my_dataset.name)
genai_client = genai.Client(http_options=HttpOptions(api_version="v1"))
job = genai_client.batches.create(
model="gemini-2.5-flash",
src=f"bq://{table_id}",
)
מידע נוסף זמין במאמר שליחת בקשה לעבודת חיזוי באצווה.
מגבלות
אפשר להשתמש במערכי נתונים מולטימודאליים רק עם תכונות מבוססות-AI גנרטיבי. אי אפשר להשתמש בהן עם תכונות מבוססות-AI שאינן גנרטיביות, כמו אימון AutoML ואימון מותאם אישית.
אפשר להשתמש במערכי נתונים מולטימודאליים רק עם מודלים של Google, כמו Gemini. אי אפשר להשתמש בהם עם מודלים של צד שלישי.
תמחור
כשמכווננים מודל או מריצים משימת חיזוי באצווה, מחויבים על השימוש ב-AI גנרטיבי ועל שאילתות במערך הנתונים ב-BigQuery.
כשיוצרים, מרכיבים או מעריכים מערך נתונים מולטימודאלי, אתם מחויבים על אחסון ועל שאילתות של מערכי נתונים מולטימודאליים ב-BigQuery. באופן ספציפי, הפעולות הבאות משתמשות בשירותים הבסיסיים האלה:
Createמערך נתונים- לא חלות עלויות אחסון נוספות על מערכי נתונים שנוצרו מטבלה קיימת ב-BigQuery או מ-DataFrame. הסיבה לכך היא שאנחנו משתמשים בתצוגה לוגית במקום לשמור עותק נוסף של הנתונים.
- מערכי נתונים שנוצרו ממקורות אחרים מעתיקים את הנתונים לטבלה חדשה ב-BigQuery, מה שמוביל לעלויות אחסון ב-BigQuery. לדוגמה, אחסון לוגי פעיל ב-0.02 $ל-GiB לחודש.
Assembleמערך נתוניםבשיטה הזו נוצרת טבלה חדשה ב-BigQuery שמכילה את מערך הנתונים המלא בפורמט של בקשת מודל, ולכן יש עלויות אחסון ב-BigQuery. לדוגמה, אחסון לוגי פעיל ב-0.02 $ל-GiB לחודש.
בשיטה הזו מתבצעת קריאה אחת של מערך הנתונים, ולכן יש עלויות של שאילתות ב-BigQuery. לדוגמה, מחשוב על פי דרישה במחיר של 25 ש"ח ל-TiB.
Assessקורא את מערך הנתונים פעם אחת, מה שגורר עלויות של שאילתות ב-BigQuery. לדוגמה, מחשוב על פי דרישה במחיר של 25 ש"ח ל-TiB.
אפשר להשתמש במחשבון התמחור כדי ליצור הערכת עלויות בהתאם לשימוש החזוי.