Fix formatting function to ensure correct fine-tuning in gemma-peft.md#3260
Open
dboyker wants to merge 1 commit intohuggingface:mainfrom
Open
Fix formatting function to ensure correct fine-tuning in gemma-peft.md#3260dboyker wants to merge 1 commit intohuggingface:mainfrom
dboyker wants to merge 1 commit intohuggingface:mainfrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Thanks for the nice tutorial on gemma + peft !!
After following it, the script throws this warning:
As
formatting_funcis ignored, the model is not correctly fine-tuned. The script works but there is no guarantee that the model ouput the formatQuote: [...] Author: [...].The line 115 is the one which prevents this:
data = data.map(lambda samples: tokenizer(samples["quote"]), batched=True). Executing it adds theinput_idscolumn to the dataset which, together with theformatting_functionarg, then trigger the warning as seen here: https://github.com/huggingface/trl/blob/main/trl/trainer/sft_trainer.py#L938-L944Removing the line 115 is safe regarding the tokenization. Indeed, the tokenizer is infered in the SFTTrainer
__init__: https://github.com/huggingface/trl/blob/main/trl/trainer/sft_trainer.py#L639-L650In addition,
formatting_funcis modified in this PR to avoid raising the following error:AttributeError: 'list' object has no attribute 'endswith'. It now returns a string instead of a list (+ it does not slice the quote and author).