chatchat-space / Langchain-Chatchat

Langchain-Chatchat(原Langchain-ChatGLM)基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain
Apache License 2.0
31.7k stars 5.53k forks source link

运行 python init_database --recreate-vs 报错 #2300

Closed yangcecode closed 10 months ago

yangcecode commented 10 months ago

拉取项目配置好环境后: 修改配置文件 EMBEDDING_MODEL = "text-embedding-ada-002" "text-embedding-ada-002": "sk-*****8h", 运行 python init_database --recreate-vs 报错

报错内容: E:\Python310\lib\site-packages\langchain\embeddings\openai.py:252: UserWarning: WARNING! model_name is not default parameter. model_name was transferred to model_kwargs. Please confirm that model_name is what you intended. warnings.warn( 2023-12-07 11:43:44,506 - embeddings_api.py[line:39] - ERROR: Embeddings.create() got an unexpected keyword argument 'model_name' AttributeError: 'NoneType' object has no attribute 'conjugate'

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

Traceback (most recent call last): File "D:\code\Langchain-Chatchat\init_database.py", line 109, in folder2db(kb_names=args.kb_name, mode="recreate_vs", embed_model=args.embed_model) File "D:\code\Langchain-Chatchat\server\knowledge_base\migrate.py", line 121, in folder2db kb.create_kb() File "D:\code\Langchain-Chatchat\server\knowledge_base\kb_service\base.py", line 81, in create_kb self.do_create_kb() File "D:\code\Langchain-Chatchat\server\knowledge_base\kb_service\faiss_kb_service.py", line 47, in do_create_kb self.load_vector_store() File "D:\code\Langchain-Chatchat\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 "D:\code\Langchain-Chatchat\server\knowledge_base\kb_cache\faiss_cache.py", line 90, in load_vector_store vector_store = self.new_vector_store(embed_model=embed_model, embed_device=embed_device) File "D:\code\Langchain-Chatchat\server\knowledge_base\kb_cache\faiss_cache.py", line 48, in new_vector_store vector_store = FAISS.from_documents([doc], embeddings, normalize_L2=True) File "E:\Python310\lib\site-packages\langchain_core\vectorstores.py", line 510, in from_documents return cls.from_texts(texts, embedding, metadatas=metadatas, *kwargs) File "E:\Python310\lib\site-packages\langchain\vectorstores\faiss.py", line 911, in from_texts embeddings = embedding.embed_documents(texts) File "D:\code\Langchain-Chatchat\server\knowledge_base\kb_service\base.py", line 399, in embed_documents return normalize(embeddings).tolist() File "D:\code\Langchain-Chatchat\server\knowledge_base\kb_service\base.py", line 38, in normalize norm = np.linalg.norm(embeddings, axis=1) File "<__array_function__ internals>", line 200, in norm File "E:\Python310\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

运行环境: Python 3.10.0rc2 site_pacjages: langchain==0.0.344 langchain-experimental>=0.0.42 pydantic==1.10.13 fschat>=0.2.33 xformers>=0.0.22.post7 openai>=1.3.6 sentence_transformers transformers>=4.35.2 torch==2.1.0 ##on Windows system, install the cuda version manually from https://pytorch.org/ torchvision #on Windows system, install the cuda version manually from https://pytorch.org/ torchaudio #on Windows system, install the cuda version manually from https://pytorch.org/ fastapi>=0.104 nltk>=3.8.1 uvicorn>=0.24.0.post1 starlette~=0.27.0 unstructured[all-docs]==0.11.0 python-magic-bin; sys_platform == 'win32' SQLAlchemy==2.0.19 faiss-cpu accelerate>=0.24.1 spacy>=3.7.2 PyMuPDF rapidocr_onnxruntime requests>=2.31.0 pathlib>=1.0.1 pytest>=7.4.3 numexpr>=2.8.7 strsimpy>=0.2.1 markdownify>=0.11.6 tiktoken>=0.5.1 tqdm>=4.66.1 websockets numpy~=1.24.4 pandas~=2.0.3 einops>=0.7.0 transformers_stream_generator==0.0.4 vllm==0.2.2; sys_platform == "linux"

Online api libs dependencies

zhipuai>=1.0.7

dashscope>=1.10.0

qianfan>=0.2.0

volcengine>=1.0.106

pymilvus>=2.3.3

psycopg2

pgvector>=0.2.4

Agent and Search Tools

arxiv>=2.0.0 youtube-search>=2.1.2 duckduckgo-search>=3.9.9 metaphor-python>=0.1.23

WebUI requirements

streamlit>=1.29.0 streamlit-option-menu>=0.3.6 streamlit-antd-components>=0.2.3 streamlit-chatbox>=1.1.11 streamlit-modal>=0.1.0 streamlit-aggrid>=0.3.4.post3 httpx[brotli,http2,socks]>=0.25.2 watchdog>=3.0.0

qianma819 commented 10 months ago

你把模型名字改下试试,我之前用的chatglm2-6bint4模型也报错,直接重命名成了chatglm2-6b,就能正常跑起来

yangcecode commented 10 months ago

你把模型名字改下试试,我之前用的chatglm2-6bint4模型也报错,直接重命名成了chatglm2-6b,就能正常跑起来

llm和EMBEDDING_MODEL 都是配置的openai得,

zhangyuehahaha commented 10 months ago

请问你的问题解决了吗?我也是这个报错,之前以为是模型文件下载得有问题。有同学部署成功了,我直接拷贝了他下载的模型,还是报一样的错

yangcecode commented 10 months ago

请问你的问题解决了吗?我也是这个报错,之前以为是模型文件下载得有问题。有同学部署成功了,我直接拷贝了他下载的模型,还是报一样的错

OpenAIEmbeddings配置需要改下,embeddings = OpenAIEmbeddings(model=model,

alphonz commented 10 months ago

请问你的问题解决了吗?我也是这个报错,之前以为是模型文件下载得有问题。有同学部署成功了,我直接拷贝了他下载的模型,还是报一样的错

OpenAIEmbeddings配置需要改下,embeddings = OpenAIEmbeddings(model=model,

能否告知下是哪个文件,感谢

yangcecode commented 10 months ago

你全局搜索下

---原始邮件--- 发件人: @.> 发送时间: 2023年12月12日(周二) 晚上6:03 收件人: @.>; 抄送: @.**@.>; 主题: Re: [chatchat-space/Langchain-Chatchat] 运行 python init_database --recreate-vs 报错 (Issue #2300)

请问你的问题解决了吗?我也是这个报错,之前以为是模型文件下载得有问题。有同学部署成功了,我直接拷贝了他下载的模型,还是报一样的错

OpenAIEmbeddings配置需要改下,embeddings = OpenAIEmbeddings(model=model,

能否告知下是哪个文件,感谢

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

alphonz commented 10 months ago

你全局搜索下 ---原始邮件--- 发件人: @.> 发送时间: 2023年12月12日(周二) 晚上6:03 收件人: @.>; 抄送: @.**@.>; 主题: Re: [chatchat-space/Langchain-Chatchat] 运行 python init_database --recreate-vs 报错 (Issue #2300) 请问你的问题解决了吗?我也是这个报错,之前以为是模型文件下载得有问题。有同学部署成功了,我直接拷贝了他下载的模型,还是报一样的错 OpenAIEmbeddings配置需要改下,embeddings = OpenAIEmbeddings(model=model, 能否告知下是哪个文件,感谢 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

感谢,已经成功

278038551 commented 10 months ago

EMBEDDING_MODEL

请问是把embeddings = OpenAIEmbeddings(model_name=model 改为embeddings = OpenAIEmbeddings(model=model 吗?