RichRAG框架:为用户提供丰富全面且令人满意的回答
检索增强型生成(RAG)使LLMs能够利用检索到的可靠信息,从而返回更可靠的响应。现有研究主要关注需要简洁明确答案的特定问题,但用户意图通常是复杂和多方面的,需要丰富和全面的答案。
一个多方面查询需要全面回答的情境示例
为了解决这一重要但未被充分探索的问题,提出了一种名为RichRAG的新型RAG框架:
子方面探索器:识别输入问题潜在的子方面。
多方面检索器:构建与这些子方面相关的多样化外部文档候选池。
生成式列表智能排序器:关键模块,为最终生成器提供最有价值的文档排名列表。
RichRAG的整体框架。在底部描述了排名器的训练阶段
1 问题定义
在基本的RAG设置中,包含知识库C、固定检索器R和作为生成器的固定LLM G。对于多方面的问题q,其下属的各个方面表示为S={s1, ..., sn},这些子方面有相应的子回答A={a1, ..., an}。目标是使RichRAG生成的回答r不仅与真实回答匹配,而且全面覆盖各个子回答,确保回答的丰富性和完整性。
2 子方面探索器
利用LLM构建子方面探索器E,预测输入查询的子方面。该模块输入提示pse和用户查询q,生成一系列子方面。
3 多方面检索器
根据查询的子方面,使用多方面检索器收集与各种子方面相关的文档,构建多样化的候选文档池。这包括针对每个子方面检索文档的过程和合并检索到的文档以创建候选池。
4 生成式列表智能排序器
为了从候选池中筛选出最有价值的文档,设计了一个基于生成模型的排名模型。该模型输入用户查询、识别的子方面和所有候选项,直接生成顶级文档ID的排名列表。排名器采用两阶段优化:监督式微调和强化学习。
4.1 监督式微调
使用贪婪算法构建银牌目标排名列表,支持排名器的监督式微调。通过覆盖效用函数,测量每个剩余文档的增量方面覆盖增益。
4.2 强化学习
使用强化学习策略探索更好的排名可能性,以最终回答的质量作为排名列表的奖励,采用直接偏好优化(DPO)算法优化排名器,并引入单边重要性采样策略(US3)构建有价值的训练样本。
在两个公开可用的数据集上进行的实验结果证明,RichRAG框架能够有效地为用户提供全面且令人满意的回答。
所有模型的总体结果。最佳和次佳结果分别用粗体和下划线标出
不同子方面数量的子集实验,RichRAG框架在所有子集上都优于所有基线,框架在多样化搜索场景中的鲁棒性
Prompt模板:标注问题方面,并将长答案拆分成相应的子答案
Your task is to adjust the results of query-facets mining. The query-facets are extensions of the
original query in various generic perspectives, rather than some specific facts. Given a query that
requires information from multiple query-facets, you should return all query-facets of the query
to fully answer it query. Note that each query has at least two query-facets. I will give you the
long-form answer to the original query to help you explore query-facets based on the perspectives
of its answer. But refrain from using the additional information from the answer to generate the
query-facets. Then you should segment the original long-form answer into several sub-answers
that each are paired with a query-facet. Please return each query-facet of the original query and its
corresponding sub-answers. The query-facets and sub-answers should be one-to-one and returned
in JSON format. You need to follow the following rules:
1. The answers are only used to help you determine the generic direction. You mustn’t generate
query-facets based on the contents of answers and the facets mustn’t contain the answers’
additional information beyond the input query.
2. Sub-answers are constructed by segmenting the original answer, you cannot generate or reorder
the original answer to create sub-answers.
3. The sub-answers should be complete. You must ensure that when the sub-answers are joined
together in order, the complete original answer should be formed.
4. The generated query-facets should be sufficiently generic and contain no specific information
about the sub-answers.
5. **You should ensure that generated query-facets cover all perspectives original answer.**
6. **You should ensure that all sub-answers cover all contents of the original answer.**
7. **The number of query surfaces must range from 2 to 7.**
8. **You should ensure that each query-facet is sufficiently generic and can be easily derived from
the original query.**
9. **You should ensure each query-facet contains no information from the answer.**
10. **You should rewrite or combine the query-facets to be more generic if some query-facets do
not meet the above requirements.**
11. The returned results should be in JSON format and contain the following key: results, which
is a list of JSON data. Each item of results should contain the following keys: query-facet, and
sub-answer.
12. I will give you some demonstrations, you should learn the pattern of them to mine query-facets
and split sub-answers.
**Demonstration**
{demonstrations}
Query: {query}
Answer: {answer}
Results:
对于RAG整个框架的更多技术,PaperAgent团队RAG专栏进行过详细的归纳总结:高级RAG之36技(术)。
高级RAG之36技试看私信获取:RAG专栏
RichRAG: Crafting Rich Responses for Multi-faceted Queries in Retrieval-Augmented Generation
https://arxiv.org/pdf/2406.12566
本文转载自PaperAgent