-
Notifications
You must be signed in to change notification settings - Fork 31.1k
[Docs] Improve PyTorch, Flax generate API #15988
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
Changes from all commits
e27ab7c
c956a0a
96dfd64
b1fad4c
cafe771
c96e15c
675ad48
a468c1b
966df07
edbae8e
06a72d9
d77eaad
8df4999
91a2b46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <!--Copyright 2022 The HuggingFace Team. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations under the License. | ||
| --> | ||
|
|
||
| # Generation | ||
|
|
||
| The methods for auto-regressive text generation, namely [`~generation_utils.GenerationMixin.generate`] (for the PyTorch models), [`~generation_tf_utils.TFGenerationMixin.generate`] (for the TensorFlow models) and [`~generation_flax_utils.FlaxGenerationMixin.generate`] (for the Flax/JAX models), are implemented in [`~generation_utils.GenerationMixin`], [`~generation_tf_utils.TFGenerationMixin`] and [`~generation_flax_utils.FlaxGenerationMixin`] respectively. | ||
|
|
||
| The `GenerationMixin` classes are inherited by the corresponding base model classes, *e.g.* [`PreTrainedModel`], [`TFPreTrainedModel`], and [`FlaxPreTrainedModel`] respectively, therefore exposing all | ||
| methods for auto-regressive text generation to every model class. | ||
|
|
||
| ## GenerationMixn | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small typo for each of the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correcting it here: #16133 (comment) . Thanks! |
||
|
|
||
| [[autodoc]] generation_utils.GenerationMixin | ||
| - generate | ||
| - greedy_search | ||
| - sample | ||
| - beam_search | ||
| - beam_sample | ||
| - group_beam_search | ||
| - constrained_beam_search | ||
|
|
||
| ## TFGenerationMixn | ||
|
|
||
| [[autodoc]] generation_tf_utils.TFGenerationMixin | ||
| - generate | ||
|
|
||
| ## FlaxGenerationMixn | ||
|
|
||
| [[autodoc]] generation_flax_utils.FlaxGenerationMixin | ||
| - 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.
I think replacing the first paragraph with the suggestion below makes it easier for the user to map each
generateto itsGenerationMixinclass :)Each framework has a
generatemethod for auto-regressive text generation implemented in their respectiveGenerationMixinclass:~generation_utils.GenerationMixin.generate] is implemented in [~generation_utils.GenerationMixin].~generation_tf_utils.TFGenerationMixin.generate] is implemented in [~generation_tf_utils.TFGenerationMixin].~generation_flax_utils.FlaxGenerationMixin.generate] is implemented in [~generation_flax_utils.FlaxGenerationMixin].