Starting April 29, 2025, Gemini 1.5 Pro and Gemini 1.5 Flash models are not available in projects that have no prior usage of these models, including new projects. For details, see Model versions and lifecycle.
Tutorial: Perform evaluation using the GenAI Client in Vertex AI SDK
Stay organized with collections
Save and categorize content based on your preferences.
This page shows you how to evaluate your generative AI models and applications across a range of use cases using the GenAI Client in Vertex AI SDK.
Before you begin
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
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
(roles/resourcemanager.projectCreator), which contains the
resourcemanager.projects.create permission. 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
(roles/resourcemanager.projectCreator), which contains the
resourcemanager.projects.create permission. Learn how to grant
roles.
importpandasaspdeval_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."]})
Visualize your inference results by calling .show() on the EvaluationDataset object to inspect the model's outputs alongside your original prompts and references:
eval_dataset.show()
The following image displays the evaluation dataset with prompts and their corresponding generated responses:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-10 UTC."],[],[],null,["| To see an example of Getting Started: Perform evaluation using the Vertex AI SDK through GenAI Client,\n| run the \"Getting Started: Perform evaluation using the Vertex AI SDK through GenAI Client\" notebook in one of the following\n| environments:\n|\n| [Open in Colab](https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/gemini/evaluation/quick_start_gen_ai_eval.ipynb)\n|\n|\n| \\|\n|\n| [Open in Colab Enterprise](https://console.cloud.google.com/vertex-ai/colab/import/https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fevaluation%2Fquick_start_gen_ai_eval.ipynb)\n|\n|\n| \\|\n|\n| [Open\n| in Vertex AI Workbench](https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fevaluation%2Fquick_start_gen_ai_eval.ipynb)\n|\n|\n| \\|\n|\n| [View on GitHub](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/evaluation/quick_start_gen_ai_eval.ipynb)\n\nThis page shows you how to evaluate your generative AI models and applications across a range of use cases using the GenAI Client in Vertex AI SDK.\n\nBefore you begin\n\n1. Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n\n In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n **Roles required to select or create a project**\n - **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.\n - **Create a project** : To create a project, you need the Project Creator (`roles/resourcemanager.projectCreator`), which contains the `resourcemanager.projects.create` permission. [Learn how to grant\n roles](/iam/docs/granting-changing-revoking-access).\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n\n\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project). \n In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n **Roles required to select or create a project**\n - **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.\n - **Create a project** : To create a project, you need the Project Creator (`roles/resourcemanager.projectCreator`), which contains the `resourcemanager.projects.create` permission. [Learn how to grant\n roles](/iam/docs/granting-changing-revoking-access).\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n\n\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n2. Install the Vertex AI SDK for Python:\n\n !pip install google-cloud-aiplatform[evaluation]\n\n3. Set up your credentials. If you are running this tutorial in Colaboratory, run the following:\n\n from google.colab import auth\n auth.authenticate_user()\n\n For other environments, refer to [Authenticate to Vertex AI](/vertex-ai/docs/authentication#client-libraries).\n\nGenerate responses\n\nGenerate model responses for your dataset using `run_inference()`:\n\n1. [Prepare your dataset](/vertex-ai/generative-ai/docs/models/evaluation-dataset) as a Pandas DataFrame:\n\n import pandas as pd\n\n eval_df = pd.DataFrame({\n \"prompt\": [\n \"Explain software 'technical debt' using a concise analogy of planting a garden.\",\n \"Write a Python function to find the nth Fibonacci number using recursion with memoization, but without using any imports.\",\n \"Write a four-line poem about a lonely robot, where every line must be a question and the word 'and' cannot be used.\",\n \"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?\",\n \"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.\"\n ]\n })\n\n2. Generate model responses using `run_inference()`:\n\n eval_dataset = client.evals.run_inference(\n model=\"gemini-2.5-flash\",\n src=eval_df,\n )\n\n3. [Visualize your inference results](/vertex-ai/generative-ai/docs/models/view-evaluation) by calling `.show()` on the `EvaluationDataset` object to inspect the model's outputs alongside your original prompts and references:\n\n eval_dataset.show()\n\nThe following image displays the evaluation dataset with prompts and their corresponding generated responses:\n\nRun the evaluation\n\nRun `evaluate()` to evaluate the model responses:\n\n1. Evaluate the model responses using the default `GENERAL_QUALITY` [adaptive rubric-based metric](/vertex-ai/generative-ai/docs/models/determine-eval):\n\n eval_result = client.evals.evaluate(dataset=eval_dataset)\n\n2. [Visualize your evaluation results](/vertex-ai/generative-ai/docs/models/view-evaluation) by calling `.show()` on the `EvaluationResult` object to display summary metrics and detailed results:\n\n eval_result.show()\n\nThe following image displays an evaluation report, which shows summary metrics and detailed results for each prompt-response pair.\n\nClean up\n\nNo Vertex AI resources are created during this tutorial.\n\nWhat's next\n\n- [Define your evaluation metrics](/vertex-ai/generative-ai/docs/models/determine-eval)."]]