Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
d4d4447d
Unverified
Commit
d4d4447d
authored
Mar 23, 2021
by
RafaelWO
Committed by
GitHub
Mar 23, 2021
Browse files
fixed prefix_allowed_tokens_fn docstring in generate() (#10862)
parent
7ef40120
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/generation_utils.py
src/transformers/generation_utils.py
+3
-3
No files found.
src/transformers/generation_utils.py
View file @
d4d4447d
...
@@ -776,9 +776,9 @@ class GenerationMixin:
...
@@ -776,9 +776,9 @@ class GenerationMixin:
enabled.
enabled.
prefix_allowed_tokens_fn: (:obj:`Callable[[int, torch.Tensor], List[int]]`, `optional`):
prefix_allowed_tokens_fn: (:obj:`Callable[[int, torch.Tensor], List[int]]`, `optional`):
If provided, this function constraints the beam search to allowed tokens only at each step. If not
If provided, this function constraints the beam search to allowed tokens only at each step. If not
provided no constraint is applied. This function takes 2 arguments :obj:`
inputs
_id
s
` and
the batch ID
provided no constraint is applied. This function takes 2 arguments
: the batch ID
:obj:`
batch
_id` and
:obj:`
batch
_id`. It has to return a list with the allowed tokens for the next generation step
:obj:`
input
_id
s
`. It has to return a list with the allowed tokens for the next generation step
conditioned on the previously generated tokens :obj:`inputs_ids`
and the batch ID :obj:`batch_id`
. This
conditioned on the
batch ID :obj:`batch_id` and the
previously generated tokens :obj:`inputs_ids`. This
argument is useful for constrained generation conditioned on the prefix, as described in
argument is useful for constrained generation conditioned on the prefix, as described in
`Autoregressive Entity Retrieval <https://arxiv.org/abs/2010.00904>`__.
`Autoregressive Entity Retrieval <https://arxiv.org/abs/2010.00904>`__.
output_attentions (:obj:`bool`, `optional`, defaults to `False`):
output_attentions (:obj:`bool`, `optional`, defaults to `False`):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment