英文 | [中文简体](https://github.com/IAAR-Shanghai/CRUD_RAG/blob/main/./README.zh_CN.md
<h1 align="center"> CRUD-RAG:大型语言模型检索增强生成的综合中文基准测试 </h1> <p align="center"> <a href="https://opensource.org/license/apache-2-0/"> <img alt="许可证:Apache" src="https://yellow-cdn.veclightyear.com/0a4dffa0/c60ca86b-579d-4b48-a222-b53efad88e48.svg"> </a> <a href="https://github.com/IAAR-Shanghai/CRUD_RAG/issues"> <img alt="GitHub问题" src="https://img.shields.io/github/issues/IAAR-Shanghai/CRUD_RAG?color=red"> </a> <a href="https://arxiv.org/abs/2401.17043"> <img alt="arXiv论文" src="https://yellow-cdn.veclightyear.com/0a4dffa0/aaa583c8-8c42-4d00-8422-aa2d62e2befc.svg"> </a></p>本仓库包含CRUD-RAG的官方代码,这是一个用于评估RAG系统的新型基准测试。它包括我们为评估RAG系统创建的数据集,以及如何在我们的基准测试上运行实验的教程。
├── data # 该文件夹包含用于评估的数据集。 │ │ │ ├── crud │ │ └── merged.json # 完整数据集。 │ │ │ ├── crud_split │ │ └── split_merged.json # 我们在论文中用于实验的数据集。 │ │ │ └── 80000_docs │ │ └── documents_dup_part... # 超过80,000篇新闻文档,用于构建RAG系统的检索数据库。 │ │ ├── src │ ├── configs # 该文件夹包含用于初始化RAG系统中LLM加载参数的脚本。 │ │ │ ├── datasets # 该文件夹包含用于加载数据集的脚本。 │ │ │ ├── embeddings # 用于构建向量数据库的嵌入模型。 │ │ │ ├── llms # 该文件夹包含用于加载大型语言模型的脚本。 │ │ ├── api_model.py # 调用GPT系列模型。 │ │ ├── local_model.py # 调用本地部署的模型。 │ │ └── remote_model.py # 调用远程部署并封装为API的模型。 │ │ │ ├── metric # 我们在实验中使用的评估指标。 │ │ ├── common.py # bleu, rouge, bertScore。 │ │ └── quest_eval.py # RAGQuestEval。注意,使用此指标需要调用GPT等大型语言模型来回答问题,或修改代码并自行部署问答模型。 │ │ │ ├── prompts # 我们在实验中使用的提示词。 │ │ │ ├── quest_eval # RAGQuestEval指标的问答数据集。 │ │ │ ├── retrievers # RAG系统中使用的检索器。 │ │ │ └── tasks # 评估任务。 │ ├── base.py │ ├── continue_writing.py │ ├── hallucinated_modified.py │ ├── quest_answer.py │ └── summary.py
pip install -r requirements.txt
milvus-server
将bge-base-zh-v1.5模型下载到sentence-transformers/bge-base-zh-v1.5/目录
根据需要修改config.py
运行quick_start.py
python quick_start.py \ --model_name 'gpt-3.5-turbo' \ --temperature 0.1 \ --max_new_tokens 1280 \ --data_path '数据集路径' \ --shuffle True \ --docs_path '检索数据库路径' \ --docs_type 'txt' \ --chunk_size 128 \ --chunk_overlap 0 \ --retriever_name 'base' \ --collection_name '检索数据库名称' \ --retrieve_top_k 8 \ --task 'all' \ --num_threads 20 \ --show_progress_bar True \ --construct_index \ # 首次使用时需要构建向量索引
@article{lyu2024crud,
title={CRUD-RAG: A comprehensive chinese benchmark for retrieval-augmented generation of large language models},
author={Lyu, Yuanjie and Li, Zhiyu and Niu, Simin and Xiong, Feiyu and Tang, Bo and Wang, Wenjin and Wu, Hao and Liu, Huanyong and Xu, Tong and Chen, Enhong},
journal={arXiv preprint arXiv:2401.17043},
year={2024}
}