-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
added warning to Trainer when label_names is not specified for PeftModel #32085
added warning to Trainer when label_names is not specified for PeftModel #32085
Conversation
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 for adding this check - LGTM but let's get confirmation from @muellerzr
src/transformers/trainer.py
Outdated
@@ -679,6 +679,11 @@ def __init__( | |||
# returned to 0 every time flos need to be logged | |||
self.current_flos = 0 | |||
self.hp_search_backend = None | |||
if self.model.__class__.name__ == "PeftModel" and self.args.label_names is None: |
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 don't think this check is robust as the model could be e.g. PeftForCausalLM
. Within this module we have _is_peft_model
which I think we should use.
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.
ok, very good suggestion!
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, agree it makes sense but cc @BenjaminBossan here since it's peft :)
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. |
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 for iterating on this!
If @BenjaminBossan is happy with it I think we can merge :)
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 for the PR.
Not sure if I fully understand the issue, does it have to do with some function signature inspection that fails on the wrapped model because it uses *args, **kwargs
? Could you maybe provide a small example where this comes up?
Basically inside Trainer's init function, it automatically finds whether 'labels' argument exist in model class's forward function. e.g. LlamaForCausalLM: have labels field in forward, so 'labels' is detected |
Thanks for clarifying, that makes sense. I had already shared this concern internally in the past (but got no response 😢):
So I guess this PR helps a little bit but the fundamental problem still remains. Thus from my side, it's okay to merge with my suggestion applied. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Does it need any other consideration, @amyeroberts ? |
I think we were waiting for the suggestion from @BenjaminBossan to be merged 🤗 |
Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
Ah, I see. I missed the suggestion. I accepted the suggestion! |
Now let's make sure |
Sorry for the late reply, I've forgotten and thought this PR was merged. |
Failing test is unrelated don't worry! |
…del (huggingface#32085) * feat: added warning to Trainer when label_names is not specified for PeftModel * Update trainer.py * feat: peft detectw ith `_is_peft_model` * Update src/transformers/trainer.py Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com> * Applied formatting in trainer.py --------- Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
What does this PR do?
in Trainer, it automatically finds
label_names
with input arguments name of model.But with model which is
PeftModel
, the input arguments are all hidden and we can't find the input argument's name automatically.So, for the case then the user didn't specified
label_names
inTrainerArguments
, I made warning message pop up.p.s. it makes the change when I add call
trainer.predict
; iflabel_names
it not set, there's no way I can get getlabel_ids
fromtrainer.predict
outcomes.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.