Langchain-Chatchat
Langchain-Chatchat copied to clipboard
[BUG] similarity_search_with_score_by_vector在找不到匹配的情况下出错
在设置匹配阈值 VECTOR_SEARCH_SCORE_THRESHOLD 的情况下,vectorstore会返回空,此时上述处理函数会出错
File "/home/liao/ex/langchain-ChatGLM/vectorstores/MyFAISS.py", line 83, in similarity_search_with_score_by_vector if (not self.chunk_conent) or ("add_context" in doc.metadata and not doc.metadata["add_context"]): UnboundLocalError: local variable 'doc' referenced before assignment
需要处理indices为空,循环没进去的情况
解决了吗?我也遇到这个问题
解决了吗?我也有这个问题,设置为0的话提供的参考数据都是没有什么相关度的。
这种情况也不是indices为空,而是搜索出来的结果的分数都超过设置的阈值了。我现在不是很懂啊,这个 scores, indices = self.index.search(vector, k) 中的scores代表什么意思? 如果谁能告诉我的话,应该这个代码就好改了。
MyFAISS.py中的这一行有问题: if i == -1 or 0 < self.score_threshold < scores[0][j]: