Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion examples/pytorch/text-classification/run_glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ def compute_metrics(p: EvalPrediction):
if data_args.task_name == "mnli":
tasks.append("mnli-mm")
eval_datasets.append(raw_datasets["validation_mismatched"])
combined = {}

for eval_dataset, task in zip(eval_datasets, tasks):
metrics = trainer.evaluate(eval_dataset=eval_dataset)
Expand All @@ -516,8 +517,13 @@ def compute_metrics(p: EvalPrediction):
)
metrics["eval_samples"] = min(max_eval_samples, len(eval_dataset))

if task == "mnli-mm":
metrics = {k + "_mm": v for k, v in metrics.items()}
if "mnli" in task:
combined.update(metrics)
Comment on lines +520 to +523
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd regroup this slightly differently:

Suggested change
if task == "mnli-mm":
metrics = {k + "_mm": v for k, v in metrics.items()}
if "mnli" in task:
combined.update(metrics)
if task == "mnli-mm":
combined.update({k + "_mm": v for k, v in metrics.items()})
elif task == "mnli":
combined.update(metrics)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this regrouping, the trainer.log_metrics("eval", metrics) won't have the "_mm" , so the stdout will be the same as before (that's the main reason why keys in metrics are updated). Given this, should we still regroup and affect only the json log files, but not the stdout?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah understood. LGTM as is then :-)


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

if training_args.do_predict:
logger.info("*** Predict ***")
Expand Down