Skip to content

Commit 9c525b7

Browse files
authored
publish 0.2.10 (#2797)
新功能: - 优化 PDF 文件的 OCR,过滤无意义的小图片 by @liunux4odoo #2525 - 支持 Gemini 在线模型 by @yhfgyyf #2630 - 支持 GLM4 在线模型 by @zRzRzRzRzRzRzR - elasticsearch更新https连接 by @xldistance #2390 - 增强对PPT、DOC知识库文件的OCR识别 by @596192804 #2013 - 更新 Agent 对话功能 by @zRzRzRzRzRzRzR - 每次创建对象时从连接池获取连接,避免每次执行方法时都新建连接 by @Lijia0 #2480 - 实现 ChatOpenAI 判断token有没有超过模型的context上下文长度 by @glide-the - 更新运行数据库报错和项目里程碑 by @zRzRzRzRzRzRzR #2659 - 更新配置文件/文档/依赖 by @imClumsyPanda @zRzRzRzRzRzRzR - 添加日文版 readme by @eltociear #2787 修复: - langchain 更新后,PGVector 向量库连接错误 by @HALIndex #2591 - Minimax's model worker 错误 by @xyhshen - ES库无法向量检索.添加mappings创建向量索引 by MSZheng20 #2688
1 parent ee6a28b commit 9c525b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1299
-1546
lines changed

README.md

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
11
![](img/logo-long-chatchat-trans-v2.png)
22

3-
43
🌍 [READ THIS IN ENGLISH](README_en.md)
54
🌍 [日本語で読む](README_ja.md)
65

76
📃 **LangChain-Chatchat** (原 Langchain-ChatGLM)
87

98
基于 ChatGLM 等大语言模型与 Langchain 等应用框架实现,开源、可离线部署的检索增强生成(RAG)大模型知识库项目。
109

10+
⚠️`0.2.10`将会是`0.2.x`系列的最后一个版本,`0.2.x`系列版本将会停止更新和技术支持,全力研发具有更强应用性的 `Langchain-Chatchat 0.3.x`
11+
1112
---
1213

1314
## 目录
1415

1516
* [介绍](README.md#介绍)
1617
* [解决的痛点](README.md#解决的痛点)
1718
* [快速上手](README.md#快速上手)
18-
* [1. 环境配置](README.md#1-环境配置)
19-
* [2. 模型下载](README.md#2-模型下载)
20-
* [3. 初始化知识库和配置文件](README.md#3-初始化知识库和配置文件)
21-
* [4. 一键启动](README.md#4-一键启动)
22-
* [5. 启动界面示例](README.md#5-启动界面示例)
19+
* [1. 环境配置](README.md#1-环境配置)
20+
* [2. 模型下载](README.md#2-模型下载)
21+
* [3. 初始化知识库和配置文件](README.md#3-初始化知识库和配置文件)
22+
* [4. 一键启动](README.md#4-一键启动)
23+
* [5. 启动界面示例](README.md#5-启动界面示例)
2324
* [联系我们](README.md#联系我们)
2425

25-
2626
## 介绍
2727

28-
🤖️ 一种利用 [langchain](https://github.com/hwchase17/langchain) 思想实现的基于本地知识库的问答应用,目标期望建立一套对中文场景与开源模型支持友好、可离线运行的知识库问答解决方案。
28+
🤖️ 一种利用 [langchain](https://github.com/langchain-ai/langchain)
29+
思想实现的基于本地知识库的问答应用,目标期望建立一套对中文场景与开源模型支持友好、可离线运行的知识库问答解决方案。
2930

30-
💡 受 [GanymedeNil](https://github.com/GanymedeNil) 的项目 [document.ai](https://github.com/GanymedeNil/document.ai)[AlexZhangji](https://github.com/AlexZhangji) 创建的 [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216) 启发,建立了全流程可使用开源模型实现的本地知识库问答应用。本项目的最新版本中通过使用 [FastChat](https://github.com/lm-sys/FastChat) 接入 Vicuna, Alpaca, LLaMA, Koala, RWKV 等模型,依托于 [langchain](https://github.com/langchain-ai/langchain) 框架支持通过基于 [FastAPI](https://github.com/tiangolo/fastapi) 提供的 API 调用服务,或使用基于 [Streamlit](https://github.com/streamlit/streamlit) 的 WebUI 进行操作。
31+
💡 受 [GanymedeNil](https://github.com/GanymedeNil) 的项目 [document.ai](https://github.com/GanymedeNil/document.ai)
32+
[AlexZhangji](https://github.com/AlexZhangji)
33+
创建的 [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216)
34+
启发,建立了全流程可使用开源模型实现的本地知识库问答应用。本项目的最新版本中通过使用 [FastChat](https://github.com/lm-sys/FastChat)
35+
接入 Vicuna, Alpaca, LLaMA, Koala, RWKV 等模型,依托于 [langchain](https://github.com/langchain-ai/langchain)
36+
框架支持通过基于 [FastAPI](https://github.com/tiangolo/fastapi) 提供的 API
37+
调用服务,或使用基于 [Streamlit](https://github.com/streamlit/streamlit) 的 WebUI 进行操作。
3138

32-
✅ 依托于本项目支持的开源 LLM 与 Embedding 模型,本项目可实现全部使用**开源**模型**离线私有部署**。与此同时,本项目也支持 OpenAI GPT API 的调用,并将在后续持续扩充对各类模型及模型 API 的接入。
39+
✅ 依托于本项目支持的开源 LLM 与 Embedding 模型,本项目可实现全部使用**开源**模型**离线私有部署**。与此同时,本项目也支持
40+
OpenAI GPT API 的调用,并将在后续持续扩充对各类模型及模型 API 的接入。
3341

34-
⛓️ 本项目实现原理如下图所示,过程包括加载文件 -> 读取文本 -> 文本分割 -> 文本向量化 -> 问句向量化 -> 在文本向量中匹配出与问句向量最相似的 `top k`个 -> 匹配出的文本作为上下文和问题一起添加到 `prompt`中 -> 提交给 `LLM`生成回答。
42+
⛓️ 本项目实现原理如下图所示,过程包括加载文件 -> 读取文本 -> 文本分割 -> 文本向量化 -> 问句向量化 ->
43+
在文本向量中匹配出与问句向量最相似的 `top k`个 -> 匹配出的文本作为上下文和问题一起添加到 `prompt`中 -> 提交给 `LLM`生成回答。
3544

3645
📺 [原理介绍视频](https://www.bilibili.com/video/BV13M4y1e7cN/?share_source=copy_web&vd_source=e6c5aafe684f30fbe41925d61ca6d514)
3746

@@ -43,7 +52,8 @@
4352

4453
🚩 本项目未涉及微调、训练过程,但可利用微调或训练对本项目效果进行优化。
4554

46-
🌐 [AutoDL 镜像](https://www.codewithgpu.com/i/chatchat-space/Langchain-Chatchat/Langchain-Chatchat)`v13` 版本所使用代码已更新至本项目 `v0.2.9` 版本。
55+
🌐 [AutoDL 镜像](https://www.codewithgpu.com/i/chatchat-space/Langchain-Chatchat/Langchain-Chatchat)`v13`
56+
版本所使用代码已更新至本项目 `v0.2.9` 版本。
4757

4858
🐳 [Docker 镜像](registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.6) 已经更新到 ```0.2.7``` 版本。
4959

@@ -53,7 +63,10 @@
5363
docker run -d --gpus all -p 80:8501 registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.7
5464
```
5565

56-
🧩 本项目有一个非常完整的[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/) , README只是一个简单的介绍,__仅仅是入门教程,能够基础运行__。 如果你想要更深入的了解本项目,或者想对本项目做出贡献。请移步 [Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/) 界面
66+
🧩 本项目有一个非常完整的[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/) , README只是一个简单的介绍,_
67+
_仅仅是入门教程,能够基础运行__
68+
如果你想要更深入的了解本项目,或者想对本项目做出贡献。请移步 [Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
69+
界面
5770

5871
## 解决的痛点
5972

@@ -63,17 +76,19 @@ docker run -d --gpus all -p 80:8501 registry.cn-beijing.aliyuncs.com/chatchat/ch
6376
我们支持市面上主流的本地大语言模型和Embedding模型,支持开源的本地向量数据库。
6477
支持列表详见[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
6578

66-
6779
## 快速上手
6880

6981
### 1. 环境配置
7082

71-
+ 首先,确保你的机器安装了 Python 3.8 - 3.11
83+
+ 首先,确保你的机器安装了 Python 3.8 - 3.11 (我们强烈推荐使用 Python3.11)。
84+
7285
```
7386
$ python --version
7487
Python 3.11.7
7588
```
89+
7690
接着,创建一个虚拟环境,并在虚拟环境内安装项目的依赖
91+
7792
```shell
7893

7994
# 拉取仓库
@@ -89,33 +104,44 @@ $ pip install -r requirements_webui.txt
89104

90105
# 默认依赖包括基本运行环境(FAISS向量库)。如果要使用 milvus/pg_vector 等向量库,请将 requirements.txt 中相应依赖取消注释再安装。
91106
```
92-
请注意,LangChain-Chatchat `0.2.x` 系列是针对 Langchain `0.0.x` 系列版本的,如果你使用的是 Langchain `0.1.x` 系列版本,需要降级。
107+
108+
请注意,LangChain-Chatchat `0.2.x` 系列是针对 Langchain `0.0.x` 系列版本的,如果你使用的是 Langchain `0.1.x`
109+
系列版本,需要降级您的`Langchain`版本。
110+
93111
### 2, 模型下载
94112

95-
如需在本地或离线环境下运行本项目,需要首先将项目所需的模型下载至本地,通常开源 LLM 与 Embedding 模型可以从 [HuggingFace](https://huggingface.co/models) 下载。
113+
如需在本地或离线环境下运行本项目,需要首先将项目所需的模型下载至本地,通常开源 LLM 与 Embedding
114+
模型可以从 [HuggingFace](https://huggingface.co/models) 下载。
96115

97-
以本项目中默认使用的 LLM 模型 [THUDM/ChatGLM3-6B](https://huggingface.co/THUDM/chatglm3-6b) 与 Embedding 模型 [BAAI/bge-large-zh](https://huggingface.co/BAAI/bge-large-zh) 为例:
116+
以本项目中默认使用的 LLM 模型 [THUDM/ChatGLM3-6B](https://huggingface.co/THUDM/chatglm3-6b) 与 Embedding
117+
模型 [BAAI/bge-large-zh](https://huggingface.co/BAAI/bge-large-zh) 为例:
98118

99-
下载模型需要先[安装 Git LFS](https://docs.github.com/zh/repositories/working-with-files/managing-large-files/installing-git-large-file-storage),然后运行
119+
下载模型需要先[安装 Git LFS](https://docs.github.com/zh/repositories/working-with-files/managing-large-files/installing-git-large-file-storage)
120+
,然后运行
100121

101122
```Shell
102123
$ git lfs install
103124
$ git clone https://huggingface.co/THUDM/chatglm3-6b
104125
$ git clone https://huggingface.co/BAAI/bge-large-zh
105126
```
127+
106128
### 3. 初始化知识库和配置文件
107129

108130
按照下列方式初始化自己的知识库和简单的复制配置文件
131+
109132
```shell
110133
$ python copy_config_example.py
111134
$ python init_database.py --recreate-vs
112135
```
136+
113137
### 4. 一键启动
114138

115139
按照以下命令启动项目
140+
116141
```shell
117142
$ python startup.py -a
118143
```
144+
119145
### 5. 启动界面示例
120146

121147
如果正常启动,你将能看到以下界面
@@ -134,19 +160,32 @@ $ python startup.py -a
134160

135161
![](img/init_knowledge_base.jpg)
136162

137-
138163
### 注意
139164

140-
以上方式只是为了快速上手,如果需要更多的功能和自定义启动方式 ,请参考[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
165+
以上方式只是为了快速上手,如果需要更多的功能和自定义启动方式
166+
,请参考[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
141167

142168

143169
---
170+
144171
## 项目里程碑
145172

173+
+ `2023年4月`: `Langchain-ChatGLM 0.1.0` 发布,支持基于 ChatGLM-6B 模型的本地知识库问答。
174+
+ `2023年8月`: `Langchain-ChatGLM` 改名为 `Langchain-Chatchat``0.2.0` 发布,使用 `fastchat` 作为模型加载方案,支持更多的模型和数据库。
175+
+ `2023年10月`: `Langchain-Chatchat 0.2.5` 发布,推出 Agent 内容,开源项目在`Founder Park & Zhipu AI & Zilliz`
176+
举办的黑客马拉松获得三等奖。
177+
+ `2023年12月`: `Langchain-Chatchat` 开源项目获得超过 **20K** stars.
178+
+ `2024年1月`: `LangChain 0.1.x` 推出,`Langchain-Chatchat 0.2.x` 发布稳定版本`0.2.10`
179+
后将停止更新和技术支持,全力研发具有更强应用性的 `Langchain-Chatchat 0.3.x`
180+
181+
+ 🔥 让我们一起期待未来 Chatchat 的故事 ···
146182

147183
---
184+
148185
## 联系我们
186+
149187
### Telegram
188+
150189
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white "langchain-chatglm")](https://t.me/+RjliQ3jnJ1YyN2E9)
151190

152191
### 项目交流群
@@ -158,4 +197,4 @@ $ python startup.py -a
158197

159198
<img src="img/official_wechat_mp_account.png" alt="二维码" width="300" />
160199

161-
🎉 Langchain-Chatchat 项目官方公众号,欢迎扫码关注。
200+
🎉 Langchain-Chatchat 项目官方公众号,欢迎扫码关注。

README_en.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
A LLM application aims to implement knowledge and search engine based QA based on Langchain and open-source or remote
99
LLM API.
1010

11+
⚠️`0.2.10` will be the last version of the `0.2.x` series. The `0.2.x` series will stop updating and technical support,
12+
and strive to develop `Langchain-Chachat 0.3.x with stronger applicability. `.
13+
14+
1115
---
1216

1317
## Table of Contents
@@ -25,7 +29,8 @@ LLM API.
2529
## Introduction
2630

2731
🤖️ A Q&A application based on local knowledge base implemented using the idea
28-
of [langchain](https://github.com/hwchase17/langchain). The goal is to build a KBQA(Knowledge based Q&A) solution that
32+
of [langchain](https://github.com/langchain-ai/langchain). The goal is to build a KBQA(Knowledge based Q&A) solution
33+
that
2934
is friendly to Chinese scenarios and open source models and can run both offline and online.
3035

3136
💡 Inspired by [document.ai](https://github.com/GanymedeNil/document.ai)
@@ -56,10 +61,9 @@ The main process analysis from the aspect of document process:
5661
🚩 The training or fine-tuning are not involved in the project, but still, one always can improve performance by do
5762
these.
5863

59-
🌐 [AutoDL image](registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.5) is supported, and in v13 the codes are update
60-
to v0.2.9.
64+
🌐 [AutoDL image](https://www.codewithgpu.com/i/chatchat-space/Langchain-Chatchat/Langchain-Chatchat) is supported, and in v13 the codes are update to v0.2.9.
6165

62-
🐳 [Docker image](registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.7)
66+
🐳 [Docker image](registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.7) is supported to 0.2.7
6367

6468
## Pain Points Addressed
6569

@@ -99,7 +103,9 @@ $ pip install -r requirements_webui.txt
99103

100104
# 默认依赖包括基本运行环境(FAISS向量库)。如果要使用 milvus/pg_vector 等向量库,请将 requirements.txt 中相应依赖取消注释再安装。
101105
```
102-
Please note that the LangChain-Chachat `0.2.x` series is for the Langchain `0.0.x` series version. If you are using the Langchain `0.1.x` series version, you need to downgrade.
106+
107+
Please note that the LangChain-Chachat `0.2.x` series is for the Langchain `0.0.x` series version. If you are using the
108+
Langchain `0.1.x` series version, you need to downgrade.
103109

104110
### Model Download
105111

@@ -159,15 +165,33 @@ please refer to the [Wiki](https://github.com/chatchat-space/Langchain-Chatchat/
159165

160166
---
161167

168+
## Project Milestones
169+
170+
+ `April 2023`: `Langchain-ChatGLM 0.1.0` released, supporting local knowledge base question and answer based on the
171+
ChatGLM-6B model.
172+
+ `August 2023`: `Langchain-ChatGLM` was renamed to `Langchain-Chatchat`, `0.2.0` was released, using `fastchat` as the
173+
model loading solution, supporting more models and databases.
174+
+ `October 2023`: `Langchain-Chachat 0.2.5` was released, Agent content was launched, and the open source project won
175+
the third prize in the hackathon held by `Founder Park & Zhipu AI & Zilliz`.
176+
+ `December 2023`: `Langchain-Chachat` open source project received more than **20K** stars.
177+
+ `January 2024`: `LangChain 0.1.x` is launched, `Langchain-Chachat 0.2.x` is released. After the stable
178+
version `0.2.10` is released, updates and technical support will be stopped, and all efforts will be made to
179+
develop `Langchain with stronger applicability -Chat 0.3.x`.
180+
181+
182+
+ 🔥 Let’s look forward to the future Chatchat stories together···
183+
184+
---
185+
162186
## Contact Us
163187

164188
### Telegram
165189

166190
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white "langchain-chatglm")](https://t.me/+RjliQ3jnJ1YyN2E9)
167191

168-
### WeChat Group
192+
### WeChat Group
169193

170-
<img src="img/qr_code_67.jpg" alt="二维码" width="300" height="300" />
194+
<img src="img/qr_code_87.jpg" alt="二维码" width="300" height="300" />
171195

172196
### WeChat Official Account
173197

configs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
from .prompt_config import *
66

77

8-
VERSION = "v0.2.9"
8+
VERSION = "v0.2.10"

configs/kb_config.py.example

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ OVERLAP_SIZE = 50
2121
# 知识库匹配向量数量
2222
VECTOR_SEARCH_TOP_K = 3
2323

24-
# 知识库匹配的距离阈值,取值范围在0-1之间,SCORE越小,距离越小从而相关度越高,
25-
# 取到1相当于不筛选,实测bge-large的距离得分大部分在0.01-0.7之间,
26-
# 相似文本的得分最高在0.55左右,因此建议针对bge设置得分为0.6
27-
SCORE_THRESHOLD = 0.6
24+
# 知识库匹配的距离阈值,一般取值范围在0-1之间,SCORE越小,距离越小从而相关度越高。
25+
# 但有用户报告遇到过匹配分值超过1的情况,为了兼容性默认设为1,在WEBUI中调整范围为0-2
26+
SCORE_THRESHOLD = 1.0
2827

2928
# 默认搜索引擎。可选:bing, duckduckgo, metaphor
3029
DEFAULT_SEARCH_ENGINE = "duckduckgo"
@@ -49,12 +48,17 @@ BING_SUBSCRIPTION_KEY = ""
4948
# metaphor搜索需要KEY
5049
METAPHOR_API_KEY = ""
5150

51+
# 心知天气 API KEY,用于天气Agent。申请:https://www.seniverse.com/
52+
SENIVERSE_API_KEY = ""
5253

5354
# 是否开启中文标题加强,以及标题增强的相关配置
5455
# 通过增加标题判断,判断哪些文本为标题,并在metadata中进行标记;
5556
# 然后将文本与往上一级的标题进行拼合,实现文本信息的增强。
5657
ZH_TITLE_ENHANCE = False
5758

59+
# PDF OCR 控制:只对宽高超过页面一定比例(图片宽/页面宽,图片高/页面高)的图片进行 OCR。
60+
# 这样可以避免 PDF 中一些小图片的干扰,提高非扫描版 PDF 处理速度
61+
PDF_OCR_THRESHOLD = (0.6, 0.6)
5862

5963
# 每个知识库的初始化介绍,用于在初始化知识库时显示和Agent调用,没写则没有介绍,不会被Agent调用。
6064
KB_INFO = {

0 commit comments

Comments
 (0)