-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add positional args to PeftModelForCausalLM.generate #1393
Add positional args to PeftModelForCausalLM.generate #1393
Conversation
_maybe_include_all_linear_layers, | ||
check_target_module_exists, | ||
inspect_matched_modules, | ||
) | ||
from peft.utils import INCLUDE_LINEAR_LAYERS_SHORTHAND |
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 a minor edit to import the constant from the right place
@@ -672,10 +686,6 @@ def _test_generate_half_prec(self, model_id, config_cls, config_kwargs): | |||
# check if `generate` works | |||
_ = model.generate(input_ids=input_ids, attention_mask=attention_mask) | |||
|
|||
with self.assertRaises(TypeError): | |||
# check if `generate` raises an error if no positional arguments are passed | |||
_ = model.generate(input_ids, attention_mask=attention_mask) |
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 a redundant check on positional args (behaviour is captured in test_generate
already) so I've removed it
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 @SumanthRH for adding support for positional args to generate
method of CausalLM. LGTM! 🤗
Given that the messy internals of input processing are handled in the prepare_inputs_for_generation method, I think this is a safe feature.
Yes, while reviewing the PR I was thinking the same, makes sense.
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.
This is very nice and fixes un-consistency between PreTrainedModel
API and PeftModel
classes ! Thanks a lot @SumanthRH !
* add positional args * update tests
What does this PR do?
A small PR for adding positional arguments to the generate method for
PeftModelForCausalLM
. The motivation is thatPeftModel
classes likePeftModelForCausalLM
should feel more like a wrapper forAutoModel
and shouldn't break existing code which uses positional args. Given that the messy internals of input processing are handled in theprepare_inputs_for_generation
method, I think this is a safe feature. Also, it looks likePeftModelForSeq2SeqLM
needs some refactoring for the prompt learning methods (to shift logic from.generate
toprepare_inputs_for_generation
), so I'm leaving that refactoring + positional args support to another PR.