Skip to content

Commit 84623e1

Browse files
committed
Merge branch 'main' of https://github.com/Azure/azureml-examples into vaibhj/sparkPipeline
2 parents 701483a + d5adb29 commit 84623e1

File tree

27 files changed

+1359
-50
lines changed

27 files changed

+1359
-50
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Distillation with CLI (Summarization)
2+
3+
## 1. Create the Job
4+
Ensure you have the proper setup.
5+
1. Run `az version` and ensure the `ml` extension is installed. `ml` version should be greater or equal to 2.32.0.
6+
2. If the `ml` extension is not installed, run `az extension add -n ml`
7+
8+
Run the Distillation CLI command pointing to the .YAML file in this folder and fill out the Azure ML IDs needed:
9+
10+
```text
11+
az ml job create --file distillation_summarization.yaml --workspace-name [YOUR_AZURE_WORKSPACE] --resource-group [YOUR_AZURE_RESOURCE_GROUP] --subscription [YOUR_AZURE_SUBSCRIPTION]
12+
```
13+
14+
**Note:** To see how the train and validation files were created, see section 2 of this [notebook](/sdk/python/foundation-models/system/distillation/summarization/distillation_summarization.ipynb)
15+
16+
## 2. Deploy to Endpoint
17+
Once the distilled model is ready, you can deploy the model through the UI or CLI.
18+
19+
### UI Deployment
20+
1. Navigate to the `model` tab in [ml studio](https://ml.azure.com) or navigate to the `Finetuning` tab in the [ai platform](https://ai.azure.com)
21+
2. If using the ml studio, locate the model using the `name` of the `registered_model` in the yaml file used to create this job. Select deploy to deploy a serverless endpoint. If using the ai platform, search for the name of the job, which in this example is `Distillation-summarization-llama`. Click on that name, and select Deploy to deploy a serverless endpoint.
22+
23+
### CLI Deployment
24+
Fill out the serverless_endpoint.yaml file in this folder. The necessary information can be found by
25+
1. Navigating to the `model` tab in [ml studio](https://ml.azure.com).
26+
2. Using the `name` of the `registered_model` in the yaml file used to create this job, select the model with that `name`. In this example, the name to use is `llama-summarization-distilled`
27+
3. Use the `asset_id` to fill out the `model_id` in the yaml.
28+
29+
With the information filled out, run the command
30+
31+
```text
32+
az ml serverless-endpoint create -f serverless_endpoint.yaml
33+
```
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
type: distillation
2+
3+
name: "Distillation-summarization-llama"
4+
description: "Distill student model using a teacher model"
5+
experiment_name: "Distillation-summarization"
6+
7+
# Data Generation Properties
8+
data_generation_type: label_generation
9+
data_generation_task_type: summarization
10+
11+
# Input data
12+
training_data:
13+
type: uri_file
14+
path: ./train_summarization.jsonl
15+
validation_data:
16+
type: uri_file
17+
path: ./validation_summarization.jsonl
18+
19+
# Teacher model serverless endpoint information
20+
teacher_model_endpoint_connection:
21+
type: serverless
22+
name: Meta-Llama-3-1-405B-Instruct-vkn
23+
endpoint: https://Meta-Llama-3-1-405B-Instruct-vkn.westus3.models.ai.azure.com/chat/completions
24+
api_key: EXAMPLE_API_KEY
25+
26+
# Model ID
27+
student_model: azureml://registries/azureml-meta/models/Meta-Llama-3.1-8B-Instruct/versions/2
28+
29+
# Output distilled model
30+
outputs:
31+
registered_model:
32+
type: mlflow_model
33+
name: llama-summarization-distilled
34+
35+
36+
# Teacher model related properties (OPTIONAL)
37+
teacher_model_settings:
38+
inference_parameters:
39+
temperature: 0.8
40+
max_tokens: 1024
41+
top_p: 0.95
42+
endpoint_request_settings:
43+
request_batch_size: 10
44+
min_endpoint_success_ratio: 0.7
45+
46+
# System prompt settings (OPTIONAL)
47+
prompt_settings:
48+
enable_chain_of_density: true
49+
max_len_summary: 80
50+
51+
# For finetuning (OPTIONAL)
52+
hyperparameters:
53+
learning_rate_multiplier: "0.2"
54+
n_epochs: "5"
55+
batch_size: "2"
56+
57+
# Resource for Data Generation Step (OPTIONAL)
58+
resources:
59+
instance_type: Standard_D2_v2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: llama-summarization-distilled
2+
model_id: azureml://locations/{AI_PROJECT_LOCATION}/workspaces/{WORKSPACE_ID}/models/llama-summarization-distilled/versions/{VERSION}

cli/foundation-models/system/distillation/summarization/validation_summarization.jsonl

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.

cli/jobs/automl-standalone-jobs/cli-automl-classification-task-bankmarketing/cli-automl-classification-task-bankmarketing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test_data:
3030
limits:
3131
timeout_minutes: 180
3232
max_trials: 40
33-
max_concurrent_trials: 5
33+
# max_concurrent_trials: 5
3434
trial_timeout_minutes: 20
3535
enable_early_termination: true
3636
exit_score: 0.92

sdk/python/dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ tensorflow==2.9.3
1010
tensorflow-hub==0.15.0
1111
transformers==4.34.0
1212
keras==2.9
13-
jupyter-client==7.4.9
13+
jupyter-client==7.4.9

sdk/python/foundation-models/meta-llama3/langchain.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Use LangChain with Meta Llama 3 in Azure AI and Azure ML\n",
7+
"# Use LangChain with Meta Llama 3 family of models in Azure AI and Azure ML\n",
88
"\n",
9-
"You can use Meta-Llama-3 models deployed in Azure AI and Azure ML with `langchain` to create more sophisticated intelligent applications. Use `langchain_community` package with the Azure Machine Learning integration."
9+
"You can use Meta-Llama-3 models family of models deployed in Azure AI and Azure ML with `langchain` to create more sophisticated intelligent applications. Use `langchain_community` package with the Azure Machine Learning integration."
1010
]
1111
},
1212
{
@@ -20,7 +20,7 @@
2020
"* Register for a valid Azure account with subscription \n",
2121
"* Make sure you have access to [Azure AI Studio](https://learn.microsoft.com/en-us/azure/ai-studio/what-is-ai-studio?tabs=home)\n",
2222
"* Create a project and resource group\n",
23-
"* Select Meta-Llama-3 models from Model catalog. This example assumes you are deploying `Meta-Llama-3-70B-Instruct`.\n",
23+
"* Select one of Meta-Llama-3 family of models from Model catalog. This example assumes you are deploying `Meta-Llama-3-70B-Instruct`.\n",
2424
"\n",
2525
" > Notice that some models may not be available in all the regions in Azure AI and Azure Machine Learning. On those cases, you can create a workspace or project in the region where the models are available and then consume it with a connection from a different one. To learn more about using connections see [Consume models with connections](https://learn.microsoft.com/en-us/azure/ai-studio/how-to/deployments-connections)\n",
2626
"\n",

sdk/python/foundation-models/system/distillation/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ We currently support numerous task types for model distillation. To view example
4747
- [Conversation](./conversation/distillation_conversational_task.ipynb)
4848
- [NLU QA (Natural Language Understanding Question and Answer)](./nlu_qa/distillation_nlu_qa_task.ipynb)
4949
- [Math](./math/distillation_math.ipynb)
50+
- [Summarization](./summarization/distillation_summarization.ipynb)
5051

5152
### CLI Examples
5253
- [NLI (Natural Language Interpretation)](/cli/foundation-models/system/distillation/nli/README.md)
5354
- [Conversation](/cli/foundation-models/system/distillation/conversation/README.md)
5455
- [NLU QA (Natural Language Understanding Question and Answer)](/cli/foundation-models/system/distillation/nlu_qa/README.md)
5556
- [Math](/cli/foundation-models/system/distillation/math/README.md)
57+
- [Summarization](/cli/foundation-models/system/distillation/summarization/README.md)

sdk/python/foundation-models/system/distillation/conversation/distillation_conversational_task.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
"\n",
350350
"# If validation data was registered to workspace already, navigate to the Data tab, select the data to use and use the 'Named asset URI'.\n",
351351
"# Example of the format is seen below\n",
352-
"# train_data = \"azureml:validation_conversation_quora:1\""
352+
"# valid_data = \"azureml:validation_conversation_quora:1\""
353353
]
354354
},
355355
{

sdk/python/foundation-models/system/distillation/math/distillation_math.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
"valid_data = Input(type=AssetTypes.URI_FILE, path=valid_data_path)\n",
350350
"\n",
351351
"# If validation data was registered to workspace already, navigate to the Data tab, select the data to use and use the 'Named asset URI'\n",
352-
"# train_data = \"azureml:math_valid_multi_arith:1\""
352+
"# valid_data = \"azureml:math_valid_multi_arith:1\""
353353
]
354354
},
355355
{

0 commit comments

Comments
 (0)