Generative AI with Azure OpenAI (GPT-4 Overview)

Introduction

Hey, there! In this article, we'll learn about Generative AI and how to use the Azure OpenAI service for natural language interaction with GPT-4.

Generative AI overview

Generative Artificial Intelligence is a type of AI that creates new and original content based on what it has learned from previous data. It can be used to generate text, images, music, and more.

In short, it's an AI that generates content based on what is described in the input (prompt).

Azure OpenAI

Azure OpenAI is part of the Azure Cognitive Services that uses generative AI models. In this sense, these are the workloads that we can consider.

  • Generating Natural Language.
  • Generating Code.
  • Generating Images.

For our Azure OpenAI overview, we'll exemplify the first scenario, Generating content through text.

Exploring Azure OpenAI

Step 1. Create Azure OpenAI service.

As a first point, within Azure, we'll have to create a new OpenAI resource like any other.

Here, in addition to the subscription and resource group, we must specify the name, region, and pricing tier for the new resource.

Create Azure OpenAI resource

With the service created, here we can see the resource overview, keys & endpoints, and the Go to Azure OpenAI Studio option to go to the low-code dashboard.

Azure OpenAI resource

Step 2. Azure OpenAI Studio.

And here we have it. The Azure OpenAI Studio (https://oai.azure.com/).

The first thing we must do is create/establish a new deployment to specify which model we want to use.

In our example, we'll use the get-4-32k model for the natural language interaction between the assistant and the users.

Here we can learn more about the available models: Azure OpenAI Service models.

Step 3. Setup Chat playground.

With the model established, we can now go to the playground to interact with it.

Image description

To adjust our chat assistant, it is important to take into account three aspects/roles

  • System message (prompt)- Instructions we can give the model about how it should behave and any context it should reference when generating a response.
  • User- The user's question or comment.
  • Assistant- The assistant's response.

Example

Let's suppose that we want our wizard to be an expert on Azure resources and that it only responds to us if the resources are considered as IaaS or SaaS.

For this scenario, we would have this System message (prompt).

You are an assistant that knows about Azure resources and who only answers if the resource name is of type Platform as a Service (PaaS), or Infrastructure as a Service (IaaS).

We can also indicate to the assistant examples so that it has more context,

  • User- Azure App Service. Assistant, Platform as a Service (PaaS)
  • User- Azure SQL Database. Assistant, Platform as a Service (PaaS)
  • User- Azure Virtual Machine. Assistant, Infrastructure as a Service (IaaS)

The recommendation is always to provide useful information so that the attendee has a good context of the topic to be discussed.

Interaction with the example

Chat examples

Parameters for the model

Within our Chat Playground area, we can see the parameters option to optimize our model-

  • Temperature- Controls randomness. At higher temperatures, the answers can be more creative and unexpected.
  • Max length (tokens)- Set a limit on the number of tokens per model response.
  • Top probabilities- Similar to temperature, this controls randomness but uses a different method.

Thanks for reading!

If you have any questions or ideas in mind, it will be a pleasure to be able to be in communication with you and together exchange knowledge with each other.

If you would like to learn more about Azure OpenAI, this Microsoft Learn module is a good option- Introduction to Azure OpenAI Service.