In generative AI, grounding is the ability to connect model output to verifiable sources of information. If you provide models with access to specific data sources, grounding tethers their output to this data and reduces the chances of inventing content. This document shows you how to ground model outputs by using either public or private data and covers the following topics: Vertex AI offers two methods for grounding model responses. The following table helps you choose the best option for your use case. For more information about grounding, see Grounding overview. When you make a request, you specify the tools the model can use for grounding. For implementation details, see Examples. To ground with public data, include the To ground with private data, include the To ground the response with Google Search public data, include the
To learn more, see the
SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
Learn how to install or update the Go.
To learn more, see the
SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
Choose a grounding method
Method
Description
Data Source
Use Case
Google Search
Grounds the model with publicly available web data.
Public web
When you need the model to answer questions about current events or general knowledge that can be found on the internet.
Vertex AI Search ([Preview](/products/#product-launch-stages))
Grounds the model with your own data from a Vertex AI Search data store.
Private data
When you need the model to answer questions based on your own documents, such as internal knowledge bases or proprietary information.
Supported models
Grounding parameters
GoogleSearchRetrieval
tool in your request.
google_search_retrieval
: An empty object ({}
) that tells the model to use Google Search to ground the response.Retrieval
tool in your request. This tool defines how the model accesses external knowledge from a Vertex AI Search data store.
retrieval
: Contains the VertexAISearch
object as its source.
vertex_ai_search
: Specifies the data store to use for grounding.
datastore
: The fully-qualified Vertex AI Search data store resource ID. Specify the ID in the following format: projects/{project}/locations/{location}/collections/default_collection/dataStores/{datastore}
.Examples
Ground response on public web data using Google Search
google_search_retrieval
tool in the request. No additional parameters are required.Python
Install
pip install --upgrade google-genai
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True
Go
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True
Ground response on private data using Vertex AI Search
You can ground the response with data from a Vertex AI Search data store. For more information, see AI Applications.
Before you ground a response with private data, you must create a data store and a search app.
Gen AI SDK for Python
What's next
For detailed documentation, see the following: