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 Chat-Completion/Text-Generation MaaS FineTuning Samples. #3480

Merged
merged 5 commits into from
Jan 8, 2025
Merged
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/cli/monitoring/generation-safety-quality-monitoring.yaml @ahughes-msft @yunjie-hub
/cli/monitoring/model-monitoring-with-collected-data.yaml @ahughes-msft @yunjie-hub
/cli/monitoring/out-of-box-monitoring.yaml @ahughes-msft @yunjie-hub
/cli/jobs/finetuning @amltres @sasum @marici
/sdk/python/foundation-models/benchmarking/evaluating_claude_models.ipynb @arun-rajora
/sdk/python/foundation-models/benchmarking/evaluating_oai_models.ipynb @arun-rajora
/sdk/python/foundation-models/benchmarking/evaluation_pipelines/* @arun-rajora
Expand All @@ -23,6 +24,7 @@ sdk/python/foundation-models/cohere/command_tools-langchain.ipynb @stewart-co @k
/sdk/python/foundation-models/nixtla/ @AzulGarza
/sdk/python/foundation-models/healthcare-ai/ @jmerkow @ivantarapov
/sdk/python/assets/data/versioning.ipynb @ShakutaiGit
/sdk/python/jobs/finetuning @amltres @sasum @marici

#### files referenced in docs (DO NOT EDIT, except for Docs team!!!) #############################################################################################
/cli/assets/component/train.yml @sdgilley @msakande @Blackmist @ssalgadodev @lgayhardt @fbsolo-ms1
Expand Down
56 changes: 56 additions & 0 deletions cli/jobs/finetuning/standalone/finetuning-job-cliv2-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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:
sagarsumant marked this conversation as resolved.
Show resolved Hide resolved

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

**Note**: MaaS finetuning is supported in following regions due to capacity constraints.
* Llama models can only be finetuned in westus3 region.
* All other models which support MaaS Finetuning can be finetuned in eastus2 region

### 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 <<resource-group-name>> --workspace-name <<azureml-workspace-or-project-name>> --name "ft-maap-llama3-instance-types-1209-01"
```

#### 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 <<resource-group-name>>: Specifies the Azure resource group.
* --workspace-name <<azureml-workspace-or-project-name>>: Specifies the Azure Machine Learning workspace.
* --name "ft-maap-llama3-instance-types-1209-01": Specifies the name of the job.

sagarsumant marked this conversation as resolved.
Show resolved Hide resolved
##### InputData
Each sample has input data files provided.
* train.jsonl - This contains training data.
* validation.jsonl - This contains validation data.

Note that these files are for demo purposes only.

Sample Yaml file for generating FineTuningJob using azureml CLIV2

**Text Generation FineTuning (Model-As-A-Service)**
1. [finetuning-with-amlcompute](./model-as-a-service/text-generation/text-generation-finetuning.yaml)

**ChatCompletion FineTuning (Model-As-A-Service)**
1. [finetuning-with-amlcompute](./model-as-a-service/chat-completion/chat-completion-finetuning.yaml)


Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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
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,2 @@
## How to run FineTuningJob using AzureML CLIV2?
[Running FineTuningJob Using AzureML CLIV2](../../finetuning-job-cliv2-readme.md)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## How to run FineTuningJob using AzureML CLIV2?
[Running FineTuningJob Using AzureML CLIV2](../../finetuning-job-cliv2-readme.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type: finetuning

name: "llama-3-8B-with-compute"
experiment_name: "llama-3-8B-finetuning-experiment"
display_name: "llama3-8B-display-name"
task: text_completion
model_provider: custom
model:
path: "azureml://registries/azureml-meta/models/Meta-Llama-3-8B/versions/8"
type: mlflow_model
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: "llama-3-8B-finetuned-model"
type: mlflow_model
Loading
Loading