当前位置:   article > 正文

LangChain数据库初始化出错_typeerror: loop of ufunc does not support argument

typeerror: loop of ufunc does not support argument 0 of type nonetype which

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

报错如下:

  1. File "E:\LangChain\Langchain-Chatchat-master\init_database.py", line 107, in <module>
  2. folder2db(kb_names=args.kb_name, mode="recreate_vs", embed_model=args.embed_model)
  3. File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\migrate.py", line 121, in folder2db
  4. kb.create_kb()
  5. File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_service\base.py", line 81, in create_kb
  6. self.do_create_kb()
  7. File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_service\faiss_kb_service.py", line 51, in do_create_kb
  8. self.load_vector_store()
  9. File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_service\faiss_kb_service.py", line 28, in load_vector_store
  10. return kb_faiss_pool.load_vector_store(kb_name=self.kb_name,
  11. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  12. File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_cache\faiss_cache.py", line 102, in load_vector_store
  13. vector_store = self.new_vector_store(embed_model=embed_model, embed_device=embed_device)
  14. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  15. File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_cache\faiss_cache.py", line 60, in new_vector_store
  16. vector_store = FAISS.from_documents([doc], embeddings, normalize_L2=True,distance_strategy="METRIC_INNER_PRODUCT")
  17. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  18. File "E:\LangChain\Langchain-Chatchat-master\venv\Lib\site-packages\langchain_core\vectorstores.py", line 508, in from_documents
  19. return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs)
  20. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  21. File "E:\LangChain\Langchain-Chatchat-master\venv\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 959, in from_texts
  22. embeddings = embedding.embed_documents(texts)
  23. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  24. File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_service\base.py", line 425, in embed_documents
  25. return normalize(embeddings).tolist()
  26. ^^^^^^^^^^^^^^^^^^^^^
  27. File "E:\LangChain\Langchain-Chatchat-master\server\knowledge_base\kb_service\base.py", line 37, in normalize
  28. norm = np.linalg.norm(embeddings, axis=1)
  29. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  30. File "<__array_function__ internals>", line 200, in norm
  31. File "E:\LangChain\Langchain-Chatchat-master\venv\Lib\site-packages\numpy\linalg\linalg.py", line 2541, in norm
  32. s = (x.conj() * x).real
  33. ^^^^^^^^
  34. 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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/586216
推荐阅读
相关标签
  

闽ICP备14008679号