Skip to content

Commit

Permalink
fix to issue huggingface#14833 in data_collator - consider no labels (h…
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinay authored and Steven committed Jan 6, 2022
1 parent 1000054 commit a439438
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/transformers/data/data_collator.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,11 @@ def __call__(self, features, return_tensors=None):
)

# prepare decoder_input_ids
if self.model is not None and hasattr(self.model, "prepare_decoder_input_ids_from_labels"):
if (
labels is not None
and self.model is not None
and hasattr(self.model, "prepare_decoder_input_ids_from_labels")
):
decoder_input_ids = self.model.prepare_decoder_input_ids_from_labels(labels=features["labels"])
features["decoder_input_ids"] = decoder_input_ids

Expand Down

0 comments on commit a439438

Please sign in to comment.