-
Notifications
You must be signed in to change notification settings - Fork 236
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
New Notebook showcasing how to perform prompt tuning using the PEFT library. #33
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@pacman100 Can you please review a notebook on prompt-tuning with peft? |
@peremartra Thank you for contributing a notebook! This looks very useful! There are a few more steps required:
|
I also fixed the link to the other notebooks on index.md, all of them are missing the .ipynb and the links were broken.
@MKhalusova Modifications Done! Thanks for the feedback :-) |
Hi @MKhalusova, I just finished another notebook about fine-tuning with QLoRA. I don't know how to proceed, should I do a second PR, or just wait to close this PR before opening a new one? |
Feel free to open a separate PR for a different notebook. We can review them in parallel and it's better to keep one notebook per PR. |
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using sampling with temperature=0.2 and top_p=0.95 would result in better generations.
def get_outputs(model, inputs, max_new_tokens=100): outputs = model.generate( input_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"], max_new_tokens=max_new_tokens, temperature=0.2, top_p=0.95, do_sample=True, repetition_penalty=1.2, #Avoid repetition. early_stopping=True, #The model can stop before reach the max_length eos_token_id=tokenizer.eos_token_id ) return outputs
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much! I was aiming for a response as consistent as possible to ensure the explanation in the notebook consistently aligns with the generated answer. With these values, a different response is obtained in each execution.
Would it be acceptable if I leave it as is, with these parameters commented, indicating that for better but more varied responses, users can uncomment and adjust the parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to leave as is, and add this context in markdown before the code. It's always great to see the reasoning behind parameter choices, and alternative options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"I want you to act as an English translator," -> "I want you to act as a motivational coach. "
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ups... modified!
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, you can do the below which would avoid loading a second copy of the base model in memory.
loaded_model_prompt.load_adapter(output_directory_sentences, adapter_name="quotes") loaded_model_prompt.set_adapter("quotes")
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Thaks I changed the code!
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the input sentence to avoid this generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update the output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! For sure, I'm just executing the notebook again, and checking the responses obtained with different configurations. I will upload the notification in few minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the generation: 'There are two nice things that should matter to you: the weather and your health.' now.
I checked with different configurations and all responses are sfw :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @peremartra for the insightful notebook on prompt tuning! 🔥
Left few comments.
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest placing the last line (display(train_sample_prompt)
) into a separate cell, so that we could show it's output but remove the output of all the downloads
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, if you place the last line in a separate cell, we can show the output of the display, and remove the output with downloading
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,7324 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I left a few comments to polish things, and we can aim to publish the notebook early next week :) |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Thanks for your corrections! I think all is fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Let's merge :)
What does this PR do?
Is a new notebook showcasing the use of the PEFT library to perform Prompt Tuning. I also provide a brief explanation of what prompt-tuning is and how it works.
Since this is my first PR request, I hope I have created the notebook in the correct style. If not, I will try to adapt and make any necessary modifications.
Thank you for reviewing it. @MKhalusova