01 Get Started With Azure OpenAI Service
01 Get Started With Azure OpenAI Service
• Azure OpenAI Service integrates these generative AI models into the Azure
platform, offering security, scalability, and integration with other Azure
services.
• The models can be accessed via REST API, various SDKs, and the Azure OpenAI
Studio interface.
• The module provides guidance on using the Azure OpenAI Studio, laying the
groundwork for developing applications utilizing generative AI.
Access Azure OpenAI
Service
• The first step in building a generative AI solution with Azure OpenAI is to
provision an Azure OpenAI resource in your Azure subscription.
• Azure OpenAI Service is currently in limited access. Users need to apply for
service access at https://aka.ms/oai/access.
• Once you have access to Azure OpenAI Service, you can get started by
creating a resource in the Azure portal or with the Azure command line
interface (CLI).
Access Azure OpenAI
Service
Create an Azure OpenAI Service resource in the
Azure portal
• When you create an Azure OpenAI
Service resource, you need to
provide a subscription name,
resource group name, region,
unique instance name, and select
a pricing tier.
Access Azure OpenAI
Service
Create an Azure OpenAI Service resource in Azure CLI
• To create an Azure OpenAI Service resource from the CLI, refer to this example
and replace the following variables with your own:
• Consult the Azure OpenAI model availability guide for region availability.
• You can access the Azure OpenAI Studio through the Azure portal after creating a
resource, or at https://oai.azure.com by logging in with your Azure OpenAI
resource instance.
• During the signin workflow, select the appropriate directory, Azure subscription,
and Azure OpenAI resource.
Use Azure OpenAI
Studio
Use Azure OpenAI
Studio
• When you first open Azure OpenAI
Studio, you'll see a calltoaction
button at the top of the screen to
deploy your first model.
• Microsoft provides base models and the option to create customized base models.
This module covers the currently available base models.
• GPT 3.5 models can generate natural language and code completions based
on natural language prompts. In particular, GPT35turbo models are
optimized for chatbased interactions and work well in most generative AI
scenarios.
• Embeddings models convert text into numeric vectors, and are useful in
language analytics scenarios such as comparing text sources for similarities.
• When you create a new deployment, you need to indicate which base model to
deploy.
• You can deploy any number of deployments in one or multiple Azure OpenAI
resources as long as their TPM adds up to less than 240K total in that region.
•Deploy
There areusing
several Azure
ways youOpenAI
can deploy Studio
your base model.
• In Azure OpenAI Studio's Deployments page, you can create a new deployment
by selecting a model name from the menu.
• The available base models come from the list in the models page.
Deploy generative AI models
Deploy generative AI models
• From the Deployments page in the Studio, you can also view information about
all your deployments including deployment name, model name, model version,
status, date created, and more.
• In the request body, you specify the base model you wish to deploy
Use prompts to get completions from
models
• Once the model is deployed, you can test how it completes prompts.
• A prompt is the text portion of a request that is sent to the deployed model's
completions endpoint.
• Responses are referred to as completions, which can come in form of text, code,
or other formats.
Use prompts to get completions from
models
Prompt types
Task type Prompt example Completion
example
Classifying content Tweet: I enjoyed the trip. Positive
Sentiment:
Generating new content List ways of traveling 1. Bike
2. Car ...
Holding a conversation A friendly AI assistant See examples
Transformation (translat English: Hello bonjour
ion and symbol French:
conversion)
Summarizing content Provide a summary of the content The content shares
{text} methods of machine
learning.
Picking up where you One way to grow tomatoes is to plant seeds.
left off
Giving factual How many moons does Earth One
responses have?
Use prompts to get completions from
models
Completion quality
• Several factors affect the quality of completions you'll get from a generative AI
solution.
• The data the model is trained on, which can be adapted through model
finetuning with customization
• You have more control over the completions returned by training a custom
model than through prompt engineering and parameter adjustment.
Use prompts to get completions from
models
Making calls
• You can start making calls to your deployed model via the REST API, Python,
C#, or from the Studio.
• If your deployed model has a GPT3.5 or GPT4 model base, use the Chat
completions documentation, which has different request endpoints and
variables required than for other base models.
Test models in Azure OpenAI Studio's
• playgrounds
Playgrounds are useful interfaces in Azure OpenAI Studio that you can use to
experiment with your deployed models without needing to develop your own
client application.
• You need to select the deployment name of your model under Deployments.
• Optionally, you can use the provided examples to get you started, and then
you can enter your own prompts.
Test models in Azure OpenAI Studio's
playgrounds
Test models in Azure OpenAI Studio's
playgrounds
Completions Playground
parameters
• There are many parameters that you can adjust to change the performance of
your model:
• You can initialize the session with a system message to set up the chat
context.
• The term few-shot refers to providing a few of examples to help the model
learn what it needs to do.
• In the Assistant setup, you can provide few-shot examples of what the user
input may be, and what the assistant response should be.
• The assistant tries to mimic the responses you include here in tone, rules, and
format you've defined in your system message.
Test models in Azure OpenAI Studio's
playgrounds
Chat playground
Test models in Azure OpenAI Studio's
playgrounds
Chat playground parameters
• The Chat playground, like the Completions playground, also includes the
Temperature parameter.
• The Chat playground also supports other parameters not available in the
Completions playground. These include:
• Max response: Set a limit on the number of tokens per model response. The
API supports a maximum of 4000 tokens shared between the prompt
(including system message, examples, message history, and user query) and
the model's response. One token is roughly four characters for typical English
text.
• Since the API calls are priced by token and it's possible to set a max response
token limit, you'll want to keep an eye out for the current token count to make
sure the conversation-in doesn't exceed the max response token count.
Exercise - Get started with Azure OpenAI
Service
Knowledge check
1. What Azure OpenAI base model can you deploy to access the capabilities of ChatGPT?
a) text-davinci-003
b) gpt-35-turbo
c) text-embedding-ada-002 (Version 2)
2. Which parameter could you adjust to change the randomness or creativeness of the
completions returned?
d) Temperature
e) Frequency penalty
f) Stop sequence
3. Which Azure OpenAI Studio playground is able to support conversation-in, message-out
scenarios?
g) Completions
h) Chat
i) Bot