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
help: The available cuda version. (Only relevant when using a remote orchestrator)
72
68
choices:
73
69
CUDA 11.8: cuda11.8
74
70
CUDA 12.1: cuda12.1
75
71
default: cuda11.8
76
-
huggingface_merged_model_repository:
72
+
system_prompt:
77
73
type: str
78
-
help: The huggingface repository to which the finetuned model should be pushed [Optional]
79
-
default: ""
80
-
huggingface_adapter_model_repository:
74
+
help: |
75
+
The system prompt to be used for the finetuning job.
76
+
default: |
77
+
Given a target sentence construct the underlying meaning representation of the input sentence as a single function with attributes and attribute values.
78
+
This function should describe the target string accurately and the function must be one of the following ['inform', 'request', 'give_opinion', 'confirm', 'verify_attribute', 'suggest', 'request_explanation', 'recommend', 'request_attribute'].
79
+
The attributes must be one of the following: ['name', 'exp_release_date', 'release_year', 'developer', 'esrb', 'rating', 'genres', 'player_perspective', 'has_multiplayer', 'platforms', 'available_on_steam', 'has_linux_release', 'has_mac_release', 'specifier']
80
+
dataset_name:
81
81
type: str
82
-
help: The huggingface repository to which the finetuned adapter should be pushed [Optional]
83
-
default: ""
82
+
help: |
83
+
The dataset to be used for the finetuning job.
84
+
default: gem/viggo
85
+
step_operator:
86
+
type: str
87
+
help: The operator to be used for the finetuning and evaluation jobs.
Copy file name to clipboardExpand all lines: template/README.md
+32-73Lines changed: 32 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# ☮️ Fine-tuning open source LLMs using MLOps pipelines
1
+
# ☮️ Fine-tuning open source LLMs using MLOps pipelines with PEFT
2
2
3
-
Welcome to your newly generated "{{project_name}}" project! This is
3
+
Welcome to your newly generated "ZenML LLM PEFT Finetuning project" project! This is
4
4
a great way to get hands-on with ZenML using production-like template.
5
5
The project contains a collection of ZenML steps, pipelines and other artifacts
6
6
and useful resources that can serve as a solid starting point for finetuning open-source LLMs using ZenML.
@@ -15,13 +15,13 @@ Using these pipelines, we can run the data-preparation and model finetuning with
15
15
<br/>
16
16
</div>
17
17
18
-
## :earth_americas: Inspiration and Credit
18
+
## 🌎 Inspiration and Credit
19
19
20
-
This project heavily relies on the [Lit-GPT project](https://github.com/Lightning-AI/litgpt) of the amazing people at Lightning AI. We used [this blogpost](https://lightning.ai/pages/community/lora-insights/#toc14) to get started with LoRA and QLoRA and modified the commands they recommend to make them work using ZenML.
20
+
This project heavily relies on the [PEFT project](https://huggingface.co/docs/peft/en/index) by the amazing people at Hugging Face and the [`{{ model_repository }}`](https://huggingface.co/{{ model_repository }}) model from the amazing people at {{ model_repository.split("/") | first }}.
21
21
22
22
## 🏃 How to run
23
23
24
-
In this project we provide a few predefined configuration files for finetuning models on the [Alpaca](https://huggingface.co/datasets/tatsu-lab/alpaca) dataset. Before we're able to run any pipeline, we need to set up our environment as follows:
24
+
In this project, we provide a predefined configuration file to finetune models on the [{{ dataset_name }}](https://huggingface.co/datasets/{{ dataset_name }}) dataset. Before we're able to run any pipeline, we need to set up our environment as follows:
25
25
26
26
```bash
27
27
# Set up a Python virtual environment, if you haven't already
@@ -30,60 +30,32 @@ source .venv/bin/activate
30
30
31
31
# Install requirements
32
32
pip install -r requirements.txt
33
-
34
-
{%- if zenml_server_url %}
35
-
# Connect to your remote ZenML server
36
-
zenml connect --url {{ zenml_server_url }}
37
-
{%- endif %}
38
-
{%- if (huggingface_merged_model_repository or huggingface_adapter_model_repository) %}
39
-
# Create a secret with your Huggingface token to push the finetuned model/adapter
### Combined feature engineering and finetuning pipeline
45
-
46
-
The easiest way to get started with just a single command is to run the finetuning pipeline with the `finetune-alpaca.yaml` configuration file, which will do both feature engineering and finetuning:
When running the pipeline like this, the trained adapter will be stored in the ZenML artifact store. You can optionally upload the adapter, the merged model or both by specifying the `adapter_output_repo` and `merged_output_repo` parameters in the configuration file.
53
-
54
-
55
-
### Evaluation pipeline
56
-
57
-
Before running this pipeline, you will need to fill in the `adapter_repo`in the `eval.yaml` configuration file. This should point to a huggingface repository that contains the finetuned adapter you got by running the finetuning pipeline.
58
-
59
-
```shell
60
-
python run.py --eval-pipeline --config eval.yaml
61
33
```
62
34
63
-
### Merging pipeline
35
+
### 👷 Combined feature engineering and finetuning pipeline
64
36
65
-
In case you have trained an adapter using the finetuning pipeline, you can merge it with the base model by filling in the `adapter_repo` and `output_repo` parameters in the `merge.yaml` file, and then running:
37
+
The easiest way to get started with just a single command is to run the finetuning pipeline with the `orchestrator_finetune.yaml` configuration file, which will do data preparation, model finetuning, evaluation with [Rouge](https://huggingface.co/spaces/evaluate-metric/rouge)and promotion:
If you want to finetune your model on a different dataset, you can do so by running the feature engineering pipeline followed by the finetuning pipeline. To define your dataset, take a look at the `scripts/prepare_*` scripts and set the dataset name in the `feature-alpaca.yaml` config file.
43
+
When running the pipeline like this, the trained model will be stored in the ZenML artifact store.
<img alt="Model version metadata" src=".assets/pipeline.png">
49
+
</a>
50
+
<br/>
51
+
</div>
79
52
80
-
## ☁️ Running with a remote stack
53
+
## ☁️ Running with a step operator in the stack
81
54
82
55
To finetune an LLM on remote infrastructure, you can either use a remote orchestrator or a remote step operator. Follow these steps to set up a complete remote stack:
83
56
- Register the [orchestrator](https://docs.zenml.io/stacks-and-components/component-guide/orchestrators) (or [step operator](https://docs.zenml.io/stacks-and-components/component-guide/step-operators)) and make sure to configure it in a way so that the finetuning step has access to a GPU with at least 24GB of VRAM. Check out our docs for more [details](https://docs.zenml.io/stacks-and-components/component-guide).
84
57
- To access GPUs with this amount of VRAM, you might need to increase your GPU quota ([AWS](https://docs.aws.amazon.com/servicequotas/latest/userguide/request-quota-increase.html), [GCP](https://console.cloud.google.com/iam-admin/quotas), [Azure](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-manage-quotas?view=azureml-api-2#request-quota-and-limit-increases)).
85
58
- The GPU instance that your finetuning will be running on will have CUDA drivers of a specific version installed. If that CUDA version is not compatible with the one provided by the default Docker image of the finetuning pipeline, you will need to modify it in the configuration file. See [here](https://hub.docker.com/r/pytorch/pytorch/tags) for a list of available PyTorch images.
86
-
- If you're running out of memory, you can experiment with quantized LoRA (QLoRA) by setting a different value for the `quantize` parameter in the configuration, or reduce the `global_batch_size`/`micro_batch_size`.
87
59
- Register a remote [artifact store](https://docs.zenml.io/stacks-and-components/component-guide/artifact-stores) and [container registry](https://docs.zenml.io/stacks-and-components/component-guide/container-registries).
88
60
- Register a stack with all these components
89
61
```shell
@@ -93,43 +65,30 @@ To finetune an LLM on remote infrastructure, you can either use a remote orchest
93
65
[-s <STEP_OPERATOR_NAME>]
94
66
```
95
67
96
-
## 💾 Running with custom data
97
-
98
-
To finetune a model with your custom data, you will need to convert it to a CSV file with the columns described
Next, update the `configs/feature-custom.yaml` file and set the value of the `csv_path` parameter to that CSV file.
102
-
With all that in place, you can now run the feature engineering pipeline to convert your CSV into the correct format for training and then run the finetuning pipeline as follows:
0 commit comments