# AWS Guardrails

AWS Guardrails 功能有

* 內容篩選（防腥羶色、暴力等）
* 防止離題
* 文字獄
* 機敏資料去除
* 幻覺防止

## <mark style="color:blue;">操作步驟說明</mark>

### Step 1: 設定 Config（名稱、描述、若被封鎖了回傳什麼訊息）

<figure><img src="/files/zlLewtpubtEeXcuGiilT" alt=""><figcaption></figcaption></figure>

他案的設定

<figure><img src="/files/xoNIgHUd70Nd0aHeP7WJ" alt=""><figcaption></figcaption></figure>

### Step 2: 設定內容篩選（User Input, Assistant Response）

<figure><img src="/files/hVh2MAQ2ljyRseRvYTh9" alt=""><figcaption></figcaption></figure>

可以指定危害層級，甚至包含 Image 的傳入

<figure><img src="/files/7gOWhDKCxI8Ab9SaViZ7" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/DrcTnIx8EV9bfODZRoIS" alt=""><figcaption></figcaption></figure>

他案的設定

<figure><img src="/files/K91AAiOLSceuzvyADhYL" alt=""><figcaption></figcaption></figure>

### Step 3: 拒絕主題，防止離題

<figure><img src="/files/xIGYoffIeDjIrcsGtuae" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/AM9dxt9rYtkyC0h2pGDR" alt=""><figcaption></figcaption></figure>

你可以透過新增描述、定義、以及提供範例來防止離題的產生

他案的設定

<figure><img src="/files/gKEA4OdhS0Gmg0VUr1ma" alt=""><figcaption></figcaption></figure>

### Step 4: 大興文字獄（禁止罵髒話或是提到 XXX）

例如：不想要模型提到佛地魔，就新增單詞，可支持多個單詞一次傳入（csv, txt, ctrl + c）。

<figure><img src="/files/aImbLahesoGO9DLsY6GC" alt=""><figcaption></figcaption></figure>

他案的設定

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcb-3vRt-Q0UkPhKEbzpygdBa4ALAaKUsXTil3m5PS3PHLQcR_3jpXXkn6T6-YoaONvnCc0H1RDrhIj-aq0WzCunLW99auRRCu36bNOEBnYqrsgK6Up5uehpKqqreKzXPWxSU0x?key=z1hebxFSyJWvHprMJ3hgOr8k)

### ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXczJwuyAQ4-FbNaBymncor9v3HA9mUURj_ghPn8N1FyNUkNvr_hW9WXw1C9ZYX3gcR5s0uYS_IybmgQ_1pSfnHNf6GTiJCu8H7apoiIm2Bczjfe1csDR3WVDpRuYWRCPS22K2OdQQ?key=z1hebxFSyJWvHprMJ3hgOr8k)

### Step 5: 機敏資料(PII)阻擋、正規表達替換

已經預設幾個模式，如：信用卡、車號、身分證字號等等

<figure><img src="/files/9hpl6kRQ26RZIUIUzToI" alt=""><figcaption></figcaption></figure>

他案的設定

<figure><img src="/files/H0KL3nAckHK9XxnGQlnU" alt=""><figcaption></figcaption></figure>

正規表達替換，可以在 AI 助理的回覆利用想要的正規表達式替換不想要的結構。

### Step 6: 防止幻覺，以及以相關性阻擋回覆的 threshold

<figure><img src="/files/6QdEd7BuKsETq1v5MGhB" alt=""><figcaption></figcaption></figure>

他案的設定

<figure><img src="/files/HoJezLT2ifh3IAslA9vY" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.maiagent.ai/tech/ai-agents/aws-guardrails.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
