xorbitsai / inference

Replace OpenAI GPT with another LLM in your app by changing a single line of code. Xinference gives you the freedom to use any LLM you need. With Xinference, you're empowered to run inference with any open-source language models, speech recognition models, and multimodal models, whether in the cloud, on-premises, or even on your laptop.
https://inference.readthedocs.io
Apache License 2.0
4.77k stars 375 forks source link

调用embedding模型报错 #2157

Closed ybsbbw closed 2 weeks ago

ybsbbw commented 2 weeks ago

System Info / 系統信息

8卡A-800,cuda12.2,

transformers 4.40.2 torch 2.1.2

Running Xinference with Docker? / 是否使用 Docker 运行 Xinfernece?

Version info / 版本信息

xinference 0.14.3

The command used to start Xinference / 用以启动 xinference 的命令

网页端启动 image

Reproduction / 复现过程

def build_vectorstore( db_name, db_path, server_url, model="Bge-m3"): """ "Bge-m3": 创建的embedding模型名称 """ embeddings = XinferenceEmbeddings(server_url=server_url, model_uid=model)

vectorstore = Chroma(collection_name=db_name,
                          persist_directory=db_path,
                          embedding_function=embeddings
                          )
return vectorstore

a_vectorstore = build_vectorstore() #此处为参数 retrieve_result = a_vectorstore .similarity_search_with_score(query=text, k=top_k, filter=where)

报错: 发生异常: RuntimeError AttributeError: [address=0.0.0.0:36191, pid=972983] 'SentenceTransformer' object has no attribute 'default_prompt_name' 2024-08-26 11:16:53,120 xinference.api.restful_api 917636 ERROR [address=0.0.0.0:36191, pid=972983] 'SentenceTransformer' object has no attribute 'default_prompt_name' Traceback (most recent call last): File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/api/restful_api.py", line 1189, in create_embedding embedding = await model.create_embedding(body.input, kwargs) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xoscar/backends/context.py", line 227, in send return self._process_result_message(result) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xoscar/backends/context.py", line 102, in _process_result_message raise message.as_instanceof_cause() File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xoscar/backends/pool.py", line 659, in send result = await self._run_coro(message.message_id, coro) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xoscar/backends/pool.py", line 370, in _run_coro return await coro File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xoscar/api.py", line 384, in on_receive return await super().on_receive(message) # type: ignore File "xoscar/core.pyx", line 558, in on_receive__ raise ex File "xoscar/core.pyx", line 520, in xoscar.core._BaseActor.on_receive async with self._lock: File "xoscar/core.pyx", line 521, in xoscar.core._BaseActor.on_receive with debug_async_timeout('actor_lock_timeout', File "xoscar/core.pyx", line 526, in xoscar.core._BaseActor.__on_receive result = await result File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/core/utils.py", line 45, in wrapped ret = await func(*args, *kwargs) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/core/model.py", line 90, in wrapped_func ret = await fn(self, args, kwargs) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/core/model.py", line 572, in create_embedding return await self._call_wrapper_json( File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/core/model.py", line 401, in _call_wrapper_json return await self._call_wrapper("json", fn, *args, kwargs) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/core/model.py", line 114, in _async_wrapper return await fn(*args, *kwargs) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/core/model.py", line 418, in _call_wrapper ret = await asyncio.to_thread(fn, args, kwargs) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/asyncio/threads.py", line 25, in to_thread return await loop.run_in_executor(None, func_call) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/model/embedding/core.py", line 378, in create_embedding all_embeddings, all_token_nums = encode( File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/xinference/model/embedding/core.py", line 260, in encode elif model.default_prompt_name is not None: File "/home/wpz/anaconda3/envs/llm/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1695, in getattr raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'") AttributeError: [address=0.0.0.0:36191, pid=972983] 'SentenceTransformer' object has no attribute 'default_prompt_name'

Expected behavior / 期待表现

能够正常调用embedding模型

ybsbbw commented 2 weeks ago

之前版本的是能用的,这个和gcc有什么关系。。。

qinxuye commented 2 weeks ago

嗯,社区的改动导致出问题, @Zzzz1111 能看下吗?

Zzzz1111 commented 2 weeks ago

嗯,社区的改动导致出问题, @Zzzz1111 能看下吗?

我看一下

octopusYan commented 2 weeks ago

以前的版本是能用的,这个和gcc有什么关系。。。

病毒文件,好多开源仓库被发这种评论

ybsbbw commented 2 weeks ago

xinference切换到0.12.0版本后能够正常运行了

Zzzz1111 commented 2 weeks ago

image image image 0.14.3 测试可以正常运行

Zzzz1111 commented 2 weeks ago

image @ybsbbw 可以发一下SentenceTransformer版本么?可能是SentenceTransformer版本太低导致的,可以尝试升级到v2.4.0之后的版本

Zzzz1111 commented 2 weeks ago

嗯,社区的改动导致出问题, @Zzzz1111 能看下吗? image

应该不是我提交的PR导致的,default_prompt_name这个参数是在#1994中增加的 @qinxuye

ybsbbw commented 2 weeks ago

image @ybsbbw 可以发一下SentenceTransformer版本么?可能是SentenceTransformer版本太低导致的,可以尝试升级到v2.4.0之后的版本

我用的SentenceTransformer版本是 2.2.2,xinference更新到最新的0.14.3就报错了,但是xinference切换到0.12.0就没有问题

qinxuye commented 2 weeks ago

@ybsbbw sentence-transformers>=2.7.0 需要这个版本至少

ybsbbw commented 2 weeks ago

@ybsbbw sentence-transformers>=2.7.0 需要这个版本至少

安装0.14.3的时候sentence-transformers也没有作为依赖项自动更新啊......下次更新的时候可以把它放到依赖项里自动更新一下

qinxuye commented 2 weeks ago

应该是限制了版本的

https://github.com/xorbitsai/inference/blob/10094f9390261aefd983ef1af9db10edff648d5d/setup.cfg#L91

先 close。