diff --git a/paddlenlp/trainer/trainer.py b/paddlenlp/trainer/trainer.py index d03fa2e56cd6..8cc065845647 100644 --- a/paddlenlp/trainer/trainer.py +++ b/paddlenlp/trainer/trainer.py @@ -1293,6 +1293,9 @@ def get_train_dataloader(self): ) def _get_eval_sampler(self, eval_dataset: Dataset): + if eval_dataset is None or not has_length(eval_dataset): + return None + if self.args.world_size <= 1: return paddle.io.BatchSampler( eval_dataset,