Skip to content

Commit f00d26e

Browse files
Merge pull request #61 from jr-MS/content-safety-louise-update
Custom categories update after dev review
2 parents c2d56b6 + 2f466b6 commit f00d26e

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

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

Lines changed: 2 additions & 2 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

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ 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

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)