towhee-io / towhee

Towhee is a framework that is dedicated to making neural data processing pipelines simple and fast.
https://towhee.io
Apache License 2.0
3.21k stars 247 forks source link

[Bug]: RuntimeError: Loading operator with error:Load operator failed #2686

Closed mechigonft closed 8 months ago

mechigonft commented 10 months ago

Is there an existing issue for this?

Current Behavior

File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/auto_config.py", line 83, in load_config pipe_loader.PipelineLoader.load_pipeline(name) File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/pipeline_loader.py", line 63, in load_pipeline if not PipelineLoader._load_builtins(name): File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/pipeline_loader.py", line 52, in _load_builtins PipelineLoader._load_pipeline_from_file(name, file_path) File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/pipeline_loader.py", line 45, in _load_pipeline_from_file spec.loader.exec_module(module) File "", line 843, in exec_module File "", line 219, in _call_with_frames_removed File "/opt/conda/lib/python3.8/site-packages/towhee/pipelines/sentence_embedding.py", line 33, in _hf_models = ops.sentence_embedding.transformers().get_op().supported_model_names() File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/factory.py", line 109, in get_op self.preload_op() File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/factory.py", line 119, in preload_op raise RuntimeError(err) from e RuntimeError: Loading operator with error:Load operator failed

Expected Behavior

File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/auto_config.py", line 83, in load_config pipe_loader.PipelineLoader.load_pipeline(name) File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/pipeline_loader.py", line 63, in load_pipeline if not PipelineLoader._load_builtins(name): File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/pipeline_loader.py", line 52, in _load_builtins PipelineLoader._load_pipeline_from_file(name, file_path) File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/pipeline_loader.py", line 45, in _load_pipeline_from_file spec.loader.exec_module(module) File "", line 843, in exec_module File "", line 219, in _call_with_frames_removed File "/opt/conda/lib/python3.8/site-packages/towhee/pipelines/sentence_embedding.py", line 33, in _hf_models = ops.sentence_embedding.transformers().get_op().supported_model_names() File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/factory.py", line 109, in get_op self.preload_op() File "/opt/conda/lib/python3.8/site-packages/towhee/runtime/factory.py", line 119, in preload_op raise RuntimeError(err) from e RuntimeError: Loading operator with error:Load operator failed

Steps To Reproduce

No response

Environment

- Towhee version(e.g. v0.1.3 or 8b23a93):
- OS(Ubuntu or CentOS):
- CPU/Memory:
- GPU:
- Others:

Anything else?

No response

junjiejiangjjj commented 10 months ago

Please provide the relevant code

mechigonft commented 10 months ago

from towhee import AutoPipes, AutoConfig

get the built-in sentence_similarity pipeline

config = AutoConfig.load_config('sentence_embedding') config.model = 'paraphrase-albert-small-v2' config.device = 0 sentence_embedding = AutoPipes.pipeline('sentence_embedding', config=config)

generate embedding for one sentence

embedding = sentence_embedding('how are you?').get()

batch generate embeddings for multi-sentences

embeddings = sentence_embedding.batch(['how are you?', 'how old are you?'])

embeddings = [e.get() for e in embeddings]

junjiejiangjjj commented 10 months ago

It works ok in my environment. Can your environment download Hugging Face models successfully?

mechigonft commented 10 months ago

hi, If I cannot download the model from hugging face, do I need to download it locally and specify it in the model path?

mechigonft commented 10 months ago

Can I load other vector models like bge-large-zh-1.5 which is not in your vector model list

junjiejiangjjj commented 10 months ago

Can I load other vector models like bge-large-zh-1.5 which is not in your vector model list

https://towhee.io/sentence-embedding/transformers Through this operation, more Hugging Face models can be invoked, including bge models.

junjiejiangjjj commented 10 months ago

hi, If I cannot download the model from hugging face, do I need to download it locally and specify it in the model path?

hi, If I cannot download the model from hugging face, do I need to download it locally and specify it in the model path?

You need to download huggingface model to the model cache, the default path is ~/.cache/huggingface/hub/

mechigonft commented 10 months ago

Does it have to be the default path, can I download the model to a different folder path and then specify this path in the code

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Close the stale issues and pull requests after 7 days of inactivity. Reopen the issue with /reopen.