diff --git a/paddlenlp/trainer/trainer.py b/paddlenlp/trainer/trainer.py index b42e596e97e4..e09a4811900a 100644 --- a/paddlenlp/trainer/trainer.py +++ b/paddlenlp/trainer/trainer.py @@ -1459,6 +1459,7 @@ def get_eval_dataloader(self, eval_dataset: Optional[Dataset] = None) -> DataLoa eval_dataset, batch_size=self.args.per_device_eval_batch_size, collate_fn=self.data_collator, + drop_last=self.args.dataloader_drop_last, num_workers=0, eval=True, ) @@ -1467,6 +1468,7 @@ def get_eval_dataloader(self, eval_dataset: Optional[Dataset] = None) -> DataLoa eval_dataset, batch_size=self.args.per_device_eval_batch_size, collate_fn=self.data_collator, + drop_last=self.args.dataloader_drop_last, num_workers=0, ) @@ -1525,6 +1527,7 @@ def get_test_dataloader(self, test_dataset: Dataset) -> DataLoader: batch_size=self.args.per_device_eval_batch_size * self.world_size, collate_fn=self.data_collator, # _get_collator_with_removed_columns num_workers=0, + drop_last=self.args.dataloader_drop_last, eval=True, ) else: @@ -1532,6 +1535,7 @@ def get_test_dataloader(self, test_dataset: Dataset) -> DataLoader: test_dataset, batch_size=self.args.per_device_eval_batch_size * self.world_size, collate_fn=self.data_collator, # _get_collator_with_removed_columns + drop_last=self.args.dataloader_drop_last, num_workers=0, )