diff --git a/sentence_transformers/SentenceTransformer.py b/sentence_transformers/SentenceTransformer.py index 830564a57..ba02f8bfa 100644 --- a/sentence_transformers/SentenceTransformer.py +++ b/sentence_transformers/SentenceTransformer.py @@ -1559,8 +1559,8 @@ def _load_module_class_from_ref( revision=revision, code_revision=code_revision, ) - except OSError: - # Ignore the error if the file does not exist, and fall back to the default import + except (OSError, ValueError): + # Ignore the error if 1) the file does not exist, or 2) the class_ref is not correctly formatted/found pass return import_from_string(class_ref)