Skip to content

Commit

Permalink
Fix generation docstrings regarding input_ids=None (#12823)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvamvas authored Aug 18, 2021
1 parent ecfa7eb commit 1fec32a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/transformers/generation_flax_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def generate(
Parameters:
input_ids (:obj:`jnp.ndarray` of shape :obj:`(batch_size, sequence_length)`, `optional`):
input_ids (:obj:`jnp.ndarray` of shape :obj:`(batch_size, sequence_length)`):
The sequence used as a prompt for the generation.
max_length (:obj:`int`, `optional`, defaults to 20):
The maximum length of the sequence to be generated.
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/generation_tf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ def generate(
Parameters:
input_ids (:obj:`tf.Tensor` of :obj:`dtype=tf.int32` and shape :obj:`(batch_size, sequence_length)`, `optional`):
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it as an empty
:obj:`tf.Tensor` of shape :obj:`(1,)`.
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it with
:obj:`bos_token_id` and a batch size of 1.
max_length (:obj:`int`, `optional`, defaults to 20):
The maximum length of the sequence to be generated.
min_length (:obj:`int`, `optional`, defaults to 10):
Expand Down
29 changes: 12 additions & 17 deletions src/transformers/generation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ def generate(
Parameters:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it as an empty
:obj:`torch.LongTensor` of shape :obj:`(1,)`.
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it with
:obj:`bos_token_id` and a batch size of 1.
max_length (:obj:`int`, `optional`, defaults to :obj:`model.config.max_length`):
The maximum length of the sequence to be generated.
max_new_tokens (:obj:`int`, `optional`, defaults to None):
Expand Down Expand Up @@ -1165,9 +1165,8 @@ def greedy_search(
Parameters:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it as an empty
:obj:`torch.LongTensor` of shape :obj:`(1,)`.
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
The sequence used as a prompt for the generation.
logits_processor (:obj:`LogitsProcessorList`, `optional`):
An instance of :class:`~transformers.LogitsProcessorList`. List of instances of class derived from
:class:`~transformers.LogitsProcessor` used to modify the prediction scores of the language modeling
Expand Down Expand Up @@ -1391,9 +1390,8 @@ def sample(
Parameters:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it as an empty
:obj:`torch.LongTensor` of shape :obj:`(1,)`.
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
The sequence used as a prompt for the generation.
logits_processor (:obj:`LogitsProcessorList`, `optional`):
An instance of :class:`~transformers.LogitsProcessorList`. List of instances of class derived from
:class:`~transformers.LogitsProcessor` used to modify the prediction scores of the language modeling
Expand Down Expand Up @@ -1632,9 +1630,8 @@ def beam_search(
Parameters:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it as an empty
:obj:`torch.LongTensor` of shape :obj:`(1,)`.
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
The sequence used as a prompt for the generation.
beam_scorer (:obj:`BeamScorer`):
An derived instance of :class:`~transformers.BeamScorer` that defines how beam hypotheses are
constructed, stored and sorted during generation. For more information, the documentation of
Expand Down Expand Up @@ -1925,9 +1922,8 @@ def beam_sample(
Parameters:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it as an empty
:obj:`torch.LongTensor` of shape :obj:`(1,)`.
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
The sequence used as a prompt for the generation.
beam_scorer (:obj:`BeamScorer`):
A derived instance of :class:`~transformers.BeamScorer` that defines how beam hypotheses are
constructed, stored and sorted during generation. For more information, the documentation of
Expand Down Expand Up @@ -2228,9 +2224,8 @@ def group_beam_search(
Parameters:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
The sequence used as a prompt for the generation. If :obj:`None` the method initializes it as an empty
:obj:`torch.LongTensor` of shape :obj:`(1,)`.
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
The sequence used as a prompt for the generation.
beam_scorer (:obj:`BeamScorer`):
An derived instance of :class:`~transformers.BeamScorer` that defines how beam hypotheses are
constructed, stored and sorted during generation. For more information, the documentation of
Expand Down

0 comments on commit 1fec32a

Please sign in to comment.