Grounding
Grounding enables Gemini to generate responses anchored in specific, verifiable information from external data sources. This reduces hallucinations and provides up-to-date, factual responses with citations.Why Ground Your Responses?
Reduce Hallucinations
Anchor responses in verified data sources
Real-time Information
Access current data beyond training cutoff
Verifiable Citations
Provide sources for transparency and trust
Grounding Sources
Vertex AI supports multiple grounding sources:- Google Search: Public web results with citations
- Enterprise Web Search: Compliant web search without logging
- Vertex AI Search: Your custom data stores
- Google Maps: Location and business data
Google Search Grounding
Basic Example
Ground responses in Google Search results:View Grounding Metadata
Access search queries and citations:Helper Function for Citations
Display responses with inline citations:Multimodal Grounding
Ground multimodal queries:Enterprise Web Search
For compliance-sensitive applications, use Enterprise Web Search:Key Differences:
- No customer query logging
- VPC Service Controls support
- Multi-region processing (US/EU)
- Same citation format as Google Search
Google Maps Grounding
Ground responses in Google Maps location data:Maps Grounding Metadata
Access place IDs and location details:Vertex AI Search Grounding
Create a Data Store
First, create a Vertex AI Search data store with your custom data:Enable APIs
Enable the Vertex AI Search API
Create Data Store
Create a data store with unstructured data from Cloud Storage:
- Go to Vertex AI Search console
- Click “Create Data Store”
- Choose “Unstructured documents”
- Point to your GCS bucket:
gs://your-bucket/documents/
Use Your Data Store
Private Data Example
Query internal documents:Grounding in Chat
Google Search Chat
Maintain grounded conversations:Vertex AI Search Chat
Chat with custom data:Combined Grounding
Use multiple grounding sources:Search Entry Points
For production applications, add a Search Entry Point:Grounding Configuration
Fine-tune grounding behavior:Response Filtering
Check grounding confidence:Comparison: Ungrounded vs Grounded
- Without Grounding
- With Grounding
Best Practices
Clear Queries
Write specific, focused queries for better grounding
Verify Sources
Always check grounding metadata for source quality
Handle Missing Data
Gracefully handle cases with no grounding results
Update Data Stores
Keep Vertex AI Search data stores current
Error Handling
Next Steps
Function Calling
Combine grounding with function calls
Context Caching
Cache grounded data for efficiency
Multimodal
Ground multimodal queries
Batch Prediction
Process grounded queries at scale