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

初始化不成功,请指导 #2873

Closed
donywoo opened this issue Jan 31, 2024 · 4 comments
Closed

初始化不成功,请指导 #2873

donywoo opened this issue Jan 31, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@donywoo
Copy link

donywoo commented Jan 31, 2024

(base) woo@Mac-Mini Langchain-Chatchat-master % python init_database.py --recreate-vs
recreating all vector stores
2024-01-31 08:45:01,430 - faiss_cache.py[line:92] - INFO: loading vector store in 'samples/vector_store/bge-large-zh-v1.5' from disk.
2024-01-31 08:45:01,534 - SentenceTransformer.py[line:66] - INFO: Load pretrained SentenceTransformer: BAAI/bge-large-zh-v1.5
2024-01-31 08:46:02,273 - embeddings_api.py[line:39] - ERROR: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/BAAI/bge-large-zh-v1.5 (Caused by ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response')))"), '(Request ID: 04968b9f-5b4a-4391-bac8-4131b2790842)')
AttributeError: 'NoneType' object has no attribute 'conjugate'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/init_database.py", line 107, in
folder2db(kb_names=args.kb_name, mode="recreate_vs", embed_model=args.embed_model)
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/server/knowledge_base/migrate.py", line 121, in folder2db
kb.create_kb()
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/server/knowledge_base/kb_service/base.py", line 80, in create_kb
self.do_create_kb()
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/server/knowledge_base/kb_service/faiss_kb_service.py", line 51, in do_create_kb
self.load_vector_store()
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/server/knowledge_base/kb_service/faiss_kb_service.py", line 28, in load_vector_store
return kb_faiss_pool.load_vector_store(kb_name=self.kb_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/server/knowledge_base/kb_cache/faiss_cache.py", line 102, in load_vector_store
vector_store = self.new_vector_store(embed_model=embed_model, embed_device=embed_device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/server/knowledge_base/kb_cache/faiss_cache.py", line 60, in new_vector_store
vector_store = FAISS.from_documents([doc], embeddings, normalize_L2=True,distance_strategy="METRIC_INNER_PRODUCT")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/woo/miniconda3/lib/python3.11/site-packages/langchain_core/vectorstores.py", line 508, in from_documents
return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/woo/miniconda3/lib/python3.11/site-packages/langchain_community/vectorstores/faiss.py", line 913, in from_texts
embeddings = embedding.embed_documents(texts)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/server/knowledge_base/kb_service/base.py", line 420, in embed_documents
return normalize(embeddings).tolist()
^^^^^^^^^^^^^^^^^^^^^
File "/Users/woo/CHAT-PDF/Langchain-Chatchat-master/server/knowledge_base/kb_service/base.py", line 37, in normalize
norm = np.linalg.norm(embeddings, axis=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<array_function internals>", line 200, in norm
File "/Users/woo/miniconda3/lib/python3.11/site-packages/numpy/linalg/linalg.py", line 2541, in norm
s = (x.conj() * x).real
^^^^^^^^
TypeError: loop of ufunc does not support argument 0 of type NoneType which has no callable conjugate method
请指导

@donywoo donywoo added the bug Something isn't working label Jan 31, 2024
Copy link

dosubot bot commented Jan 31, 2024

🤖

嗨,@donywoo!很高兴再次见到你。希望你一切都好。

看起来你在尝试初始化Langchain-Chatchat的数据库时遇到了问题。根据你提供的错误信息,问题似乎出在了embed_documents函数中,这个函数试图对NoneType对象进行操作,这是不允许的。这可能是因为在尝试获取模型BAAI/bge-large-zh-v1.5时出现了问题,导致没有正确地获取到模型。

这个问题可能是由于网络连接问题导致的,因为错误信息中提到了MaxRetryErrorProxyError。你可能需要检查你的网络连接,确保你的设备可以正常访问huggingface.co。如果你在一个需要代理服务器才能访问互联网的网络环境中,你可能需要检查你的代理服务器设置。

另外,你也可以尝试在本地预先下载模型,然后在初始化数据库时指定本地的模型路径,而不是在线获取。你可以在Hugging Face模型库中找到BAAI/bge-large-zh-v1.5模型,然后下载到你的设备上。

如果以上建议都不能解决你的问题,你可能需要提供更多的信息,例如你的操作系统、Python版本、你是否已经安装了所有必要的依赖库等,这样我才能更好地帮助你解决问题。

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@zRzRzRzRzRzRzR
Copy link
Collaborator

大概率是模型有问题或者你是cpu的设备但是装了gpu的torch

@wangkx0107
Copy link

可以多来几次,我是第一次失败了,但是第二次就ok了

@Leng-bingo
Copy link

打开翻墙VPN即可解决,亲测问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants