Get the length and first five elements of the text embedding

Check my progress

/ 10

Compare similarity of text examples using cosine similarity

Check my progress

/ 15

Generate image embeddings for the specified image

Check my progress

/ 15

Find product based on text query

Check my progress

/ 15

Generate video embeddings for the specified video

Check my progress

/ 15

Find videos based on text search query

Check my progress

/ 15

Find similar video based on video

Check my progress

/ 15

This lab may incorporate AI tools to support your learning.

GSP1280

Google Cloud 自學實驗室

總覽

本實驗室將深入介紹 Agent Platform Embeddings API,探討其處理文字和多模態資料 (圖片和影片) 的能力。您將瞭解嵌入的基本概念,學習如何將各種內容類型轉換為數值表示,並掌握數據的意義和關係。接著,本實驗室會引導您透過實作練習,瞭解 Agent Platform Text 和 Multimodal Embeddings API,並示範如何實際運用這些 API,建構簡易的電子商務資料搜尋系統。您將瞭解如何根據文字查詢、圖片或影片來尋找產品,並認識嵌入技術在增強搜尋和推薦系統方面的強大功能。

事前準備

開始這個實驗室之前,您應已熟悉下列概念:

  • 基本 Python 程式設計。
  • 一般 API 概念。
  • Agent Platform Workbench 使用 Jupyter 筆記本執行 Python 程式碼。

目標

本實驗室的學習內容包括:

  • Agent Platform Text Embeddings API。
  • Agent Platform Multimodal Embeddings API (圖片和影片)。
  • 使用電子商務資料建構簡單的搜尋系統
    • 根據文字查詢尋找產品。
    • 根據圖片尋找產品。
    • 根據影片尋找影片。

設定和需求

瞭解以下事項後,再點選「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」

工作 2:設定筆記本

  1. 開啟 檔案。

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

  3. 執行筆記本的「Getting Started」部分,專案 ID 和位置已預先設定完成。

注意:如果執行筆記本儲存格後出現 429 回應,請稍候一分鐘再重新執行儲存格,應該就能繼續操作。

工作 3:生成文字嵌入

在這個部分,您將嘗試使用 Gemini 的 Text Embeddings API。

  1. 執行筆記本的「生成文字嵌入」部分

點按「Check my progress」,確認目標已達成。 取得文字嵌入的長度和前五個元素。

點按「Check my progress」,確認目標已達成。 使用餘弦相似度比較文字範例的相似度。

工作 4:生成圖片嵌入

在這個部分,您將嘗試使用 Gemini 的 Multimodal Embedding API。

  1. 執行筆記本的「生成圖片嵌入」部分。

點按「Check my progress」,確認目標已達成。 生成圖片嵌入。

工作 5:根據文字查詢尋找產品

  1. 執行筆記本的「根據文字查詢尋找產品」部分

點按「Check my progress」,確認目標已達成。 根據文字查詢尋找產品。

工作 6:生成影片嵌入

  1. 執行筆記本的「生成影片嵌入」部分。

點按「Check my progress」,確認目標已達成。 生成影片嵌入。

工作 7:根據文字搜尋查詢尋找影片

  1. 執行筆記本的「根據文字搜尋查詢尋找影片」部分

點按「Check my progress」,確認目標已達成。 根據文字搜尋查詢尋找影片。

工作 8:尋找類似影片

  1. 執行筆記本的「尋找類似影片」部分。

點按「Check my progress」,確認目標已達成。 尋找類似影片。

恭喜!

在本實驗室,您已學會如何使用 Agent Platform Text 和 Multimodal Embeddings API 嵌入內容。

後續行動/瞭解詳情

歡迎參考下列資源,進一步瞭解 Gemini:

Google Cloud 教育訓練與認證

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

使用手冊上次更新日期:2025 年 10 月 17 日

實驗室上次測試日期:2025 年 10 月 17 日

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.