Skip to content

Commit 962a626

Browse files
committed
Merge branch 'content-safety-updates' of https://github.com/PatrickFarley/azure-docs-pr into content-safety-updates
2 parents cc62610 + f00d26e commit 962a626

File tree

7 files changed

+94
-28
lines changed

7 files changed

+94
-28
lines changed

articles/ai-services/content-safety/concepts/custom-categories.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ Then, you collect a balanced dataset with **positive** and (optionally) **negati
6161

6262
### Step 2: Model training
6363

64-
Once your dataset is ready, the Azure AI Content Safety service uses it to train a new machine learning model. During training, the AI analyzes the data and learns to distinguish between content that matches the category and content that doesn't.
64+
After you prepare your dataset and define categories, the Azure AI Content Safety service trains a new machine learning model. This model uses your definitions and uploaded dataset to perform data augmentation using a large language model. As a result, the training dataset is made larger and of higher quality. During training, the AI model analyzes the data and learns to differentiate between content that aligns with the specified category and content that does not.
6565

6666
### Step 3: Model inferencing
6767

6868
After training, you need to evaluate the model to ensure it meets your accuracy requirements. Test the model with new content that it hasn't received before. The evaluation phase helps you identify any potential adjustments you need to make deploying the model into a production environment.
6969

7070
### Step 4: Model usage
7171

72-
You use the **analyzeCustomCategory** API to analyze text content and determine whether it matches the custom category you've defined. The service will return a score indicating the likelihood that the content matches the category.
72+
You use the **analyzeCustomCategory** API to analyze text content and determine whether it matches the custom category you've defined. The service will return a Boolean indicating whether the content aligns with the specified category
7373

7474
#### [Custom categories (rapid) API](#tab/rapid)
7575

@@ -95,12 +95,11 @@ See the following table for the input limitations of the custom categories (stan
9595
| Object | Limitation |
9696
| ---------------- | ------------ |
9797
| Supported languages | English only |
98-
| Number of categories per user | 5 |
99-
| Number of versions per category | 5 |
98+
| Number of categories per user | 3 |
99+
| Number of versions per category | 3 |
100100
| Number of concurrent builds (processes) per category | 1 |
101-
| Inference operations per second | 10 |
102-
| Number of custom categories in one text analyze request | 5 |
103-
| Number of samples in a category version | minimum 50, maximum 10K (no duplicate samples allowed) |
101+
| Inference operations per second | 5 |
102+
| Number of samples in a category version | Positive samples(required):minimum 50, maximum 5K<br>In total (both negative and positive samples): 10K<br>No duplicate samples allowed. |
104103
| Sample file size | maximum 128000 bytes |
105104
| Length of a text sample | maximum 125K characters |
106105
| Length of a category definition | maximum 1000 chars |

articles/ai-services/content-safety/concepts/response-codes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ The content APIs may return the following error codes:
2424
| InternalError | Some unexpected situations on the server side have been triggered. | You may want to retry a few times after a small period and see it the issue happens again. <br/> Contact Azure Support if this issue persists. |
2525
| ServerBusy | The server side cannot process the request temporarily. | You may want to retry a few times after a small period and see it the issue happens again. <br/>Contact Azure Support if this issue persists. |
2626
| TooManyRequests | The current RPS has exceeded the quota for your current SKU. | Check the pricing table to understand the RPS quota. <br/>Contact Azure Support if you need more QPS. |
27+
28+
29+
## Azure AI Studio error messages
30+
31+
If you encounter the error **Your account does not have access to this resource, please contact your resource owner to get access**, please ensure your account is assigned the role of `Cognitive Services User` for the Content Safety resource or Azure AI Services resource you are using.
32+

articles/ai-services/content-safety/how-to/custom-categories.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ ms.date: 04/11/2024
1212
ms.author: pafarley
1313
---
1414

15-
# Use the custom category API
15+
# Use the custom categories (standard) API
1616

1717

18-
The custom category API lets you create your own content categories for your use case and train Azure AI Content Safety to detect them in new content.
18+
The custom categories (standard) API lets you create your own content categories for your use case and train Azure AI Content Safety to detect them in new content.
1919

2020
> [!IMPORTANT]
2121
> This feature is only available in certain Azure regions. See [Region availability](../overview.md#region-availability).
@@ -86,8 +86,20 @@ curl -X PUT "<your_endpoint>/contentsafety/text/categories/<your_category_name>?
8686

8787
### Start the category build process:
8888

89+
After you receive the response, store the operation ID (referred to as `id`) in a temporary. You need this ID to retrieve the build status using the **Get status** API.
90+
8991
```bash
90-
curl -X POST "<your_endpoint>/contentsafety/text/categories/<your_category_name>:build?api-version=2024-02-15-preview" \
92+
curl -X POST "<your_endpoint>/contentsafety/text/categories/<your_category_name>:build?api-version=2024-02-15-preview&version={version}" \
93+
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
94+
-H "Content-Type: application/json"
95+
```
96+
97+
### Get the category build status:
98+
99+
To retrieve the status, utilize the `id` obtained from the previous API response and place it in the path of the API below.
100+
101+
```bash
102+
curl -X GET "<your_endpoint>/contentsafety/text/categories/operations/<id>?api-version=2024-02-15-preview" \
91103
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
92104
-H "Content-Type: application/json"
93105
```
@@ -172,6 +184,22 @@ result = trigger_category_build_process(category_name, version)
172184
print(result)
173185
```
174186

187+
### Get the category build status:
188+
189+
To retrieve the status, utilize the `id` obtained from the previous response.
190+
191+
```python
192+
def get_build_status(id):
193+
url = f"{ENDPOINT}/contentsafety/text/categories/operations/{id}?api-version=2024-02-15-preview"
194+
response = requests.get(url, headers=headers)
195+
return response.status_code
196+
197+
# Replace the parameter with your own value
198+
id = "your-operation-id"
199+
200+
result = get_build_status(id)
201+
print(result)
202+
```
175203

176204
## Analyze text with a customized category
177205

articles/ai-services/content-safety/includes/storage-account-access.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Next, you need to give your Content Safety resource access to read from the Azur
1616

1717
:::image type="content" source="/azure/ai-services/content-safety/media/role-assignment.png" alt-text="Screenshot of Azure portal enabling managed identity.":::
1818

19-
1. Assign the role of **Storage Blob Data Contributor/Owner/Reader** to the Managed identity. Any roles highlighted below should work.
19+
1. Assign the role of **Storage Blob Data Contributor/Owner** to the Managed identity. Any roles highlighted below should work.
2020

2121
:::image type="content" source="/azure/ai-services/content-safety/media/add-role-assignment.png" alt-text="Screenshot of the Add role assignment screen in Azure portal.":::
2222

2323
:::image type="content" source="/azure/ai-services/content-safety/media/assigned-roles.png" alt-text="Screenshot of assigned roles in the Azure portal.":::
2424

25-
:::image type="content" source="/azure/ai-services/content-safety/media/managed-identity-role.png" alt-text="Screenshot of the managed identity role.":::
25+
:::image type="content" source="/azure/ai-services/content-safety/media/managed-identity-role.png" alt-text="Screenshot of the managed identity role.":::

articles/ai-services/content-safety/overview.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,16 @@ See the following list for the input requirements for each feature.
124124
- **Protected material detection (preview)**:
125125
- Default maximum length: 1K characters.
126126
- Default minimum length: 110 characters (for scanning LLM completions, not user prompts).
127+
- **Custom categories (standard)**:
128+
- Maximum inference input length: 1K characters.
127129

128130

129131
### Language support
130132

131133
Content Safety models have been specifically trained and tested in the following languages: English, German, Japanese, Spanish, French, Italian, Portuguese, and Chinese. However, the service can work in many other languages, but the quality might vary. In all cases, you should do your own testing to ensure that it works for your application.
132134

135+
Custom Categories currently only works well in English. You can try to use other languages with your own dataset, but the quality might vary across languages.
136+
133137
For more information, see [Language support](/azure/ai-services/content-safety/language-support).
134138

135139
### Region availability
@@ -139,20 +143,20 @@ To use the Content Safety APIs, you must create your Azure AI Content Safety res
139143
|Region | Moderation APIs | Prompt Shields<br>(preview) | Protected material<br>detection (preview) | Groundedness<br>detection (preview) | Custom categories<br>(rapid) (preview) | Custom categories<br>(standard) | Blocklists |
140144
|---|---|---|---|---|---|---|--|
141145
| East US ||||||||
142-
| East US 2 || | || | ||
146+
| East US 2 || | || | ||
143147
| West US | | | | || | |
144-
| West US 2 || | | | | ||
148+
| West US 2 || | | | | ||
145149
| Central US || | | | | ||
146-
| North Central US || | | | | ||
147-
| South Central US || | | | | ||
148-
| Canada East || | | | | ||
149-
| Switzerland North || | | | | ||
150+
| North Central US || | | | | ||
151+
| South Central US || | | | | ||
152+
| Canada East || | | | | ||
153+
| Switzerland North || | | || ||
150154
| Sweden Central || | ||| ||
151-
| UK South || | | | | ||
152-
| France Central || | | | | ||
153-
| West Europe |||| | | ||
154-
| Japan East || | | | | ||
155-
| Australia East||| | | | ||
155+
| UK South || | | | | ||
156+
| France Central || | | | | ||
157+
| West Europe |||| | | ||
158+
| Japan East || | | | | ||
159+
| Australia East||| | | | ||
156160

157161
Feel free to [contact us](mailto:[email protected]) if you need other regions for your business.
158162

articles/ai-services/content-safety/quickstart-custom-categories.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.date: 07/03/2024
1111
ms.author: pafarley
1212
---
1313

14-
# Quickstart: Custom categories
14+
# Quickstart: Custom categories (standard mode)
1515

1616
Follow this guide to use Azure AI Content Safety Custom category REST API to create your own content categories for your use case and train Azure AI Content Safety to detect them in new text content.
1717

@@ -69,13 +69,22 @@ curl -X PUT "<your_endpoint>/contentsafety/text/categories/survival-advice?api-v
6969

7070
### Start the category build process:
7171

72-
Replace `<your_api_key>` and `<your_endpoint>` with your own values. Allow enough time for model training: the end-to-end execution of custom category training can take from around five hours to ten hours. Plan your moderation pipeline accordingly.
72+
Replace `<your_api_key>` and `<your_endpoint>` with your own values. Allow enough time for model training: the end-to-end execution of custom category training can take from around five hours to ten hours. Plan your moderation pipeline accordingly. After you receive the response, store the operation ID (referred to as `id`) in a temporary location. This ID will be necessary for retrieving the build status using the **Get status** API in the next section.
7373

7474
```bash
7575
curl -X POST "<your_endpoint>/contentsafety/text/categories/survival-advice:build?api-version=2024-02-15-preview" \
7676
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
7777
-H "Content-Type: application/json"
7878
```
79+
### Get the category build status:
80+
81+
To retrieve the status, utilize the `id` obtained from the previous API response and place it in the path of the API below.
82+
83+
```bash
84+
curl -X GET "<your_endpoint>/contentsafety/text/categories/operations/<id>?api-version=2024-02-15-preview" \
85+
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
86+
-H "Content-Type: application/json"
87+
```
7988

8089
## Analyze text with a customized category
8190

@@ -141,7 +150,7 @@ print(result)
141150

142151
### Start the category build process
143152

144-
You can start the category build process with the *category name* and *version number*. Allow enough time for model training: the end-to-end execution of custom category training can take from around five hours to ten hours. Plan your moderation pipeline accordingly.
153+
You can start the category build process with the *category name* and *version number*. Allow enough time for model training: the end-to-end execution of custom category training can take from around five hours to ten hours. Plan your moderation pipeline accordingly. After receiving the response, ensure that you store the operation ID (referred to as `id`) somewhere like your notebook. This ID will be necessary for retrieving the build status using the ‘get_build_status’ function in the next section.
145154

146155
```python
147156
def trigger_category_build_process(category_name, version):
@@ -157,6 +166,23 @@ result = trigger_category_build_process(category_name, version)
157166
print(result)
158167
```
159168

169+
### Get the category build status:
170+
171+
To retrieve the status, utilize the `id` obtained from the previous response.
172+
173+
```python
174+
def get_build_status(id):
175+
url = f"{ENDPOINT}/contentsafety/text/categories/operations/{id}?api-version=2024-02-15-preview"
176+
response = requests.get(url, headers=headers)
177+
return response.status_code
178+
179+
# Replace the parameter with your own value
180+
id = "your-operation-id"
181+
182+
result = get_build_status(id)
183+
print(result)
184+
```
185+
160186

161187
## Analyze text with a customized category
162188

articles/ai-services/content-safety/whats-new.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ ms.author: pafarley
1616

1717
Learn what's new in the service. These items might be release notes, videos, blog posts, and other types of information. Bookmark this page to stay up to date with new features, enhancements, fixes, and documentation updates.
1818

19-
## May 2024
19+
## July 2024
2020

21-
### Custom category support in Content Safety moderation APIs
21+
### Custom categories (standard) API
2222

2323
The custom categories API lets you create and train your own custom content categories and scan text for matches. See [Custom categories](./concepts/custom-categories.md) to learn more.
2424

25+
## May 2024
26+
27+
2528
### Custom categories (rapid) API
2629

2730
The custom categories (rapid) API lets you quickly define emerging harmful content patterns and scan text and images for matches. See [Custom categories](./concepts/custom-categories.md) to learn more.

0 commit comments

Comments
 (0)