Docs Menu

Integrate Atlas with Google Vertex AI

You can integrate Vertex AI with MongoDB Atlas to build and deploy AI applications. The Vertex AI platform includes several tools and pre-trained models from Google that you can use with Atlas for RAG and other uses cases such as natural language querying.

Vertex AI enables a variety of use cases with MongoDB Atlas:

The following sample application demonstrates how to use Vertex AI with Atlas for RAG. The application includes an interface that allows you to upload PDF documents and answer questions on the PDF data by using Atlas Vector Search and Vertex AI models.

Before starting this tutorial, you must have the following:

Follow the steps in the Google Cloud documentation to create and start a virtual machine (VM) instance in your Google Cloud console. Configure the Google Cloud VM instance with the following settings and use the default settings for the remaining options:

Option
Configuration

Name

vertexai-chatapp

Region and Zone

Any Google Cloud region and zone near your physical location

Machine Configuration

  • Series: High Memory

  • Machine Type: n1-standard-1

Boot disk

Size: 100 GB

Access

Allow full access to all Cloud APIs

Firewall

Select all

Networking

For the External IP range, specify Reserve external static IP address

This section loads a sample application that you can use to transform and store PDFs in Atlas and query them using Atlas Vector Search. To deploy and run the application on your Google Cloud VM instance, complete the following steps:

1

You must create an Atlas Vector Search index named vector_index on the vertexaiApp.chat-vec namespace in your Atlas cluster to enable queries against your vector embeddings. Use the default settings and specify 768 dimensions.

To learn more, see How to Index Fields for Vector Search.

2

Connect to the VM instance by using SSH. In the environment, clone the GitHub repository that contains the application code:

git clone https://github.com/mongodb-partners/MongoDB-VertexAI-Qwiklab.git

Note

To learn more about the application, see the repository.

3

Run the following commands to install the dependencies:

sudo apt update
sudo apt install python3-pip
sudo apt install git
cd MongoDB-VertexAI-Qwiklab
pip3 install -r requirements.txt
4
streamlit run app.py
5

Open the public IP address of your VM in a web browser with the port shown in the command output.

6

In the application, upload PDF data that you want to search.

The repository includes a sample PDF file that you can use. The app chunks the data into batches, converts each chunk into vector embeddings by using an embedding model from Vertex AI, and ingests this data into your Atlas collection.

Tip

After uploading the file, you can view your vector embeddings in the Atlas UI by navigating to the vertexaiApp.chat-vec collection in your cluster.

7
  1. In the application, click the Q&A tab.

  2. Enter a question in the search bar, and then press Enter.

    The application performs RAG by running a vector search query on your collection to retrieve the most relevant documents, and then uses a chat model from Vertex AI to generate a context-aware response.