
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Install packages, and configure the notebook.
/ 15
Prepare the dataset
/ 15
Use token based search
/ 15
Create an index endpoint and sparse embedding index in Vector Search
/ 15
Create the hybrid index and deploy it to the Endpoint
/ 20
Run a hybrid query
/ 20
Vertex AI Vector Search supports hybrid search, a popular architecture pattern in information retrieval (IR) that combines both semantic search and keyword search (also called token-based search). With hybrid search, developers can take advantage of the best of the two approaches, effectively providing higher search quality.
With this lab you learn how to use hybrid search with a Google merchandise dataset of products. At the end of the lab you will compare the results of the hybrid search to token-based search.
When you start the lab, the environment will contain the resources that are shown in the following diagram.
By the end of the lab, you will have used the architecture to perform several tasks.
The following table provides a detailed explanation of each task in relation to the lab architecture.
Numbered Task | Detail |
---|---|
1. | Open the notebook in Vertex AI Workbench and choose the kernel. |
2. |
Install packages, and configure the notebook for your project: You will use the Google Gen AI SDK to work with the text embeddings model through the Developer API and Vertex AI. This will require you to install Python libraries and reference them throughout the lab. You also need to configure the notebook to have access to resources in your project, like the Cloud Storage bucket provided to you at lab launch. |
3. |
Prepare the dataset: In this task you download the dataset .csv file including the Google Merch Shop items, and add them to a Pandas DataFrame. |
4. |
Use Token-based Search: You will train a vectorizer, a model that generates sparse embeddings from text and then apply it to the dataset. |
5. |
Create an index endpoint: Before you can use hybrid search in Vertex AI Vector Search, you have to create an index endpoint. |
6. |
Create the hybrid query index and deploy it to the endpoint: You will get the 'text-embedding-005' model to generate dense embeddings for your dataset items, which will be combined with the sparse embeddings to create the hybrid index. Once this is complete you will deploy the hybrid index to your endpoint. |
7. |
Run the hybrid query: With your index deployed you first need to create the HybridQuery object to encapsulate the sparse embedding of the query text, and then you can run your query. |
Before starting this lab, you should be familiar with:
In this lab, you will:
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 are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
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.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
In the Google Cloud console, on the Navigation menu (), click Vertex AI > Workbench.
Find the
The JupyterLab interface for your Workbench instance opens in a new browser tab.
1. Close the browser tab for JupyterLab, and return to the Workbench home page.
2. Select the checkbox next to the instance name, and click Reset.
3. After the Open JupyterLab button is enabled again, wait one minute, and then click Open JupyterLab.
Open the
In the Select Kernel dialog, choose Python 3 from the list of available kernels.
To start using the notebook, you begin with section 1, Create sparse embeddings.
In this task you install the required Python packages, restart the kernel runtime, configure your notebook to use your project and region, and import libraries.
Complete the cells in Task 2, Install packages, and configure the notebook.
For Project ID, use
Click Check my progress to verify the objective.
In this task, you download the dataset .csv file, and prepare it for use with your notebook.
Click Check my progress to verify the objective.
In this task, you will create a sparse embedding and search for the "Chrome Dino Pin" item in the dataset to get the vector-based values and dimensions. You will also retrieve these values for the other products in the dataset. You will then save them to the items.json file within Workbench and copy this file to your Cloud Storage bucket.
Click Check my progress to verify the objective.
Now you will move on to section 2 of the notebook where you will use hybrid search.
First, in this fifth task, you will create an index endpoint.
Click Check my progress to verify the objective.
In this task, you will retrieve the text embedding model, run a sample query for dense embeddings for an item, and then for all items. You will then store these in the items.json file. You will then create the hybrid index from this file and deploy the index to the endpoint.
While you are waiting for the hybrid index to be deployed, you can observe its deployment by going to Vertex AI > Vector Search > Index Endpoints.
You can also take time to review this demo. The demo provides a realistic example that will help you learn how Vector Search works, explore semantic and hybrid search, and see re-ranking in action. Submit a brief description of an animal, plant, e-commerce merchandise, or other item, and allow Vector Search to complete the remaining steps!
Click Check my progress to verify the objective.
In this task, you run a hybrid query with the hybrid index that you just deployed and you will compare the results of this query with the sparse embeddings.
Click Check my progress to verify the objective.
In this lab, you learned how to use hybrid search in Vertex AI Vector Search, including creating and deploying a hybrid search index, and querying it to compare with sparse embeddings.
Check out the following resources to learn more about Gemini:
...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 July 11, 2025
Lab Last Tested July 11, 2025
Copyright 2025 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.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one