From e74fe2d95061b78a65e705d2f4c6bb1f363dc9a7 Mon Sep 17 00:00:00 2001 From: zR <2448370773@qq.com> Date: Wed, 25 Oct 2023 21:59:26 +0800 Subject: [PATCH] =?UTF-8?q?Zilliz=E4=BF=AE=E5=A4=8D=20(#1874)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复zilliz的问题 --- README_en.md | 8 ++++---- configs/server_config.py.example | 3 +++ server/knowledge_base/kb_service/base.py | 11 +++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README_en.md b/README_en.md index f2aee60..c0b88ab 100644 --- a/README_en.md +++ b/README_en.md @@ -27,7 +27,7 @@ LLM API. of [langchain](https://github.com/hwchase17/langchain). The goal is to build a KBQA(Knowledge based Q&A) solution that is friendly to Chinese scenarios and open source models and can run both offline and online. -💡 Inspried by [document.ai](https://github.com/GanymedeNil/document.ai) +💡 Inspired by [document.ai](https://github.com/GanymedeNil/document.ai) and [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216) , we build a local knowledge base question answering application that can be implemented using an open source model or remote LLM api throughout the process. In the latest version of this project, [FastChat](https://github.com/lm-sys/FastChat) is used to access Vicuna, Alpaca, @@ -41,10 +41,10 @@ to expand the access to various models and remote APIs in the future. ⛓️ The implementation principle of this project is shown in the graph below. The main process includes: loading files -> reading text -> text segmentation -> text vectorization -> question vectorization -> matching the `top-k` most similar -to the question vector in the text vector -> The matched text is added to `prompt `as context and question -> submitted +to the question vector in the text vector -> The matched text is added to `prompt `as context and question -> submitte to `LLM` to generate an answer. -📺[video introdution](https://www.bilibili.com/video/BV13M4y1e7cN/?share_source=copy_web&vd_source=e6c5aafe684f30fbe41925d61ca6d514) +📺[video introduction](https://www.bilibili.com/video/BV13M4y1e7cN/?share_source=copy_web&vd_source=e6c5aafe684f30fbe41925d61ca6d514) ![实现原理图](img/langchain+chatglm.png) @@ -52,7 +52,7 @@ The main process analysis from the aspect of document process: ![实现原理图2](img/langchain+chatglm2.png) -🚩 The training or fined-tuning are not involved in the project, but still, one always can improve performance by do +🚩 The training or fine-tuning are not involved in the project, but still, one always can improve performance by do these. 🌐 [AutoDL image](registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.5) is supported, and in v9 the codes are update diff --git a/configs/server_config.py.example b/configs/server_config.py.example index 5da8f13..e7bfb5a 100644 --- a/configs/server_config.py.example +++ b/configs/server_config.py.example @@ -117,6 +117,9 @@ FSCHAT_MODEL_WORKERS = { # "baichuan-api": { # "port": 21007, # }, + # "azure-api": { + # "port": 21008, + # }, } # fastchat multi model worker server diff --git a/server/knowledge_base/kb_service/base.py b/server/knowledge_base/kb_service/base.py index 701f0cd..9ef9fa4 100644 --- a/server/knowledge_base/kb_service/base.py +++ b/server/knowledge_base/kb_service/base.py @@ -32,6 +32,7 @@ class SupportedVSType: FAISS = 'faiss' MILVUS = 'milvus' DEFAULT = 'default' + ZILLIZ = 'zilliz' PG = 'pg' @@ -246,14 +247,16 @@ class KBServiceFactory: if SupportedVSType.FAISS == vector_store_type: from server.knowledge_base.kb_service.faiss_kb_service import FaissKBService return FaissKBService(kb_name, embed_model=embed_model) - if SupportedVSType.PG == vector_store_type: + elif SupportedVSType.PG == vector_store_type: from server.knowledge_base.kb_service.pg_kb_service import PGKBService return PGKBService(kb_name, embed_model=embed_model) elif SupportedVSType.MILVUS == vector_store_type: from server.knowledge_base.kb_service.milvus_kb_service import MilvusKBService - return MilvusKBService(kb_name, - embed_model=embed_model) # other milvus parameters are set in model_config.kbs_config - elif SupportedVSType.DEFAULT == vector_store_type: # kb_exists of default kbservice is False, to make validation easier. + return MilvusKBService(kb_name,embed_model=embed_model) + elif SupportedVSType.ZILLIZ == vector_store_type: + from server.knowledge_base.kb_service.zilliz_kb_service import ZillizKBService + return ZillizKBService(kb_name, embed_model=embed_model) + elif SupportedVSType.DEFAULT == vector_store_type: from server.knowledge_base.kb_service.default_kb_service import DefaultKBService return DefaultKBService(kb_name)