Unverified Commit b513ec8b authored by Patrick von Platen's avatar Patrick von Platen Committed by GitHub
Browse files

[Bart] better error message (#14854)

parent 7af80f66
...@@ -1171,6 +1171,13 @@ class BartModel(BartPretrainedModel): ...@@ -1171,6 +1171,13 @@ class BartModel(BartPretrainedModel):
# different to other models, Bart automatically creates decoder_input_ids from # different to other models, Bart automatically creates decoder_input_ids from
# input_ids if no decoder_input_ids are provided # input_ids if no decoder_input_ids are provided
if decoder_input_ids is None and decoder_inputs_embeds is None: if decoder_input_ids is None and decoder_inputs_embeds is None:
if input_ids is None:
raise ValueError(
"If no `decoder_input_ids` or `decoder_inputs_embeds` are "
"passed, `input_ids` cannot be `None`. Please pass either "
"`input_ids` or `decoder_input_ids` or `decoder_inputs_embeds`."
)
decoder_input_ids = shift_tokens_right( decoder_input_ids = shift_tokens_right(
input_ids, self.config.pad_token_id, self.config.decoder_start_token_id input_ids, self.config.pad_token_id, self.config.decoder_start_token_id
) )
......
...@@ -2369,6 +2369,13 @@ class BigBirdPegasusModel(BigBirdPegasusPreTrainedModel): ...@@ -2369,6 +2369,13 @@ class BigBirdPegasusModel(BigBirdPegasusPreTrainedModel):
# different to other models, BigBirdPegasus automatically creates decoder_input_ids from # different to other models, BigBirdPegasus automatically creates decoder_input_ids from
# input_ids if no decoder_input_ids are provided # input_ids if no decoder_input_ids are provided
if decoder_input_ids is None and decoder_inputs_embeds is None: if decoder_input_ids is None and decoder_inputs_embeds is None:
if input_ids is None:
raise ValueError(
"If no `decoder_input_ids` or `decoder_inputs_embeds` are "
"passed, `input_ids` cannot be `None`. Please pass either "
"`input_ids` or `decoder_input_ids` or `decoder_inputs_embeds`."
)
decoder_input_ids = shift_tokens_right( decoder_input_ids = shift_tokens_right(
input_ids, self.config.pad_token_id, self.config.decoder_start_token_id input_ids, self.config.pad_token_id, self.config.decoder_start_token_id
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment