Skip to content

Commit 5b43b57

Browse files
committed
writer edits
1 parent 8b555f6 commit 5b43b57

File tree

4 files changed

+70
-45
lines changed

4 files changed

+70
-45
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ ms.author: pafarley
1414

1515
# Custom categories
1616

17-
The Azure AI Content Safety Custom Category feature lets you create and manage your own content categories for enhanced moderation and filtering. This feature enables customers to define categories specific to their needs, provide sample data, train a custom machine learning model, and use it to classify new content according to the predefined categories.
17+
The Azure AI Content Safety custom category feature lets you create and manage your own content categories for enhanced moderation and filtering. This feature enables customers to define categories specific to their needs, provide sample data, train a custom machine learning model, and use it to classify new content according to the predefined categories.
1818

1919
## Types of analysis
2020

2121
| API | Functionality |
2222
| :--------- | :------------ |
23-
| Customized categories | Create, get, and delete a customized category or list all customized categories for further annotation task |
23+
| Customized categories | Create, get, and delete a customized category or list all customized categories for further annotation tasks |
2424

2525
## How it works
2626

27-
The Azure AI Content Safety Custom Category feature provides a streamlined process for creating, training, and using custom content classification models. Here's an in-depth look at the underlying workflow:
27+
The Azure AI Content Safety custom category feature provides a streamlined process for creating, training, and using custom content classification models. Here's a look at the underlying workflow:
2828

2929
### Step 1: Definition and setup
3030

3131
When you define a custom category, you need to teach the AI what type of content you want to identify. This involves providing a clear **category name** and a detailed **definition** that encapsulates the content's characteristics.
3232

33-
Then, you collect a balanced dataset with **positive** and (optionally)**negative examples** to help the AI to learn the nuances of your category. This data should be representative of the variety of content that the model will encounter in a real-world scenario.
33+
Then, you collect a balanced dataset with **positive** and (optionally) **negative examples** to help the AI to learn the nuances of your category. This data should be representative of the variety of content that the model will encounter in a real-world scenario.
3434

3535
### Step 2: Model training
3636

@@ -44,6 +44,8 @@ After training, you need to evaluate the model to ensure it meets your accuracy
4444

4545
### Input limitations
4646

47+
See the following table for the input limitations of the service.
48+
4749
| Object | Limitation |
4850
| ---------------- | ------------ |
4951
| Supported languages | English only |
@@ -60,6 +62,11 @@ After training, you need to evaluate the model to ensure it meets your accuracy
6062
| Length of a blob url | maximum 500 characters |
6163

6264

65+
### Region availability
66+
67+
To use this API, you must create your Azure AI Content Safety resource in one of the supported regions:
68+
- East US
69+
6370

6471
## Next steps
6572

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ One way to deal with emerging content incidents is to use [Blocklists](/azure/ai
2626

2727
## How it works
2828

29-
First, you create an incident object with a description. Then you add any number of image or text samples to the incident. The service will analyze the description and samples right away: no training step is needed.
29+
First, you use the API to create an incident object with a description. Then you add any number of image or text samples to the incident. No training step is needed.
3030

31-
Then, you can include your defined incident in a regular text analysis or image analysis request. The service will return whether the submitted content is an instance of your incident. The service can still do other content moderation tasks in the same API call.
31+
Then, you can include your defined incident in a regular text analysis or image analysis request. The service will indicate whether the submitted content is an instance of your incident. The service can still do other content moderation tasks in the same API call.
3232

3333
## Limitations
3434

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

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ The custom category API lets you create your own content categories for your use
2626
## Prerequisites
2727

2828
* An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services/)
29-
* Once you have your Azure subscription, <a href="https://aka.ms/acs-create" title="Create a Content Safety resource" target="_blank">create a Content Safety resource </a> in the Azure portal to get your key and endpoint. Enter a unique name for your resource, select your subscription, and select a resource group, supported region (East US), and supported pricing tier. Then select **Create**.
29+
* Once you have your Azure subscription, <a href="https://aka.ms/acs-create" title="Create a Content Safety resource" target="_blank">create a Content Safety resource</a> in the Azure portal to get your key and endpoint. Enter a unique name for your resource, select your subscription, and select a resource group, supported region (East US), and supported pricing tier. Then select **Create**.
3030
* The resource takes a few minutes to deploy. After it finishes, Select **go to resource**. In the left pane, under **Resource Management**, select **Subscription Key and Endpoint**. Copy the endpoint and either of the key values to a temporary location for later use.
31-
* Also create an Azure blob storage container where you'll keep your training annotation file.
31+
* Also [create an Azure blob storage container](https://ms.portal.azure.com/#create/Microsoft.StorageAccount-ARM) where you'll keep your training annotation file.
3232
* One of the following installed:
3333
* [cURL](https://curl.haxx.se/) for REST API calls.
3434
* [Python 3.x](https://www.python.org/) installed
@@ -39,7 +39,7 @@ The custom category API lets you create your own content categories for your use
3939

4040
To train a custom category, you need example text data that represents the category you want to detect. Follow these steps to prepare your sample data:
4141

42-
1. Collect or write sample data.
42+
1. Collect or write your sample data:
4343
- The quality of your sample data is important for training an effective model. Aim to collect at least 50 positive samples that accurately represent the content you want to identify. These samples should be clear, varied, and directly related to the category definition.
4444
- Negative samples aren't required, but they can improve the model's ability to distinguish relevant content from irrelevant content.
4545
To improve performance, aim for 50 samples that aren't related to the positive case definition. These should be varied but still within the context of the content your model will encounter. Choose negative samples carefully to ensure they don't inadvertently overlap with the positive category.
@@ -52,7 +52,7 @@ To train a custom category, you need example text data that represents the categ
5252
{"text": "This is the 3rd sample (negative).", "isPositive": false}
5353
```
5454

55-
1. Upload the _.jsonl_ file to an Azure Storage account blob container. You can create a new [Azure Storage Account](https://ms.portal.azure.com/#create/Microsoft.StorageAccount-ARM) if you don't have one. Copy the blob URL to a temporary location for later use.
55+
1. Upload the _.jsonl_ file to an Azure Storage account blob container. Copy the blob URL to a temporary location for later use.
5656

5757
### Grant storage access
5858

@@ -70,7 +70,7 @@ To train a custom category, you need example text data that represents the categ
7070

7171
#### [cURL](#tab/curl)
7272

73-
In the commands below, replace `<your_api_key>`, `<your_endpoint>`, and other necessary parameters with your own values:
73+
In the commands below, replace `<your_api_key>`, `<your_endpoint>`, and other necessary parameters with your own values. Then enter each command in a terminal window and run it.
7474

7575
### Create new category version
7676

@@ -93,7 +93,9 @@ curl -X POST "<endpoint>/contentsafety/text/categories/<your_category_name>:buil
9393
-H "Content-Type: application/json"
9494
```
9595

96-
## Analyze text with a customized category:
96+
## Analyze text with a customized category
97+
98+
Run the following command to analyze text with your customized category. Replace `<your_category_name>` with your own value:
9799

98100
```bash
99101
curl -X POST "<endpoint>/contentsafety/text:analyzeCustomCategory?api-version=2024-02-15-preview" \
@@ -115,7 +117,7 @@ First, you need to install the required Python library:
115117
pip install requests
116118
```
117119

118-
Then, define the necessary variables with your own Azure resource details:
120+
Then, open a new Python script and define the necessary variables with your own Azure resource details:
119121

120122
```python
121123
import requests
@@ -147,15 +149,15 @@ def create_new_category_version(category_name, definition, sample_blob_url):
147149
# Replace the parameters with your own values
148150
category_name = "DrugAbuse"
149151
definition = "This category is related to Drug Abuse."
150-
sample_blob_url = "https://example.blob.core.windows.net/example-container/drugsample.jsonl"
152+
sample_blob_url = "https://<your-azure-storage-url>/example-container/drugsample.jsonl"
151153

152154
result = create_new_category_version(category_name, definition, sample_blob_url)
153155
print(result)
154156
```
155157

156158
### Start the category build process
157159

158-
You can trigger the category build process with the *category name* and *version number*.
160+
You can start the category build process with the *category name* and *version number*.
159161

160162
```python
161163
def trigger_category_build_process(category_name, version):
@@ -200,11 +202,13 @@ print(result)
200202

201203
## Other custom category operations
202204

203-
Remember to replace the placeholders with your actual values for the API key, endpoint, and specific content (category name, definition, and so on). These examples help you get started using Azure AI Content Safety to analyze your text and work with customized categories.
205+
Remember to replace the placeholders below with your actual values for the API key, endpoint, and specific content (category name, definition, and so on). These examples help you to manage the customized categories in your account.
204206

205207
#### [cURL](#tab/curl)
206208

207-
### Get a customized category or a specific version of it:
209+
### Get a customized category or a specific version of it
210+
211+
Replace the placeholders with your own values and run the following command in a terminal window:
208212

209213
```bash
210214
curl -X GET "<endpoint>/contentsafety/text/categories/<your_category_name>?api-version=2024-02-15-preview&version=1" \
@@ -214,6 +218,8 @@ curl -X GET "<endpoint>/contentsafety/text/categories/<your_category_name>?api-v
214218

215219
### List categories of their latest versions
216220

221+
Replace the placeholders with your own values and run the following command in a terminal window:
222+
217223
```bash
218224
curl -X GET "<endpoint>/contentsafety/text/categories?api-version=2024-02-15-preview" \
219225
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
@@ -222,6 +228,8 @@ curl -X GET "<endpoint>/contentsafety/text/categories?api-version=2024-02-15-pre
222228

223229
### Delete a customized category or a specific version of it
224230

231+
Replace the placeholders with your own values and run the following command in a terminal window:
232+
225233
```bash
226234
curl -X DELETE "<endpoint>/contentsafety/text/categories/<your_category_name>?api-version=2024-02-15-preview&version=1" \
227235
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
@@ -250,7 +258,9 @@ headers = {
250258
}
251259
```
252260

253-
### Get a customized category or a specific version of it:
261+
### Get a customized category or a specific version of it
262+
263+
Replace the placeholders with your own values and run the following code in your Python script:
254264

255265
```python
256266
def get_customized_category(category_name, version=None):
@@ -269,7 +279,7 @@ result = get_customized_category(category_name, version)
269279
print(result)
270280
```
271281

272-
### List categories of their latest versions:
282+
### List categories of their latest versions
273283

274284
```python
275285
def list_categories_latest_versions():
@@ -281,7 +291,9 @@ result = list_categories_latest_versions()
281291
print(result)
282292
```
283293

284-
### Delete a customized category or a specific version of it:
294+
### Delete a customized category or a specific version of it
295+
296+
Replace the placeholders with your own values and run the following code in your Python script:
285297

286298
```python
287299
def delete_customized_category(category_name, version=None):
@@ -299,8 +311,10 @@ version = 1
299311
result = delete_customized_category(category_name, version)
300312
print(result)
301313
```
302-
303314
---
304315

305316

317+
## Related content
306318

319+
* [Custom categories concepts](../concepts/custom-categories.md)
320+
* [Moderate content with Content Safety](../quickstart-text.md)

0 commit comments

Comments
 (0)