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

Embedding模型加载失败 #2672

Closed panxiaohuan9 closed 10 months ago

panxiaohuan9 commented 11 months ago

Is there an existing issue for this?

Current Behavior

linux系统中将模型修改为本地下载好的模型,模型加载失败,同样的方法在window系统中可以加载成功 出错代码: self.sentence_embedding_pipe = ( pipe.input('sentence') .map('sentence', 'embedding', ops.sentence_embedding.sbert(model_name='../model/all-MiniLM-L12-v2')) .map('embedding', 'embedding', ops.towhee.np_normalize()) .output('embedding') )

错误信息: RuntimeError: Node-sentence-embedding/sbert-0 runs failed, error msg: Create sentence-embedding/sbert-0 operator sentence-embedding/sbert:main with args None and kws {'model_name': '../model/all-MiniLM-L12-v2'} failed, err: Load operator failed, Traceback (most recent call last): File "/soft/anaconda3/envs/qa/lib/python3.8/site-packages/towhee/runtime/nodes/node.py", line 88, in initialize self._op = self._op_pool.acquire_op( File "/soft/anaconda3/envs/qa/lib/python3.8/site-packages/towhee/runtime/operator_manager/operator_pool.py", line 106, in acquire_op op = self._op_loader.load_operator(hub_op_id, op_args, op_kws, tag, latest) File "/soft/anaconda3/envs/qa/lib/python3.8/site-packages/towhee/runtime/operator_manager/operator_loader.py", line 158, in load_operator raise RuntimeError('Load operator failed') RuntimeError: Load operator failed

Expected Behavior

No response

Steps To Reproduce

linux 
python3.8

Environment

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

Anything else?

No response

junjiejiangjjj commented 11 months ago

Try running these codes to see if they work.

from sentence_transformers import SentenceTransformer
model  = SentenceTransformer(model_name_or_path='../model/all-MiniLM-L12-v2')

 

jaelgu commented 11 months ago

@panxiaohuan9 hi I've just tried in linux and it works well:

image

Here are some suggestions:

  1. Make sure the model path ../model/all-MiniLM-L12-v2 is valid in your linux.
  2. Check your Towhee version in linux
  3. Force op re-download and try again: ops.sentence_embedding.sbert(model_name='../model/all-MiniLM-L12-v2').latest()
panxiaohuan9 commented 11 months ago

towhee 版本 1.1.1

panxiaohuan9 commented 11 months ago

678973F7-119A-4c0a-BC18-A8898A8DF719

junjiejiangjjj commented 11 months ago

It seems to be a network problem. Setting the environment variable TRANSFORMERS_OFFLINE=1 to use huggingface offline mode.

panxiaohuan9 commented 11 months ago

It seems to be a network problem. Setting the environment variable TRANSFORMERS_OFFLINE=1 to use huggingface offline mode.

image image

junjiejiangjjj commented 11 months ago

The model_name parameter specifies the path to the locally downloaded model.

panxiaohuan9 commented 11 months ago

是本地模型路径 image

jaelgu commented 11 months ago

Do you have sbert folder under ~/.towhee/operators/sentence-embedding?

jaelgu commented 11 months ago

没有找到,这个模型必须放到towhee/operators/这个路径吗? image

No, you've checked the incorrect location. ~/.towhee, which is usually under the user's home directory, is the towhee cache where operators are saved. An operator (e.g. ops.sentence_embedding.sbert) will be downloaded the first time you run it.

panxiaohuan9 commented 11 months ago

没有这个文件.towhee,使用ops方式,我在这个服务器上从来就没有下载模型成功过,都是网络错误

stale[bot] commented 10 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.