arrow_back

Getting Started with Vector Search and Embeddings

Testez vos connaissances et partagez-les avec notre communauté
done
Accédez à plus de 700 ateliers pratiques, badges de compétence et cours

Getting Started with Vector Search and Embeddings

Atelier 1 heure 30 minutes universal_currency_alt 5 crédits show_chart Intermédiaire
info Cet atelier peut intégrer des outils d'IA pour vous accompagner dans votre apprentissage.
Testez vos connaissances et partagez-les avec notre communauté
done
Accédez à plus de 700 ateliers pratiques, badges de compétence et cours

GSP1202

Google Cloud self-paced labs logo

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).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud console

  1. 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
  2. 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.
  3. 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.

  4. Click Next.

  5. 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.

  6. 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.
  7. 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.

Note: To view a menu with a list of Google Cloud products and services, click the Navigation menu at the top-left. Navigation menu icon

Task 1. Create a Vertex AI Workbench Instance

  1. In the Google Cloud Console, on the Navigation menu, click Vertex AI > Workbench.

  2. Click + Create New.

  3. 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.

  4. Click Create.

  5. Click Open JupyterLab.

Clone and run the lab notebook

  1. In your notebook, click the Terminal.

  2. Run the following command to clone the Google Cloud Generative AI repo:

git clone https://github.com/GoogleCloudPlatform/generative-ai.git

Click Check my progress to verify the objective. Clone and run the lab notebook

  1. In the left navigation pane, navigate to the generative-ai/embeddings folder and open the intro-textemb-vectorsearch.ipynb notebook.

  2. For the prompt Select Kernel leave the default Python3 and click Select.

  3. Scroll down to the Text Embeddings in Action section, and run the setup cells.

  4. When setting your environment variables, use for the location, and for the Project ID.

Note: you can skip any notebook cells that are noted Colab only.
  1. Skip the Set IAM permissions section, as your service account already has the required permissions.

Task 2. Generate embeddings

  1. Navigate to the Getting Started with Vertex AI Embeddings for Text section and run through the cells to create the text embeddings.

  2. Navigate to the Getting Started with Vector Search section and run through the cells.

  3. Save the embeddings in a JSON file.

  4. Create a new Cloud Storage bucket and copy the file to it.

Click Check my progress to verify the objective. Get Started with Vector Search

Task 3. Create and deploy an index

  1. Navigate to the Create an Index section and run through the cells to create and deploy an index.
Note: index creation and deployment takes around 20-30 minutes. Feel free to check out the following resources while you wait.

Click Check my progress to verify the objective. Create an Index

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

  1. 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

  1. 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

  1. 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. Query the Index

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:

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 April 04, 2024

Lab Last Tested April 04, 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.

Ce contenu n'est pas disponible pour le moment

We will notify you via email when it becomes available

Parfait !

We will contact you via email if it becomes available