Skip to content

Commit 495db0d

Browse files
committed
Merge branch 'main' of github.com:MicrosoftDocs/azure-ai-docs-pr into sdg-replace-llmops
2 parents 4837955 + 9e9cd99 commit 495db0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+784
-104
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: "Mitigate false results in Azure AI Content Safety"
3+
titleSuffix: Azure AI services
4+
description: Learn techniques to improve the performance of Azure AI Content Safety models by handling false positives and false negatives.
5+
#services: cognitive-services
6+
author: PatrickFarley
7+
manager: nitinme
8+
ms.service: azure-ai-content-safety
9+
ms.topic: how-to
10+
ms.date: 09/18/2024
11+
ms.author: pafarley
12+
#customer intent: As a user, I want to improve the performance of Azure AI Content Safety so that I can ensure accurate content moderation.
13+
---
14+
15+
# Mitigate false results in Azure AI Content Safety
16+
17+
This guide provides a step-by-step process for handling false positives and false negatives from Azure AI Content Safety models.
18+
19+
False positives are when the system incorrectly flags non-harmful content as harmful; false negatives are when harmful content is not flagged as harmful. Address these instances to ensure the integrity and reliability of your content moderation process, including responsible generative AI deployment.
20+
21+
## Prerequisites
22+
23+
* An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services/)
24+
* 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 (see [Region availability](/azure/ai-services/content-safety/overview#region-availability)), and supported pricing tier. Then select **Create**.
25+
26+
## Review and verification
27+
28+
Conduct an initial assessment to confirm that the flagged content is really a false positive or false negative. This can involve:
29+
- Checking the context of the flagged content.
30+
- Comparing the flagged content against the content safety risk categories and severity definitions:
31+
- If you're using content safety in Azure OpenAI, see the [Azure OpenAI content filtering doc](/azure/ai-services/openai/concepts/content-filter).
32+
- If you're using the Azure AI Content Safety standalone API, see the [Harm categories doc](/azure/ai-services/content-safety/concepts/harm-categories?tabs=warning) or the [Prompt Shields doc](/azure/ai-services/content-safety/concepts/jailbreak-detection), depending on which API you're using.
33+
34+
## Customize your severity settings
35+
36+
If your assessment confirms that you found a false positive or false negative, you can try customizing your severity settings to mitigate the issue. The settings depend on which platform you're using.
37+
38+
#### [Content Safety standalone API](#tab/standalone-api)
39+
40+
If you're using the Azure AI Content Safety standalone API directly, try experimenting by setting the severity threshold at different levels for [harm categories](/azure/ai-services/content-safety/concepts/harm-categories?tabs=definitions) based on API output. Alternatively, if you prefer the no-code approach, you can try out those settings in [Content Safety Studio](https://contentsafety.cognitive.azure.com/) or Azure AI Studio’s [Content Safety page](https://ai.azure.com/explore/contentsafety). Instructions can be found [here](/azure/ai-studio/quickstarts/content-safety?tabs=moderate-text-content).
41+
42+
In addition to adjusting the severity levels for false negatives, you can also use blocklists. More information on using blocklists for text moderation can be found in [Use blocklists for text moderation](/azure/ai-services/content-safety/how-to/use-blocklist?tabs=windows%2Crest).
43+
44+
45+
#### [Azure OpenAI](#tab/azure-openai-studio)
46+
47+
Read the [Configurability](/en-us/azure/ai-services/openai/concepts/content-filter?tabs=warning%2Cuser-prompt%2Cpython-new#configurability-preview) documentation, as some content filtering configurations may require approval through the process mentioned there.
48+
49+
Follow the steps in the documentation to update configurations to handle false positives or negatives: [How to use content filters (preview) with Azure OpenAI Service](/azure/ai-services/openai/how-to/content-filters).
50+
51+
In addition to adjusting the severity levels for false negatives, you can also use blocklists. Detailed instruction can be found in [How to use blocklists with Azure OpenAI Service](/azure/ai-services/openai/how-to/use-blocklists).
52+
53+
#### [Azure AI Studio](#tab/azure-ai-studio)
54+
55+
Read the [Configurability](/azure/ai-studio/concepts/content-filtering#configurability-preview) documentation, as some content filtering configurations may require approval through the process mentioned there.
56+
57+
Follow the steps in the documentation to update configurations to handle false positives or negatives: [Azure AI Studio content filtering](/azure/ai-studio/concepts/content-filtering#create-a-content-filter).
58+
59+
In addition to adjusting the severity levels for false negatives, you can also use blocklists. Detailed instruction can be found in [Azure AI Studio content filtering](/azure/ai-studio/concepts/content-filtering#use-a-blocklist-as-a-filter).
60+
61+
---
62+
63+
## Create a custom category based on your own RAI policy
64+
65+
Sometimes you might need to create a custom category to ensure the filtering aligns with your specific Responsible AI policy, as prebuilt categories or content filtering may not be enough.
66+
67+
Refer to the [Custom categories documentation](/azure/ai-services/content-safety/concepts/custom-categories) to build your own categories with the Azure AI Content Safety API.
68+
69+
## Document issues and send feedback to Azure
70+
71+
If, after you’ve tried all the steps mentioned above, Azure AI Content Safety still can't resolve the false positives or negatives, there is likely a policy definition or model issue that needs further attention.
72+
73+
Document the details of the false positives and/or false negatives by providing the following information to the [Content safety support team](mailto:[email protected]):
74+
- Description of the flagged content.
75+
- Context in which the content was posted.
76+
- Reason given by Azure AI Content Safety for the flagging (if positive).
77+
- Explanation of why the content is a false positive or negative.
78+
- Any adjustments already attempted by adjusting severity settings or using custom categories.
79+
- Screenshots or logs of the flagged content and system responses.
80+
81+
This documentation helps in escalating the issue to the appropriate teams for resolution.
82+
83+
## Related content
84+
85+
- [Azure AI Content Safety overview](/azure/ai-services/content-safety/overview)
86+
- [Harm categories](/azure/ai-services/content-safety/concepts/harm-categories?tabs=warning)

articles/ai-services/content-safety/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ items:
6363
href: how-to/custom-categories-rapid.md
6464
- name: Use a blocklist
6565
href: how-to/use-blocklist.md
66+
- name: Mitigate false results
67+
href: how-to/improve-performance.md
6668
- name: Encryption of data at rest
6769
href: how-to/encrypt-data-at-rest.md
6870
- name: Migrate from public preview to GA

articles/ai-services/openai/assistants-quickstart.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ manager: nitinme
66
ms.service: azure-ai-openai
77
ms.custom: devx-track-python, devx-track-dotnet, devx-track-extended-java, devx-track-js
88
ms.topic: quickstart
9-
author: mrbullwinkle
10-
ms.author: mbullwin
11-
ms.date: 07/18/2024
9+
author: aahill
10+
ms.author: aahi
11+
ms.date: 09/18/2024
1212
zone_pivot_groups: openai-quickstart-assistants
1313
recommendations: false
1414
---
@@ -18,15 +18,9 @@ recommendations: false
1818

1919
Azure OpenAI Assistants (Preview) allows you to create AI assistants tailored to your needs through custom instructions and augmented by advanced tools like code interpreter, and custom functions.
2020

21-
::: zone pivot="programming-language-studio"
22-
23-
[!INCLUDE [Azure OpenAI Studio quickstart](includes/assistants-studio.md)]
24-
25-
::: zone-end
26-
2721
::: zone pivot="programming-language-ai-studio"
2822

29-
[!INCLUDE [AI Studio (Preview)](includes/assistants-ai-studio.md)]
23+
[!INCLUDE [AI Studio](includes/assistants-ai-studio.md)]
3024

3125
::: zone-end
3226

articles/ai-services/openai/how-to/quota.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ The flexibility to distribute TPM globally within a subscription and region has
4444

4545
When you create a model deployment, you have the option to assign Tokens-Per-Minute (TPM) to that deployment. TPM can be modified in increments of 1,000, and will map to the TPM and RPM rate limits enforced on your deployment, as discussed above.
4646

47-
To create a new deployment from within the Azure AI Studio under **Management** select **Deployments** > **Create new deployment**.
48-
49-
The option to set the TPM is under the **Advanced options** drop-down:
47+
To create a new deployment from within the Azure AI Studio under **Shared Resources** select **Deployments** > **Deploy model** > **Deploy base model** > **Select Model** > **Confirm**.
5048

5149
:::image type="content" source="../media/quota/deployment.png" alt-text="Screenshot of the deployment UI of Azure AI Studio" lightbox="../media/quota/deployment.png":::
5250

53-
Post deployment you can adjust your TPM allocation by selecting **Edit deployment** under **Management** > **Deployments** in Azure AI Studio. You can also modify this selection within the new quota management experience under **Management** > **Quotas**.
51+
Post deployment you can adjust your TPM allocation by selecting **Edit** under **Shared resources** > **Deployments** in Azure OpenAI Studio. You can also modify this selection within the new quota management experience under **Management** > **Quotas**.
5452

5553
> [!IMPORTANT]
5654
> Quotas and limits are subject to change, for the most up-date-information consult our [quotas and limits article](../quotas-limits.md).
@@ -70,10 +68,10 @@ For an all up view of your quota allocations across deployments in a given regio
7068

7169
:::image type="content" source="../media/quota/quota.png" alt-text="Screenshot of the quota UI of Azure AI Studio" lightbox="../media/quota/quota.png":::
7270

73-
- **Quota Name**: There's one quota value per region for each model type. The quota covers all versions of that model. The quota name can be expanded in the UI to show the deployments that are using the quota.
7471
- **Deployment**: Model deployments divided by model class.
75-
- **Usage/Limit**: For the quota name, this shows how much quota is used by deployments and the total quota approved for this subscription and region. This amount of quota used is also represented in the bar graph.
76-
- **Request Quota**: The icon in this field navigates to a form where requests to increase quota can be submitted.
72+
- **Quota type**: There's one quota value per region for each model type. The quota covers all versions of that model.
73+
- **Quota allocation**: For the quota name, this shows how much quota is used by deployments and the total quota approved for this subscription and region. This amount of quota used is also represented in the bar graph.
74+
- **Request Quota**: The icon navigates to a form where requests to increase quota can be submitted.
7775

7876
## Migrating existing deployments
7977

articles/ai-services/openai/includes/assistants-ai-studio.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ author: mrbullwinkle
2222

2323
## Go to the Azure AI Studio (Preview)
2424

25+
> [!NOTE]
26+
> While you can use [Azure OpenAI Studio](https://oai.azure.com/), we recommend using the steps here to use [Azure AI Studio](https://ai.azure.com). AI Studio lets you use Assistants v2 which provides several upgrades such as the [file search](../how-to/file-search.md) tool which is faster and supports more files.
27+
2528
1. Sign in to [Azure AI Studio](https://ai.azure.com).
2629
1. Go to your project or [create a new project](../../../ai-studio//how-to/create-projects.md) in Azure AI Studio.
2730
1. From your project overview, select **Assistants**, located under **Project playground**.

articles/ai-services/openai/includes/chatgpt-javascript.md

Lines changed: 167 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,34 @@ ms.author: mbullwin
1111
ms.date: 05/21/2024
1212
---
1313

14-
[Source code](https://github.com/openai/openai-node) | [Package (npm)](https://www.npmjs.com/package/openai)
14+
[Source code](https://github.com/openai/openai-node) | [Package (npm)](https://www.npmjs.com/package/openai) | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/openai/openai/samples)
1515

1616
> [!NOTE]
1717
> This article has been updated to use the [latest OpenAI npm package](https://www.npmjs.com/package/openai) which now fully supports Azure OpenAI. If you are looking for code examples for the legacy Azure OpenAI JavaScript SDK they are currently still [available in this repo](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/openai/openai/samples/v2-beta/javascript).
1818
1919
## Prerequisites
2020

21+
## [**TypeScript**](#tab/typescript)
22+
23+
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services?azure-portal=true)
24+
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
25+
- [TypeScript](https://www.typescriptlang.org/download/)
26+
- An Azure OpenAI Service resource with a `gpt-35-turbo` or `gpt-4` series models deployed. For more information about model deployment, see the [resource deployment guide](../how-to/create-resource.md).
27+
28+
> [!div class="nextstepaction"]
29+
> [I ran into an issue with the prerequisites.](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVASCRIPT&Pillar=AOAI&Product=Chatgpt&Page=quickstart&Section=Prerequisites)
30+
31+
## [**JavaScript**](#tab/javascript)
32+
2133
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services?azure-portal=true)
2234
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
2335
- An Azure OpenAI Service resource with either a `gpt-35-turbo` or `gpt-4` series models deployed. For more information about model deployment, see the [resource deployment guide](../how-to/create-resource.md).
2436

2537
> [!div class="nextstepaction"]
2638
> [I ran into an issue with the prerequisites.](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVASCRIPT&Pillar=AOAI&Product=Chatgpt&Page=quickstart&Section=Prerequisites)
2739
40+
---
41+
2842
## Set up
2943

3044
[!INCLUDE [get-key-endpoint](get-key-endpoint.md)]
@@ -52,6 +66,81 @@ Your app's _package.json_ file will be updated with the dependencies.
5266

5367
Open a command prompt where you want the new project, and create a new file named ChatCompletion.js. Copy the following code into the ChatCompletion.js file.
5468

69+
## [**TypeScript**](#tab/typescript)
70+
71+
```typescript
72+
import "dotenv/config";
73+
import { AzureOpenAI } from "openai";
74+
import type {
75+
ChatCompletion,
76+
ChatCompletionCreateParamsNonStreaming,
77+
} from "openai/resources/index";
78+
79+
// You will need to set these environment variables or edit the following values
80+
const endpoint = process.env["AZURE_OPENAI_ENDPOINT"] || "<endpoint>";
81+
const apiKey = process.env["AZURE_OPENAI_API_KEY"] || "<api key>";
82+
83+
// Required Azure OpenAI deployment name and API version
84+
const apiVersion = "2024-08-01-preview";
85+
const deploymentName = "gpt-4o-mini"; //This must match your deployment name.
86+
87+
function getClient(): AzureOpenAI {
88+
return new AzureOpenAI({
89+
endpoint,
90+
apiKey,
91+
apiVersion,
92+
deployment: deploymentName,
93+
});
94+
}
95+
96+
function createMessages(): ChatCompletionCreateParamsNonStreaming {
97+
return {
98+
messages: [
99+
{ role: "system", content: "You are a helpful assistant." },
100+
{
101+
role: "user",
102+
content: "Does Azure OpenAI support customer managed keys?",
103+
},
104+
{
105+
role: "assistant",
106+
content: "Yes, customer managed keys are supported by Azure OpenAI?",
107+
},
108+
{ role: "user", content: "Do other Azure AI services support this too?" },
109+
],
110+
model: "",
111+
};
112+
}
113+
async function printChoices(completion: ChatCompletion): Promise<void> {
114+
for (const choice of completion.choices) {
115+
console.log(choice.message);
116+
}
117+
}
118+
export async function main() {
119+
const client = getClient();
120+
const messages = createMessages();
121+
const result = await client.chat.completions.create(messages);
122+
await printChoices(result);
123+
}
124+
125+
main().catch((err) => {
126+
console.error("The sample encountered an error:", err);
127+
});
128+
```
129+
130+
Build the script with the following command:
131+
132+
```cmd
133+
tsc
134+
```
135+
136+
Run the script with the following command:
137+
138+
```cmd
139+
node.exe Completion.js
140+
```
141+
142+
## [**JavaScript**](#tab/javascript)
143+
55144
```javascript
56145
const { AzureOpenAI } = require("openai");
57146

@@ -97,6 +186,8 @@ Run the script with the following command:
97186
node.exe ChatCompletion.js
98187
```
99188

189+
---
190+
100191
## Output
101192

102193
```output
@@ -112,6 +203,78 @@ node.exe ChatCompletion.js
112203
> [!IMPORTANT]
113204
> In the previous example we are demonstrating key-based authentication. Once you have tested with key-based authentication successfully, we recommend using the more secure [Microsoft Entra ID](/entra/fundamentals/whatis) for authentication which is demonstrated in the next code sample. Getting started with [Microsoft Entra ID] will require some additional [prerequisites](https://www.npmjs.com/package/@azure/identity).
114205
206+
## [**TypeScript**](#tab/typescript)
207+
208+
```typescript
209+
import {
210+
DefaultAzureCredential,
211+
getBearerTokenProvider,
212+
} from "@azure/identity";
213+
import "dotenv/config";
214+
import { AzureOpenAI } from "openai";
215+
import type {
216+
ChatCompletion,
217+
ChatCompletionCreateParamsNonStreaming,
218+
} from "openai/resources/index";
219+
220+
// You will need to set these environment variables or edit the following values
221+
const endpoint = process.env["AZURE_OPENAI_ENDPOINT"] || "<endpoint>";
222+
223+
// Required Azure OpenAI deployment name and API version
224+
const apiVersion = "2024-08-01-preview";
225+
const deploymentName = "gpt-4o-mini"; //This must match your deployment name.
226+
227+
function getClient(): AzureOpenAI {
228+
const scope = "https://cognitiveservices.azure.com/.default";
229+
const azureADTokenProvider = getBearerTokenProvider(
230+
new DefaultAzureCredential(),
231+
scope
232+
);
233+
return new AzureOpenAI({
234+
endpoint,
235+
azureADTokenProvider,
236+
deployment: deploymentName,
237+
apiVersion,
238+
});
239+
}
240+
241+
function createMessages(): ChatCompletionCreateParamsNonStreaming {
242+
return {
243+
messages: [
244+
{ role: "system", content: "You are a helpful assistant." },
245+
{
246+
role: "user",
247+
content: "Does Azure OpenAI support customer managed keys?",
248+
},
249+
{
250+
role: "assistant",
251+
content: "Yes, customer managed keys are supported by Azure OpenAI?",
252+
},
253+
{ role: "user", content: "Do other Azure AI services support this too?" },
254+
],
255+
model: "",
256+
};
257+
}
258+
async function printChoices(completion: ChatCompletion): Promise<void> {
259+
for (const choice of completion.choices) {
260+
console.log(choice.message);
261+
}
262+
}
263+
export async function main() {
264+
const client = getClient();
265+
const messages = createMessages();
266+
const result = await client.chat.completions.create(messages);
267+
await printChoices(result);
268+
}
269+
270+
main().catch((err) => {
271+
console.error("The sample encountered an error:", err);
272+
});
273+
```
274+
275+
276+
## [**JavaScript**](#tab/javascript)
277+
115278
```javascript
116279
const { AzureOpenAI } = require("openai");
117280
const { DefaultAzureCredential, getBearerTokenProvider } = require("@azure/identity");
@@ -150,6 +313,9 @@ main().catch((err) => {
150313

151314
module.exports = { main };
152315
```
316+
317+
---
318+
153319
> [!NOTE]
154320
> If your receive the error: *Error occurred: OpenAIError: The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.* You may need to remove a pre-existing environment variable for the API key from your system. Even though the Microsoft Entra ID code sample is not explicitly referencing the API key environment variable, if one is present on the system executing this sample, this error will still be generated.
155321

articles/ai-services/openai/includes/connect-your-data-studio.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Navigate to [Azure OpenAI Studio](https://oai.azure.com/) and sign-in with crede
2121

2222
:::image type="content" source="../media/use-your-data/bring-your-data-card.png" alt-text="A screenshot of the Azure OpenAI Studio landing page." lightbox="../media/use-your-data/bring-your-data-card.png":::
2323

24+
1. In the **Chat playground**, Select **Add your data** and then **Add a data source**
25+
26+
:::image type="content" source="../media/use-your-data/chat-playground.png" alt-text="A screenshot of the chat playground in OpenAI Studio." lightbox="../media/use-your-data/chat-playground.png":::
27+
2428
1. In the pane that appears, select **Upload files (preview)** under **Select data source**. Azure OpenAI needs both a storage resource and a search resource to access and index your data.
2529

2630
> [!TIP]

0 commit comments

Comments
 (0)