Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[warn] Throw a warning if compute_metrics is set, as it's not used #3002

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 9 additions & 5 deletions sentence_transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging
import os
import warnings
from collections import OrderedDict
from contextlib import nullcontext
from typing import TYPE_CHECKING, Any, Callable
Expand Down Expand Up @@ -156,14 +155,19 @@ def __init__(
raise RuntimeError("`Trainer` requires either a `model` or `model_init` argument")
else:
if model_init is not None:
warnings.warn(
logger.warning(
"`Trainer` requires either a `model` or `model_init` argument, but not both. `model_init` will"
" overwrite your model when calling the `train` method. This will become a fatal error in the next"
" release.",
FutureWarning,
" overwrite your model when calling the `train` method."
)
self.model_init = model_init

if compute_metrics is not None:
logger.warning(
"`compute_metrics` is currently not compatible with the SentenceTransformerTrainer. Please use the "
"`evaluator` argument instead for detailed evaluation metrics, or the `eval_dataset` argument for "
"the evaluation loss."
)

# Get a dictionary of the default training arguments, so we can determine which arguments have been changed
# for the model card
default_args_dict = SentenceTransformerTrainingArguments(output_dir="unused").to_dict()
Expand Down