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: articles/machine-learning/how-to-use-batch-model-openai-embeddings.md
+72-87Lines changed: 72 additions & 87 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,17 @@
1
1
---
2
2
title: Run OpenAI models in batch endpoints
3
3
titleSuffix: Azure Machine Learning
4
-
description: In this article, learn how to use batch endpoints with OpenAI models.
4
+
description: Find out how to compute embeddings by running OpenAI models in batch endpoints. See how to deploy an OpenAI ADA-002 model in MLflow format to a batch endpoint.
5
5
services: machine-learning
6
6
ms.service: azure-machine-learning
7
7
ms.subservice: inferencing
8
8
ms.topic: how-to
9
9
author: msakande
10
10
ms.author: mopeakande
11
11
ms.reviewer: cacrest
12
-
ms.date: 11/13/2024
12
+
ms.date: 11/19/2024
13
13
ms.custom: how-to, devplatv2, update-code
14
+
# customer intent: As a developer, I want to deploy an OpenAI ADA-002 model to a batch endpoint so I can compute embeddings at scale.
14
15
---
15
16
16
17
# Run OpenAI models in batch endpoints to compute embeddings
To run inference over large amounts of data, you can use batch endpoints to deploy models, including OpenAI models. In this article, you see how to create a batch endpoint to deploy an ADA-002 model from OpenAI to compute embeddings at scale. You can use the same approach for completions and chat completions models.
21
22
22
-
The examples in this article use Microsoft Entra authentication to grant access to the Azure OpenAI resource. The model is registered in MLflow format. It uses the OpenAI flavor, which provides support for calling the OpenAI service at scale.
23
+
The example in this article uses Microsoft Entra authentication to grant access to an Azure OpenAI Service resource. The model is registered in MLflow format. It uses the OpenAI flavor, which provides support for calling the OpenAI service at scale.
23
24
24
25
To follow along with the example steps, see the Jupyter notebook [Score OpenAI models in batch using Batch Endpoints](https://github.com/Azure/azureml-examples/blob/main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb).
25
26
@@ -47,13 +48,13 @@ cd endpoints/batch/deploy-models/openai-embeddings
47
48
48
49
---
49
50
50
-
## Create an OpenAI resource
51
+
## Create an Azure OpenAI resource
51
52
52
-
This article shows you how to run OpenAI models hosted in Azure OpenAI Service. To follow the steps, you need an OpenAI resource that's deployed in Azure. For information about creating an Azure OpenAI Service resource, see [Create a resource](../ai-services/openai/how-to/create-resource.md#create-a-resource).
53
+
This article shows you how to run OpenAI models hosted in Azure OpenAI. To follow the steps, you need an OpenAI resource that's deployed in Azure. For information about creating an Azure OpenAI resource, see [Create a resource](../ai-services/openai/how-to/create-resource.md#create-a-resource).
53
54
54
-
:::image type="content" source="./media/how-to-use-batch-model-openai-embeddings/aoai-deployments.png" alt-text="An screenshot showing the Azure OpenAI studio with the list of model deployments available.":::
55
+
:::image type="content" source="./media/how-to-use-batch-model-openai-embeddings/azure-openai-deployments.png" alt-text="Screenshot of Azure OpenAI Studio that shows a list of available model deployments.":::
55
56
56
-
The name of your OpenAI resource forms part of the resource URL. Use the following command to save that URL for use in later steps.
57
+
The name of your Azure OpenAI resource forms part of the resource URL. Use the following command to save that URL for use in later steps.
57
58
58
59
# [Azure CLI](#tab/cli)
59
60
@@ -97,7 +98,7 @@ Using Microsoft Entra is recommended because it helps you avoid managing secrets
97
98
98
99
# [Microsoft Entra authentication](#tab/ad)
99
100
100
-
You can configure the identity of the compute instance to have access to the Azure OpenAI deployment to get predictions. In this way, you don't need to manage permissions for each endpoint user. To give the identity of the compute cluster access to the Azure OpenAI resource, follow these steps:
101
+
You can configure the identity of the compute cluster to have access to the Azure OpenAI deployment to get predictions. In this way, you don't need to manage permissions for each endpoint user. To give the identity of the compute cluster access to the Azure OpenAI resource, follow these steps:
101
102
102
103
1. Assign an identity to the compute cluster that your deployment uses. This example uses a compute cluster called **batch-cluster-lp** and a system-assigned managed identity, but you can use other alternatives. If your compute cluster already has an assigned identity, you can skip this step.
103
104
@@ -106,7 +107,7 @@ You can configure the identity of the compute instance to have access to the Azu
106
107
az ml compute update --name $COMPUTE_NAME --identity-type system_assigned
107
108
```
108
109
109
-
1. Get the managed identity principal ID assigned to the compute cluster you plan to use.
110
+
1. Get the managed identity principal ID that's assigned to the compute cluster you plan to use.
110
111
111
112
```azurecli
112
113
PRINCIPAL_ID=$(az ml compute show -n $COMPUTE_NAME --query identity.principal_id)
@@ -119,39 +120,39 @@ You can configure the identity of the compute instance to have access to the Azu
119
120
RESOURCE_ID=$(az group show -g $RG --query "id" -o tsv)
120
121
```
121
122
122
-
1. Grant the role **Cognitive Services User** to the managed identity:
123
+
1. Assign the **Cognitive Services User** role to the managed identity:
123
124
124
125
```azurecli
125
126
az role assignment create --role "Cognitive Services User" --assignee $PRINCIPAL_ID --scope $RESOURCE_ID
126
127
```
127
128
128
-
If you get an error message about not finding a user or service principal in the graph database for your principal, check your role assignments. You might need to assign yourself a Global Administrator or Application Administrator role.
129
-
130
129
# [Access keys](#tab/keys)
131
130
132
-
You can configure the batch deployment to use the access key of your OpenAI resource to get predictions. Copy the access key from your account, and keep it for later steps.
131
+
You can configure the batch deployment to use the access key of your Azure OpenAI resource to get predictions. Copy the access key from your account, and keep it for later steps.
133
132
134
133
---
135
134
136
135
## Register the OpenAI model
137
136
138
137
Model deployments in batch endpoints can deploy only registered models. You can use MLflow models with the flavor OpenAI to create a model in your workspace that references a deployment in Azure OpenAI.
139
138
140
-
In the cloned repository, the **model** folder contains an MLflow model that generates embeddings based on the ADA-002 model.
139
+
In the cloned repository, the *model* folder contains an MLflow model that generates embeddings based on the ADA-002 model.
To deploy the OpenAI model, you need to create an endpoint, an environment, a scoring script, and a batch deployment. The following sections show you how to create these components.
155
+
To deploy the OpenAI model, you need to create an endpoint, an environment, a scoring script, and a batch deployment. The following sections show you how to set up these components.
155
156
156
157
### Create an endpoint
157
158
@@ -167,6 +168,8 @@ An endpoint is needed to host the model. Take the following steps to create an e
The scoring script in this example uses some libraries that aren't part of the standard OpenAI SDK. Create an environment that contains a base image and also a conda YAML file to capture those dependencies:
195
202
196
203
# [Azure CLI](#tab/cli)
197
204
198
-
The *environment* folder contains a file named *environment.yml* that configures the environment.
205
+
The environment definition consists of the following lines, which are included in the deployment definition.
For testing the endpoint, you use a sample of the dataset [BillSum: A Corpus for Automatic Summarization of US Legislation](https://arxiv.org/abs/1910.00523). This sample is included in the repository, in the *data* folder.
296
+
For testing the endpoint, you use a sample of the dataset [BillSum: A Corpus for Automatic Summarization of US Legislation](https://arxiv.org/abs/1910.00523). This sample is included in the *data* folder of cloned repository.
Copy file name to clipboardExpand all lines: articles/machine-learning/includes/azureml-batch-prereqs.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ ms.author: cacrest
11
11
- The following permissions in the Azure Machine Learning workspace:
12
12
- For creating or managing batch endpoints and deployments: Use an Owner, Contributor, or Custom role that has been assigned the `Microsoft.MachineLearningServices/workspaces/batchEndpoints/*` actions.
13
13
- For creating Azure Resource Manager deployments in the workspace resource group: Use an Owner, Contributor, or Custom role that has been assigned the `Microsoft.Resources/deployments/write` action in the resource group where the workspace is deployed.
14
-
- The following software to work with Azure Machine Learning:
14
+
- The Azure Machine Learning CLI or the Azure Machine Learning SDK for Python:
0 commit comments