fix to issue #14833 in data_collator - consider no labels (#14930)

This commit is contained in:
Ayal Klein 2021-12-27 18:48:48 +02:00 committed by GitHub
parent 501307b58b
commit 03885a3f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -591,7 +591,11 @@ class DataCollatorForSeq2Seq:
)
# 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