---
# System prepended metadata

title: Amazon Bedrock Workshop for FSI (6. Guardrails)

---

# Amazon Bedrock Workshop for FSI (6. Guardrails)

## 目錄
- [實驗環境準備](https://hackmd.io/@6g-86IJuRWiQ17aprBneGQ/HkjF3MBcge)
- [1. Amazon Bedrock Foundation Model 使用概覽](https://hackmd.io/@6g-86IJuRWiQ17aprBneGQ/B1PFXXHcex)
- [2. Amazon Bedrock Knowledge Bases (Vector Store) for RAG](https://hackmd.io/@6g-86IJuRWiQ17aprBneGQ/ByyeB7r5eg)
- [3. Amazon Bedrock Knowledge Bases (Vector Store) for GraphRag](https://hackmd.io/@6g-86IJuRWiQ17aprBneGQ/HJmVw7S9gl)
- [4. Amazon Bedrock Agents](https://hackmd.io/@6g-86IJuRWiQ17aprBneGQ/HJe4D7Bcxl)
- [5. Amazon Bedrock Flows](https://hackmd.io/@6g-86IJuRWiQ17aprBneGQ/B1eEw7H5gl)
- [6. Amazon Bedrock Guardrails](#6-Amazon-Bedrock-Guardrails)
    - [6-1. 建立 Guardrail](#6-1-建立-Guardrail)
    - [6-2. 測試 Guardrail](#6-2-測試-Guardrail)
- [其他相關參考資料](https://hackmd.io/@6g-86IJuRWiQ17aprBneGQ/B1Dw5XBclg)

---

## 6. Amazon Bedrock Guardrails

### 6-1. 建立 Guardrail
1. 點擊 **防護機制 (Guardrail)**
![image](https://hackmd.io/_uploads/HkPheOUqxg.png =100x)

2. 點擊 **建立防護機制**
![圖片](https://hackmd.io/_uploads/HJR7KX_bJl.png)

3. 按照以下步驟並完成相關設定，完成後點擊 **建立防護機制**
    - *步驟 (1/8)*：提供防護機制詳細資訊
        - **名稱：** `chatbot-restriction`
        - **Enable cross-Region inference for your guardrail:** `checked`
            ![image](https://hackmd.io/_uploads/BynbGdU5xx.png =500x)
            
    - *步驟 (2/8)*：設定內容篩選條件
        - 啟用 `危害性類別篩選條件`
            ![image](https://hackmd.io/_uploads/SyaFb_I9lx.png =500x)
        - 啟用 `提示攻擊篩選條件`
            ![image](https://hackmd.io/_uploads/HkN2Z_Uqge.png =500x)
        - **Content Filter**: `Standard`
            ![image](https://hackmd.io/_uploads/SJWDMOI5lg.png =500x)
            
    - *步驟 (3/8)*：新增拒絕的主題
        - **名稱：** `investment-advice`
        - **定義：** `投資建議`
            ![image](https://hackmd.io/_uploads/ryhBm_Lqlx.png =400x)
        - **Denied topics tier**: `Standard`
            ![image](https://hackmd.io/_uploads/S1zKm_85lx.png =500x)
            
    - *步驟 (4/8)*：新增單詞篩選條件
        - 啟用 `篩選粗俗語言`
            ![image](https://hackmd.io/_uploads/HyfT7O8qxe.png =500x)
        - **新增自訂單詞或短語：** `你媽`
            ![image](https://hackmd.io/_uploads/r1ClEOL5ll.png =500x)
            
    - *步驟 (5/8)*：新增敏感資訊篩選條件
        - 新增 PII 類型：
            - **名稱 (Name)：** 防護機制行為 `遮罩 (Mask)`
                ![image](https://hackmd.io/_uploads/SJqINdU5gg.png =300x)
            - **IPv4 位址：** 防護機制行為 `區塊 (Block)`
                ![image](https://hackmd.io/_uploads/HyXFNO8cee.png =300x)
                
    - *步驟 (6/8)*：新增內容關聯查詢依據檢查
        - 啟用 `依據檢查`
            ![image](https://hackmd.io/_uploads/r17aEuL9xx.png =600x)
        - 啟用 `相關性檢查`
            ![image](https://hackmd.io/_uploads/SycREOUcxx.png =600x)

    - *步驟 (7/8)*：新增自動推理檢查
        - 略過
            
    - *步驟 (8/8)*：檢閱和建立
        - 點擊 `建立防護機制`

[**[ ⤴️ 回到目錄]**](#目錄)

---

### 6-2. 測試 Guardrail
1. 可於右方測試框進行 Guardrail 測試
![圖片](https://hackmd.io/_uploads/H1O0oX_Zkx.png)

:::spoiler **回應結果示範**
![圖片](https://hackmd.io/_uploads/Sys-2Q_Wkx.png)
![圖片](https://hackmd.io/_uploads/BkpyDKvn1x.png)
![圖片](https://hackmd.io/_uploads/BkteIjD2yl.png)
:::

[**[ ⤴️ 回到目錄]**](#目錄)

---