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

Fix filenotfounderror #3056 #3057

Open
wants to merge 7 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: 14 additions & 0 deletions sentence_transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
import os
import warnings
from collections import OrderedDict
from contextlib import nullcontext
from functools import partial
Expand Down Expand Up @@ -497,6 +498,19 @@ def _load_best_model(self) -> None:
if not isinstance(self.model[0], Transformer):
logger.info("Could not load best model, as the model is not a `transformers`-based model.")
return

try:
if len(self.model[0].auto_model.active_adapters()):
warn_msg = "Could not load best model, as the model has at least one adapter set. Please wait for an update of the transformers library to enable this feature."
warnings.warn(
warn_msg,
UserWarning, # No need to import UserWarning; it's already available
stacklevel=2
)
logger.info(warn_msg)
return
except ValueError:
pass

try:
if checkpoint := self.state.best_model_checkpoint:
Expand Down
Loading