Skip to content

Commit ae549df

Browse files
committed
Update text
1 parent 3590124 commit ae549df

File tree

3 files changed

+56
-51
lines changed

3 files changed

+56
-51
lines changed

articles/machine-learning/how-to-use-batch-model-openai-embeddings.md

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,108 @@
11
---
2-
title: 'Run OpenAI models in batch endpoints'
2+
title: Run OpenAI models in batch endpoints
33
titleSuffix: Azure Machine Learning
44
description: In this article, learn how to use batch endpoints with OpenAI models.
55
services: machine-learning
66
ms.service: azure-machine-learning
77
ms.subservice: inferencing
8-
ms.topic: conceptual
8+
ms.topic: how-to
99
author: msakande
1010
ms.author: mopeakande
1111
ms.reviewer: cacrest
12-
ms.date: 11/04/2023
12+
ms.date: 11/13/2024
1313
ms.custom: how-to, devplatv2, update-code
1414
---
1515

1616
# Run OpenAI models in batch endpoints to compute embeddings
1717

1818
[!INCLUDE [cli v2](includes/machine-learning-dev-v2.md)]
1919

20-
Batch Endpoints can deploy models to run inference over large amounts of data, including OpenAI models. In this example, you learn how to create a batch endpoint to deploy ADA-002 model from OpenAI to compute embeddings at scale but you can use the same approach for completions and chat completions models. It uses Microsoft Entra authentication to grant access to the Azure OpenAI resource.
20+
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.
2121

22-
## About this example
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.
2323

24-
In this example, we're going to compute embeddings over a dataset using ADA-002 model from OpenAI. We will register the particular model in MLflow format using the OpenAI flavor which has support to orchestrate all the calls to the OpenAI service at scale.
24+
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+
## Prerequisites
27+
28+
[!INCLUDE [machine-learning-batch-prereqs](includes/azureml-batch-prereqs.md)]
29+
30+
## Clone the examples repository
2531

2632
[!INCLUDE [machine-learning-batch-clone](includes/azureml-batch-clone-samples.md)]
2733

28-
The files for this example are in:
34+
Use the following command to go to the folder for this example:
35+
36+
# [Azure CLI](#tab/cli)
2937

3038
```azurecli
3139
cd endpoints/batch/deploy-models/openai-embeddings
3240
```
3341

34-
### Follow along in Jupyter Notebooks
35-
36-
You can follow along this sample in the following notebooks. In the cloned repository, open the notebook: [deploy-and-test.ipynb](https://github.com/Azure/azureml-examples/blob/main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb).
42+
# [Python SDK](#tab/python)
3743

38-
## Prerequisites
39-
40-
[!INCLUDE [machine-learning-batch-prereqs](includes/azureml-batch-prereqs.md)]
44+
```python
45+
cd endpoints/batch/deploy-models/openai-embeddings
46+
```
4147

48+
---
4249

43-
### Ensure you have an OpenAI deployment
50+
## Create an OpenAI resource
4451

45-
The example shows how to run OpenAI models hosted in Azure OpenAI Service. To successfully do it, you need an OpenAI resource correctly deployed in Azure and a deployment for the model you want to use.
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).
4653

4754
:::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.":::
4855

49-
Take note of the OpenAI resource being used. We use the name to construct the URL of the resource. Save the URL for later use on the tutorial.
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.
5057

5158
# [Azure CLI](#tab/cli)
5259

5360
```azurecli
5461
OPENAI_API_BASE="https://<your-azure-openai-resource-name>.openai.azure.com"
5562
```
5663

57-
# [Python](#tab/python)
64+
# [Python SDK](#tab/python)
5865

5966
```python
6067
openai_api_base="https://<your-azure-openai-resource-name>.openai.azure.com"
6168
```
6269

6370
---
6471

65-
### Ensure you have a compute cluster where to deploy the endpoint
72+
## Create a compute cluster
6673

67-
Batch endpoints use compute cluster to run the models. In this example, we use a compute cluster called **batch-cluster**. We create the compute cluster here but you can skip this step if you already have one:
74+
Batch endpoints use a compute cluster to run models. Use the following code to create a compute cluster called **batch-cluster-lp**. If you already have a compute cluster, you can skip this step.
6875

6976
# [Azure CLI](#tab/cli)
7077

7178
```azurecli
72-
COMPUTE_NAME="batch-cluster"
73-
az ml compute create -n batch-cluster --type amlcompute --min-instances 0 --max-instances 5
79+
COMPUTE_NAME="batch-cluster-lp"
80+
az ml compute create -n batch-cluster-lp --type amlcompute --min-instances 0 --max-instances 5
7481
```
7582

76-
# [Python](#tab/python)
83+
# [Python SDK](#tab/python)
7784

7885
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=create_compute)]
7986

8087
---
8188

82-
### Decide in the authentication mode
89+
## Choose an authentication mode
8390

8491
You can access the Azure OpenAI resource in two ways:
8592

86-
* Using Microsoft Entra authentication (recommended).
87-
* Using an access key.
93+
* Microsoft Entra authentication (recommended)
94+
* An access key
8895

89-
Using Microsoft Entra is recommended because it helps you avoid managing secrets in the deployments.
96+
Using Microsoft Entra is recommended because it helps you avoid managing secrets in deployments.
9097

9198
# [Microsoft Entra authentication](#tab/ad)
9299

93-
You can configure the identity of the compute to have access to the Azure OpenAI deployment to get predictions. In this way, you don't need to manage permissions for each of the users using the endpoint. To configure the identity of the compute cluster get access to the Azure OpenAI resource, follow these steps:
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:
94101

95-
1. Ensure or assign an identity to the compute cluster your deployment uses. In this example, we use a compute cluster called **batch-cluster** and we assign a system assigned managed identity, but you can use other alternatives.
102+
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.
96103

97104
```azurecli
98-
COMPUTE_NAME="batch-cluster"
105+
COMPUTE_NAME="batch-cluster-lp"
99106
az ml compute update --name $COMPUTE_NAME --identity-type system_assigned
100107
```
101108
@@ -120,7 +127,7 @@ You can configure the identity of the compute to have access to the Azure OpenAI
120127
121128
# [Access keys](#tab/keys)
122129
123-
You can get an access key and configure the batch deployment to use the access key to get predictions. Grab the access key from your account and keep it for future reference in this tutorial.
130+
You can configure the batch deployment to use the OpenAI resource access key to get predictions. Copy the access key from your account, and keep it for later steps.
124131
125132
---
126133
@@ -154,7 +161,7 @@ Model deployments in batch endpoints can only deploy registered models. You can
154161
155162
:::code language="azurecli" source="~/azureml-examples-main/cli/endpoints/batch/deploy-models/openai-embeddings/deploy-and-run.sh" ID="register_model" :::
156163
157-
# [Python](#tab/python)
164+
# [Python SDK](#tab/python)
158165
159166
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=register_model)]
160167
@@ -167,7 +174,7 @@ Model deployments in batch endpoints can only deploy registered models. You can
167174
168175
:::code language="azurecli" source="~/azureml-examples-main/cli/endpoints/batch/deploy-models/openai-embeddings/deploy-and-run.sh" ID="name_endpoint" :::
169176
170-
# [Python](#tab/python)
177+
# [Python SDK](#tab/python)
171178
172179
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=name_endpoint)]
173180
@@ -182,7 +189,7 @@ Model deployments in batch endpoints can only deploy registered models. You can
182189
183190
:::code language="yaml" source="~/azureml-examples-main/cli/endpoints/batch/deploy-models/openai-embeddings/endpoint.yml":::
184191
185-
# [Python](#tab/python)
192+
# [Python SDK](#tab/python)
186193
187194
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=configure_endpoint)]
188195
@@ -192,7 +199,7 @@ Model deployments in batch endpoints can only deploy registered models. You can
192199
193200
:::code language="azurecli" source="~/azureml-examples-main/cli/endpoints/batch/deploy-models/openai-embeddings/deploy-and-run.sh" ID="create_endpoint" :::
194201
195-
# [Python](#tab/python)
202+
# [Python SDK](#tab/python)
196203
197204
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=create_endpoint)]
198205
@@ -204,7 +211,7 @@ Model deployments in batch endpoints can only deploy registered models. You can
204211
205212
:::code language="yaml" source="~/azureml-examples-main/cli/endpoints/batch/deploy-models/openai-embeddings/environment/environment.yml":::
206213
207-
# [Python](#tab/python)
214+
# [Python SDK](#tab/python)
208215
209216
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=configure_environment)]
210217
@@ -261,7 +268,7 @@ Model deployments in batch endpoints can only deploy registered models. You can
261268
> [!TIP]
262269
> Notice the `environment_variables` section where we indicate the configuration for the OpenAI deployment. The value for `OPENAI_API_BASE` will be set later in the creation command so you don't have to edit the YAML configuration file.
263270
264-
# [Python](#tab/python)
271+
# [Python SDK](#tab/python)
265272
266273
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=configure_deployment)]
267274
@@ -274,7 +281,7 @@ Model deployments in batch endpoints can only deploy registered models. You can
274281
275282
:::code language="azurecli" source="~/azureml-examples-main/cli/endpoints/batch/deploy-models/openai-embeddings/deploy-and-run.sh" ID="create_deployment" :::
276283
277-
# [Python](#tab/python)
284+
# [Python SDK](#tab/python)
278285
279286
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=create_deployment)]
280287
@@ -314,7 +321,7 @@ For testing our endpoint, we are going to use a sample of the dataset [BillSum:
314321
DATA_ASSET_ID=$(az ml data show -n bill_summarization --label latest | jq -r .id)
315322
```
316323
317-
# [Python](#tab/python)
324+
# [Python SDK](#tab/python)
318325
319326
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=configure_inputs)]
320327
@@ -326,7 +333,7 @@ For testing our endpoint, we are going to use a sample of the dataset [BillSum:
326333
JOB_NAME=$(az ml batch-endpoint invoke --name $ENDPOINT_NAME --set inputs.bill_summarization.type="uri_file" inputs.bill_summarization.path=$DATASET_ID --query name -o tsv)
327334
```
328335

329-
# [Python](#tab/python)
336+
# [Python SDK](#tab/python)
330337

331338
> [!TIP]
332339
> [!INCLUDE [batch-endpoint-invoke-inputs-sdk](includes/batch-endpoint-invoke-inputs-sdk.md)]
@@ -339,7 +346,7 @@ For testing our endpoint, we are going to use a sample of the dataset [BillSum:
339346

340347
:::code language="azurecli" source="~/azureml-examples-main/cli/endpoints/batch/deploy-models/openai-embeddings/deploy-and-run.sh" ID="show_job_in_studio" :::
341348

342-
# [Python](#tab/python)
349+
# [Python SDK](#tab/python)
343350

344351
[!notebook-python[] (~/azureml-examples-main/sdk/python/endpoints/batch/deploy-models/openai-embeddings/deploy-and-test.ipynb?name=get_job)]
345352

@@ -351,7 +358,7 @@ For testing our endpoint, we are going to use a sample of the dataset [BillSum:
351358

352359
:::code language="azurecli" source="~/azureml-examples-main/cli/endpoints/batch/deploy-models/openai-embeddings/deploy-and-run.sh" ID="download_outputs" :::
353360

354-
# [Python](#tab/python)
361+
# [Python SDK](#tab/python)
355362

356363
The deployment creates a child job that implements the scoring. Get a reference to that child job:
357364

articles/machine-learning/includes/azureml-batch-clone-samples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: ccrestana
66
ms.author: cacrest
77
---
88

9-
The example in this article is based on code samples contained in the [azureml-examples](https://github.com/azure/azureml-examples) repository. To run the commands locally without having to copy/paste YAML and other files, first clone the repo and then change directories to the folder:
9+
The example in this article is based on code samples contained in the [azureml-examples](https://github.com/azure/azureml-examples) repository. To run the commands locally without having to copy or paste YAML and other files, use the following commands to clone the repository and go to the folder for your coding language:
1010

1111
# [Azure CLI](#tab/cli)
1212

articles/machine-learning/includes/azureml-batch-prereqs.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ author: ccrestana
66
ms.author: cacrest
77
---
88

9-
- An Azure subscription. If you don't have an Azure subscription, create a free account before you begin. Try the [free or paid version of Azure Machine Learning](https://azure.microsoft.com/free/).
9+
- An Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
1010
- An Azure Machine Learning workspace. To create a workspace, see [Manage Azure Machine Learning workspaces](../how-to-manage-workspace.md).
11-
- Ensure that you have the following permissions in the Machine Learning workspace:
12-
13-
- Create or manage batch endpoints and deployments: Use an Owner, Contributor, or Custom role that allows `Microsoft.MachineLearningServices/workspaces/batchEndpoints/*`.
14-
- Create Azure Resource Manager deployments in the workspace resource group: Use an Owner, Contributor, or Custom role that allows `Microsoft.Resources/deployments/write` in the resource group where the workspace is deployed.
15-
16-
- Install the following software to work with Machine Learning:
11+
- The following permissions in the Azure Machine Learning workspace:
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+
- 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:
1715

1816
# [Azure CLI](#tab/cli)
1917

@@ -23,7 +21,7 @@ ms.author: cacrest
2321
az extension add -n ml
2422
```
2523

26-
Pipeline component deployments for Batch Endpoints are introduced in version 2.7 of the `ml` extension for the Azure CLI. Use the `az extension update --name ml` command to get the latest version.
24+
Pipeline component deployments for batch endpoints are introduced in version 2.7 of the `ml` extension for the Azure CLI. Use the `az extension update --name ml` command to get the latest version.
2725

2826
# [Python](#tab/python)
2927

@@ -39,7 +37,7 @@ ms.author: cacrest
3937

4038
### Connect to your workspace
4139

42-
The workspace is the top-level resource for Machine Learning. It provides a centralized place to work with all artifacts you create when you use Machine Learning. In this section, you connect to the workspace where you perform your deployment tasks.
40+
The workspace is the top-level resource for Azure Machine Learning. It provides a centralized place to work with all artifacts you create when you use Azure Machine Learning. In this section, you connect to the workspace where you perform your deployment tasks.
4341

4442
# [Azure CLI](#tab/cli)
4543

0 commit comments

Comments
 (0)