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: learn-pr/azure/open-ai-dotnet-text-completions/includes/1-introduction.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ The GPT-3.5 and GPT-4 models from OpenAI are prompt-based optimized for conversa
2
2
3
3
You input some text as a prompt, and the model generates a completion that attempts to match whatever context or pattern you gave it. For example, if you give the AI the prompt, "As Descartes said, I think, therefore", it returns the completion " I am" with high probability.
4
4
5
-
At a practical level, the prompt-based models allow you to develop applications that enable users to ask questions of the model as free-form text and the model responds with the answer. GPT-3.5 and GPT-4 are even capable of having multi-turn conversations with the users of your application.
5
+
At a practical level, the prompt-based models allow you to develop applications that enable users to ask questions of the model as free-form text, and the model responds with the answer. GPT-3.5 and GPT-4 are even capable of having multi-turn conversations with the users of your application.
6
6
7
7
For example, imagine you want to build an AI that recommends hikes to people based on the preferences they enter for the hike. The AI could ask them what attributes they are looking for, and then respond based on what they input.
Copy file name to clipboardExpand all lines: learn-pr/azure/open-ai-dotnet-text-completions/includes/2-azure-openai-text-completions-overview.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
Azure OpenAI Service provides REST API access to OpenAI's powerful language models including the GPT-3.5 and GPT-4 model series. These models can be easily adapted to your specific task including but not limited to content generation, summarization, semantic search, and natural language to code translation.
1
+
Azure OpenAI Service provides REST API access to OpenAI's powerful language models, including the GPT-3.5 and GPT-4 model series. These models can be easily adapted to your specific task including but not limited to content generation, summarization, semantic search, and natural language to code translation.
2
2
3
-
In addition to the REST API access, a .NET SDK exists to access Azure OpenAI Service. And that's what we will use to build our application. But before building the application, let's learn a bit more about what Azure OpenAI is and what text completions are. Knowing that give us the foundation we need to build amazing applications with AI.
3
+
In addition to the REST API access, a .NET SDK exists to access Azure OpenAI Service. That's what we'll use to build our application. But before building the application, let's learn a bit more about what Azure OpenAI is and what text completions are. Knowing that gives us the foundation we need to build amazing applications with AI.
4
4
5
5
## Azure OpenAI overview
6
6
@@ -22,15 +22,15 @@ We'll take a look at how to write a good prompt a bit later, but for now let's l
22
22
23
23
## Types of Azure OpenAI completions
24
24
25
-
As mentioned, you pass in a prompt to the Azure OpenAI API that provides instructions on what you want it to do. And you can make it do things like classify text, generate ideas, or even translate text into emojis.
25
+
As mentioned, you pass in a prompt to the Azure OpenAI API that provides instructions on what you want it to do. You can make it do things like classify text, generate ideas, or even translate text into emojis.
26
26
27
27
### Classification
28
28
29
29
For this first completion type, let's dive deep into how to "program" the model with instructions.
30
30
31
31
You can tell the model you want it to sort data into predefined categories. This completion type is known as **Classification**.
32
32
33
-
For example, you can pass instructions, or a prompt, similar to following to the completion API:
33
+
For example, you can pass instructions or a prompt, similar to following to the completion API:
34
34
35
35
```
36
36
This is a sentiment classifier
@@ -74,27 +74,27 @@ Sentiment classifications:
74
74
75
75
After showing the model 4 examples of a sentence classified by sentiment, we then provide it a list of examples and then a list of sentiment ratings with the same number index. The API is able to pick up from this how it is supposed to output the classified sentiments.
76
76
77
-
And that leads us to what we want the model to do: we give it 5 sentiments for it to classify and then it should output the classification of each in an ordered list.
77
+
That leads us to what we want the model to do: we give it five sentiments to classify, and then it should output the classification of each in an ordered list.
78
78
79
79
This allows the model to rate five (and even more) examples in just one call to it.
80
80
81
-
You can begin to see how the prompt, or the text passed to the model is the programming language.
81
+
You can begin to see how the prompt or the text passed to the model is the programming language.
82
82
83
83
### Generation
84
84
85
-
One of the most powerful yet simplest tasks you can accomplish with the various GPT models is generating new ideas or versions of input. You can give the model a list of a few story ideas and it tries to add to that list. We've seen it create business plans, character descriptions and marketing slogans just by providing it a handful of examples.
85
+
One of the most powerful yet simplest tasks you can accomplish with the various GPT models is generating new ideas or versions of input. You can give the model a list of a few story ideas, and it tries to add to that list. We've seen it create business plans, character descriptions, and marketing slogans just by providing it a handful of examples.
86
86
87
87
### Conversation
88
88
89
-
The model is extremely adept at carrying on conversations with humans and even with itself. With just a few lines of instruction, we've seen the model perform as a customer service chatbot that intelligently answers questions without ever getting flustered or a wise-cracking conversation partner that makes jokes and puns.
89
+
The model is extremely adept at carrying on conversations with humans and even with itself. With just a few lines of instruction, we've seen the model perform as a customer service chatbot that intelligently answers questions without ever getting flustered, or a wise-cracking conversation partner that makes jokes and puns.
90
90
91
91
### Transformation
92
92
93
-
The model is a language model that is familiar with a variety of ways that words and characters can be used to express information. This ranges from natural language text to code and languages other than English. The model is also able to understand content on a level that allows it to summarize, convert and express it in different ways.
93
+
The model is a language model that is familiar with a variety of ways that words and characters can be used to express information. This ranges from natural language text to code and languages other than English. The model is also able to understand content on a level that allows it to summarize, convert, and express it in different ways.
94
94
95
95
#### Translation
96
96
97
-
The model already has a grasp of many languages, such as French, so you do not need to teach it. Instead you just need to provide it enough examples of the translation in the prompt so it understands that it is translating from one language to another.
97
+
The model already has a grasp of many languages, such as French, so you do not need to teach it. Instead, you just need to provide it enough examples of the translation in the prompt so it understands that it's translating from one language to another.
98
98
99
99
#### Conversion
100
100
@@ -130,9 +130,9 @@ Vertical farming provides a novel solution for producing food locally, reducing
130
130
131
131
Large language models (LLMs) have a lot of knowledge that they've learned from the data they trained on. They also have the ability to provide responses that sound real but are in fact made up. There are two ways to limit the likelihood of LLMs making up an answer.
132
132
133
-
***1. Provide a ground truth for the API** If you provide the model with a body of text to answer questions about (like a Wikipedia entry) it is less likely to confabulate a response.
133
+
***1. Provide a ground truth for the API.**: If you provide the model with a body of text to answer questions about (like a Wikipedia entry) it's less likely to confabulate a response.
134
134
135
-
***2. Use a low probability and show the API how to say "I don't know"** If the model understands that in cases where it's less certain about a response that saying "I don't know" or some variation is appropriate, it is less inclined to make up answers.
135
+
***2. Use a low probability and show the API how to say "I don't know."**: If the model understands that in cases where it's less certain about a response that saying "I don't know" or some variation is appropriate, it's less inclined to make up answers.
136
136
137
137
In this example, we give the model examples of questions and answers it knows and then examples of things it wouldn't know and provide question marks. We also set the probability to zero so the model is more likely to respond with a "?" if there's any doubt.
138
138
@@ -147,11 +147,11 @@ Q: What is Devz9?
147
147
A: ?
148
148
149
149
Q: Who is George Lucas?
150
-
A: George Lucas is American film director and producer famous for creating Star Wars.
150
+
A: George Lucas is an American film director and producer famous for creating Star Wars.
151
151
```
152
152
153
153
## Summary
154
154
155
-
Azure OpenAI Service provides REST API access to OpenAI's powerful language models including the GPT-3.5 and GPT-4 model series. It also gives you the security and enterprise features you've come to rely from the Azure cloud.
155
+
Azure OpenAI Service provides REST API access to OpenAI's powerful language models including the GPT-3.5 and GPT-4 model series. It also gives you the security and enterprise features you've come to rely on from the Azure cloud.
156
156
157
157
One of the most useful features from the OpenAI language models is text completion. You pass in a **prompt** or a plain language description of what you want the model to do, and it can perform tasks such as text classification, text generation, or text summarization.
Copy file name to clipboardExpand all lines: learn-pr/azure/open-ai-dotnet-text-completions/includes/3-chat-completions.md
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,10 @@ GPT-35-Turbo and GPT-4 can still accept and generate text completions, but where
6
6
7
7
In Azure OpenAI there are two different options for interacting with these type of models:
8
8
9
-
* Chat Completion API.
10
-
* Completion API with Chat Markup Language (ChatML).
9
+
* Chat Completion API
10
+
* Completion API with Chat Markup Language (ChatML)
11
11
12
-
The Chat Completion API is a new dedicated API for interacting with the GPT-35-Turbo and GPT-4 models and we'll use it as we go along here.
12
+
The Chat Completion API is a new dedicated API for interacting with the GPT-35-Turbo and GPT-4 models, and we'll use it as we go along here.
13
13
14
14
## Understanding the Chat Completion API roles
15
15
@@ -21,12 +21,12 @@ The model accepts an array of message objects with a conversation organized by r
21
21
22
22
### The System role
23
23
24
-
The system role also known as the system message is included at the beginning of the array. This message provides the initial instructions to the model. You can provide various information in the system role including:
24
+
The system role, also known as the system message, is included at the beginning of the array. This message provides the initial instructions to the model. You can provide various information in the system role including:
25
25
26
-
* A brief description of the assistant
27
-
* Personality traits of the assistant
28
-
* Instructions or rules you would like the assistant to follow
29
-
* Data or information needed for the model, such as relevant questions from an FAQ
26
+
* A brief description of the assistant.
27
+
* Personality traits of the assistant.
28
+
* Instructions or rules you would like the assistant to follow.
29
+
* Data or information needed for the model, such as relevant questions from an FAQ.
30
30
31
31
You can customize the system role for your use case or just include basic instructions. The system role/message is optional, but it's recommended to at least include a basic one to get the best results.
32
32
@@ -38,17 +38,17 @@ The message the user sends to the model should follow best practices for designi
38
38
39
39
## Message prompt examples
40
40
41
-
Here are a few examples of different styles of prompts that you could use with the GPT-35-Turbo and GPT-4 models. The examples are just a starting point and you can experiment with different prompts to customize the behavior.
41
+
Here are a few examples of different styles of prompts that you could use with the GPT-35-Turbo and GPT-4 models. The examples are just a starting point, and you can experiment with different prompts to customize the behavior.
42
42
43
43
### Basic example
44
44
45
-
If you want the GPT-35-Turbo model to behave similarly to [chat.openai.com](https://chat.openai.com), you can use a basic system message like "Assistant is a large language model trained by OpenAI".
45
+
If you want the GPT-35-Turbo model to behave similarly to [chat.openai.com](https://chat.openai.com), you can use a basic system message like "Assistant is a large language model trained by OpenAI."
46
46
47
-
We'll learn how to use the Chat Completion API's .NET SDK in the next unit, for now we'll stick with variable names as an example.
47
+
We'll learn how to use the Chat Completion API's .NET SDK in the next unit. For now we'll stick with variable names as an example.
48
48
49
49
```csharp
50
50
51
-
stringsystemMessage="Assistant is a large language model trained by OpenAI";
51
+
stringsystemMessage="Assistant is a large language model trained by OpenAI.";
52
52
stringuserMessage="Who were the founders of Microsoft?";
53
53
54
54
```
@@ -70,13 +70,12 @@ string userMessage = "When are my taxes due?";
70
70
71
71
## Managing conversations
72
72
73
-
The model has no memory, so it needs an updated transcript with each new question with all questions and answers otherwise it will lose context.
73
+
The model has no memory, so it needs an updated transcript with each new question with all questions and answers, otherwise it will lose context.
74
74
75
-
This means you will need to send the entire, updated conversation to the model every time you interact with it and then token limit for each model could easily be hit.
75
+
This means you'll need to send the entire updated conversation to the model every time you interact with it, and then token limit for each model could easily be hit.
76
76
77
-
The token limit for `gpt-35-turbo` is 4096 tokens, whereas the token limits for `gpt-4` and `gpt-4-32k` are 8192 and 32768 respectively. You must stay under those limits otherwise you'll receive an error.
77
+
The token limit for `gpt-35-turbo` is 4096 tokens, whereas the token limits for `gpt-4` and `gpt-4-32k` are 8192 and 32768 respectively. You must stay under those limits, otherwise you'll receive an error.
78
78
79
-
You can keep track of the token count and remove the oldest messages from the array sent to the model. It's best to always keep the system message and only remove assistant or user messages. However over time this method of managing the conversation can cause the conversation quality to degrade as context of earlier parts of the conversation are lost.
79
+
You can keep track of the token count and remove the oldest messages from the array sent to the model. It's best to always keep the system message and only remove assistant or user messages. However, over time this method of managing the conversation can cause the conversation quality to degrade as context of earlier parts of the conversation are lost.
80
80
81
81
Alternatively, once the token limit is reached, you can prompt the user to start a new conversation.
0 commit comments