forked from netease-youdao/QAnything
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Junxiong Liu
committed
Jan 3, 2024
0 parents
commit 881a0d4
Showing
223 changed files
with
432,753 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,201 @@ | ||
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. |
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,186 @@ | ||
<div align="center"> | ||
|
||
<a href="https://github.com/netease-youdao/QAnything"> | ||
<!-- Please provide path to your logo here --> | ||
<img src="docs/images/qanything_logo.png" alt="Logo" width="800"> | ||
</a> | ||
|
||
# **Q**uestion and **A**nswer based on **Anything** | ||
|
||
<p align="center"> | ||
<a href="./README.md">English</a> | | ||
<a href="./README_zh.md">简体中文</a> | ||
</p> | ||
|
||
</div> | ||
|
||
<div align="center"> | ||
<br /> | ||
<a href="https://aitest.youdao.com/saas/qanything/#/home"><img src="https://img.shields.io/badge/try%20online-QAnything-purple"></a> | ||
| ||
<a href="https://read.youdao.com#/home"><img src="https://img.shields.io/badge/try%20online-read.youdao.com-purple"></a> | ||
| ||
|
||
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-yellow"></a> | ||
| ||
<a href=""><img src="https://img.shields.io/badge/PRs-welcome-red"></a> | ||
| ||
<a href="https://twitter.com/YDopensource"><img src="https://img.shields.io/badge/follow-%40YDOpenSource-1DA1F2?logo=twitter&style={style}"></a> | ||
| ||
|
||
</div> | ||
|
||
<details open="open"> | ||
<summary>Table of Contents</summary> | ||
|
||
- [What is QAnything?](#What-is-QAnything?) | ||
- [Key features](#Key-features) | ||
- [Architecture](#Architecture) | ||
- [Getting Started](#getting-started) | ||
- [Prerequisites](#prerequisites) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [API Document](#API-Document) | ||
- [WeChat Group](#WeChat-Group) | ||
- [Support](#support) | ||
- [License](#license) | ||
- [Acknowledgements](#Acknowledgments) | ||
|
||
</details> | ||
|
||
## What is QAnything? | ||
**Q**uestion and **A**nswer based on **Anything** (`QAnything`) is a local knowledge base question-answering system designed to support a wide range of file formats and databases, allowing for offline installation and use. | ||
|
||
With `QAnything`, you can simply drop any locally stored file of any format and receive accurate, fast, and reliable answers. | ||
|
||
Currently supported formats include: **PDF, Word (doc/docx), PPT, Markdown, Eml, TXT, Images (jpg, png, etc.), Web links** and more formats coming soon… | ||
|
||
|
||
### Key features | ||
|
||
- **Data Security**, supports installation and usage with network cable unplugged throughout the process. | ||
- **Cross-language QA support**, freely switch between Chinese and English QA, regardless of the language of the document. | ||
- **Supports massive data QA**, two-stage vector sorting, solving the degradation problem of large-scale data retrieval; the more data, the better the performance. | ||
- **High-performance production-grade system**, directly deployable for enterprise applications. | ||
- **User-friendly**, no need for cumbersome configurations, one-click installation and deployment, ready to use. | ||
- **Multi knowledge base QA** Support selecting multiple knowledge bases for Q&A | ||
|
||
### Architecture | ||
<div align="center"> | ||
<img src="docs/images/qanything_system.png" width = "700" alt="qanything_system" align=center /> | ||
</div> | ||
|
||
#### 1st Retrieval(embedding) | ||
| Model | Retrieval | STS | PairClassification | Classification | Reranking | Clustering | Avg | | ||
|:-------------------------------|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:| | ||
| 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*** | | ||
|
||
- More evaluation details please check [Embedding Models Evaluation Summary](https://github.com/netease-youdao/BCEmbedding/blob/master/Docs/EvaluationSummary/embedding_eval_summary.md)。 | ||
|
||
#### 2nd Retrieval(rerank) | ||
| Model | Reranking | Avg | | ||
|:-------------------------------|:--------:|:--------:| | ||
| bge-reranker-base | 57.78 | 57.78 | | ||
| bge-reranker-large | 59.69 | 59.69 | | ||
| ***bce-reranker-base_v1*** | **60.06** | ***60.06*** | | ||
|
||
- More evaluation details please check [Reranker Models Evaluation Summary](https://github.com/netease-youdao/BCEmbedding/blob/master/Docs/EvaluationSummary/reranker_eval_summary.md) | ||
|
||
#### RAG Evaluations in LlamaIndex(embedding and rerank) | ||
|
||
<img src="https://github.com/netease-youdao/BCEmbedding/blob/master/Docs/assets/rag_eval_multiple_domains_summary.jpg"> | ||
|
||
***NOTE:*** | ||
|
||
- In `WithoutReranker` setting, our `bce-embedding-base_v1` outperforms all the other embedding models. | ||
- With fixing the embedding model, our `bce-reranker-base_v1` achieves the best performence. | ||
- **The combination of `bce-embedding-base_v1` and `bce-reranker-base_v1` is SOTA**. | ||
- If you want to use embedding and rerank separately, please refer to [BCEmbedding](https://github.com/netease-youdao/BCEmbedding) | ||
|
||
#### LLM | ||
|
||
The open source version of QAnything is based on QwenLM and has been fine-tuned on a large number of professional question-answering datasets. It greatly enhances the ability of question-answering. | ||
If you need to use it for commercial purposes, please follow the license of QwenLM. For more details, please refer to: [QwenLM](https://github.com/QwenLM/Qwen) | ||
|
||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
| **Required item** | **Minimum Requirement** | **Note** | | ||
| -------------- | ------------------------- | --------------------------------- | | ||
| NVIDIA GPU Memory | >= 16GB | NVIDIA 3090 recommended | | ||
| NVIDIA Driver Version | >= 525.105.17 | | | ||
| CUDA Version | >= 12.0 | | | ||
| docker compose version| >=1.27.4 | [docker compose install](https://docs.docker.com/compose/install/)| | ||
|
||
|
||
|
||
### Installation | ||
* step1: pull qanything repository | ||
``` | ||
git clone [email protected]:netease-youdao/QAnything.git | ||
``` | ||
* step2: download the model and unzip it to the root directory of the current project. | ||
``` | ||
cd qanything | ||
git clone https://www.modelscope.cn/renrenren/qanything_models.git | ||
unzip models.zip ./ # in root directory of the current project | ||
``` | ||
* step3: start server | ||
``` | ||
docker-compose up -d | ||
``` | ||
|
||
|
||
## Usage | ||
[:point_right: try QAnything online](https://aitest.youdao.com/saas/qanything/#/home) | ||
|
||
### Cross-lingual: Multiple English paper Q&A | ||
![](docs/videos/multi_paper_qa.mp4) | ||
### Information extraction | ||
![](docs/videos/information_extraction.mp4) | ||
### Various files | ||
![](docs/videos/various_files_qa.mp4) | ||
### Web Q&A | ||
![](docs/videos/web_qa.mp4) | ||
|
||
### API Document | ||
If you need to access the API, please refer to the [QAnything API documentation](docs/API.md). | ||
|
||
## WeChat Group | ||
|
||
Welcome to scan the QR code below and join the WeChat group. | ||
|
||
<img src="docs/images/Wechat.jpg" width="20%" height="auto"> | ||
|
||
## Support | ||
Reach out to the maintainer at one of the following places: | ||
|
||
- [Github issues](https://github.com/netease-youdao/QAnything/-/issues) | ||
- Contact options listed on [this GitHub profile](https://github.com/netease-youdao) | ||
|
||
## License | ||
|
||
`QAnything` is licensed under [Apache 2.0 License](./LICENSE) | ||
|
||
## Acknowledgments | ||
`QAnything` adopts dependencies from the following: | ||
- Thanks to our [BCEmbedding](https://github.com/netease-youdao/BCEmbedding) for the excellent embedding and rerank model. | ||
- Thanks to [Qwen](https://github.com/QwenLM/Qwen) for strong base language models. | ||
- Thanks to [Triton Inference Server](https://github.com/triton-inference-server/server) for providing great open source inference serving. | ||
- Thanks to [Langchain](https://github.com/langchain-ai/langchain) for the wonderful llm application framework. | ||
- Thanks to [Langchain-Chatchat](https://github.com/chatchat-space/Langchain-Chatchat) for the inspiration provided on local knowledge base Q&A. | ||
- Thanks to [Milvus](https://github.com/milvus-io/milvus) for the excellent semantic search library. | ||
- Thanks to [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) for its ease-to-use OCR library. | ||
- Thanks to [Sanic](https://github.com/sanic-org/sanic) for the powerful web service framework. | ||
|
Oops, something went wrong.