בדף הזה מוסבר איך להעריך את המודלים והאפליקציות שלכם ל-AI גנרטיבי במגוון תרחישים לדוגמה, באמצעות GenAI Client ב-Agent Platform SDK.
לפני שמתחילים
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance 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 Cloud de Confiance project.
מתקינים את Agent Platform SDK:
!pip install google-cloud-aiplatform[evaluation]מגדירים את פרטי הכניסה. אם אתם מריצים את המדריך הזה ב-Colaboratory, הריצו את הפקודה הבאה:
from google.colab import auth auth.authenticate_user()בסביבות אחרות, אפשר לעיין במאמר אימות ב-Agent Platform.
הפעלת לקוח ה-AI הגנרטיבי
כדי לאתחל את לקוח GenAI, מריצים את הפקודה הבאה:
from vertexai import Client
client = Client(project="YOUR_PROJECT_ID", location="YOUR_LOCATION")
כאשר:
-
YOUR_PROJECT_ID: מזהה הפרויקט ב- Cloud de Confiance by S3NS . -
YOUR_LOCATION: האזור בענן, לדוגמהus-central1.
יצירת תשובות
יוצרים תשובות של המודל למערך הנתונים באמצעות run_inference():
מכינים את מערך הנתונים בתור Pandas DataFrame:
import pandas as pd eval_df = pd.DataFrame({ "prompt": [ "Explain software 'technical debt' using a concise analogy of planting a garden.", "Write a Python function to find the nth Fibonacci number using recursion with memoization, but without using any imports.", "Write a four-line poem about a lonely robot, where every line must be a question and the word 'and' cannot be used.", "A drawer has 10 red socks and 10 blue socks. In complete darkness, what is the minimum number of socks you must pull out to guarantee you have a matching pair?", "An AI discovers a cure for a major disease, but the cure is based on private data it analyzed without consent. Should the cure be released? Justify your answer." ] })יוצרים תשובות של המודל באמצעות
run_inference():eval_dataset = client.evals.run_inference( model="gemini-2.5-flash", src=eval_df, )הצגת תוצאות ההסקה: מפעילים את
.show()באובייקטEvaluationDatasetכדי לבדוק את הפלט של המודל לצד ההנחיות וההפניות המקוריות:eval_dataset.show()
בתמונה הבאה מוצגת קבוצת הנתונים להערכה עם הנחיות והתשובות שנוצרו בהתאם:

הרצת ההערכה
מריצים את evaluate() כדי להעריך את התשובות של המודל:
מעריכים את התשובות של המודל באמצעות
GENERAL_QUALITYמדד ברירת המחדל שמבוסס על רובריקה דינמית:eval_result = client.evals.evaluate(dataset=eval_dataset)הצגת תוצאות ההערכה: מפעילים את
.show()באובייקטEvaluationResultכדי להציג מדדי סיכום ותוצאות מפורטות:eval_result.show()
בתמונה הבאה מוצג דוח הערכה, שכולל מדדי סיכום ותוצאות מפורטות לכל צמד של הנחיה ותשובה.

הסרת המשאבים
במדריך הזה לא נוצרים משאבים של Gemini Enterprise Agent Platform.