diff --git a/sentence_transformers/SentenceTransformer.py b/sentence_transformers/SentenceTransformer.py index 15cf36cba..f2d38cc31 100644 --- a/sentence_transformers/SentenceTransformer.py +++ b/sentence_transformers/SentenceTransformer.py @@ -1554,7 +1554,7 @@ def _load_module_class_from_ref( if class_ref.startswith("sentence_transformers."): return import_from_string(class_ref) - if trust_remote_code: + if trust_remote_code or os.path.exists(model_name_or_path): code_revision = model_kwargs.pop("code_revision", None) if model_kwargs else None try: return get_class_from_dynamic_module(