-
Notifications
You must be signed in to change notification settings - Fork 23
Add parameters to FineTune #92
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
Merged
thiago-aixplain
merged 6 commits into
main
from
M-5470304031-addFinetunePromptParameters
Nov 17, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3f79795
Add parameters to FineTune
lucas-aixplain b8973c1
Address PR comments and add finetune to modules folder
lucas-aixplain 8a03a8e
Add dataclasses-json dependency
lucas-aixplain 6346424
Model Removal service M-5376311900
thiago-aixplain 1a8410f
Deletion model on Model class
thiago-aixplain 985509e
Update finetune functional test to run on all envs
lucas-aixplain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| from typing import List, Text | ||
| from aixplain.modules.dataset import Dataset | ||
| import re | ||
|
|
||
|
|
||
| def _get_data_list(dataset: Dataset): | ||
| flatten_target_values = [item for sublist in list(dataset.target_data.values()) for item in sublist] | ||
| data_list = list(dataset.source_data.values()) + flatten_target_values | ||
| return data_list | ||
|
|
||
|
|
||
| def validate_prompt(prompt: Text, dataset_list: List[Dataset]) -> Text: | ||
| result_prompt = prompt | ||
| referenced_data = set(re.findall("<<(.+?)>>", prompt)) | ||
| for dataset in dataset_list: | ||
| data_list = _get_data_list(dataset) | ||
| for data in data_list: | ||
| if data.id in referenced_data: | ||
| result_prompt = result_prompt.replace(f"<<{data.id}>>", f"<<{data.name}>>") | ||
| referenced_data.remove(data.id) | ||
| referenced_data.add(data.name) | ||
|
|
||
| # check if dataset list has same data name and it is referenced | ||
| name_set = set() | ||
| for dataset in dataset_list: | ||
| data_list = _get_data_list(dataset) | ||
| for data in data_list: | ||
| assert not ( | ||
| data.name in name_set and data.name in referenced_data | ||
| ), "Datasets must not have more than one referenced data with same name" | ||
| name_set.add(data.name) | ||
|
|
||
| # check if all referenced data have a respective data in dataset list | ||
| for dataset in dataset_list: | ||
| data_list = _get_data_list(dataset) | ||
| for data in data_list: | ||
| if data.name in referenced_data: | ||
| result_prompt = result_prompt.replace(f"<<{data.name}>>", f"{{{data.name}}}") | ||
| referenced_data.remove(data.name) | ||
| assert len(referenced_data) == 0, "Referenced data are not present in dataset list" | ||
| return result_prompt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from dataclasses import dataclass | ||
| from dataclasses_json import dataclass_json | ||
|
|
||
|
|
||
| @dataclass_json | ||
| @dataclass | ||
| class Hyperparameters(object): | ||
| epochs: int = 4 | ||
| train_batch_size: int = 4 | ||
| eval_batch_size: int = 4 | ||
| learning_rate: float = 2e-5 | ||
| warmup_steps: int = 500 | ||
| generation_max_length: int = 225 | ||
| tokenizer_batch_size: int = 256 | ||
| gradient_checkpointing: bool = False | ||
| gradient_accumulation_steps: int = 1 | ||
| max_seq_length: int = 4096 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from dataclasses import dataclass | ||
| from dataclasses_json import dataclass_json | ||
|
|
||
|
|
||
| @dataclass_json | ||
| @dataclass | ||
| class Peft(object): | ||
| peft_lora_r: int = 8 | ||
| peft_lora_alpha: int = 32 | ||
| peft_lora_dropout: float = 0.05 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [ | ||
| { | ||
| "model_name": "Chat GPT 3.5", | ||
| "dataset_name": "Test text generation dataset", | ||
| "inference_data": "Hello!" | ||
| }, | ||
| { | ||
| "model_name": "GPT2", | ||
| "dataset_name": "Test text generation dataset", | ||
| "inference_data": "Hello!" | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,5 @@ | ||
| [ | ||
| { | ||
| "function": "translation", | ||
| "source_language": {"language": "en", "dialect": ""}, | ||
| "target_language": {"language": "fr", "dialect": ""} | ||
| }, | ||
| { | ||
| "function": "speech-recognition", | ||
| "source_language": {"language": "en", "dialect": ""} | ||
| "function": "text-generation" | ||
| } | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.