-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
216 changed files
with
4,431 additions
and
2,231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b | |
|
||
1. 强大的可视化编排,轻松构建 AI 应用 | ||
- [x] 提供简易模式,无需操作编排 | ||
- [x] 用户对话前引导, 全局字符串变量 | ||
- [x] 用户对话前引导,全局字符串变量 | ||
- [x] 知识库搜索 | ||
- [x] 多 LLM 模型对话 | ||
- [x] 文本内容提取成结构化数据 | ||
|
@@ -56,12 +56,12 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b | |
- [x] 对话下一步指引 | ||
- [ ] 对话多路线选择 | ||
- [x] 源文件引用追踪 | ||
- [ ] 自定义文件阅读器 | ||
- [x] 模块封装,实现多级复用 | ||
2. 丰富的知识库预处理 | ||
- [x] 多库复用,混用 | ||
- [x] chunk 记录修改和删除 | ||
- [x] 支持 手动输入, 直接分段, QA 拆分导入 | ||
- [x] 支持 url 读取、 CSV 批量导入 | ||
- [x] 支持手动输入,直接分段,QA 拆分导入 | ||
- [x] 支持 url 读取、CSV 批量导入 | ||
- [x] 支持知识库单独设置向量模型 | ||
- [x] 源文件存储 | ||
- [ ] 文件学习 Agent | ||
|
@@ -71,7 +71,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b | |
- [x] 完整上下文呈现 | ||
- [x] 完整模块中间值呈现 | ||
4. OpenAPI | ||
- [x] completions 接口(对齐 GPT 接口) | ||
- [x] completions 接口 (对齐 GPT 接口) | ||
- [ ] 知识库 CRUD | ||
5. 运营功能 | ||
- [x] 免登录分享窗口 | ||
|
@@ -80,7 +80,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b | |
|
||
## 👨💻 开发 | ||
|
||
项目技术栈: NextJs + TS + ChakraUI + Mongo + Postgres(Vector 插件) | ||
项目技术栈:NextJs + TS + ChakraUI + Mongo + Postgres (Vector 插件) | ||
|
||
- **⚡ 快速部署** | ||
|
||
|
@@ -95,7 +95,8 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b | |
* [系统配置文件说明](https://doc.fastgpt.in/docs/development/configuration/) | ||
* [多模型配置](https://doc.fastgpt.in/docs/installation/one-api/) | ||
* [版本更新/升级介绍](https://doc.fastgpt.in/docs/installation/upgrading) | ||
* [API 文档](https://doc.fastgpt.in/docs/development/openapi/) | ||
* [OpenAPI API 文档](https://doc.fastgpt.in/docs/development/openapi/) | ||
* [知识库结构详解](https://doc.fastgpt.in/docs/use-cases/datasetengine/) | ||
|
||
## 🏘️ 社区交流群 | ||
|
||
|
@@ -105,10 +106,10 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b | |
|
||
## 💪 相关项目 | ||
|
||
- [Laf: 3 分钟快速接入三方应用](https://github.com/labring/laf) | ||
- [Sealos: 快速部署集群应用](https://github.com/labring/sealos) | ||
- [One API: 多模型管理,支持 Azure、文心一言等](https://github.com/songquanpeng/one-api) | ||
- [TuShan: 5 分钟搭建后台管理系统](https://github.com/msgbyte/tushan) | ||
- [Laf:3 分钟快速接入三方应用](https://github.com/labring/laf) | ||
- [Sealos:快速部署集群应用](https://github.com/labring/sealos) | ||
- [One API:多模型管理,支持 Azure、文心一言等](https://github.com/songquanpeng/one-api) | ||
- [TuShan:5 分钟搭建后台管理系统](https://github.com/msgbyte/tushan) | ||
|
||
## 👀 其他 | ||
|
||
|
@@ -129,6 +130,6 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b | |
本仓库遵循 [FastGPT Open Source License](./LICENSE) 开源协议。 | ||
|
||
1. 允许作为后台服务直接商用,但不允许提供 SaaS 服务。 | ||
2. 需保留相关版权信息。 | ||
2. 未经商业授权,任何形式的商用服务均需保留相关版权信息。 | ||
3. 完整请查看 [FastGPT Open Source License](./LICENSE) | ||
4. 联系方式:[email protected], [点击查看定价策略](https://doc.fastgpt.run/docs/commercial) | ||
4. 联系方式:[email protected],[点击查看商业版定价策略](https://doc.fastgpt.run/docs/commercial) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"preset": "default", | ||
"rules": { | ||
"adjustedFullWidthPunctuation": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: 'V4.5.2' | ||
description: 'FastGPT V4.5.2 更新' | ||
icon: 'upgrade' | ||
draft: false | ||
toc: true | ||
weight: 837 | ||
--- | ||
|
||
## 功能介绍 | ||
|
||
### Fast GPT V4.5.2 | ||
|
||
1. 新增 - 模块插件,允许自行组装插件进行模块复用。 | ||
2. 优化 - 知识库引用提示。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
title: "知识库结构讲解" | ||
description: "本节会介绍 FastGPT 知识库结构设计,理解其 QA 的存储格式和检索格式,以便更好的构建知识库。这篇介绍主要以使用为主,详细原理不多介绍。" | ||
icon: "dataset" | ||
draft: false | ||
toc: true | ||
weight: 311 | ||
--- | ||
|
||
# 理解向量 | ||
|
||
FastGPT 采用了 RAG 中的 Embedding 方案构建知识库,要使用好 FastGPT 需要简单的理解`Embedding`向量是如何工作的及其特点。 | ||
|
||
人类的文字、图片、视频等媒介是无法直接被计算机理解的,要想让计算机理解两段文字是否有相似性、相关性,通常需要将它们转成计算机可以理解的语言,向量是其中的一种方式。 | ||
|
||
向量可以简单理解为一个数字数组,两个向量之间可以通过数学公式得出一个`距离`,距离越小代表两个向量的相似度越大。从而映射到文字、图片、视频等媒介上,可以用来判断两个媒介之间的相似度。向量搜索便是利用了这个原理。 | ||
|
||
而由于文字是有多种类型,并且拥有成千上万种组合方式,因此在转成向量进行相似度匹配时,很难保障其精确性。在向量方案构建的知识库中,通常使用`topk`召回的方式,也就是查找前`k`个最相似的内容,丢给大模型去做更进一步的`语义判断`、`逻辑推理`和`归纳总结`,从而实现知识库问答。因此,在知识库问答中,向量搜索的环节是最为重要的。 | ||
|
||
影响向量搜索精度的因素非常多,主要包括:向量模型的质量、数据的质量(长度,完整性,多样性)、检索器的精度(速度与精度之间的取舍)。与数据质量对应的就是检索词的质量。 | ||
|
||
检索器的精度比较容易解决,向量模型的训练略复杂,因此数据和检索词质量优化成了一个重要的环节。 | ||
|
||
# FastGPT 中向量的结构设计 | ||
|
||
FastGPT 采用了 `PostgresSQL` 的 `PG Vector` 插件作为向量检索器,索引为`HNSW`。且`PostgresSQL`仅用于向量检索,`MongoDB`用于其他数据的存取。 | ||
|
||
在`PostgresSQL`的表中,设置一个 `index` 字段用于存储向量、一个 `q` 字段用于存储向量对应的内容,以及一个 `a` 字段用于检索映射。之所以取字段为 `qa` 是由于一些历史缘故,无需完全解为 “问答对” 的格式。在实际使用过程中,可以利用`q`和`a`的组合,对检索后的内容做进一步的声明,提高大模型的理解力(注意,这里不直接提高搜索精度)。 | ||
|
||
目前,提高向量搜索的精度,主要可以通过几种途径: | ||
|
||
1. 精简`q`的内容,减少向量内容的长度:当`q`的内容更少,更准确时,检索精度自然会提高。但与此同时,会牺牲一定的检索范围,适合答案较为严格的场景。 | ||
2. 更好分词分段:当一段话的结构和语义是完整的,并且是单一的,精度也会提高。因此,许多系统都会优化分词器,尽可能的保障每组数据的完整性。 | ||
3. 多样性文本:为一段内容增加关键词、摘要、相似问题等描述性信息,可以使得该内容的向量具有更大的检索覆盖范围。 | ||
4. 优化检索词:在实际使用过程中,用户的问题通常是模糊的或是缺失的,并不一定是完整清晰的问题。因此优化用户的问题(检索词)很大程度上也可以提高精度。 | ||
5. 微调向量模型:由于市面上直接使用的向量模型都是通用型模型,在特定领域的检索精度并不高,因此微调向量模型可以很大程度上提高专业领域的检索效果。 | ||
|
||
# FastGPT 构建知识库方案 | ||
|
||
在 FastGPT 中,整个知识库由库、集合和数据 3 部分组成。集合可以简单理解为一个`文件`。一个`库`中可以包含多个`集合`,一个`集合`中可以包含多组`数据`。最小的搜索单位是`库`,也就是说,知识库搜索时,是对整个`库`进行搜索,而集合仅是为了对数据进行分类管理,与搜索效果无关。(起码目前还是) | ||
|
||
| 库 | 集合 | 数据 | | ||
| --- | --- | --- | | ||
| ![](/imgs/datasetEngine1.png) | ![](/imgs/datasetEngine2.png) | ![](/imgs/datasetEngine3.png) | | ||
|
||
## 导入数据方案1 - 直接分段导入 | ||
|
||
选择文件导入时,可以选择直接分段方案。直接分段会利用`句子分词器`对文本进行一定长度拆分,最终分割中多组的`q`。如果使用了直接分段方案,我们建议在`应用`设置`引用提示词`时,使用`通用模板`即可,无需选择`问答模板`。 | ||
|
||
| 交互 | 结果 | | ||
| --- | --- | | ||
| ![](/imgs/datasetEngine4.png) | ![](/imgs/datasetEngine5.png) | | ||
|
||
|
||
## 导入数据方案2 - QA导入 | ||
|
||
选择文件导入时,可以选择QA拆分方案。仍然需要使用到`句子分词器`对文本进行拆分,但长度比直接分段大很多。在导入后,会先调用`大模型`对分段进行学习,并给出一些`问题`和`答案`,最终问题和答案会一起被存储到`q`中。注意,新版的 FastGPT 为了提高搜索的范围,不再将问题和答案分别存储到 qa 中。 | ||
|
||
| 交互 | 结果 | | ||
| --- | --- | | ||
| ![](/imgs/datasetEngine6.png) | ![](/imgs/datasetEngine7.png) | | ||
|
||
## 导入数据方案3 - 手动录入 | ||
|
||
在 FastGPT 中,你可以在任何一个`集合`中点击右上角的`插入`手动录入知识点,或者使用`标注`功能手动录入。被搜索的内容为`q`,补充内容(可选)为`a`。 | ||
|
||
| | | | | ||
| --- | --- | --- | | ||
| ![](/imgs/datasetEngine8.png) | ![](/imgs/datasetEngine9.png) | ![](/imgs/datasetEngine10.png) | | ||
|
||
## 导入数据方案4 - CSV录入 | ||
|
||
有些数据较为独特,可能需要单独的进行预处理分割后再导入 FastGPT,此时可以选择 csv 导入,可批量的将处理好的数据导入。 | ||
|
||
![](/imgs/datasetEngine11.png) | ||
|
||
## 导入数据方案5 - API导入 | ||
|
||
参考[FastGPT OpenAPI使用](/docs/development/openapi/#知识库添加数据)。 | ||
|
||
# QA的组合与引用提示词构建 | ||
|
||
参考[引用模板与引用提示词示例](/docs/use-cases/ai_settings/#示例) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.