Home

Awesome

<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>

Question and Answer based on Anything

<p align="center"> <a href="./README.md">English</a> | <a href="./README_zh.md">简体中文</a> | <a href="./README_jp.md">日本語</a> </p> </div> <div align="center">

<a href="https://qanything.ai"><img src="https://img.shields.io/badge/try%20online-qanything.ai-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="https://github.com/netease-youdao/QAnything/pulls"><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>     

<a href="https://discord.gg/5uNpPsEJz8"><img src="https://img.shields.io/discord/1197874288963895436?style=social&logo=discord"></a>     

</div> <details open="open"> <summary>Table of Contents</summary> </details>

🚀 Important Updates

<h1><span style="color:red;">Important things should be said three times.</span></h1>

2024-05-17:Latest Installation and Usage Documentation

2024-05-17:Latest Installation and Usage Documentation

2024-05-17:Latest Installation and Usage Documentation

Business contact information:

010-82558901

What is QAnything?

QAnything(Question and Answer based on Anything) 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(pdf),Word(docx),PPT(pptx),XLS(xlsx),Markdown(md),Email(eml),TXT(txt),Image(jpg,jpeg,png),CSV(csv),Web links(html) and more formats coming soon…

Key features

Architecture

<div align="center"> <img src="docs/images/qanything_arch.png" width = "700" alt="qanything_system" align=center /> </div>

Why 2 stage retrieval?

In scenarios with a large volume of knowledge base data, the advantages of a two-stage approach are very clear. If only a first-stage embedding retrieval is used, there will be a problem of retrieval degradation as the data volume increases, as indicated by the green line in the following graph. However, after the second-stage reranking, there can be a stable increase in accuracy, the more data, the better the performance.

<div align="center"> <img src="docs/images/two_stage_retrieval.jpg" width = "500" alt="two stage retrievaal" align=center /> </div>

QAnything uses the retrieval component BCEmbedding, which is distinguished for its bilingual and crosslingual proficiency. BCEmbedding excels in bridging Chinese and English linguistic gaps, which achieves

1st Retrieval(embedding)

ModelRetrievalSTSPairClassificationClassificationRerankingClusteringAvg
bge-base-en-v1.537.1455.0675.4559.7343.0537.7447.20
bge-base-zh-v1.547.6063.7277.4063.3854.8532.5653.60
bge-large-en-v1.537.1554.0975.0059.2442.6837.3246.82
bge-large-zh-v1.547.5464.7379.1464.1955.8833.2654.21
jina-embeddings-v2-base-en31.5854.2874.8458.4241.1634.6744.29
m3e-base46.2963.9371.8464.0852.3837.8453.54
m3e-large34.8559.7467.6960.0748.9931.6246.78
bce-embedding-base_v157.6065.7374.9669.0057.2938.9559.43

2nd Retrieval(rerank)

ModelRerankingAvg
bge-reranker-base57.7857.78
bge-reranker-large59.6959.69
bce-reranker-base_v160.0660.06

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:

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

🚀 Latest Updates

Before You Start

Star us on GitHub, and be instantly notified for new release! star_us

Getting Started

Installation Methods

We provide two versions: Python version and Docker version The Python version is suitable for quickly experiencing new features, while the Docker version is suitable for secondary development and use in actual production environments, with new features temporarily not supported.

The features corresponding to different installation methods are as follows:

featurespython versiondocker versionExplanation
Detailed installation documentDetailsDetails
Support APIDetailsDetails
Support production environment
Support offline installation (private deployment)Details
Support multiple concurrencyDetailsWhen using API instead of local large models in Python, manual settings are possible.Details
Support multi-card inferenceDetails
Support Mac (M series chips)Currently running the local LLM on Mac relies on llamacpp, and the question-answering speed is slow. It is recommended to use the OpenAI API to call the model service.
Support LinuxPython version defaults to onnxruntime-gpu on Linux, automatically switching to onnxruntime when glibc<2.28.
Support windows WSL
Support CPU onlyDetails
Support hybrid search (BM25+embedding)
Support web search (need VPN)DetailsDocker version plan.
Support FAQDetailsDocker version plan.
Support BOTDetailsDocker version plan.
Support TraceabilityDetailsDocker version plan.
Support Log retrieval by APIDetailsDocker version plan.
Support audio fileIn the Docker version plan, uploading files will support mp3 and wav format files.
Support OpenCloudOSDetails
Support interfaces compatible with Openaiapi (including ollama)DetailsDetailsThe api_key, base_url, model and other parameters need to be set manually.
PDF parsing performance improvement (including tables)Details
User-defined configuration (Experimental: Improve speed)Details
Improvement in parsing performance of other file typesThe next version is expected to be released in 15 days.

Installation(Pure Python environment)

If you prefer not to use Docker for installation, we provide a Pure Python Installation Guide. The installation of a pure Python environment is intended for demo purposes only and is not recommended for deployment in a production environment.

Installation(Docker)

Prerequisites

For Linux

SystemRequired itemMinimum RequirementNote
LinuxNVIDIA GPU Memory>= 4GB (use OpenAI API)Minimum: GTX 1050Ti(use OpenAI API) <br> Recommended: RTX 3090
NVIDIA Driver Version>= 525.105.17
Docker version>= 20.10.5Docker install
docker compose version>= 2.23.3docker compose install
git-lfsgit-lfs install

For Windows with WSL Ubuntu Subsystem

SystemRequired itemMinimum RequirementNote
Windows with WSL Ubuntu SubsystemNVIDIA GPU Memory>= 4GB (use OpenAI API)Minimum: GTX 1050Ti(use OpenAI API) <br> Recommended: RTX 3090
GEFORCE EXPERIENCE>= 546.33GEFORCE EXPERIENCE download
Docker Desktop>= 4.26.1(131620)Docker Desktop for Windows
git-lfsgit-lfs install

Lazy installation steps, please click here.

step1: pull qanything repository

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

step2: Enter the project root directory and execute the startup script.

cd QAnything
bash run.sh  # Start on GPU 0 by default.
<details> <summary>(Note) If automatic download fails, you can manually download the model from one of the three addresses below.</summary>

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

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

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

</details> <details> <summary>(Optional) Specify GPU startup </summary>
cd QAnything
bash ./run.sh -c local -i 0 -b default  # gpu id 0
</details> <details> <summary>(Optional) Specify GPU startup - Recommended for Windows10/Windows11 WSL2 User</summary>
# For Windows OS: Need to enter the **WSL2** environment.
# Step 1. Download the public LLM model (e.g., Qwen-7B-QAnything) and save to "/path/to/QAnything/assets/custom_models"
# (Optional) Download Qwen-7B-QAnything from ModelScope: https://www.modelscope.cn/models/netease-youdao/Qwen-7B-QAnything
# (Optional) Download Qwen-7B-QAnything from Huggingface: 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. Execute the service startup command. Here we use "-b hf" to specify the Huggingface transformers backend.
cd ../../
bash ./run.sh -c local -i 0 -b hf -m Qwen-7B-QAnything -t qwen-7b-qanything
</details> <details> <summary>(Optional) Specify GPU startup - Recommended for GPU Compute Capability >= 8.6 and VRAM >= 24GB</summary>
# GPU Compute Capability: https://developer.nvidia.com/cuda-gpus
# Step 1. Download the public LLM model (e.g., Qwen-7B-QAnything) and save to "/path/to/QAnything/assets/custom_models"
# (Optional) Download Qwen-7B-QAnything from ModelScope: https://www.modelscope.cn/models/netease-youdao/Qwen-7B-QAnything
# (Optional) Download Qwen-7B-QAnything from Huggingface: 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. Execute the service startup command. Here we use "-b vllm" to specify the vllm backend.
cd ../../
bash ./run.sh -c local -i 0 -b vllm -m Qwen-7B-QAnything -t qwen-7b-qanything -p 1 -r 0.85
</details> <details> <summary>(Optional) Specify multi-GPU startup </summary>
cd QAnything
bash ./run.sh -c local -i 0,1 -b default  # gpu ids: 0,1, Please confirm how many GPUs are available. Supports up to two cards for startup. 
</details>

step3: start to experience

Front end

After successful installation, you can experience the application by entering the following addresses in your web browser.

API

If you want to visit API, please refer to the following address:

DEBUG

If you want to view the relevant logs, please check the log files in the QAnything/logs/debug_logs directory.

Close service

If you are in the Windows11 system: Need to enter the WSL environment.

bash close.sh

offline install

If you want to install QAnything offline, you can start the service using the following command.

install offline for windows

# Download the docker image on a networked machine
docker pull quay.io/coreos/etcd:v3.5.5
docker pull minio/minio:RELEASE.2023-03-20T20-16-18Z
docker pull milvusdb/milvus:v2.3.4
docker pull mysql:latest
docker pull freeren/qanything-win:v1.2.x  # From [https://github.com/netease-youdao/QAnything/blob/master/docker-compose-windows.yaml#L103] Get the latest version number.

# pack image
docker save quay.io/coreos/etcd:v3.5.5 minio/minio:RELEASE.2023-03-20T20-16-18Z milvusdb/milvus:v2.3.4 mysql:latest freeren/qanything-win:v1.2.1 -o qanything_offline.tar

# download QAnything code
wget https://github.com/netease-youdao/QAnything/archive/refs/heads/master.zip

# Copy the image qanything_offline.tar and the code qany-master.zip to the offline machine
cp QAnything-master.zip qanything_offline.tar /path/to/your/offline/machine

# Load the image on the disconnected machine
docker load -i qanything_offline.tar

# Unzip the code and run it
unzip QAnything-master.zip
cd QAnything-master
bash run.sh

install offline for linux

# Download the docker image on a networked machine
docker pull quay.io/coreos/etcd:v3.5.5
docker pull minio/minio:RELEASE.2023-03-20T20-16-18Z
docker pull milvusdb/milvus:v2.3.4
docker pull mysql:latest
docker pull freeren/qanything:v1.2.x  # From [https://github.com/netease-youdao/qanything/blob/master/docker-compose-linux.yaml#L104] Get the latest version number.

# pack image
docker save quay.io/coreos/etcd:v3.5.5 minio/minio:RELEASE.2023-03-20T20-16-18Z milvusdb/milvus:v2.3.4 mysql:latest freeren/qanything:v1.2.1 -o qanything_offline.tar

# download QAnything code
wget https://github.com/netease-youdao/QAnything/archive/refs/heads/master.zip

# Copy the image qanything_offline.tar and the code qany-master.zip to the offline machine
cp QAnything-master.zip qanything_offline.tar /path/to/your/offline/machine

# Load the image on the disconnected machine
docker load -i qanything_offline.tar

# Unzip the code and run it
unzip QAnything-master.zip
cd QAnything-master
bash run.sh

FAQ

FAQ

Usage

Cross-lingual: Multiple English paper Q&A

Information extraction

Various files

Web Q&A

API Document

If you need to access the API, please refer to the QAnything API documentation.

Contributing

We appreciate your interest in contributing to our project. Whether you're fixing a bug, improving an existing feature, or adding something completely new, your contributions are welcome!

Thanks to all contributors for their efforts

<a href="https://github.com/netease-youdao/QAnything/graphs/contributors"> <img src="https://contrib.rocks/image?repo=netease-youdao/QAnything" /> </a>

🛣️ Roadmap & Feedback

🔎 To learn about QAnything's future plans and progress, please see here: QAnything Roadmap

🤬To provide feedback to QAnything, please see here: QAnything Feedbak

Community & Support

Discord <a href="https://discord.gg/5uNpPsEJz8"><img src="https://img.shields.io/discord/1197874288963895436?style=social&logo=discord"></a>

Welcome to the QAnything Discord community

WeChat

Welcome to follow QAnything WeChat Official Account to get the latest information.

<img src="docs/images/qrcode_for_qanything.jpg" width="30%" height="auto">

Welcome to scan the code to join the QAnything discussion group.

<img src="docs/images/Wechat_0509.jpg" width="30%" height="auto">

Email

If you need to contact our team privately, please reach out to us via the following email:

qanything@rd.netease.com

GitHub issues & discussions

Reach out to the maintainer at one of the following places:

<a href="https://github.com/netease-youdao/QAnything/discussions"> <!-- Please provide path to your logo here --> <img src="https://github.com/netease-youdao/QAnything/assets/29041332/ad027ec5-0bbc-4ea0-92eb-81b30c5359a1" alt="Logo" width="600"> </a>

Star History

Star History Chart

License

QAnything is licensed under Apache 2.0 License

Acknowledgments

QAnything adopts dependencies from the following: