From 5431a5792877d7504d10ba10c38f0f5326c7860a Mon Sep 17 00:00:00 2001 From: Jintao Date: Mon, 25 Nov 2024 13:47:31 +0800 Subject: [PATCH] fix eval_dataset no (#2497) --- swift/llm/sft.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/swift/llm/sft.py b/swift/llm/sft.py index 5c3b55f4a..04aaf8625 100644 --- a/swift/llm/sft.py +++ b/swift/llm/sft.py @@ -355,11 +355,6 @@ def prepare_dataset(args, template: Template, msg: Optional[Dict[str, Any]] = No if use_torchacc(): training_args.train_dataset_sample = train_dataset.shape[0] if train_dataset is not None else 0 - if val_dataset is None: - training_args.evaluation_strategy = IntervalStrategy.NO - training_args.eval_strategy = IntervalStrategy.NO - training_args.do_eval = False - tokenizer = template.tokenizer dataset_info = {} if args.packing: @@ -415,6 +410,11 @@ def prepare_dataset(args, template: Template, msg: Optional[Dict[str, Any]] = No train_dataset = LazyLLMDataset(train_dataset, template.encode) if val_dataset is not None: val_dataset = LazyLLMDataset(val_dataset, template.encode) + + if val_dataset is None: + training_args.evaluation_strategy = IntervalStrategy.NO + training_args.eval_strategy = IntervalStrategy.NO + training_args.do_eval = False if isinstance(msg, dict): msg['dataset_info'] = dataset_info return train_dataset, val_dataset