Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 6836555

Browse files
spacemanidolspacemanidol
andauthored
minor change to avoid crash when training and testing with files vs task (#943)
* minor change to avoid crash when training and testing with files vs task * style Co-authored-by: spacemanidol <daniel.campos@neuralmagic.com>
1 parent 43aafc7 commit 6836555

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/sparseml/transformers/text_classification.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,13 @@ def compute_metrics(p: EvalPrediction):
783783

784784
if task == "mnli-mm":
785785
metrics = {k + "_mm": v for k, v in metrics.items()}
786-
if "mnli" in task:
786+
if task is not None and "mnli" in task:
787787
combined.update(metrics)
788+
trainer.save_metrics("eval", combined)
789+
else:
790+
trainer.save_metrics("eval", metrics)
788791

789792
trainer.log_metrics("eval", metrics)
790-
trainer.save_metrics("eval", combined if "mnli" in task else metrics)
791793

792794
if training_args.do_predict and not trainer.one_shot:
793795
_LOGGER.info("*** Predict ***")

0 commit comments

Comments
 (0)