-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
fix for custom pipeline configuration #29004
fix for custom pipeline configuration #29004
Conversation
@Rocketknight1 could you review this one too ? |
Sure, I'll try to take a look at this one and the pipeline upload one! |
cc @Rocketknight1 any review on this one |
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.
I reviewed this and I'm going to approve it on the basis that I think it fixes some specific issues and doesn't break anything that currently works, but I think we need much more clarity in the docs and our conceptual model of custom pipelines in future - this was quite a hard PR to review because I wasn't really sure what behaviour our library was "supposed" to have in these cases.
See my comment here for more.
cc @ArthurZucker for core maintainer review |
cc @Rocketknight1 @ArthurZucker |
it also explains the fundamentals of the transformers library on how to load the custom architecture from a repo that has the architecture defined on another one, which is a workaround i used before on this . it's pretty much always depends on the config.json which is why it's essential to fix 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.
My main question is why don't we update the save_pretrained
part as well to make sure what we already have the correct module?
We can keep your changes for the previous checkpoints, and make sure new ones have the full path (like it is the case for tokenizer and model code path)
Also let's maybe add a test close to https://github.com/huggingface/transformers/blob/d03de1c1070cee0fb7b9358669abc3f68ef56b75/tests/pipelines/test_pipelines_common.py#L709
to make sure we can load a custom pipeline from not-laion
when it was pushed from laion
!
feature_extractor_dict["auto_map"] = add_model_info_to_auto_map( | ||
feature_extractor_dict["auto_map"], pretrained_model_name_or_path | ||
) | ||
if not is_local: |
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.
just curious as to why we only do it if not local whereas before we did it for local and not local? 🤗
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.
what does
is_local
mean ?
if i call a model using this
path = "./folder1/folder2/folder3"
from transformers import AutoModelForImageClassification
model = AutoModelForImageClassification.from_pretrained(path, trust_remote_code=True)
if the path exists in my pc then we load from there
what if the
is_local
is false ?
then in this case we call the model from the hub and add the tag
is the tag added when we are only calling a custom model from huggingface ?
yes, there is no need to add the tag if we are calling the model from the local pc
hope this answers your questions 🤗
@ArthurZucker in this pr the configuration tag is added when we are calling the model not when we are saving it which is why it is funadamentally different from the other pr. check more about the config.json in this repo and then try loading the model and check the config after calling it for more details # Load model directly
from transformers import AutoModelForImageClassification
model = AutoModelForImageClassification.from_pretrained("not-lain/29004", trust_remote_code=True)
model.config i know it's pretty weird but this is how the transformers library is working rn. as for the tests
|
@ArthurZucker again apologies for the confusion EDIT |
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.
Let's wait for the test to do another round of review!
…not-lain/transformers into fix-config-for-custom-pipelines
cc @ArthurZucker |
@ArthurZucker @Rocketknight1 i'll update the tests on this pull request right after, sending lots of hugs 🤗🤗 |
Sorry on our late answers here! I was off for a while ! |
@ArthurZucker hope you had fun ✨✨, anyways I have updated the tests to be more straight forward and to the point, do let me know if you have any reviews on this |
@ArthurZucker there's no need to wait for |
Hi @ArthurZucker |
@ArthurZucker friendly tagging you here |
hey @ArthurZucker , hope you're doing well. |
Wow I am sorry @not-lain really my bad here |
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 seems to work well, I think overall I just don't like that we have to duplicate the logic everywhere but that's not on you!
Thanks for your continuous contribution to the library and the ecosytem! And sorry for being so late here
@ArthurZucker it's ok, you have been busy with lots of stuff including llama-3 and I know things are hectic on your side, just remember to take a break once in a while. |
* fix for custom pipeline configuration * fix for custom pipelines * remove extra exception * added test for custom pipelines extra tag * format with ruff * limit extra tag for first time only * format with ruff * improve tests for custom pipelines
* fix for custom pipeline configuration * fix for custom pipelines * remove extra exception * added test for custom pipelines extra tag * format with ruff * limit extra tag for first time only * format with ruff * improve tests for custom pipelines
What does this PR do?
fixes configuration file not pointing at a remote repo with custom pipeline architecture
Fixes #28907
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@Rocketknight1