-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Donut: fix generate
call from local path
#31470
Conversation
# exception: Donut checkpoints have task-specific decoder starts and don't expect a BOS token. Note that the | ||
# original checkpoints can't be detected through `self.__class__.__name__.lower()`, needing custom logic. | ||
elif "donut" in self.__class__.__name__.lower() or ( | ||
self.config.model_type == "vision-encoder-decoder" and "donut" in self.config.encoder.model_type.lower() |
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.
1st or
clause: new checkpoints
2nd or
clause: original donut checkpoints. self.name_or_path
doesn't work for local files, self.config.encoder.model_type
does
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 for fixing!
Seems like the best fix for a not-ideal hard-to-fix situation.
# exception: Donut checkpoints have task-specific decoder starts and don't expect a BOS token. Note that the | ||
# original checkpoints can't be detected through `self.__class__.__name__.lower()`, needing custom logic. | ||
elif "donut" in self.__class__.__name__.lower() or ( | ||
self.config.model_type == "vision-encoder-decoder" and "donut" in self.config.encoder.model_type.lower() |
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.
😬
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. |
Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
* local donut path fix * engrish * Update src/transformers/generation/utils.py Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com> --------- Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
* local donut path fix * engrish * Update src/transformers/generation/utils.py Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com> --------- Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
What does this PR do?
Donut has custom logic in
generate
. Typically, we can detect certain architectures throughself.__class__.__name__
, to then trigger custom logic. However, to detect donut's original checkpoints, whosemodel_type
andarchitectures
is incorrectly defined (e.g. here), we can't rely onself.__class__.__name__
.The custom logic that was in place relied on the hub path, but that doesn't work for local file paths. This PR fixes it by clawing at the only piece of text saying "donut" in the original config 👀
cc @nbroad1881