TypeError: loop of ufunc does not support argument 0 of type NoneType which has no callable conjugate method

报错如下:

File "E:\LangChain\Langchain-Chatchat-master\init_database.py", line 107, in

folder2db(kb_names=args.kb_name, mode="recreate_vs", embed_model=args.embed_model)

File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\migrate.py", line 121, in folder2db

kb.create_kb()

File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_service\base.py", line 81, in create_kb

self.do_create_kb()

File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_service\faiss_kb_service.py", line 51, in do_create_kb

self.load_vector_store()

File "E:\LangChain\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 "E:\LangChain\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 "E:\LangChain\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 "E:\LangChain\Langchain-Chatchat-master\venv\Lib\site-packages\langchain_core\vectorstores.py", line 508, in from_documents

return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "E:\LangChain\Langchain-Chatchat-master\venv\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 959, in from_texts

embeddings = embedding.embed_documents(texts)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_service\base.py", line 425, in embed_documents

return normalize(embeddings).tolist()

^^^^^^^^^^^^^^^^^^^^^

File "E:\LangChain\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 "E:\LangChain\Langchain-Chatchat-master\venv\Lib\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

原因为连接不上https://huggingface.co

解决方法,使用梯子

或者直接访问镜像源下载

BAAI/bge-large-zh-v1.5 at main

下载完后,复制到路径中C:\Users\Administrator\.cache\torch\sentence_transformers\BAAI_bge-large-zh-v1.5

再次运行就正常了

python init_database.py --recreate-vs

参考链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: