-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Generate: move generation_*.py src files into generation/*.py #20096
Conversation
c90ad80
to
2677903
Compare
The documentation is not available anymore as the PR was closed or merged. |
docs/source/de/pipeline_tutorial.mdx
Outdated
@@ -56,7 +56,7 @@ Wenn Sie mehr als eine Eingabe haben, übergeben Sie die Eingabe als Liste: | |||
... ) # doctest: +SKIP | |||
``` | |||
|
|||
Alle zusätzlichen Parameter für Ihre Aufgabe können auch in die [`pipeline`] aufgenommen werden. Die Aufgabe `Text-Generierung` hat eine [`~generation_utils.GenerationMixin.generate`]-Methode mit mehreren Parametern zur Steuerung der Ausgabe. Wenn Sie zum Beispiel mehr als eine Ausgabe erzeugen wollen, setzen Sie den Parameter `num_return_sequences`: | |||
Alle zusätzlichen Parameter für Ihre Aufgabe können auch in die [`pipeline`] aufgenommen werden. Die Aufgabe `Text-Generierung` hat eine [`~generation.utils.GenerationMixin.generate`]-Methode mit mehreren Parametern zur Steuerung der Ausgabe. Wenn Sie zum Beispiel mehr als eine Ausgabe erzeugen wollen, setzen Sie den Parameter `num_return_sequences`: |
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.
Note: these changes were mass made with generation_X
-> generation.X
, X
being the name of the moved files (with light manual checking before committing the changes)
@@ -0,0 +1,947 @@ | |||
# coding=utf-8 |
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.
(No changes in this file, wasn't tagged as moved because of the new Mixin alias left in the original file. The same comment applies to the PT and TF changes)
class FlaxGenerationMixin(FlaxGenerationMixin): | ||
# warning at import time | ||
warnings.warn( | ||
"Importing `FlaxGenerationMixin` from `src/transformers/generation_flax_utils.py` is deprecated and will " | ||
"be removed in Transformers v5. Import from `src/transformers/generation/flax_utils.py` instead.", | ||
FutureWarning, | ||
) |
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.
Our deprecation warnings typically go in __init__()
(example). However, the generation mixins have no __init__()
-- as it stands, the warning is printed at import time.
@@ -11,7 +11,8 @@ docs/source/en/model_doc/byt5.mdx | |||
docs/source/en/model_doc/tapex.mdx | |||
docs/source/en/model_doc/donut.mdx | |||
docs/source/en/model_doc/encoder-decoder.mdx | |||
src/transformers/generation_utils.py | |||
src/transformers/generation/utils.py | |||
src/transformers/generation/tf_utils.py |
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.
Sneakily added this one 👼
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.
Looking at the changes, would be great to see all imports move to a simple from .generation import Xxx
. What do you think?
@@ -0,0 +1,13 @@ | |||
# Copyright 2022 The HuggingFace Team. All rights reserved. |
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.
It's a bit sad to have an empty init here. Would probably will make it easier for users to have everything importable in this submodule directly? That would just quire building this init like the main init of the models init.
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.
Sounds good 👍
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!
@sgugger now with I've updated all references to objects outside |
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.
New init is looking great! Can you jsut track all the generation.xxx
to just abbreviate them into generation
?
[`~generation_utils.GenerationMixin.beam_sample`], | ||
[`~generation_utils.GenerationMixin.group_beam_search`], and | ||
[`~generation_utils.GenerationMixin.constrained_beam_search`]. | ||
This page lists all the utility functions used by [`~generation.utils.GenerationMixin.generate`], |
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.
Can we use generation
everywhere generation.utils
is used?
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.
Nice refactor!
…gface#20096) * move generation_*.py src files into generation/*.py * populate generation.__init__ with lazy loading * move imports and references from generation.xxx.object to generation.object
Could you please update
|
The PR huggingface/optimum#536 has just been merged and solves this issue. |
…gface#20096) * move generation_*.py src files into generation/*.py * populate generation.__init__ with lazy loading * move imports and references from generation.xxx.object to generation.object
What does this PR do?
Moves
generation_*.py
source files intogeneration/*.py
.I tried a few slow tests locally, no problems were raised.