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: Instructions/Exercises/01-get-started-azure-openai.md
+86-42Lines changed: 86 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,13 @@
1
1
---
2
2
lab:
3
-
title: 'Get started with Azure OpenAI'
3
+
title: 'Get started with Azure OpenAI service'
4
4
---
5
5
6
-
# Get started with Azure OpenAI Service
6
+
# Get started with Azure OpenAI service
7
7
8
-
Azure OpenAI Service brings the generative AI models developed by OpenAI to the Azure platform, enabling you to develop powerful AI solutions that benefit from the security, scalability, and integration of services provided by the Azure cloud platform. In this exercise, you'll learn how to get started with Azure OpenAI by provisioning the service as an Azure resource and using Azure OpenAI Studio to deploy and explore OpenAI models.
8
+
Azure OpenAI Service brings the generative AI models developed by OpenAI to the Azure platform, enabling you to develop powerful AI solutions that benefit from the security, scalability, and integration of services provided by the Azure cloud platform. In this exercise, you'll learn how to get started with Azure OpenAI by provisioning the service as an Azure resource and using Azure OpenAI Studio to deploy and explore generative AI models.
9
+
10
+
In scenario for this exercise, you will perform the role of a software developer who has been tasked to implement an AI agent that can use generative AI to help a marketing organization improve its effectiveness at reaching customers and advertising new products. The techniques used in the exercise can be applied to any scenario where an organization wants to use generative AI models to help employees be more effective and productive.
9
11
10
12
This exercise takes approximately **30** minutes.
11
13
@@ -37,10 +39,15 @@ If you don't already have one, provision an Azure OpenAI resource in your Azure
37
39
38
40
## Deploy a model
39
41
40
-
Azure OpenAI provides a web-based portal named **Azure OpenAI Studio**, that you can use to deploy, manage, and explore models. You'll start your exploration of Azure OpenAI by using Azure OpenAI Studio to deploy a model.
42
+
Azure OpenAI service provides a web-based portal named **Azure OpenAI Studio**, that you can use to deploy, manage, and explore models. You'll start your exploration of Azure OpenAI by using Azure OpenAI Studio to deploy a model.
43
+
44
+
> **Note**: As you use Azure OpenAI Studio, message boxes suggesting tasks for you to perform may be displayed. You can close these and follow the steps in this exercise.
45
+
46
+
1. In the Azure portal, on the **Overview** page for your Azure OpenAI resource, use the **Go to Azure OpenAI Studio** button to open Azure OpenAI Studio in a new browser tab.
47
+
48
+
After the new tab opens, you can close any banner notifications for new preview services that are displayed at the top of the Azure OpenAI Studio page.
41
49
42
-
1. On the **Overview** page for your Azure OpenAI resource, use the **Go to Azure OpenAI Studio** button to open Azure OpenAI Studio in a new browser tab.
43
-
2. In Azure OpenAI Studio, on the **Deployments** page, view your existing model deployments. If you don't already have one, create a new deployment of the **gpt-35-turbo-16k** model with the following settings:
50
+
1. In Azure OpenAI Studio, in the pane on the left, select the **Deployments** page and view your existing model deployments. If you don't already have one, create a new deployment of the **gpt-35-turbo-16k** model with the following settings:
44
51
-**Model**: gpt-35-turbo-16k *(if the 16k model isn't available, choose gpt-35-turbo)*
45
52
-**Model version**: Auto-update to default
46
53
-**Deployment name**: *A unique name of your choice*
@@ -54,76 +61,113 @@ Azure OpenAI provides a web-based portal named **Azure OpenAI Studio**, that you
54
61
55
62
## Use the Chat playground
56
63
57
-
The *Chat* playground provides a chatbot interface for GPT 3.5 and higher models.
64
+
Now that you've deployed a model, you can use it to generate responses based on natural language prompts. The *Chat* playground in Azure OpenAI Studio provides a chatbot interface for GPT 3.5 and higher models.
58
65
59
66
> **Note:** The *Chat* playground uses the *ChatCompletions* API rather than the older *Completions* API that is used by the *Completions* playground. The Completions playground is provided for compatibility with older models.
60
67
61
-
1. In the **Playground** section, select the **Chat** page. The **Chat** playground page consists of three main sections:
68
+
1. In the **Playground** section, select the **Chat** page. The **Chat** playground page consists of three main panels (which may be arranged right-to-left horizontally, or top-to-bottom vertically depending on your screen resolution):
62
69
-**Setup** - used to set the context for the model's responses.
63
70
-**Chat session** - used to submit chat messages and view responses.
64
71
-**Configuration** - used to configure settings for the model deployment.
65
-
1. In the **Configuration** section, ensure that your model deployment is selected.
66
-
1. In the **Setup** section, in the **System message** box, replace the current text with the following statement: `The system is an AI teacher that helps people learn about AI`.
72
+
1. In the **Configuration** panel, ensure that your gpt-35-turbo-16k model deployment is selected.
73
+
1. In the **Assistant setup** panel, review the default **System message**, which should be *You are an AI assistant that helps people find information.* The system message is included in prompts submitted to the model, and provides context for the model's responses; setting expectations about how an AI agent based on the model should interact with the user.
74
+
1. In the **Chat session** panel, enter the user query `How can I use generative AI to help me market a new product?`
67
75
68
-
3. Below the **System message** box, in the **Examples** section, select **Add**. Then type the following message and response in the designated boxes:
76
+
> **Note**: You may receive a response that the API deployment is not yet ready. If so, wait for a few minutes and try again.
69
77
70
-
-**User**: `What are different types of artificial intelligence?`
71
-
-**Assistant**: `There are three main types of artificial intelligence: Narrow or Weak AI (such as virtual assistants like Siri or Alexa, image recognition software, and spam filters), General or Strong AI (AI designed to be as intelligent as a human being. This type of AI does not currently exist and is purely theoretical), and Artificial Superintelligence (AI that is more intelligent than any human being and can perform tasks that are beyond human comprehension. This type of AI is also purely theoretical and has not yet been developed).`
78
+
1. Review the response, noting that the model has generated a cohesive natural language answer that is relevant to the query with which it was prompted.
79
+
1. Enter the user query `What skills do I need if I want to develop a solution to accomplish this?`.
80
+
1. Review the response, noting that the chat session has retained the conversational context (so "this" is interpreted as a generative AI solution for marketing). This contextualization is achieved by including the recent conversation history in each successive prompt submission, so the prompt sent to the model for the second query included the original query and response as well as the new user input.
81
+
1. In the **Chat session** panel toolbar, select **Clear chat** and confirm that you want to restart the chat session.
82
+
1. Enter the query `Can you help me find resources to learn those skills?` and review the response, which should be a valid natural language answer, but since the previous chat history has been lost, the answer is likely to be about finding generic skilling resources rather than being related to the specific skills needed to build a generative AI marketing solution.
72
83
73
-
> **Note**: Few-shot examples are used to provide the model with examples of the types of responses that are expected. The model will attempt to reflect the tone and style of the examples in its own responses.
84
+
## Experiment with system messages, prompts, and few-shot examples
74
85
75
-
4. Apply the changes to start a new session and set the behavioral context of the chat system.
76
-
5. In the **Chat session** section, enter the user query `What is artificial intelligence?`
86
+
So far, you've engaged in a chat conversation with your model based on the default system message. You can customize the system setup to have more control over the kinds of responses generated by your model.
77
87
78
-
> **Note**: You may receive a response that the API deployment is not yet ready. If so, wait for a few minutes and try again.
88
+
1. In the **Assistant setup** panel, under **Use a system message template**, select the **Marketing Writing Assistant** template and confirm that you want to update the system message.
89
+
1. Review the new system message, which describes how an AI agent should use the model to respond.
90
+
1. In the **Chat session** panel, enter the user query `Create an advertisement for a new scrubbing brush`.
91
+
1. Review the response, which should include advertising copy for a scrubbing brush. The copy may be quite extensive and creative.
79
92
80
-
6. Review the response and then submit the following message to continue the conversation: `How is it related to machine learning?`
81
-
7. Review the response, noting that context from the previous interaction is retained (so the model understands that "it" refers to artificial intelligence).
82
-
8. Use the **View Code** button to view the code for the interaction. The prompt consists of the *system* message, the few-shot examples of *user* and *assistant* messages, and the sequence of *user* and *assistant* messages in the chat session so far.
93
+
In a real scenario, a marketing professional would likely already know the name of the scrubbing brush product as well as have some ideas about key features that should be highlighted in an advert. To get the most useful results from a generative AI model, users need to design their prompts to include as much pertinent information as possible.
83
94
84
-
## Explore prompts and parameters
95
+
1. Enter the prompt `Revise the advertisement for a scrubbing brush named "Scrubadub 2000", which is made of carbon fiber and reduces cleaning times by half compared to ordinary scrubbing brushes`.
96
+
1. Review the response, which should take into account the additional information you provided about the scrubbing brush product.
85
97
86
-
You can use the prompt and parameters to maximize the likelihood of generating the response you need.
98
+
The response should now be more useful, but to have even more control over the output from the model, you can provide one or more *few-shot* examples on which responses should be based.
87
99
88
100
1. In the **Configuration** > **Parameters** pane, set the following parameter values:
89
101
-**Temperature**: 0
90
102
-**Max response**: 500
91
103
92
-
2. Submit the following message
104
+
1. In the **Setup** panel, under **Examples**, select **Add**. Then type the following message and response in the designated boxes:
93
105
106
+
**User**:
107
+
108
+
```
109
+
Write an advertisement for the lightweight "Ultramop" mop, which uses patented absorbent materials to clean floors.
110
+
```
111
+
112
+
**Assistant**:
113
+
114
+
```
115
+
Welcome to the future of cleaning!
116
+
117
+
The Ultramop makes light work of even the dirtiest of floors. Thanks to its patented absorbent materials, it ensures a brilliant shine. Just look at these features:
118
+
- Lightweight construction, making it easy to use.
119
+
- High absorbency, enabling you to apply lots of clean soapy water to the floor.
120
+
- Great low price.
121
+
122
+
Check out this and other products on our website at www.contoso.com.
94
123
```
95
-
Write three multiple choice questions based on the following text, indcating the correct answers.
96
-
97
-
Most computer vision solutions are based on machine learning models that can be applied to visual input from cameras, videos, or images.*
98
124
99
-
- Image classification involves training a machine learning model to classify images based on their contents. For example, in a traffic monitoring solution you might use an image classification model to classify images based on the type of vehicle they contain, such as taxis, buses, cyclists, and so on.*
125
+
1. Use the **Apply changes** button to save the examples and start a new session.
126
+
1. In the **Chat session** section, enter the user query `Create an advertisement for the Scrubadub 2000 - a new scrubbing brush made of carbon fiber that reduces cleaning time by half`.
127
+
1. Review the response, which should be a new advert for the "Scrubadub 2000" that is modeled on the "Ultramop" example provided in the system setup.
100
128
101
-
- Object detection machine learning models are trained to classify individual objects within an image, and identify their location with a bounding box. For example, a traffic monitoring solution might use object detection to identify the location of different classes of vehicle.*
129
+
## Experiment with parameters
102
130
103
-
- Semantic segmentation is an advanced machine learning technique in which individual pixels in the image are classified according to the object to which they belong. For example, a traffic monitoring solution might overlay traffic images with "mask" layers to highlight different vehicles using specific colors.
104
-
```
131
+
You've explored how the system message, examples, and prompts can help refine the responses returned by the model. You can also use parameters to control model behavior.
105
132
106
-
3. Review the results, which should consist of multiple-choice questions that a teacher could use to test students on the computer vision topics in the prompt. The total response should be smaller than the maximum length you specified as a parameter.
133
+
1. In the **Configuration** panel, select the **Parameters** tab and set the following parameter values:
134
+
- **Max response**: 1000
135
+
- **Temperature**: 1
107
136
108
-
Observe the following about the prompt and parameters you used:
137
+
1. In the **Chat session** section, use the **Clear chat** button to reset the chat session. Then enter the user query `Create an advertisement for a cleaning sponge` and review the response. The resulting advertisement copy should include a maximum of 1000 text tokens, and include some creative elements - for example, the model may have invented a product name for the sponge and made some claims about its features.
138
+
1. Use the **Clear chat** button to reset the chat session again, and then re-enter the same query as before (`Create an advertisement for a cleaning sponge`) and review the response. The response may be different from the previous response.
139
+
1. In the **Configuration** panel, on the **Parameters** tab, change the **Temperature** parameter value to 0.
140
+
1. In the **Chat session** section, use the **Clear chat** button to reset the chat session again, and then re-enter the same query as before (`Create an advertisement for a cleaning sponge`) and review the response. This time, the response may not be quite so creative.
141
+
1. Use the **Clear chat** button to reset the chat session one more time, and then re-enter the same query as before (`Create an advertisement for a cleaning sponge`) and review the response; which should be very similar (if not identical) to the previous response.
109
142
110
-
- The prompt specifically states that the desired output should be three multiple choice questions.
111
-
- The parameters include *Temperature*, which controls the degree to which response generation includes an element of randomness. The value of **0** used in your submission minimizes randomness, resulting in stable, predictable responses.
143
+
The **Temperature** parameter controls the degree to which the model can be creative in its generation of a response. A low value results in a consistent response with little random variation, while a high value encourages the model to add creative elements its output; which may affect the accuracy and realism of the reeponse.
112
144
113
-
## Explore code-generation
145
+
## Deploy your model to a web app
114
146
115
-
In addition to generating natural language responses, you can use GPT models to generate code.
147
+
Now that you've explored some of the capabilities of a generative AI model in the Azure OpenAI Studio playground, you can deploy an Azure web app to provide a basic AI agent interface through which users can chat with the model.
116
148
117
-
1. In the **Setup** pane, select the **Empty Example** template to reset the system message.
118
-
2. Enter the system message: `You are a Python developer.` and apply the changes.
119
-
3. In the **Chat session** pane, select **Clear chat** to clear the chat history and start a new session.
120
-
4. Submit the following user message:
149
+
1. At the top right of the **Chat** playground page, in the **Deploy to** menu, select **A new web app**.
150
+
1. In the **Deploy to a web app** dialog box, create a new web app with the following settings:
151
+
- **Name**: *A unique name*
152
+
- **Subscription**: *Your Azure subscription*
153
+
- **Resource group**: *The resource group in which you provisioned your Azure OpenAI resource*
154
+
- **Locations**: *The region where you provisioned your Azure OpenAI resource*
155
+
- **Pricing plan**: Free (F1) - *If this is not available, select Basic (B1)*
156
+
- **Enable chat history in the web app**: <u>Un</u>selected
157
+
- **I acknowledge that web apps will incur usage to my account**: Selected
158
+
1. Deploy the new web app and wait for deployment to complete (which may take 10 minutes or so)
159
+
1. After your web app has deployed successfully, use the button at the top right of the **Chat** playground page to launch the web app. The app may take a few minutes to launch. If prompted, accept the permissions request.
160
+
1. In the web app, enter the following chat message:
121
161
122
162
```
123
-
Write a Python function named Multiply that multiplies two numeric parameters.
163
+
Write an advertisement for the new "WonderWipe" cloth that attracts dust particulates and can be used to clean any household surface.
124
164
```
125
165
126
-
5. Review the response, which should include sample Python code that meets the requirement in the prompt.
166
+
1. Review the response.
167
+
168
+
> **Note**: You deployed the *model* to a web app, but this deployment doesn't include the system settings and parameters you set in the playground; so the response may not reflect the examples you specified in the playground. In a real scenario, you would add logic to your application to modify the prompt so that it includes the appropriate contextual data for the kinds of response you want to generate. This kind of customization is beyond the scope of this introductory-level exercise, but you can learn about prompt engineering techniques and Azure OpenAI APIs in other exercises and product documentation.
169
+
170
+
1. When you have finished experimenting with your model in the web app, close the web app tab in your browser to return to Azure OpenAI Studio.
0 commit comments