Ground responses using RAG

Grounding connects model responses to verifiable sources of information to make them more trustworthy, helpful, and factual. A common method to implement grounding is retrieval-augmented generation (RAG). RAG uses a search engine to retrieve relevant information from an indexed data source based on the semantic meaning of the source text.

This document shows you how to ground model responses using RAG in Vertex AI and covers the following topics:

Components for building a RAG solution

You can implement a RAG solution by using a combination of the following services and APIs:

Service / API Description Use Case
Grounding generation API Connects your generative model to a data source to enable grounding for the entire RAG lifecycle. When you need to connect your generative model to a data source for fact-based responses.
Document layout parser Combines features from Document AI and Gemini for advanced document understanding. For more information, see Use the layout parser. For processing complex documents with varied layouts, such as PDFs with tables and images, for retrieval.
Vertex AI Vector Search A search service that uses a vector database to find information based on semantic meaning. For building the retrieval part of a RAG system that needs to find relevant information based on meaning.
Check grounding API Compares the model's generated response with the retrieved source data to verify that the response is factually grounded. As a final step in your RAG pipeline to help ensure the generated response is factually consistent with the source data.

Ground responses using Vertex AI RAG Engine

To ground responses using Vertex AI RAG Engine, follow these steps to create a prompt:

  1. In the Google Cloud console, go to the Create prompt page in Vertex AI Studio.

    Go to Create prompt

  2. Select Grounding: Your data.

  3. Select RAG Engine as the grounding source.

  4. From the Corpus list, select your corpus name.

  5. In the Top-K Similarity field, select 20, which is the default.

  6. Click Save.

What's next