Get Started with Vector Search

Check my progress

/ 30

Create an Index

Check my progress

/ 40

Query the Index

Check my progress

/ 30

This lab may incorporate AI tools to support your learning.

GSP1202

Google Cloud 自學實驗室

總覽

Vector Search 能在數十億個語意相似或語意相關的項目中進行搜尋。向量相似度比對服務有許多用途,例如導入推薦引擎、搜尋引擎、聊天機器人、以及文字分類。語意比對能簡化成幾個步驟:首先,您必須生成多個項目的嵌入表示,這項作業是在 Vector Search 之外進行。其次,將嵌入上傳到 Google Cloud 並將資料連到 Vector Search。將嵌入新增到 Vector Search 後,就能建立索引來執行查詢,取得推薦或結果。

嵌入的使用不限於字詞或文字。您可以為多種資料生成語意嵌入,包含圖片、音訊、影片和使用者偏好設定。如要使用 Agent Platform 生成多模態嵌入,請參考「Get multimodal embeddings」(取得多模態嵌入)。在本研究室中,您將瞭解如何透過 Agent Platform Embeddings for Text 建立文字嵌入,並用來建立 Vector Search 索引。

目標

在本研究室中,您會執行下列工作:

  • 建立 Agent Platform 筆記本執行個體
  • 複製並執行研究室筆記本
  • 建立文字嵌入
  • 建立及部署 Vector Search 索引
  • 查詢索引

設定和需求

瞭解以下事項後,再點選「Start Lab」按鈕

請詳閱以下操作說明。實驗室活動會計時,且中途無法暫停。點選「Start Lab」後就會開始計時,顯示可使用 Google Cloud 資源的時間。

您將在真正的雲端環境完成實作實驗室活動,而不是模擬或示範環境。為此,我們會提供新的暫時憑證,供您在實驗室活動期間登入及存取 Google Cloud。

為了順利完成這個實驗室,請先確認:

  • 可以使用標準的網際網路瀏覽器 (Chrome 瀏覽器為佳)。
注意事項:請使用無痕模式 (建議選項) 或私密瀏覽視窗執行此實驗室,這可以防止個人帳戶和學員帳戶之間的衝突,避免個人帳戶產生額外費用。
  • 是時候完成實驗室活動了!別忘了,活動一旦開始將無法暫停。
注意事項:務必使用實驗室專用的學員帳戶。如果使用其他 Google Cloud 帳戶,可能會產生額外費用。

如何開始研究室及登入 Google Cloud 控制台

  1. 點選「Start Lab」按鈕。如果實驗室會產生費用,畫面上會出現選擇付款方式的對話方塊。左側的「Lab Details」窗格會顯示下列項目:

    • 「Open Google Cloud console」按鈕
    • 剩餘時間
    • 必須在這個研究室中使用的臨時憑證
    • 完成這個實驗室所需的其他資訊 (如有)
  2. 點選「Open Google Cloud console」;如果使用 Chrome 瀏覽器,也能按一下滑鼠右鍵,選取「在無痕視窗中開啟連結」

    接著,實驗室會啟動相關資源,並開啟另一個分頁,顯示「登入」頁面。

    提示:您可以在不同的視窗中並排開啟分頁。

    注意:如果頁面中顯示「選擇帳戶」對話方塊,請點選「使用其他帳戶」
  3. 如有必要,請將下方的 Username 貼到「登入」對話方塊。

    {{{user_0.username | "Username"}}}

    您也可以在「Lab Details」窗格找到 Username。

  4. 點選「下一步」

  5. 複製下方的 Password,並貼到「歡迎使用」對話方塊。

    {{{user_0.password | "Password"}}}

    您也可以在「Lab Details」窗格找到 Password。

  6. 點選「下一步」

    重要事項:請務必使用實驗室提供的憑證,而非自己的 Google Cloud 帳戶憑證。 注意:如果使用自己的 Google Cloud 帳戶來進行這個實驗室,可能會產生額外費用。
  7. 按過後續的所有頁面:

    • 接受條款及細則。
    • 由於這是臨時帳戶,請勿新增救援選項或雙重驗證機制。
    • 請勿申請免費試用。

Google Cloud 控制台稍後會在這個分頁開啟。

注意:如要使用 Google Cloud 產品和服務,請點選「導覽選單」,或在「搜尋」欄位輸入服務或產品名稱。「導覽選單」圖示和搜尋欄位

工作 1:開啟 Agent Platform Workbench 中的筆記本

  1. 前往 Google Cloud 控制台,依序點按「導覽選單」圖示 「導覽選單」圖示 >「Agent Platform」>「Notebooks」

  2. 在左側導覽列中,點擊 Workbench

  3. 找出 執行個體,點按「Open JupyterLab」按鈕。

Workbench 執行個體的 JupyterLab 介面會在新瀏覽器分頁開啟。

注意:如果在 JupyterLab 沒有看見筆記本,請按照以下額外步驟重設執行個體:

1. 關閉 JupyterLab 的瀏覽器分頁,回到 Workbench 首頁。

2. 勾選執行個體名稱旁的核取方塊,然後點按「重設」

3. 「開啟 JupyterLab」按鈕再次啟用後,等待一分鐘,然後點按「開啟 JupyterLab」

  1. 在左側面板按兩下 intro-textemb-vectorsearch.ipynb,即可在右側視窗開啟該筆記本檔案。

  2. 出現「Select Kernel」對話方塊時,從可用核心清單選取「Python 3」

  3. 向下捲動至「Text Embeddings in Action」部分,執行設定儲存格。

注意:您可以略過任何標有「Colab only」的筆記本儲存格。
  1. 略過Set IAM permissions」(設定 IAM 權限) 部分,因為服務帳戶已具備必要權限。

工作 2:生成嵌入

  1. 前往「Getting Started with Agent Platform Embeddings for Text」(開始使用 Agent Platform Embeddings for Text) 部分,執行各個儲存格來建立文字嵌入。

  2. 前往「Getting Started with Vector Search」(開始使用 Vector Search) 部分,執行各個儲存格。

  3. 將嵌入儲存為 JSON 檔案。

  4. 建立新的 Cloud Storage bucket,將檔案複製到該 bucket。

點選「Check my progress」,確認目標已達成。 開始使用 Vector Search

工作 3:建立及部署索引

  1. 前往「Create an Index」(建立索引) 部分,執行各個儲存格來建立並部署索引。
注意:建立及部署索引大約需要 20 到 30 分鐘。在等待期間,歡迎瀏覽下列資源。

點選「Check my progress」,確認目標已達成。 建立索引

探索 Vector Search

這項工作中,您將探索 Vector Search 筆記本。建立及部署索引大約需要 30 分鐘,您可以在等待期間探索筆記本。

在等待期間:探索 Vector Search 筆記本

  1. 在筆記本中,前往頂端的「Bringing Gen AI and LLMs to production services」(將生成式 AI 和 LLM 用於正式服務) 部分,閱讀 Vector Search 用途與說明。

工作 4:執行查詢

  1. 前往「Run Query」(執行查詢) 部分,執行各個儲存格來查詢索引。您可以嘗試改變 test_embeddings 變數中的字串,查看不同的搜尋結果。

點選「Check my progress」,確認目標已達成。 查詢索引

恭喜!

恭喜!您在本研究室中學會如何建立文字嵌入,並用來建立 Vector Search 索引。您現在可以在自己的應用程式中使用文字嵌入了!

後續步驟/瞭解詳情

歡迎參考下列資源,進一步瞭解文字嵌入及 Vector Search:

Google Cloud 教育訓練與認證

協助您瞭解如何充分運用 Google Cloud 的技術。我們的課程會介紹專業技能和最佳做法,讓您可以快速掌握要領並持續進修。我們提供從基本到進階等級的訓練課程,並有隨選、線上和虛擬課程等選項,方便您抽空參加。認證可協助您驗證及證明自己在 Google Cloud 技術方面的技能和專業知識。

使用手冊上次更新日期:2025 年 11 月 4 日

實驗室上次測試日期:2025 年 11 月 4 日

Copyright 2026 Google LLC 保留所有權利。Google 和 Google 標誌是 Google LLC 的商標,其他公司和產品名稱則有可能是其關聯公司的商標。

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

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

Use private browsing to run the lab

Using an Incognito or private browser window is the best way 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.

Complete this quick step to start your lab.