Enable the Model Armor API

Check my progress

/ 10

Create a Model Armor template

Check my progress

/ 10

Configure Sensitive Data Protection with Inspect and De-identify templates

Check my progress

/ 10

Input a user prompt to screen Responsible AI

Check my progress

/ 10

Input a user prompt to screen Malicious URI

Check my progress

/ 10

Input a user prompt to screen DLP

Check my progress

/ 10

Input a model response to screen DLP

Check my progress

/ 20

Sanitize a file-based user prompt

Check my progress

/ 20

This lab may incorporate AI tools to support your learning.
This content is not yet optimized for mobile devices.
For the best experience, please visit us on a desktop computer using a link sent by email.

GSP1327

Google Cloud 自學實驗室

總覽

Google Cloud 的 Model Armor 會過濾使用者提示詞和 LLM 回覆,抵禦有害內容、提示詞注入和敏感資料外洩等風險,強化 AI 安全防護。這項服務能讓組織集中管理並落實 AI 應用的安全政策,透過篩選機制確保互動安全且符合規範。Model Armor 整合了 Security Command Center,您可以在統一的檢視畫面掌握全局,防止 AI 模型未經授權即遭人公開或操縱。

在本實驗室中,您將瞭解如何使用 Model Armor 清理提示詞和回覆。

目標

挑戰本實驗室,展現執行下列工作的能力:

  • 啟用 Model Armor API。
  • 建立 Model Armor 範本。
  • 執行各種指令,運用不同安全防護功能清理使用者提示詞。

設定和需求

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

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

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

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

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

如何開始實驗室及登入 Google Cloud 控制台

  1. 按一下「Start Lab」按鈕。如果實驗室會產生費用,請在開啟的對話方塊中選取付款方式。右側的「Lab setup and access」面板會顯示下列項目:

    • 「Open Google Cloud console」按鈕
    • 此實驗室所需的臨時憑證 (使用者名稱和密碼)
    • 完成此實驗室所需的其他資訊 (如有)

    請注意,實驗室計時器位於頁面頂端附近,會顯示剩餘時間。

  2. 按一下「Open Google Cloud console」。如果使用 Chrome 瀏覽器,也可以按一下滑鼠右鍵,選取「在無痕視窗中開啟連結」。

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

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

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

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

    您也可以在「Lab setup and access」面板找到「Username」。

  4. 點選「下一步」。

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

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

    您也可以在「Lab setup and access」面板找到「Password」。

  6. 點選「下一步」。

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

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

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

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

工作 1:啟用 Model Armor API

您必須先啟用 API,才能使用 Model Armor。

  1. 在 Google Cloud 控制台啟用 Cloud Shell。

  2. 執行下列指令:

PROJECT=$(gcloud config get-value project) gcloud services enable modelarmor.googleapis.com --project=$PROJECT

點選「Check my progress」,確認目標已達成。 啟用 Model Armor API

工作 2:在 Agent Platform Workbench 開啟筆記本

  1. 在 Google Cloud 控制台,依序點選「導覽選單」圖示 「導覽選單」圖示 >「Agent Platform」>「Notebooks」>「Workbench」。

  2. 找出 執行個體,然後點選「Open JupyterLab」按鈕。

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

工作 3:設定筆記本

  1. 開啟 檔案。

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

  3. 執行筆記本的「Getting Started」和「Import libraries」部分。

注意:您可以略過標有「Colab only」字樣的筆記本儲存格。如果執行筆記本儲存格後出現 429 回應,請稍候 1 分鐘再重新執行儲存格,即可繼續操作。 注意:如果筆記本顯示儲存格 1 缺少專案「environment」標記的相關通知,請直接忽略。

工作 4:建立 Model Armor 範本

在這項工作中,您將建立 Model Armor 範本 ma-template,定義 AI 互動的安全防護和內容篩選規則。這個範本會建立相關政策,協助偵測並降低敏感資料外洩風險,確保符合資料保護標準。

執行筆記本的「Create a Model Armor Template」部分,依照提供的過濾設定,在 位置建立 ma-template。完成後,請返回這裡查看進度並確認目標已達成。

注意:點選「Check my progress」按鈕前,請先儲存筆記本檔案。

點選「Check my progress」,確認目標已達成。 建立 Model Armor 範本

工作 5:使用 Model Armor 驗證使用者提示詞

在這項工作中,您將測試各種使用者提示詞,評估 Model Armor 能否根據預先定義的 Sensitive Data Protection (SDP) infoType,偵測及過濾不同類型的敏感資料。這項程序可確保 Model Armor 有效過濾內容,防範未經授權的資料暴露事件。

前往筆記本的「Validate user prompts with Model Armor」部分,然後執行各種指令,運用不同安全防護功能清理使用者提示詞。完成後,請返回這裡查看進度並確認目標已達成。

注意:每次點選「Check my progress」按鈕前,請先儲存筆記本檔案。
  1. 輸入使用者提示詞,讓 Model Armor 篩除違反負責任 AI 準則的內容。

點選「Check my progress」,確認目標已達成。 輸入使用者提示詞,篩除違反負責任 AI 準則的內容

  1. 輸入使用者提示詞,讓 Model Armor 篩除惡意 URI。

點選「Check my progress」,確認目標已達成。 輸入使用者提示詞,篩除惡意 URI

  1. 輸入使用者提示詞,讓 Model Armor 篩除違反資料遺失防護 (DLP) 規則的內容。

點選「Check my progress」,確認目標已達成。 輸入使用者提示詞,篩除違反資料遺失防護規則的內容

  1. 輸入模型回覆,讓 Model Armor 篩除違反資料遺失防護規則的內容。

點選「Check my progress」,確認目標已達成。 輸入模型回覆,篩除違反資料遺失防護規則的內容

  1. 執行「Sanitize file-based prompts」子部分的儲存格,傳送使用者提示詞檔案,交由 Model Armor 清理該檔案中指定格式的內容。

點選「Check my progress」,確認目標已達成。 清理使用者提示詞檔案

恭喜!

您已成功完成挑戰,建立 Model Armor 範本,並執行不同的使用者提示詞,針對各類 Sensitive Data Protection (SDP) infoType 過濾內容。

使用手冊上次更新日期:2026 年 5 月 18 日

實驗室上次測試日期:2026 年 4 月 22 日

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 can notify you via email when it becomes available

Great!

We can 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.