Unverified Commit df5abae8 authored by miivanov90's avatar miivanov90 Committed by GitHub
Browse files

Set greater_is_better to False if metric_for_best_model ends with "loss" (#31142)

* update to not(endswith(loss))

* ruff formatting
parent 924c46d4
...@@ -464,8 +464,8 @@ class TrainingArguments: ...@@ -464,8 +464,8 @@ class TrainingArguments:
Use in conjunction with `load_best_model_at_end` and `metric_for_best_model` to specify if better models Use in conjunction with `load_best_model_at_end` and `metric_for_best_model` to specify if better models
should have a greater metric or not. Will default to: should have a greater metric or not. Will default to:
- `True` if `metric_for_best_model` is set to a value that isn't `"loss"` or `"eval_loss"`. - `True` if `metric_for_best_model` is set to a value that doesn't end in `"loss"`.
- `False` if `metric_for_best_model` is not set, or set to `"loss"` or `"eval_loss"`. - `False` if `metric_for_best_model` is not set, or set to a value that ends in `"loss"`.
ignore_data_skip (`bool`, *optional*, defaults to `False`): ignore_data_skip (`bool`, *optional*, defaults to `False`):
When resuming training, whether or not to skip the epochs and batches to get the data loading at the same When resuming training, whether or not to skip the epochs and batches to get the data loading at the same
stage as in the previous training. If set to `True`, the training will begin faster (as that skipping step stage as in the previous training. If set to `True`, the training will begin faster (as that skipping step
...@@ -1592,7 +1592,7 @@ class TrainingArguments: ...@@ -1592,7 +1592,7 @@ class TrainingArguments:
) and self.metric_for_best_model is None: ) and self.metric_for_best_model is None:
self.metric_for_best_model = "loss" self.metric_for_best_model = "loss"
if self.greater_is_better is None and self.metric_for_best_model is not None: if self.greater_is_better is None and self.metric_for_best_model is not None:
self.greater_is_better = self.metric_for_best_model not in ["loss", "eval_loss"] self.greater_is_better = not (self.metric_for_best_model.endswith("loss"))
if self.run_name is None: if self.run_name is None:
self.run_name = self.output_dir self.run_name = self.output_dir
if self.framework == "pt" and is_torch_available(): if self.framework == "pt" and is_torch_available():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment