ModuleNotFoundError: No module named 'custom_st'

#75
by LeMoussel - opened
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("jinaai/jina-embeddings-v3", trust_remote_code=True)

I got this error

  File "/home/dev/Python/AI/MTEB/venv/lib/python3.12/site-packages/sentence_transformers/util.py", line 1124, in import_from_string
    module = importlib.import_module(dotted_path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_st'

Hello!

I suspect that your sentence_transformers version is a tad too old. Could you retry your script with

pip install -U sentence_transformers
  • Tom Aarsen

I'm using the latest version of sentence_transformers version 3.3.0

Hmm, then I think there's one of 2 issues:

  1. Multiple Python versions - you've installed Sentence Transformers v3.3.0 in a different Python environment than the one that's used to run your script.
  2. Caching issue - the model is partially/incorrectly cached under ~/.cache/huggingface/hub/models--jinaai--jina-embeddings-v3.

To figure out if 1 is happening, you can try and run:

from sentence_transformers import SentenceTransformer, __version__ as sentence_transformers_version

print(sentence_transformers_version)
model = SentenceTransformer("jinaai/jina-embeddings-v3", trust_remote_code=True)

For 2, you can try and delete ~/.cache/huggingface/hub/models--jinaai--jina-embeddings-v3 and rerun the script.

  • Tom Aarsen

For 1. I use a virtual environment with only one version of Python v3.12.3, so no multiple versions of Python.
For 2. I delete ~/.cache/huggingface/hub/models--jinaai--jina-embeddings-v3
It's OK

LeMoussel changed discussion status to closed

Sign up or log in to comment