Today, we are excited to announce the rollout of Grounding with Google Search in both Google AI Studio and the Gemini API. This innovative feature empowers developers to obtain more accurate and up-to-date responses from the Gemini models, utilizing the capabilities of Google Search. In addition to delivering precise answers, the model now includes grounding sources—supporting links that provide context—and Search Suggestions that direct users to relevant search results linked to the grounded response.
Grounding with Google Search is available for all generally accessible versions of the Gemini 1.5 models. Developers can easily enable this feature in Google AI Studio under the “Tools” section or by activating the 'google_search_retrieval' tool in the API. For those looking to experiment, grounding can be tested for free in Google AI Studio, while API access is available at a cost of $35 per 1,000 grounded queries.
When Should Developers Use Grounding?
Developers are encouraged to enable Grounding with Google Search for applications that could benefit from:
- Reduced Hallucinations: Grounding enhances the factual accuracy of AI applications, ensuring users receive reliable information.
- Real-Time Information: With grounding, models can access current data, making AI applications more relevant across various scenarios.
- Increased Trustworthiness: By providing supporting links, grounding enhances transparency in AI applications, encouraging users to explore original sources for further information.
- Richer Responses: Grounding allows models to draw from Google Search, resulting in more comprehensive answers to user queries.
Grounding with Google Search in Action
We’ve included examples showcasing how Grounding with Google Search improves model responses using AI Studio’s new Compare Mode. In one instance, a model response based on outdated knowledge (shown on the left) is contrasted with a more accurate answer derived from the latest sources (shown on the right) when grounding is enabled.
In another example, without grounding (on the left), the model provides a minimal response by default. However, grounding activated (on the right), generates a richer answer complete with supporting links.
How Does Grounding with Google Search Work?
When users submit a query with grounding enabled, the service utilizes Google’s search engine to retrieve up-to-date and relevant information. This information is then sent to the model, which responds with enhanced accuracy and freshness, including in-line grounding sources and Search Suggestions.
Notably, not every query requires grounding within a session, which can incur additional costs and latency. Developers have control over this through dynamic retrieval settings.
When requesting a grounded answer, dynamic retrieval assigns a prediction score—a value between 0 and 1—indicating how likely a prompt will benefit from grounding.
Developers can set a threshold for which scores should trigger grounding (the default is 0.3). We recommend experimenting with different threshold values to determine what works best for specific applications.By leveraging Google’s search results for Gemini-based applications, developers can provide users with more accurate, relevant, and trustworthy information. For detailed code examples and step-by-step instructions, please refer to our documentation.
Image reference