[QEff Finetune]: Adding steps about how to fine tune on any custom dataset. - #381
Conversation
Signed-off-by: Swati Allabadi <quic_sallabad@quicinc.com>
8485344 to
e757ab8
Compare
Signed-off-by: Swati Allabadi <quic_sallabad@quicinc.com>
quic-meetkuma
left a comment
There was a problem hiding this comment.
Good work in listing down the detailed steps for custom dataset, Swati! Please check on the comments. :)
|
|
||
| To run fine tuning for any user specific dataset, prepare the dataset using the following steps: | ||
|
|
||
| 1) Create a directory named 'dataset' inside efficient-transformers. |
There was a problem hiding this comment.
double space between "a" and "directory"
| def apply_prompt_template(): | ||
|
|
||
| def tokenize(): | ||
|
|
There was a problem hiding this comment.
Add some comment as "Implement tokenization and prepare inputs for the training."
|
|
||
| # load dataset | ||
| # based on split, retrieve only the specific portion of the dataset (train or eval) either here or at the last | ||
|
|
There was a problem hiding this comment.
Add one more comment as "Define a prompt template"
There was a problem hiding this comment.
It's already there. ( # define prompt)
| # based on split, retrieve only the specific portion of the dataset (train or eval) either here or at the last | ||
|
|
||
| def apply_prompt_template(): | ||
|
|
There was a problem hiding this comment.
Add some comment as "Convert the raw input into format as per the template defined earlier."
| 4) get_custom_dataset() should have following 4 parameters: dataset_config, tokenizer, split, context_length. This function gets called twice through Qefficient/cloud/finetune.py with the name get_preprocessed_dataset. | ||
| 5) Inside get_custom_dataset(), dataset needs to prepared for fine tuning. So, the user needs to apply prompt and tokenize the dataset accordingly. Please refer the below template on how to define get_custom_dataset(). | ||
| 6) For examples, please refer python files present in efficient-transformers/QEfficient/finetune/dataset. In case of Samsum dataset, get_preprocessed_samsum() of efficient-transformers/QEfficient/finetune/dataset/samsum_dataset.py is called. | ||
| 7) In efficient-transformers/QEfficient/finetune/configs/dataset_config.py, for custom_dataset class, pass the appropriate value for train_split and test_split according to the dataset keys corresponding to train and test data points. |
There was a problem hiding this comment.
I think this is no longer needed after PR#289. We can directly pass --train_split and --test_split from the CLI.
There was a problem hiding this comment.
Yes, correct! Thanks for pointing this. After PR 289, user can do this through both ways. Updated step #7 accordingly.
Signed-off-by: Swati Allabadi <quic_sallabad@quicinc.com>
f46f537 to
05a385a
Compare
| use_autocast: bool = True | ||
| val_batch_size: int = 1 | ||
| dataset = "samsum_dataset" | ||
| dataset = "alpaca_dataset" |
There was a problem hiding this comment.
Good that you have added this change in this gerrit.
|
|
||
| To run fine tuning for any user specific dataset, prepare the dataset using the following steps: | ||
|
|
||
| 1) Create a directory named 'dataset' inside efficient-transformers. |
There was a problem hiding this comment.
Add the location "at root of the repo."
| 1) Create a directory named 'dataset' inside efficient-transformers. | ||
| 2) Inside this directory, create a file named 'custom_dataset.py'. This is different than the custom_dataset.py present at efficient-transformers/QEfficient/finetune/dataset. | ||
| 3) Inside the newly created efficient-transformers/dataset/custom_dataset.py, define a function named 'get_custom_dataset'. | ||
| 4) get_custom_dataset() should have following 4 parameters: dataset_config, tokenizer, split, context_length. This function gets called twice through Qefficient/cloud/finetune.py with the name get_preprocessed_dataset. |
There was a problem hiding this comment.
QEfficient not Qefficient
| 3) Inside the newly created efficient-transformers/dataset/custom_dataset.py, define a function named 'get_custom_dataset'. | ||
| 4) get_custom_dataset() should have following 4 parameters: dataset_config, tokenizer, split, context_length. This function gets called twice through Qefficient/cloud/finetune.py with the name get_preprocessed_dataset. | ||
| 5) Inside get_custom_dataset(), dataset needs to prepared for fine tuning. So, the user needs to apply prompt and tokenize the dataset accordingly. Please refer the below template on how to define get_custom_dataset(). | ||
| 6) For examples, please refer python files present in efficient-transformers/QEfficient/finetune/dataset. In case of Samsum dataset, get_preprocessed_samsum() of efficient-transformers/QEfficient/finetune/dataset/samsum_dataset.py is called. |
There was a problem hiding this comment.
since default dataset is changed, we should mention alpaca here.
There was a problem hiding this comment.
The steps I have mentioned matches with the format of samsum_dataset.py. It doesn't match with alpaca_dataset.py. Hence, I didn't change it.
There was a problem hiding this comment.
too verbose. Make it simple pointed steps
There was a problem hiding this comment.
Done. Added the detailed points in confluence and made them crisp in the PR.
Signed-off-by: Swati Allabadi <quic_sallabad@quicinc.com>
| 3) Inside the newly created efficient-transformers/dataset/custom_dataset.py, define a function named 'get_custom_dataset'. | ||
| 4) get_custom_dataset() should have following 4 parameters: dataset_config, tokenizer, split, context_length. This function gets called twice through Qefficient/cloud/finetune.py with the name get_preprocessed_dataset. | ||
| 5) Inside get_custom_dataset(), dataset needs to prepared for fine tuning. So, the user needs to apply prompt and tokenize the dataset accordingly. Please refer the below template on how to define get_custom_dataset(). | ||
| 6) For examples, please refer python files present in efficient-transformers/QEfficient/finetune/dataset. In case of Samsum dataset, get_preprocessed_samsum() of efficient-transformers/QEfficient/finetune/dataset/samsum_dataset.py is called. |
There was a problem hiding this comment.
too verbose. Make it simple pointed steps
| 4) get_custom_dataset() should have following 4 parameters: dataset_config, tokenizer, split, context_length. This function gets called twice through QEfficient/cloud/finetune.py with the name get_preprocessed_dataset. | ||
| 5) Inside get_custom_dataset(), dataset needs to prepared for fine tuning. So, the user needs to apply prompt and tokenize the dataset accordingly. Please refer the below template on how to define get_custom_dataset(). | ||
| 6) For examples, please refer python files present in efficient-transformers/QEfficient/finetune/dataset. In case of Samsum dataset, get_preprocessed_samsum() of efficient-transformers/QEfficient/finetune/dataset/samsum_dataset.py is called. | ||
| 7) In efficient-transformers/QEfficient/finetune/configs/dataset_config.py, for custom_dataset class, pass the appropriate value for train_split and test_split according to the dataset keys corresponding to train and test data points. As an alternative, these values can be passed as command line arguemnets as well with the finetune command. For example "--train_split train". |
There was a problem hiding this comment.
Add hyperlinks to the relative paths annotated in the steps below
| ``` No newline at end of file | ||
| ``` | ||
|
|
||
| ## Fine-Tuning on custom dataset |
There was a problem hiding this comment.
You should include details on how we use gradient accumulation, how the dataset is shuffled, how activation checkpointing is enabled in separate sections.
In custom dataset, add a point that if any user wants to use these, refer xyz section
There was a problem hiding this comment.
Added the section explaining how to use gradient accumulation and gradient checkpointing.
For single SOC, we are not doing any shuffling of data. By default, it is False.
For DDP, in case of sorting, shuffling is set to false.
For DDP without sorting, shuffling was set to True. Made it False to sync it up with single SOC run and also to be able to use 'resume finetuning from between' feature. this was not caught earlier because by default we run DDP with sorting only.
Hence, didn't add any information about shuffling in the doc.
43aab17 to
155bb77
Compare
Signed-off-by: Swati Allabadi <quic_sallabad@quicinc.com>
ea0f63a to
1be1053
Compare
Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
1be1053 to
25a2ac5
Compare
…taset. (quic#381) 1) Added steps on how to create the custom_dataset.py to run fine-tuning through QEfficient pipeline on any custom dataset. Also, added a detailed template for the user which covers how to create custom_dataset.py 2) Added the argument 'context_length' in the existing APIs which helps run fine tuning with padding for custom dataset. 3) Made alpaca_dataset as the default dataset. 4) For DDP without sorting, shuffling was set to True. Made it False to sync it up with single SOC run and also to be able to use 'resume finetuning from between' feature. --------- Signed-off-by: Swati Allabadi <quic_sallabad@quicinc.com> Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Uh oh!
There was an error while loading. Please reload this page.