You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/content-safety/quickstart-groundedness.md
+49-34Lines changed: 49 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,39 +17,16 @@ Follow this guide to use Azure AI Content Safety Groundedness detection to check
17
17
18
18
## Prerequisites
19
19
20
-
21
20
* An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services/)
22
21
* Once you have your Azure subscription, <ahref="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 US2, West US, Sweden Central), and supported pricing tier. Then select **Create**.
23
22
* The resource takes a few minutes to deploy. After it does, go to the new resource. In the left pane, under **Resource Management**, select **API Keys and Endpoints**. Copy one of the subscription key values and endpoint to a temporary location for later use.
23
+
(Optional) If you want to use the _reasoning_ feature, create an Azure OpenAI Service resource with a GPT model deployed.
24
24
*[cURL](https://curl.haxx.se/) or [Python](https://www.python.org/downloads/) installed.
25
25
26
-
## Check groundedness with reasinging
27
-
28
-
The Groundedness detection API provides the option to include _reasoning_ in the API response. In your request to the Groundedness detection API, set the `"Reasoning"` body parameter to `true`, and provide the other needed parameters:
29
-
30
-
31
-
### Enable reasoning with your own GPT deployment
32
-
33
-
If you want to use your Azure OpenAI resource to enable the reasoning feature, use Managed Identity to allow your Content Safety resource to access the Azure OpenAI resource first:
34
-
35
-
1. Enable Managed Identity for Azure AI Content Safety.
36
-
37
-
Navigate to your Azure AI Content Safety instance in the Azure portal. Find the **Identity** section under the **Settings** category. Enable the system-assigned managed identity. This action grants your Azure AI Content Safety instance an identity that can be recognized and used within Azure for accessing other resources.
38
-
39
-
:::image type="content" source="media/content-safety-identity.png" alt-text="Screenshot of a Content Safety identity resource in the Azure portal." lightbox="media/content-safety-identity.png":::
40
26
41
-
2. Assign Role to Managed Identity.
27
+
## Check groundedness without reasoning
42
28
43
-
Navigate to your Azure OpenAI instance, select **Add role assignment** to start the process of assigning an Azure OpenAI role to the Azure AI Content Safety identity.
44
-
45
-
image type="content" source="media/add-role-assignment.png" alt-text="Screenshot of adding role assignment in Azure portal.":::
46
-
47
-
Choose the **User** or **Contributor** role.
48
-
49
-
:::image type="content" source="media/assigned-roles-simple.png" alt-text="Screenshot of the Azure portal with the Contributor and User roles displayed in a list." lightbox="media/assigned-roles-simple.png":::
50
-
51
-
52
-
## Detect groundedness without Reasoning
29
+
The Groundedness detection classifies the ungroundedness of the submitted content as `true` or `false` and provides a confidence score.
53
30
54
31
#### [cURL](#tab/curl)
55
32
@@ -204,9 +181,34 @@ The JSON objects in the output are defined here:
204
181
| - `length > utf16`| The length of the ungrounded text in UTF-16 encoding. | Integer |
205
182
| - `length > codePoint`| The length of the ungrounded text in terms of Unicode code points. |Integer |
206
183
207
-
## Making a request with reasoning using the default resource
208
184
209
-
The Groundedness detection API provides the option to include _reasoning_ in the API response. In your request to the Groundedness detection API, set the `"Reasoning"` body parameter to `true`, and provide the other needed parameters:
185
+
## Check groundedness with reasoning
186
+
187
+
The Groundedness detection API provides the option to include _reasoning_ in the API response. With reasoning enabled, the response includes a `"reasoning"` field that details specific instances and explanations for any detected ungroundedness. Be careful: using reasoning increases the processing time and incurs extra fees.
188
+
189
+
### Bring your own GPT deployment
190
+
191
+
In order to use your Azure OpenAI resource to enable the reasoning feature, use Managed Identity to allow your Content Safety resource to access the Azure OpenAI resource:
192
+
193
+
1. Enable Managed Identity for Azure AI Content Safety.
194
+
195
+
Navigate to your Azure AI Content Safety instance in the Azure portal. Find the **Identity** section under the **Settings** category. Enable the system-assigned managed identity. This action grants your Azure AI Content Safety instance an identity that can be recognized and used within Azure for accessing other resources.
196
+
197
+
:::image type="content" source="media/content-safety-identity.png" alt-text="Screenshot of a Content Safety identity resource in the Azure portal." lightbox="media/content-safety-identity.png":::
198
+
199
+
1. Assign Role to Managed Identity.
200
+
201
+
Navigate to your Azure OpenAI instance, select **Add role assignment** to start the process of assigning an Azure OpenAI role to the Azure AI Content Safety identity.
202
+
203
+
:::image type="content" source="media/add-role-assignment.png" alt-text="Screenshot of adding role assignment in Azure portal.":::
204
+
205
+
Choose the **User** or **Contributor** role.
206
+
207
+
:::image type="content" source="media/assigned-roles-simple.png" alt-text="Screenshot of the Azure portal with the Contributor and User roles displayed in a list." lightbox="media/assigned-roles-simple.png":::
208
+
209
+
### Make the API request
210
+
211
+
In your request to the Groundedness detection API, set the `"Reasoning"` body parameter to `true`, and provide the other needed parameters:
210
212
211
213
```json
212
214
{
@@ -219,8 +221,14 @@ The Groundedness detection API provides the option to include _reasoning_ in the
219
221
}
220
222
```
221
223
224
+
#### [cURL](#tab/curl)
225
+
226
+
This section walks through a sample request with cURL. Paste the command below into a text editor, and make the following changes.
227
+
228
+
1. Replace `<endpoint>` with the endpoint URL associated with your resource.
229
+
1. Replace `<your_subscription_key>` with one of the keys for your resource.
230
+
1. Optionally, replace the `"query"` or `"text"` fields in the body with your own text you'd like to analyze.
222
231
223
-
the response includes a `"reasoning"` field that details specific instances and explanations for any detected ungroundedness. If you opt to use reasoning, you must provide your own Azure OpenAI resources. Be careful: using reasoning increases the processing time and incurs extra fees. If you choose not to use reasoning, the API only classifies the ungroundedness of the submitted content as `true` or `false` and provides a confidence score.
224
232
225
233
```shell
226
234
curl --location --request POST '<endpoint>/contentsafety/text:detectGroundedness?api-version=2024-02-15-preview' \
@@ -239,8 +247,8 @@ curl --location --request POST '<endpoint>/contentsafety/text:detectGroundedness
0 commit comments