Conversation
|
I would like to have first review of the draft if possible, to see if we are inline with the approach 🙏 @sgugger - Thanks ! |
sgugger
left a comment
There was a problem hiding this comment.
Thanks for working on this, left some initial comments!
src/transformers/modeling_utils.py
Outdated
|
|
||
| is_adapter_file = False | ||
| if is_peft_available(): | ||
| is_adapter_file = peft_adapter_model_id is not None |
There was a problem hiding this comment.
Maybe raise an error if someone wants to load a model with an adapter file and peft is not installed? I don't know how common that case is, but it seems to me that the user would want to use the adapter file if it's there no?
There was a problem hiding this comment.
I think this is a great idea, and I am keen to add that condition as well. However, I am worried about something, this means we'll need to look for the adapter_config.json file on the local dir or remote directory in any case and I want to avoid that and restrict only to users that have PEFT installed. What do you think? If you think that this is fine, happy to add it.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
There was a problem hiding this comment.
Thank you @younesbelkada for integration of PEFT deeply into transformers 🚀! A concern that I have now is that there are various ways of loading PEFT models now, i.e., PeftModel.from_pretrained(model, peft_model_id), AutoPeftModelForCausalLM.from_pretrained(peft_model_id) and now AutoModelForCausalLM.from_pretrained(peft_model_id); this may lead to confusion among end-users. We need to clearly document the preferred/recommended way. And this needs to be updated on the inference widgets too. WDTY?
|
Thank you for your review @pacman100 ! |
sgugger
left a comment
There was a problem hiding this comment.
Left a couple more comments!
|
|
||
| @require_peft | ||
| @require_torch | ||
| @slow |
There was a problem hiding this comment.
Can we also add one non-slow test with a small fake model?
There was a problem hiding this comment.
Should be done, also added a new job to run peft tests thanks to @ydshieh
[docs] PEFT + Transformer docs
sgugger
left a comment
There was a problem hiding this comment.
Mmm that's not the correct way to add a new peft job as it will always run on any PR, even if it shouldn't be run.
You can take a look transformers/utils/tests_fetcher.py Line 720 in 476be08 (check |
|
The design as is would make it hard for from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
# now we have a loaded CLIPTextModel under `pipe.text_encoder`
pipe.load_lora(...)
# doing this means we would want to call `text_encoder.load_adapter(...)` under the hoodThis means we necessarily need [Edit] We could come around it, by wrapping
|
|
From purely a 1.) PEFT weights seemingly should only be loaded with It does look like the following would be possible: from transformers import LlamaForCausalLM
model = LlamaForCausalLM.from_pretrained("tloen/alpaca-lora-7b")but then 2.) I don't like that => Could we not create a |
|
Closing as #25077 got merged |
What does this PR do?
This PR is an attempt to tightly integrate PEFT library with transformers, by offering users the ability to load PEFT models out of the box from
AutoModelForxxx.from_pretrained()if the local directory or the Hub model id contains adapter weights and adapter config.Although this is similar to what have been introduced in huggingface/peft#694 this PR offers a direct integration with transformers
TODOs:
PeftModel.from_pretrained(xxx)kwargscc @sgugger @pacman100 @BenjaminBossan