Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Text-Generation/Chat MaaP FineTuning sample #3459

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Running a Fine-Tuning Job from CLI

This guide provides instructions on how to run a fine-tuning job using the Azure Machine Learning CLI v2.

## Prerequisites

1. **Azure CLI**: Ensure you have the Azure CLI installed. If not, you can install it from [here](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli).

2. **Azure Machine Learning CLI v2**: Install the Azure Machine Learning CLI extension v2.
```bash
az extension add -n ml -y
```

3. **Azure Subscription**: Ensure you have an active Azure subscription and the necessary permissions to create and manage resources.

4. **Resource Group and Workspace**: Ensure you have an Azure resource group and an Azure Machine Learning workspace. If not, you can create them using the following commands:

```bash
az group create --name <resource-group-name> --location <location>
az ml workspace create --name <workspace-name> --resource-group <resource-group-name> --location <location>
```

### Running the Fine-Tuning Job
To run the fine-tuning job, use the following command:

```bash
az ml job create --file text-generation-finetuning-amlcompute.yaml --resource-group hyperdrive-service-static-rg --workspace-name train-finetune-dev-eastus --name "ft-maap-llama3-instance-types-1209-01"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using instead of hardcoded values for rg, ws etc.

```

#### Command Breakdown
* az ml job create: Command to create and run a job in Azure Machine Learning.
* --file text-generation-finetuning-amlcompute.yaml: Specifies the YAML file that defines the job configuration.
* --resource-group hyperdrive-service-static-rg: Specifies the Azure resource group.
* --workspace-name train-finetune-dev-eastus: Specifies the Azure Machine Learning workspace.
* --name "ft-maap-llama3-instance-types-1209-01": Specifies the name of the job.

Sample Yaml file for generating FineTuningJob using azureml CLIV2

**Text Generation FineTuning**
1. [finetuning-with-amlcompute](./model-as-a-platform/text-generation/text-generation-finetuning-amlcompute.yaml)
2. [finetuning-with-instance-types](./model-as-a-platform/text-generation/text-generation-finetuning-instance-types.yaml)

**ChatCompletion FineTuning**
1. [finetuning-with-amlcompute](./model-as-a-platform/chat/chat-completion-finetuning-amlcompute.yaml)
2. [finetuning-with-instance-types](./model-as-a-platform/chat/chat-completion-finetuning-instance-types.yaml)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
type: finetuning

name: "Phi-3-mini-4k-instruct-with-amlcompute"
experiment_name: "Phi-3-mini-4k-instruct-finetuning-experiment"
display_name: "Phi-3-mini-4k-instruct-display-name"
task: chat_completion
model_provider: custom
model:
path: "azureml://registries/azureml/models/Phi-3-mini-4k-instruct/versions/14"
type: mlflow_model
compute: "lowpri-a100"
training_data: train.jsonl
validation_data:
path: validation.jsonl
type: uri_file
hyperparameters:
num_train_epochs: "1"
per_device_train_batch_size: "1"
learning_rate: "0.00002"
properties:
my_property: "my_value"
tags:
foo_tag: "bar"
outputs:
registered_model:
name: "Phi-3-mini-4k-instruct-finetuned-model"
type: mlflow_model
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
type: finetuning

name: "Phi-3-mini-4k-instruct-with-instance-types"
experiment_name: "Phi-3-mini-4k-instruct-finetuning-experiment-instance-types"
display_name: "Phi-3-mini-4k-instruct-display-name"
task: chat_completion
model_provider: custom
model:
path: "azureml://registries/azureml/models/Phi-3-mini-4k-instruct/versions/14"
type: mlflow_model
resources:
instance_types:
# You can specify multiple instance types for the training job
# Backend will decide which instance type to use based on the constraints on training job.
- "Standard_NC96ads_A100_v4"
- "Standard_E4s_v3"
training_data: train.jsonl
validation_data:
path: validation.jsonl
type: uri_file
hyperparameters:
num_train_epochs: "1"
per_device_train_batch_size: "1"
learning_rate: "0.00002"
properties:
my_property: "my_value"
tags:
foo_tag: "bar"
outputs:
registered_model:
name: "Phi-3-mini-4k-instruct-finetuned-model"
type: mlflow_model
Loading
Loading