1 Star 0 Fork 72

ysdxhsw / QAnything

forked from 网易有道 / QAnything 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0
Logo

Question and Answer based on Anything

English | 简体中文

         

              

目 录

什么是QAnything?

QAnything (Question and Answer based on Anything) 是致力于支持任意格式文件或数据库的本地知识库问答系统,可断网安装使用。

您的任何格式的本地文件都可以往里扔,即可获得准确、快速、靠谱的问答体验。

目前已支持格式: PDF(pdf)Word(docx)PPT(pptx)XLS(xlsx)Markdown(md)电子邮件(eml)TXT(txt)图片(jpg,jpeg,png)CSV(csv)网页链接(html),更多格式,敬请期待...

特点

  • 数据安全,支持全程拔网线安装使用。
  • 支持跨语种问答,中英文问答随意切换,无所谓文件是什么语种。
  • 支持海量数据问答,两阶段向量排序,解决了大规模数据检索退化的问题,数据越多,效果越好。
  • 高性能生产级系统,可直接部署企业应用。
  • 易用性,无需繁琐的配置,一键安装部署,拿来就用。
  • 支持选择多知识库问答。

架构

qanything_system

为什么是两阶段检索?

知识库数据量大的场景下两阶段优势非常明显,如果只用一阶段embedding检索,随着数据量增大会出现检索退化的问题,如下图中绿线所示,二阶段rerank重排后能实现准确率稳定增长,即数据越多,效果越好

two stage retrievaal

QAnything使用的检索组件BCEmbedding有非常强悍的双语和跨语种能力,能消除语义检索里面的中英语言之间的差异,从而实现:

一阶段检索(embedding)

模型名称 Retrieval STS PairClassification Classification Reranking Clustering 平均
bge-base-en-v1.5 37.14 55.06 75.45 59.73 43.05 37.74 47.20
bge-base-zh-v1.5 47.60 63.72 77.40 63.38 54.85 32.56 53.60
bge-large-en-v1.5 37.15 54.09 75.00 59.24 42.68 37.32 46.82
bge-large-zh-v1.5 47.54 64.73 79.14 64.19 55.88 33.26 54.21
jina-embeddings-v2-base-en 31.58 54.28 74.84 58.42 41.16 34.67 44.29
m3e-base 46.29 63.93 71.84 64.08 52.38 37.84 53.54
m3e-large 34.85 59.74 67.69 60.07 48.99 31.62 46.78
bce-embedding-base_v1 57.60 65.73 74.96 69.00 57.29 38.95 59.43

二阶段检索(rerank)

模型名称 Reranking 平均
bge-reranker-base 57.78 57.78
bge-reranker-large 59.69 59.69
bce-reranker-base_v1 60.06 60.06

基于LlamaIndex的RAG评测(embedding and rerank)

NOTE:

  • 在WithoutReranker列中,我们的bce-embedding-base_v1模型优于所有其他embedding模型。
  • 在固定embedding模型的情况下,我们的bce-reranker-base_v1模型达到了最佳表现。
  • bce-embedding-base_v1和bce-reranker-base_v1的组合是SOTA。
  • 如果想单独使用embedding和rerank请参阅:BCEmbedding

LLM

开源版本QAnything的大模型基于通义千问,并在大量专业问答数据集上进行微调;在千问的基础上大大加强了问答的能力。 如果需要商用请遵循千问的license,具体请参阅:通义千问

开始之前

在GitHub上加星,即可立即收到新版本的通知! star_us

🚀 最近更新

  • 2024-01-29: 支持自定义大模型,包括OpenAI API和其他开源大模型,GPU需求最低降至GTX 1050Ti,极大提升部署,调试等方面的用户体验 - 详见👉 v1.2.0
  • 2024-01-23: 默认开启rerank,修复在windows上启动时存在的各类问题 - 详见👉 v1.1.1
  • 2024-01-18: 支持一键启动,支持windows部署,提升pdf,xlsx,html解析效果 - 详见👉 v1.1.0

开始

必要条件

For Linux

System Required item Minimum Requirement Note
Linux NVIDIA GPU Memory >= 4GB (use OpenAI API) 最低: GTX 1050Ti(use OpenAI API)
推荐: RTX 3090
NVIDIA Driver Version >= 525.105.17
Docker version >= 20.10.5 Docker install
docker compose version >= 2.23.3 docker compose install
git-lfs git-lfs install

For Windows with WSL Ubuntu子系统

System Required item Minimum Requirement Note
Windows with WSL Ubuntu子系统 NVIDIA GPU Memory >= 4GB (use OpenAI API) 最低: GTX 1050Ti(use OpenAI API)
推荐: RTX 3090
GEFORCE EXPERIENCE >= 546.33 GEFORCE EXPERIENCE download
Docker Desktop >= 4.26.1(131620) Docker Desktop for Windows
git-lfs git-lfs install

下载安装

step1: 下载本项目

git clone https://github.com/netease-youdao/QAnything.git

step2: 进入项目根目录执行启动脚本

cd QAnything
bash run.sh  # 默认在0号GPU上启动
(注意)如果自动下载失败,您可以从以下三个地址之一手动下载模型。

modelscope: https://modelscope.cn/models/netease-youdao/QAnything

wisemodel: https://wisemodel.cn/models/Netease_Youdao/qanything

huggingfase: https://huggingface.co/netease-youdao/QAnything

(可选)指定单GPU启动
cd QAnything
bash ./run.sh -c local -i 0 -b default # 指定0号GPU启动 GPU编号从0开始 windows机器一般只有一张卡,所以只能指定0号GPU
(可选)指定单GPU启动 - 推荐 Windows10/Windows11 WSL2 用户使用此方式运行 QAnything
# 注意: Windows系统请先进入**WSL2**环境
# Step 1. 下载开源 LLM 模型 (e.g., Qwen-7B-QAnything) 并保存在路径 "/path/to/QAnything/assets/custom_models"
# (可选) 从 ModelScope 下载 Qwen-7B-QAnything: https://www.modelscope.cn/models/netease-youdao/Qwen-7B-QAnything
# (可选) 从 Huggingface 下载 Qwen-7B-QAnything: https://huggingface.co/netease-youdao/Qwen-7B-QAnything
cd QAnything/assets/custom_models
git clone https://huggingface.co/netease-youdao/Qwen-7B-QAnything

# Step 2. 执行启动命令,其中"-b hf"表示指定使用 Huggingface transformers 后端运行 LLM.
cd ../../
bash ./run.sh -c local -i 0 -b hf -m Qwen-7B-QAnything -t qwen-7b-qanything
(可选)指定单GPU启动 - 推荐 GPU Compute Capability >= 8.6 && VRAM >= 24GB 使用此方式运行 QAnything
# 查看 GPU 算力 GPU Compute Capability: https://developer.nvidia.com/cuda-gpus
# Step 1. 下载开源 LLM 模型 (e.g., Qwen-7B-QAnything) 并保存在路径 "/path/to/QAnything/assets/custom_models"
# (可选) 从 ModelScope 下载 Qwen-7B-QAnything: https://www.modelscope.cn/models/netease-youdao/Qwen-7B-QAnything
# (可选) 从 Huggingface 下载 Qwen-7B-QAnything: https://huggingface.co/netease-youdao/Qwen-7B-QAnything
cd QAnything/assets/custom_models
git clone https://huggingface.co/netease-youdao/Qwen-7B-QAnything

# Step 2. 执行启动命令,其中"-b vllm"表示指定使用 vllm 后端运行 LLM.
cd ../../
bash ./run.sh -c local -i 0 -b vllm -m Qwen-7B-QAnything -t qwen-7b-qanything -p 1 -r 0.85
(可选)指定多GPU启动
cd QAnything
bash ./run.sh -c local -i 0,1 -b default  # 指定0,1号GPU启动,请确认有多张GPU可用,最多支持两张卡启动

step3: 开始体验

前端页面

运行成功后,即可在浏览器输入以下地址进行体验。

  • 前端地址: http://your_host:5052/qanything/

API

如果想要访问API接口,请参考下面的地址:

  • API address: http://your_host:8777/api/
  • For detailed API documentation, please refer to QAnything API 文档

DEBUG

如果想要查看相关日志,请查看QAnything/logs/debug_logs目录下的日志文件。

  • debug.log
    • 用户请求处理日志
  • sanic_api.log
    • 后端服务运行日志
  • llm_embed_rerank_tritonserver.log(单卡部署)
    • LLM embedding和rerank tritonserver服务启动日志
  • llm_tritonserver.log(多卡部署)
    • LLM tritonserver服务启动日志
  • embed_rerank_tritonserver.log(多卡部署或使用openai接口)
    • embedding和rerank tritonserver服务启动日志
  • rerank_server.log
    • rerank服务运行日志
  • ocr_server.log
    • OCR服务运行日志
  • npm_server.log
    • 前端服务运行日志
  • llm_server_entrypoint.log
    • LLM中转服务运行日志
  • fastchat_logs/*.log
    • FastChat服务运行日志

关闭服务

bash close.sh

常见问题

常见问题

使用

跨语种:多篇英文论文问答

信息抽取

文件大杂烩

网页问答

接入API

如果需要接入API,请参阅QAnything API 文档

贡献代码

我们感谢您对贡献到我们项目的兴趣。无论您是修复错误、改进现有功能还是添加全新内容,我们都欢迎您的贡献!

感谢以下所有贡献者

支持

Discord

欢迎加入QAnything Discord 社区!

微信群

扫描下方二维码,加入QAnything官方微信群

邮箱

如果你需要私信我们团队,请通过下面的邮箱联系我们:

qanything@rd.netease.com

GitHub issues

有任何公开的问题,欢迎提交 Github issues

Star History

Star History Chart

协议

QAnything 依照 Apache 2.0 协议开源。

Acknowledgements

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2023 Zihui Ren Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

Question and Answer based on Anything. 展开 收起
Python
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ysdxhsw/QAnything.git
git@gitee.com:ysdxhsw/QAnything.git
ysdxhsw
QAnything
QAnything
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891