Skip to content

Commit 54ed34f

Browse files
committed
Line edits2
1 parent 57609ca commit 54ed34f

File tree

7 files changed

+55
-56
lines changed

7 files changed

+55
-56
lines changed

learn-pr/azure/open-ai-dotnet-text-completions/includes/1-introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ The GPT-3.5 and GPT-4 models from OpenAI are prompt-based optimized for conversa
22

33
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.
44

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.
66

77
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.
88

learn-pr/azure/open-ai-dotnet-text-completions/includes/2-azure-openai-text-completions-overview.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff 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.
22

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.
44

55
## Azure OpenAI overview
66

@@ -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
2222

2323
## Types of Azure OpenAI completions
2424

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.
2626

2727
### Classification
2828

2929
For this first completion type, let's dive deep into how to "program" the model with instructions.
3030

3131
You can tell the model you want it to sort data into predefined categories. This completion type is known as **Classification**.
3232

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:
3434

3535
```
3636
This is a sentiment classifier
@@ -74,27 +74,27 @@ Sentiment classifications:
7474

7575
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.
7676

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.
7878

7979
This allows the model to rate five (and even more) examples in just one call to it.
8080

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.
8282

8383
### Generation
8484

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.
8686

8787
### Conversation
8888

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.
9090

9191
### Transformation
9292

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.
9494

9595
#### Translation
9696

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.
9898

9999
#### Conversion
100100

@@ -130,9 +130,9 @@ Vertical farming provides a novel solution for producing food locally, reducing
130130

131131
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.
132132

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.
134134

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.
136136

137137
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.
138138

@@ -147,11 +147,11 @@ Q: What is Devz9?
147147
A: ?
148148
149149
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.
151151
```
152152

153153
## Summary
154154

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.
156156

157157
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.

learn-pr/azure/open-ai-dotnet-text-completions/includes/3-chat-completions.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ GPT-35-Turbo and GPT-4 can still accept and generate text completions, but where
66

77
In Azure OpenAI there are two different options for interacting with these type of models:
88

9-
* Chat Completion API.
10-
* Completion API with Chat Markup Language (ChatML).
9+
* Chat Completion API
10+
* Completion API with Chat Markup Language (ChatML)
1111

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.
1313

1414
## Understanding the Chat Completion API roles
1515

@@ -21,12 +21,12 @@ The model accepts an array of message objects with a conversation organized by r
2121

2222
### The System role
2323

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:
2525

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.
3030

3131
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.
3232

@@ -38,17 +38,17 @@ The message the user sends to the model should follow best practices for designi
3838

3939
## Message prompt examples
4040

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.
4242

4343
### Basic example
4444

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."
4646

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.
4848

4949
```csharp
5050

51-
string systemMessage = "Assistant is a large language model trained by OpenAI";
51+
string systemMessage = "Assistant is a large language model trained by OpenAI.";
5252
string userMessage = "Who were the founders of Microsoft?";
5353

5454
```
@@ -70,13 +70,12 @@ string userMessage = "When are my taxes due?";
7070

7171
## Managing conversations
7272

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.
7474

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.
7676

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.
7878

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.
8080

8181
Alternatively, once the token limit is reached, you can prompt the user to start a new conversation.
82-

0 commit comments

Comments
 (0)