Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/ai/conceptual/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Agents and Copilots Bring Automation and Interactive Assistance to Your
description: "Learn how agents and copilots intelligently extend the functionality of LLMs to automatically meet user goals in .NET."
author: catbutler
ms.topic: concept-article #Don't change.
ms.date: 04/15/2024
ms.date: 11/24/2024

#customer intent: As a .NET developer, I want to understand how agents and copilots extend the functionality of LLMs, so that my apps can handle any type of content and automatically meet user goals.

Expand Down
11 changes: 5 additions & 6 deletions docs/ai/conceptual/chain-of-thought-prompting.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ title: "Chain of Thought Prompting - .NET"
description: "Learn how chain of thought prompting can simplify prompt engineering."
author: catbutler
ms.topic: concept-article #Don't change.
ms.date: 04/10/2024
ms.date: 11/24/2024

#customer intent: As a .NET developer, I want to understand what chain-of-thought prompting is and how it can help me save time and get better completions out of prompt engineering.

---

# Chain of thought prompting

This article explains the use of chain of thought prompting in .NET.
GPT model performance and response quality benefits from *prompt engineering*, which is the practice of providing instructions and examples to a model to prime or refine its output. As they process instructions, models make more reasoning errors when they try to answer right away rather than taking time to work out an answer. You can help the model reason its way toward correct answers more reliably by asking for the model to include its chain of thought—that is, the steps it took to follow an instruction, along with the results of each step.

GPT model performance benefits from *prompt engineering*, which is the practice of providing instructions and examples to a model to prime or refine its output. As they process instructions, models make more reasoning errors when they try to answer right away rather than taking time to work out an answer. You can help the model reason its way toward correct answers more reliably by asking for the model to include its chain of thought—that is, the steps it took to follow an instruction, along with the results of each step.

*Chain of thought prompting* is the practice of prompting a GPT model to perform a task step-by-step and to present each step and its result in order in the output. This simplifies prompt engineering by offloading some execution planning to the model, and makes it easier to connect any problem to a specific step so you know where to focus further efforts.
*Chain of thought prompting* is the practice of prompting a model to perform a task step-by-step and to present each step and its result in order in the output. This simplifies prompt engineering by offloading some execution planning to the model, and makes it easier to connect any problem to a specific step so you know where to focus further efforts.

It's generally simpler to just instruct the model to include its chain of thought, but you can use examples to show the model how to break down tasks. The following sections show both ways.

Expand All @@ -24,7 +22,8 @@ It's generally simpler to just instruct the model to include its chain of though
To use an instruction for chain of thought prompting, include a directive that tells the model to perform the task step-by-step and to output the result of each step.

```csharp
prompt= "Instructions: Compare the pros and cons of EVs and petroleum-fueled vehicles. Break the task into steps, and output the result of each step as you perform it.";
prompt= """Instructions: Compare the pros and cons of EVs and petroleum-fueled vehicles.
Break the task into steps, and output the result of each step as you perform it.""";
```

## Use chain of thought prompting in examples
Expand Down
2 changes: 1 addition & 1 deletion docs/ai/conceptual/how-genai-and-llms-work.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "How Generative AI and LLMs work"
description: "Understand how Generative AI and large language models (LLMs) work and how they might be useful in your .NET projects."
author: haywoodsloan
ms.topic: concept-article
ms.date: 04/04/2024
ms.date: 11/24/2024

#customer intent: As a .NET developer, I want to understand how Generative AI and large language models (LLMs) work and how they may be useful in my .NET projects.

Expand Down
2 changes: 1 addition & 1 deletion docs/ai/conceptual/rag.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Integrate Your Data into AI Apps with Retrieval-Augmented Generation"
description: "Learn how retrieval-augmented generation lets you use your data with LLMs to generate better completions in .NET."
author: catbutler
ms.topic: concept-article #Don't change.
ms.date: 04/15/2024
ms.date: 11/24/2024

#customer intent: As a .NET developer, I want to understand how retrieval-augmented generation works in .NET so that LLMs can use my data sources to provide more valuable completions.

Expand Down
2 changes: 1 addition & 1 deletion docs/ai/conceptual/vector-databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Using Vector Databases to Extend LLM Capabilities"
description: "Learn how vector databases extend LLM capabilities by storing and processing embeddings in .NET."
author: catbutler
ms.topic: concept-article #Don't change.
ms.date: 05/16/2024
ms.date: 11/24/2024

#customer intent: As a .NET developer, I want to learn how vector databases store and process embeddings in .NET so I can make more data available to LLMs in my apps.

Expand Down
34 changes: 16 additions & 18 deletions docs/ai/conceptual/zero-shot-learning.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Zero-shot and few-shot learning"
description: "Learn the use cases for zero-shot and few-shot learning in prompt engineering."
author: catbutler
ms.topic: concept-article #Don't change.
ms.date: 04/12/2024
ms.date: 11/25/2024

#customer intent: As a .NET developer, I want to understand how zero-shot and few-shot learning techniques can help me improve my prompt engineering.

Expand All @@ -13,11 +13,13 @@ ms.date: 04/12/2024

This article explains zero-shot learning and few-shot learning for prompt engineering in .NET, including their primary use cases.

GPT model performance benefits from *prompt engineering*, the practice of providing instructions and examples to a model to refine its output. Zero-shot learning and few-shot learning are techniques that you can use when providing examples.
GPT model performance benefits from *prompt engineering*, the practice of providing instructions and examples to a model to refine its output. Zero-shot learning and few-shot learning are techniques you can use when providing examples.

With zero-shot learning, you include prompts but not verbatim completions. You can include completions that only consist of cues. Zero-shot learning relies entirely on the model's existing knowledge to generate responses, which reduces the number of tokens created and can help you control costs. However, zero-shot learning doesn't add to the model's knowledge.
## Zero-shot learning

Here's an example zero-shot prompt that tells the model to evaluate user input to determine which of four possible intents the input represents, and then to preface its response with **"Intent: "**.
Zero-shot learning is the practice of passing prompts that aren't paired with verbatim completions, although you can include completions that consist of cues. Zero-shot learning relies entirely on the model's existing knowledge to generate responses, which reduces the number of tokens created and can help you control costs. However, zero-shot learning doesn't add to the model's knowledge or context.

Here's an example zero-shot prompt that tells the model to evaluate user input to determine which of four possible intents the input represents, and then to preface the response with **"Intent: "**.

```csharp
prompt = $"""
Expand All @@ -29,7 +31,14 @@ Intent:
""";
```

With few-shot learning, you include prompts paired with verbatim completions. Compared to zero-shot learning, this means few-shot learning produces more tokens and causes the model to update its knowledge, which can make few-shot learning more resource-intensive. However, for the same reasons few-shot learning also helps the model produce more relevant responses.
There are two primary use cases for zero-shot learning:

- **Work with fined-tuned LLMs** - Because it relies on the model's existing knowledge, zero-shot learning is not as resource-intensive as few-shot learning, and it works well with LLMs that have already been fined-tuned on instruction datasets. You might be able to rely solely on zero-shot learning and keep costs relatively low.
- **Establish performance baselines** - Zero-shot learning can help you simulate how your app would perform for actual users. This lets you evaluate various aspects of your model's current performance, such as accuracy or precision. In this case, you typically use zero-shot learning to establish a performance baseline and then experiment with few-shot learning to improve performance.

## Few-shot learning

Few-shot learning is the practice of passing prompts paired with verbatim completions (few-shot prompts) to show your model how to respond. Compared to zero-shot learning, this means few-shot learning produces more tokens and causes the model to update its knowledge, which can make few-shot learning more resource-intensive. However, few-shot learning also helps the model produce more relevant responses.

```csharp
prompt = $"""
Expand All @@ -48,21 +57,10 @@ Intent:
""";
```

## Zero-shot learning use cases

Zero-shot learning is the practice of passing prompts that aren't paired with verbatim completions, although they can be paired with a cue. There are two primary use cases for zero-shot learning:

- **Working with fined-tuned LLMs** - Because it relies on the model's existing knowledge, zero-shot learning is not as resource-intensive as few-shot learning, and it works well with LLMs that have already been fined-tuned on instruction datasets. You might be able to rely solely on zero-shot learning and keep costs relatively low.
- **Establish performance baselines** - Zero-shot learning can help you simulate how your app would perform for actual users. This lets you evaluate various aspects of your model's current performance, such as accuracy or precision. In this case, you typically use zero-shot learning to establish a performance baseline and then experiment with few-shot learning to improve performance.

## Few-shot learning use cases

Few-shot learning is the practice of passing prompts paired with verbatim completions (few-shot prompts) to show your model how to respond. Unlike zero-shot learning, few-shot learning can add to the model's knowledge. You can even use your own datasets to automatically generate few-shot prompts, by performing retrieval-augmented generation.

Few-shot learning has two primary use cases:

- **Tuning an LLM** - Because it can add to the model's knowledge, few-shot learning can improve a model's performance. It also causes the model to create more tokens than zero-shot learning does, which can eventually become prohibitively expensive or even infeasible. However, if your LLM isn't fined-tuned yet, you won't get good performance with zero-shot prompts, and few-shot learning is warranted.
- **Fixing performance issues** - You can use few-shot learning as a follow-on to zero-shot learning. In this case, you use zero-shot learning to establish a performance baseline, and then experiment with few-shot learning based on the zero-shot prompts you used. This lets you add to the model's knowledge after seeing how it currently responds, so you can iterate and improve performance while minimizing the number of tokens you introduce.
- **Tuning an LLM** - Because it can add to the model's knowledge, few-shot learning can improve a model's performance. It also causes the model to create more tokens than zero-shot learning does, which can eventually become prohibitively expensive or even infeasible. However, if your LLM isn't fined-tuned yet, you won't always get good performance with zero-shot prompts, and few-shot learning is warranted.
- **Fixing performance issues** - You can use few-shot learning as a follow-up to zero-shot learning. In this case, you use zero-shot learning to establish a performance baseline, and then experiment with few-shot learning based on the zero-shot prompts you used. This lets you add to the model's knowledge after seeing how it currently responds, so you can iterate and improve performance while minimizing the number of tokens you introduce.

### Caveats

Expand Down
2 changes: 1 addition & 1 deletion docs/ai/dotnet-ai-ecosystem.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Overview of the .NET + AI ecosystem
description: This article provides an overview of the ecosystem of SDKs and tools available to .NET developers integrating AI into their applications.
ms.date: 04/04/2024
ms.date: 11/24/2024
ms.topic: overview
ms.custom: devx-track-dotnet, devx-track-dotnet-ai
---
Expand Down
42 changes: 21 additions & 21 deletions docs/ai/how-to/app-service-aoai-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ description: "Learn how to authenticate and authorize your app service applicati
author: haywoodsloan
ms.topic: how-to
ms.custom: devx-track-azurecli
ms.date: 04/19/2024
ms.date: 11/24/2024
zone_pivot_groups: azure-interface
#customer intent: As a .NET developer, I want authenticate and authorize my App Service to Azure OpenAI by using Microsoft Entra so that I can securely use AI in my .NET application.
---

# Authenticate and authorize App Service to Azure OpenAI using Microsoft Entra and the Semantic Kernel SDK
# Authenticate an AI app hosted on Azure App Service to Azure OpenAI using Microsoft Entra ID

This article demonstrates how to use [Microsoft Entra-managed identities](/azure/app-service/overview-managed-identity) to authenticate and authorize an App Service application to an Azure OpenAI resource.
This article demonstrates how to use [Microsoft Entra ID managed identities](/azure/app-service/overview-managed-identity) to authenticate and authorize an App Service application to an Azure OpenAI resource.

This article also demonstrates how to use the [Semantic Kernel SDK](/semantic-kernel/overview) to easily implement Microsoft Entra authentication in your .NET application.

Expand All @@ -33,32 +33,18 @@ Your application can be granted two types of identities:
* A **system-assigned identity** is tied to your application and is deleted if your app is deleted. An app can have only one system-assigned identity.
* A **user-assigned identity** is a standalone Azure resource that can be assigned to your app. An app can have multiple user-assigned identities.

### Add a system-assigned identity

:::zone target="docs" pivot="azure-portal"

# [System-assigned](#tab/system-assigned)

1. Navigate to your app's page in the [Azure portal](https://aka.ms/azureportal), and then scroll down to the **Settings** group.
1. Select **Identity**.
1. On the **System assigned** tab, toggle *Status* to **On**, and then select **Save**.

:::zone-end

:::zone target="docs" pivot="azure-cli"

Run the `az webapp identity assign` command to create a system-assigned identity:

```azurecli
az webapp identity assign --name <appName> --resource-group <groupName>
```

:::zone-end

### Add a user-assigned identity
## [User-assigned](#tab/user-assigned)

To add a user-assigned identity to your app, create the identity, and then add its resource identifier to your app config.

:::zone target="docs" pivot="azure-portal"

1. Create a user-assigned managed identity resource by following [these instructions](/azure/active-directory/managed-identities-azure-resources/how-to-manage-ua-identity-portal#create-a-user-assigned-managed-identity).
1. In the left navigation pane of your app's page, scroll down to the **Settings** group.
1. Select **Identity**.
Expand All @@ -68,10 +54,22 @@ To add a user-assigned identity to your app, create the identity, and then add i
> [!IMPORTANT]
> After you select **Add**, the app restarts.

---

:::zone-end

:::zone target="docs" pivot="azure-cli"

## [System-assigned](#tab/system-assigned)

Run the `az webapp identity assign` command to create a system-assigned identity:

```azurecli
az webapp identity assign --name <appName> --resource-group <groupName>
```

## [User-assigned](#tab/user-assigned)

1. Create a user-assigned identity:

```azurecli
Expand All @@ -84,6 +82,8 @@ To add a user-assigned identity to your app, create the identity, and then add i
az webapp identity assign --resource-group <groupName> --name <appName> --identities <identityId>
```

---

:::zone-end

## Add an Azure OpenAI user role to your managed identity
Expand Down Expand Up @@ -135,7 +135,7 @@ az role assignment create --assignee "<managedIdentityObjectID>" \

:::zone-end

## Implement token-based authentication by using Semantic Kernel SDK
## Implement token-based authentication using Semantic Kernel SDK

1. Initialize a `DefaultAzureCredential` object to assume your app's managed identity:

Expand Down
Loading