Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

遇到一个很奇怪的问题 #17

Closed
whosyourdadds opened this issue Feb 6, 2024 · 2 comments
Closed

遇到一个很奇怪的问题 #17

whosyourdadds opened this issue Feb 6, 2024 · 2 comments

Comments

@whosyourdadds
Copy link

代码:
reranker = BCERerank(model="./bce-reranker-base_v1", top_n=5, device='cuda:0')

错误信息:

ValueError Traceback (most recent call last)
Cell In[6], line 39
31 embed_model = HuggingFaceEmbeddings(
32 model_name=embedding_model_name,
33 model_kwargs=embedding_model_kwargs,
34 encode_kwargs=embedding_encode_kwargs
35 )
36 # 创建一个reranker模型
37 # reranker_args = {'model': './bce-reranker-base_v1', 'top_n': 5, 'device': 'cuda:0'}
38 # reranker = BCERerank()
---> 39 reranker = BCERerank(model="./bce-reranker-base_v1", top_n=5, device='cuda:0')

File /mnt/workspace/BCEmbedding/BCEmbedding/tools/langchain/bce_rerank.py:55, in BCERerank.init(self, top_n, model, device, **kwargs)
50 except ImportError:
51 raise ImportError(
52 "Cannot import BCEmbedding package,",
53 "please pip install BCEmbedding>=0.1.2",
54 )
---> 55 self._model = RerankerModel(model_name_or_path=model, device=device, **kwargs)
56 super().init(top_n=top_n, model=model)

File /opt/conda/lib/python3.10/site-packages/pydantic/v1/main.py:357, in BaseModel.setattr(self, name, value)
354 return object_setattr(self, name, value)
356 if self.config.extra is not Extra.allow and name not in self.fields:
--> 357 raise ValueError(f'"{self.class.name}" object has no field "{name}"')
358 elif not self.config.allow_mutation or self.config.frozen:
359 raise TypeError(f'"{self.class.name}" is immutable and does not support item assignment')

ValueError: "BCERerank" object has no field "_model"

@shenlei1020
Copy link
Collaborator

langchain对reranker的支持不如llamaindex,所以集成进langchain的reranker接口由BCEmbedding这个python包提供,解决方案:
1、你需要安装本repository:pip install BCEmbedding==0.1.3
2、按照这个样例来调用:https://github.com/netease-youdao/BCEmbedding?tab=readme-ov-file#1-used-in-langchain

@whosyourdadds
Copy link
Author

langchain对reranker的支持不如llamaindex,所以集成进langchain的reranker接口由BCEmbedding这个python包提供,解决方案: 1、你需要安装本存储库:pip install BCEmbedding==0.1.3 2、按照这个样例来调用:https://github.com/netease-youdao/BCEmbedding?tab=readme-ov-file#1-used-in-langchain

我使用的就是这段样例,同时也安装了相关的依赖包. 似乎是我的环境导致的,前一天还没报错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants