Checkpoints
Clone and run the lab notebook
/ 25
Get Started with Vector Search
/ 25
Create an Index
/ 25
Query the Index
/ 25
Getting Started with Vector Search and Embeddings
GSP1202
Overview
Vector Search can search from billions of semantically similar or semantically related items. A vector similarity-matching service has many use cases such as implementing recommendation engines, search engines, chatbots, and text classification. Semantic matching can be simplified into a few steps. First, you must generate embedding representations of many items (done outside of Vector Search). Secondly, you upload your embeddings to Google Cloud, and then link your data to Vector Search. After your embeddings are added to Vector Search, you can create an index to run queries to get recommendations or results.
The use of embeddings is not limited to words or text. You can generate semantic embeddings for many kinds of data, including images, audio, video, and user preferences. For generating a multimodal embedding with Vertex AI, see Get multimodal embeddings. In this lab, you will learn how to use Vertex AI Embeddings for text to create text embeddings and use them to create a vector search index.
Objectives
In this lab, you will perform the following tasks:
- Create a Vertex AI Notebook Instance
- Clone and run the lab notebook
- Create text embeddings
- Create and deploy vector search index
- Query the index
Setup and requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
How to start your lab and sign in to the Google Cloud console
-
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:
- The Open Google Cloud console button
- Time remaining
- The temporary credentials that you must use for this lab
- Other information, if needed, to step through this lab
-
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account. -
If necessary, copy the Username below and paste it into the Sign in dialog.
{{{user_0.username | "Username"}}} You can also find the Username in the Lab Details panel.
-
Click Next.
-
Copy the Password below and paste it into the Welcome dialog.
{{{user_0.password | "Password"}}} You can also find the Password in the Lab Details panel.
-
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges. -
Click through the subsequent pages:
- Accept the terms and conditions.
- Do not add recovery options or two-factor authentication (because this is a temporary account).
- Do not sign up for free trials.
After a few moments, the Google Cloud console opens in this tab.
Task 1. Create a Vertex AI Workbench Instance
-
In the Google Cloud Console, on the Navigation menu, click Vertex AI > Workbench.
-
Click + Create New.
-
In the Create instance dialog, use the default name or enter a unique name for the Vertex AI Workbench Instance. Set the region to
and zone to and leave the rest of the settings as default. -
Click Create.
-
Click Open JupyterLab.
Clone and run the lab notebook
-
In your notebook, click the Terminal.
-
Run the following command to clone the Google Cloud Generative AI repo:
Click Check my progress to verify the objective.
-
In the left navigation pane, navigate to the
generative-ai/embeddings
folder and open theintro-textemb-vectorsearch.ipynb
notebook. -
For the prompt Select Kernel leave the default Python3 and click Select.
-
Scroll down to the Text Embeddings in Action section, and run the setup cells.
-
When setting your environment variables, use
for the location, and for the Project ID.
- Skip the Set IAM permissions section, as your service account already has the required permissions.
Task 2. Generate embeddings
-
Navigate to the Getting Started with Vertex AI Embeddings for Text section and run through the cells to create the text embeddings.
-
Navigate to the Getting Started with Vector Search section and run through the cells.
-
Save the embeddings in a JSON file.
-
Create a new Cloud Storage bucket and copy the file to it.
Click Check my progress to verify the objective.
Task 3. Create and deploy an index
- Navigate to the Create an Index section and run through the cells to create and deploy an index.
Click Check my progress to verify the objective.
Explore Vector Search and try the demo
In this task, you will explore the Vector search notebook and try the public demo. Since index creation and deployment takes ~30 minutes, you can try the public demo and explore the notebook while you wait.
While you wait: Try the Stack Overflow semantic search demo
- The Vector Search public demo is available as a public live demo. Select "STACKOVERFLOW" and enter any coding question as a query, so it runs a text search on 8 million questions posted on Stack Overflow. Try the text semantic search with some queries like 'How to shuffle rows in SQL?' or arbitrary programming questions.
While you wait: Explore the Vector Search notebook
- In the notebook, navigate to the Bringing Gen AI and LLMs to production services section at the top and read through the vector search use cases and explanations.
Task 4. Run a query
- Navigate to the Run Query section and run through the cells to query the index. You can try changing the string in the
test_embeddings
variable to see different results.
Click Check my progress to verify the objective.
Congratulations!
Congratulations! In this lab, you learned how to create text embeddings and use them to create a vector search index. You are now ready to use text embeddings in your own applications!
Next steps / Learn more
Check out the following resources for more information on text embeddings and vector search:
- Vertex AI Embeddings for Text: Grounding LLMs made easy
- Overview of Vertex AI Vector Search
- Vector Search notebook tutorials
Google Cloud training and certification
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated October 23, 2024
Lab Last Tested October 23, 2024
Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.