一个全面、先进、公平且模块化的开源RAG框架
来源:互联网
时间:2026-08-27 13:55:17
要说 RAG 发展路上卡在哪,其实就两个关键问题。
第一,各种新型 RAG 算法之间,始终缺少一种
全面且公平
这正是 RAGLAB 要解决的事。它是一个
模块化
先进
全面
公平
开发新算法
不同 RAG 库和框架的比较
这里需要先厘清一个概念。所谓的
公平比较
数据收集器
回到 RAGLAB。它的模块化架构,让你能像搭积木一样,轻松替换和扩展算法的各个组成部分:
检索器(retriever)
生成器(generator)
指令(instruction)
RAGLAB 框架的架构和组件
具体拆开来看,RAGLAB 的核心组件包括这么几块:
- :集成了 Contriever 和 ColBERT 这类基于 BERT 的模型,统一了查询接口,还搞了个客户端-服务器架构,配合检索缓存机制。简单说,就是查得快,还不容易打架。
检索器(Retriever)
- :直接提供了预处理好的 Wikipedia 语料库,包括 2018 年和 2023 年两个版本,对应的索引和嵌入都打包好了。开箱即用。
语料库(Corpus)
- :集成了 Huggingface Transformers 和 VLLM,还支持量化和 LoRA(低秩适应)技术。这意味着你跑大模型的时候,显存没那么容易爆。
生成器(Generator)
- :包含系统指令、任务指令和算法指令。说白了,你怎么调教模型生成结果,全看这里怎么组合指令。
指令实验室(Instruction Lab)
- :集成了 Accelerate 和 DeepSpeed 库,支持模型微调,包括 LoRA 和量化 LoRA。想自己训个定制版?挺方便。
训练器(Trainer)
- :一口气收集了 10 个广泛使用的基准数据集,覆盖 5 种不同类型的任务,还提供了灵活的数据适配机制和多样的评估指标。
数据集和度量(Dataset and Metric)
一个使用 RAGLAB 来复现 Self-RAG 算法的脚本
光说不练假把式。RAGLAB 的实际效果如何?他们做了一组全面的实验,用不同的基础模型当生成器,同时死死按住其他组件不变,就为了看不同 RAG 算法在公平条件下到底谁更强。
实验分析了
Naive RAG、RRR、ITER-RETGEN、Self-Ask、Active RAG、Self-RAG
Self-RAG 算法


不同算法的指令
以下是各算法在实际代码中的指令示例,供你参考:
Naive RAG
# read process insruction
"### Instruction:n {task_instrucion} n## Input:nn{query}nn Now, based on the following passages
and your knowledge, please answer the question more succinctly and professionally. ### Background
Knowledge:n {passages} nn### Response:n"
RRR
# rewrite process instruction
"Provide a better search query for Wikipedia to answer the given question, end the query with '**'. nn
Question: Ezzard Charles was a world champion in which sport? nn Query: Ezzard Charles
champion** nn Question: What is the correct name of laughing gas? nn Query: laughing gas
name** nn Question: {query} nn Query: " # read process insruction
"### Instruction:n {task_instrucion} n## Input:nn{query}nn Now, based on the following passages
and your knowledge, please answer the question more succinctly and professionally. ### Background
Knowledge:n {passages} nn### Response:n"
ITER-RETGEN
# read process insruction
"### Instruction:n {task_instrucion} n## Input:nn{query}nn Now, based on the following passages
and your knowledge, please answer the question more succinctly and professionally. ### Background
Knowledge:n {passages} nn### Response:n"
Self ASK
# follow up question instruction
"Question: When does monsoon season end in the state the area code 575 is located? Are follow up
questions needed here: Yes. Follow up: Which state is the area code 575 located in? Intermediate
answer: The area code 575 is located in New Mexico. Follow up: When does monsoon season end in
New Mexico? Intermediate answer: Monsoon season in New Mexico typically ends in mid-September. So the final answer is: mid-September. n{query} Are follow up questions needed here:" # read process insruction
"### Instruction:n {task_instrucion} n## Input:nn{query}nn Now, based on the following passages
and your knowledge, please answer the question more succinctly and professionally. ### Background
Knowledge:n {passages} nn### Response:n"
Active RAG
# read process insruction
"### Instruction:n {task_instrucion} n## Input:nn{query}nn Now, based on the following passages
and your knowledge, please answer the question more succinctly and professionally. ### Background
Knowledge:n {passages} nn### Response:n"
Self-RAG
# read process instruction
"### Instruction:n{task_instruction}nn## Input:nn{query}nn### Response:n"
RAGLAB 系统用户评估问卷

想深入了解的,直接看论文和代码:
-
- 关于宇宙的好的网名有哪些
- 角色扮演 | 1
- 网名