Azure OpenAI

1. What is Azure OpenAI?

Azure OpenAI is one of the newest additions to the Azure Cognitive Services family, a cloud-based service that provides access to OpenAI's generative artificial intelligence models such as GPT-3 and Codex, with the enterprise readiness of Azure (e.g. private networking, regional availability, responsible AI content filtering). Once an Azure OpenAI Service resource is provisioned within an Azure subscription, users can access the service through REST APIs, Python SDK, or a web-based interface known as Azure OpenAI Studio.

 
 

Since teaming up with OpenAI, a research laboratory dedicated to developing safe and beneficial artificial intelligence, Microsoft has been working to make OpenAI's powerful AI models more widely accessible. Here is a brief summary of some of the major milestones to date.

 
 

3. Azure OpenAI Models

Azure's OpenAI service provides access to a variety of models that belong to a specific model family (such as GPT-3, Codex, and Embeddings), with each model family comprising of several models, each differentiated by their level of capability (such as ada, babbage, curie, and davinci).

Model Family Description
GPT-3 A set of models capable of understanding and generating text.
Codex A set of models capable of understanding and generating code.
Embeddings A set of models capable of understanding and using embeddings.
 

Although Davinci is the most capable, the other models have a faster inference time, and are therefore available at a lower price point. Microsoft recommends starting with Davinci when experimenting as it will yield the best results. Once you have a working prototype, you can optimize your model choice to meet your application’s latency/performance requirements.

 
 

4. Getting Started

You can quickly get started with the Azure OpenAI Service by:

  1. Provisioning an Azure OpenAI Service resource within your Azure subscription.

  2. Deploying a model (e.g. text-davinci-003).

  3. Interact with the model by calling the API using your Endpoint, API Key, and Deployment Name.

Note: Access to the Azure OpenAI Service is currently available upon request, which can be made by filling out the form at https://aka.ms/aoi/access. Once approved, you will be able to provision an Azure OpenAI Service resource within your Azure subscription, and deploy an OpenAI model (e.g. text-davinci-003).

In order to successfully make a call against the Azure OpenAI service, you will need the following:

  • Endpoint - This can be found in the Overview or Keys and Endpoint section when examining your Azure OpenAI resource from the Azure portal.

  • API Key - This can be found in the Keys and Endpoint section when examining your Azure OpenAI resource from the Azure portal. You can use either Key 1 or Key 2.

  • Deployment Name - This is the custom name you chose when you deployed a model. This can be found under the Model deployments section when examining your Azure OpenAI resource from the Azure portal.

 
 

Using API development tools such as Postman or lightweight REST clients such as Thunder Client for VS Code, you can create and send API requests to the Azure OpenAI Service.

The following is a basic request using the completions API (text-in, text-out).

Method
POST

Endpoint
https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/completions?api-version=2022-12-01

Headers

  • api-key: YOUR_API_KEY

  • Content-Type: application/json

Body

{        
    "prompt":"What is Azure OpenAI?",
    "max_tokens": 100
}

Response

{
  "id": "cmpl-6jBx8XBz0lf7SpbUMSfpq5i3vH3ua",
  "object": "text_completion",
  "created": 1676228726,
  "model": "text-davinci-003",
  "choices": [
    {
      "text": "\n\nAzure OpenAI is a platform from Microsoft Azure that allows customers to access pre-trained AI models for natural language processing, computer vision, and forecasting tasks. The platform also provides access to cloud-native ML experimentation and the possibility to create custom AI models. The platform is intended to enable customers to get their AI models into production quickly and easily.",
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 6,
    "completion_tokens": 72,
    "total_tokens": 78
  }
}

5. Use Cases

Due to the general-purpose nature of the Azure OpenAI service, the models can adapt to a variety of use cases and scenarios. An example of use cases is provided below.

Summarization
Generate condensed versions of longer texts while retaining the most important information. This can be used for quick content review, creating executive summaries, and improving document accessibility.

 

Classification
Categorize text into predefined categories based on its content. This can be used for sentiment analysis, content moderation, fraud detection, and other applications that require the automatic identification and labelling of data.

 

Content Generation
Produce human-like text. This can be used for writing assistance, content creation, chatbots, and other applications that require the automated generation of text.

 

Code Generation
Generate code snippets or complete programs based on natural language inputs. This can be used for software development, coding assistance, and other applications that require the automatic generation of code.

 

Translation
Translate text from one language to another. This can be used for communication between people who speak different languages, content localization, and other applications that require the automatic translation of text.

 

Information Extraction
Identify and extract relevant information from unstructured text. This can be used for data mining, content analysis, and other applications that require the automated extraction of information from large datasets.

 

6. Key Concepts

Completions
Completions is one of the core operations available for a deployed Azure OpenAI model (e.g. YOUR_ENDPOINT/openai/deployments/YOUR_DEPLOYMENT/completions). This API can generate one or more predicted completions based on a provided prompt (text in, text out).

Prompt
A prompt refers to the text input provided to an Azure OpenAI model to generate a completion. The quality and relevance of the prompt can significantly impact the quality of the model's output.

Embeddings
Embeddings is a technique used to represent words or other pieces of text in a numerical format so that it can be easily consumed by machine learning models. Azure OpenAI currently offers three types of embedding models: text similarity, text search, and code search. For more information, check out Understanding embeddings in Azure OpenAI.

Tokens
Before Azure OpenAI processes text, the input is broken down into tokens. Tokens can be words, punctuation marks, or other characters, and they are used to represent the text in a format that can be analyzed and processed by a machine learning model. To further explore tokenization, use OpenAI’s interactive Tokenizer tool.

Fine-tuning
The process of fine-tuning involves training an OpenAI model on personal training data, resulting in a customized model that performs better across a variety of tasks without requiring examples in the prompt.

Content filtering
The Azure OpenAI Service provides a content filtering system that operates in conjunction with core models. This system utilizes an ensemble of classification models to identify misuse by analyzing both the input prompt and generated content.

7. Resources

To learn more about Azure OpenAI, refer to the resources provided below.