Azure OpenAI のコンテンツ フィルタリング システムは、システム入力、ユーザー入力、AI アシスタントの出力など、プロンプトのさまざまな要素を区別できる場合にパフォーマンスが向上します。 検出機能を強化するには、次の推奨される方法に従ってプロンプトを書式設定する必要があります。
Chat Completions API の既定の動作
Chat Completion API は定義によって構成されます。 入力はメッセージの一覧で構成され、それぞれにロールが割り当てられます。
安全システムにより、この構造化形式が解析され、次の動作が適用されます。
- 最新の "ユーザー" コンテンツでは、RAI リスクの次のカテゴリが検出されます。
- 憎しみ
- 性的
- 暴力
- 自傷行為
- プロンプト シールド (省略可能)
メッセージ配列の例を次に示します。
{"role": "system", "content": "Provide some context and/or instructions to the model."},
{"role": "user", "content": "Example question goes here."},
{"role": "assistant", "content": "Example answer goes here."},
{"role": "user", "content": "First question/message for the model to actually respond to."}
プロンプトにドキュメントを埋め込む
Azure OpenAI では、最後のユーザー コンテンツの検出に加えて、 Prompt Shields – Indirect Prompt Attack Detection を使用したコンテキスト ドキュメント内の特定のリスクの検出もサポートされています。 次のドキュメント区切り記号を使用して、ドキュメント (取得した Web サイト、電子メールなど) である入力の部分を識別する必要があります。
\"\"\" <documents> *insert your document content here* </documents> \"\"\"
これを行うと、タグ付けされたドキュメントで次のオプションを検出できます。
- 間接攻撃 (省略可能)
チャット完了メッセージ配列の例を次に示します。
{"role": "system", "content": "Provide some context and/or instructions to the model.},
{"role": "user", "content": "First question/message for the model to actually respond to, including document context. \"\"\" <documents>\n*insert your document content here*\n</documents> \"\"\"""}
JSON エスケープ
検出のために未検証のドキュメントにタグを付ける場合は、Azure OpenAI 安全システムによる解析を成功させるために、ドキュメント コンテンツを JSON エスケープにする必要があります。
たとえば、次のメールの本文をご覧ください。
Hello Josè,
I hope this email finds you well today.
JSON エスケープでは、次のように読み取ります。
Hello Jos\u00E9,\nI hope this email finds you well today.
チャット完了コンテキストでエスケープされたテキストは次のように表示されます。
{"role": "system", "content": "Provide some context and/or instructions to the model, including document context. \"\"\" <documents>\n Hello Jos\\u00E9,\\nI hope this email finds you well today. \n</documents> \"\"\""},
{"role": "user", "content": "First question/message for the model to actually respond to."}