简介
本文使用 Windows 11 + Python 3.10.3 + CUDA 11.8 + Langchain-Chatchat + THUDM/chatglm2-6b-32k-int4 + sensenova/piccolo-large-zh 构建知识库。
使用其他分词和数据库待完善……
环境准备
- Python Windows 历史版本下载:adang1345/PythonWindows: Unofficial Python installers for Windows
- CUDA 所需最低驱动版本:CUDA Release Notes (nvidia.com)
- CUDA 下载:CUDA Toolkit Archive | NVIDIA Developer
部署 Langchain-Chatchat
按照 Langchain-Chatchat 开发部署文档部署。
报错解决
- git lsf 报错:
Use `git lfs logs last` to view the log. error: external filter 'git-lfs filter-process' failed fatal: pytorch_model.bin: smudge filter lfs failed warning: Clone succeeded, but checkout failed. You can inspect what was checked out with 'git status' and retry with 'git restore --source=HEAD :/'
git lfs install --skip-smudge git clone git@hf.co:THUDM/chatglm2-6b-32k-int4 cd chatglm2-6b-32k-int4 git lfs pull
python init_database.py --recreate-vs
时报错,删除knowledgebase
目录下的vector_store
。Traceback (most recent call last): File "/home/tskj/Langchain-Chatchat-0.2.5/Langchain-Chatchat-master/init_database.py", line 81, in folder2db(kb_names=args.kb_name, mode="recreate_vs") File "/home/tskj/Langchain-Chatchat-0.2.5/Langchain-Chatchat-master/server/knowledge_base/migrate.py", line 76, in folder2db files2vs(kb_name, kb_files) File "/home/tskj/Langchain-Chatchat-0.2.5/Langchain-Chatchat-master/server/knowledge_base/migrate.py", line 63, in files2vs kb.add_doc(kb_file=kb_file, not_refresh_vs_cache=True) File "/home/tskj/Langchain-Chatchat-0.2.5/Langchain-Chatchat-master/server/knowledge_base/kb_service/base.py", line 100, in add_doc doc_infos = self.do_add_doc(docs, **kwargs) File "/home/tskj/Langchain-Chatchat-0.2.5/Langchain-Chatchat-master/server/knowledge_base/kb_service/faiss_kb_service.py", line 72, in do_add_doc ids = vs.add_documents(docs) File "/home/tskj/miniconda3/envs/chatchat/lib/python3.10/site-packages/langchain/schema/vectorstore.py", line 104, in add_documents return self.add_texts(texts, metadatas, **kwargs) File "/home/tskj/miniconda3/envs/chatchat/lib/python3.10/site-packages/langchain/vectorstores/faiss.py", line 167, in add_texts return self.__add(texts, embeddings, metadatas=metadatas, ids=ids) File "/home/tskj/miniconda3/envs/chatchat/lib/python3.10/site-packages/langchain/vectorstores/faiss.py", line 139, in __add self.index.add(vector) File "/home/tskj/miniconda3/envs/chatchat/lib/python3.10/site-packages/faiss/class_wrappers.py", line 228, in replacement_add assert d == self.d AssertionError
-
python startup.py --all-webui
时报错Max retries exceeded with url: /register_worker……
,修改server_config.py
中DEFAULT_BIND_HOST
的值为127.0.0.1
。 -
修改
model_config.py
中EMBEDDING_DEVICE
的值为cuda
后启动报错raise AssertionError("Torch not compiled with CUDA enabled")
,安装 torch cuda 指定版本:pip install torch==2.1.0+cu118 torchvision==0.16.0+cu118 torchaudio==2.1.0+cu118 -f https://download.pytorch.org/whl/torch_stable.html --trusted-host pypi.org --trusted-host download.pytorch.org --trusted-host files.pythonhosted.org
找对应版本的话就在 https://download.pytorch.org/whl/torch_stable.html 看。
-
启动报错:
transformers_modules.chatglm2-6b-32k-int4.quantization | Failed to load cpm_kernels:No module named 'cpm_kernels' …… AttributeError: 'NoneType' object has no attribute 'int4WeightExtractionHalf'
安装 cpm_kernels 即可。
pip install cpm_kernels
-
搜索引擎问答时报错
API 通信遇到错误:peer closed connection without sending complete message body (incomplete chunked read)
:ImportError: Could not import duckduckgo-search python package. Please install it with `pip install duckduckgo-search`. 2023-10-12 19:04:59 | ERROR | root | RemoteProtocolError: API通信遇到错误:peer closed connection without sending complete message body (incomplete chunked read)
安装 duckduckgo-search 即可。
pip install duckduckgo-search
效果
参考
- [求助] 初始化知识库发生错误・Issue #1657・chatchat-space/Langchain-Chatchat
- [BUG] 运行 python startup.py --all-webui 打不开网页・Issue #1650・chatchat-space/Langchain-Chatchat
- windows 下用 chatglm2-6b-int4 做 LLM 基座,报 AttributeError: 'NoneType' object has no attribute 'int4WeightExtractionHalf'・Issue #1694・chatchat-space/Langchain-Chatchat
评论区