Sündmused
17. märts, 21 - 21. märts, 10
Liituge sarjaga, et luua muude arendajate ja ekspertidega skaleeritavad tehisintellektilahendused, mis põhinevad reaalajas kasutusjuhtumitel.
Registreeruge koheSeda brauserit enam ei toetata.
Uusimate funktsioonide, turbevärskenduste ja tehnilise toe kasutamiseks võtke kasutusele Microsoft Edge.
The configurable content filters available in Azure OpenAI are sufficient for most content moderation needs. However, you might need to filter terms specific to your use case. For this, you can use custom blocklists.
You can create blocklists with the Azure OpenAI API. The following steps help you get started.
First, you need to get a token for accessing the APIs for creating, editing and deleting blocklists. You can get this token using the following Azure CLI command:
az account get-access-token
Copy the cURL command below to a text editor and make the following changes:
0-9, A-Z, a-z, - . _ ~
.curl --location --request PUT 'https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}?api-version=2024-04-01-preview' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"properties": {
"description": "This is a prompt blocklist"
}
}'
The response code should be 201
(created a new list) or 200
(updated an existing list).
If you haven't yet created a content filter, you can do so in Azure AI Foundry. See Content filtering.
To apply a completion blocklist to a content filter, use the following cURL command:
"completionBlocklists"
title to "promptBlocklists"
if you want the blocklist to apply to user prompts instead of AI model completions."raiBlocklistName"
in the body with a custom name for your list. Allowed characters: 0-9, A-Z, a-z, - . _ ~
.curl --location --request PUT 'https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName}?api-version=2024-04-01-preview' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"properties": {
"basePolicyName": "Microsoft.Default",
"completionBlocklists": [{
"blocklistName": "raiBlocklistName",
"blocking": true
}],
"contentFilters": [ ]
}
}'
Märkus
There is a maximum limit of 10,000 terms allowed in one list.
Copy the cURL command below to a text editor and make the following changes:
0-9, A-Z, a-z, - . _ ~
."blocking pattern"
field with the item you'd like to add to your blocklist. The maximum length of a blockItem is 1000 characters. Also specify whether the pattern is regex or exact match.curl --location --request PUT 'https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName}?api-version=2024-04-01-preview' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"properties": {
"pattern": "blocking pattern",
"isRegex": false
}
}'
Märkus
It can take around 5 minutes for a new term to be added to the blocklist. Please test after 5 minutes.
The response code should be 200
.
{
"name": "raiBlocklistItemName",
"id": "/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiBlocklists/raiBlocklistName/raiBlocklistItems/raiBlocklistItemName",
"properties": {
"pattern": "blocking pattern",
"isRegex": false
}
}
Now you can test out your deployment that has the blocklist. For instructions on calling the Azure OpenAI endpoints, visit the Quickstart.
In the below example, a GPT-35-Turbo deployment with a blocklist is blocking the prompt. The response returns a 400
error.
{
"error": {
"message": "The response was filtered due to the prompt triggering Azure OpenAI’s content management policy. Please modify your prompt and retry. To learn more about our content filtering policies please read our documentation: https://go.microsoft.com/fwlink/?linkid=2198766",
"type": null,
"param": "prompt",
"code": "content_filter",
"status": 400,
"innererror": {
"code": "ResponsibleAIPolicyViolation",
"content_filter_result": {
"custom_blocklists": [
{
"filtered": true,
"id": "raiBlocklistName"
}
],
"hate": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
}
}
If the completion itself is blocked, the response returns 200
, as the completion only cuts off when the blocklist content is matched. The annotations show that a blocklist item was matched.
{
"id": "chatcmpl-85NkyY0AkeBMunOjyxivQSiTaxGAl",
"object": "chat.completion",
"created": 1696293652,
"model": "gpt-35-turbo",
"prompt_filter_results": [
{
"prompt_index": 0,
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
],
"choices": [
{
"index": 0,
"finish_reason": "content_filter",
"message": {
"role": "assistant"
},
"content_filter_results": {
"custom_blocklists": [
{
"filtered": true,
"id": "myBlocklistName"
}
],
"hate": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
],
"usage": {
"completion_tokens": 75,
"prompt_tokens": 27,
"total_tokens": 102
}
}
Learn more about Responsible AI practices for Azure OpenAI: Overview of Responsible AI practices for Azure OpenAI models.
Read more about content filtering categories and severity levels with Azure OpenAI Service.
Learn more about red teaming from our: Introduction to red teaming large language models (LLMs) article.
Sündmused
17. märts, 21 - 21. märts, 10
Liituge sarjaga, et luua muude arendajate ja ekspertidega skaleeritavad tehisintellektilahendused, mis põhinevad reaalajas kasutusjuhtumitel.
Registreeruge koheKoolitus
Moodul
Implement generative AI guardrails with Azure AI Content Safety - Training
Learn how to implement generative AI guardrails with Azure AI Content Safety.
Sertimine
Microsoft Certified: Azure AI Engineer Associate - Certifications
Design and implement an Azure AI solution using Azure AI services, Azure AI Search, and Azure Open AI.
Dokumentatsioon
How to use Risks & Safety monitoring in Azure AI Foundry - Azure OpenAI Service
Learn how to check statistics and insights from your Azure OpenAI content filtering activity.
Use content filters (preview) with Azure AI Foundry - Azure OpenAI
Learn how to use and configure the content filters that come with Azure AI Foundry, including getting approval for gated modifications.
Azure OpenAI Service content filtering - Azure OpenAI
Learn about the content filtering capabilities of Azure OpenAI in Azure AI services.