赞
踩
LLMs之RAG:《Retrieval-Augmented Generation for Large Language Models: A Survey大型语言模型的检索增强生成研究综述》翻译与解读
导读:这篇论文主要围绕信息检索增强生成(Retrieval Augmented Generation,简称RAG)技术进行概述和分析。
背景痛点:
>> 大语言模型(LLM)在处理知识密集型任务和回答离线知识更丰富的问题时面临难题,例如产生错误信息或过时信息等问题。
>> 往往需要对LLM进行定制化训练,才能适应不同场景下的应用,这对开发人员和研究人员来说难度很大。
RAG技术的核心思想和解决方案:RAG通过将外部知识库中的信息检索成果整合到LLM的输入context中,从而增强LLM处理知识型任务和产生更准确答案的能力。
RAG技术发展趋势:
>> 从初级RAG到高级RAG,再到模块化RAG,不断优化框架结构。
>> 结合信息检索、生成和增强不同技术模块,形成完整流程。
>> 利用结构化和非结构化数据、LLM产生的内容等不同来源进行信息增强。
>> 探索迭代检索、递归检索、自适应检索等方法来优化检索过程。
>> 将RAG技术应用和整合到定制训练中,实现LLM优化的多种方式结合。
RAG技术的优势:
>> 无需重新训练LLM即可将外部新知识整合到模型中,更轻松地应对需求变化。
>> 借助外部知识库,LLM产出的答案更加准确、相关,能更好解决知识型问题。
>> RAG框架性能不断提高,且可扩展到图像、语音等多模态信息处理。
综上,RAG技术通过有效结合LLM与外部知识,在保留LLM优点的同时弥补其知识不足的缺陷,为LLM应用于生产环境提供一条良好的路径。
目录
《Retrieval-Augmented Generation for Large Language Models: A Survey大型语言模型的检索增强生成研究综述》翻译与解读
4.1 Enhancing Semantic Representations
4.2 Aligning Queries and Documents
4.3 Aligning Retriever and LLM
5.1 Post-retrieval with Frozen LLM
6.1 RAG in Augmentation Stages
7.3 Evaluation Benchmarks and Tools
地址 | |
时间 | 2024年1月5日 |
作者 | Yunfan Gao 1, Yun Xiong 2, Xinyu Gao 2, Kangxiang Jia 2, Jinliu Pan 2, Yuxi Bi 3, Yi Dai1, Jiawei Sun1, Qianyu Guo4, Meng Wang 3 and Haofen Wang 1,3 ∗ 同济大学,复旦大学 |
Large Language Models (LLMs) demonstrate significant capabilities but face challenges such as hallucination, outdated knowledge, and non-transparent, untraceable reasoning processes. Retrieval-Augmented Generation (RAG) has emerged as a promising solution by incorporating knowledge from external databases. This enhances the accuracy and credibility of the models, particu-larly for knowledge-intensive tasks, and allows for continuous knowledge updates and integration of domain-specific information. RAG synergistically merges LLMs’ intrinsic knowledge with the vast, dynamic repositories of external databases. This comprehensive review paper offers a detailed examination of the progression of RAG paradigms, encompassing the Naive RAG, the Advanced RAG, and the Modular RAG. It meticulously scrutinizes the tripartite foundation of RAG frameworks, which includes the retrieval , the generation and the augmentation techniques. The paper highlights the state-of-the-art technologies embedded in each of these critical components, providing a profound understanding of the advancements in RAG systems. Furthermore, this paper introduces the metrics and benchmarks for assessing RAG models, along with the most up-to-date evaluation framework. In conclusion, the paper delineates prospective avenues for research, including the identification of challenges, the expansion of multi-modalities, and the progression of the RAG infrastructure and its ecosystem. 1. | 大型语言模型(llm)展示了重要的功能,但面临着诸如幻觉、过时的知识和不透明、不可追溯的推理过程等挑战。检索-增强生成(Retrieval-Augmented Generation, RAG)通过整合来自外部数据库的知识而成为一种很有前途的解决方案。这增强了模型的准确性和可信度,特别是对于知识密集型任务,并允许持续的知识更新和特定领域信息的集成。RAG将llm的内在知识与外部数据库的庞大动态存储库协同合并。这篇全面的综述论文提供了对RAG范式进展的详细检查,包括幼稚RAG、高级RAG和模块化RAG。详细分析了RAG框架的三方面基础,包括检索技术、生成技术和增强技术。本文强调了这些关键组件中嵌入的最先进的技术,提供了对RAG系统进步的深刻理解。此外,本文还介绍了用于评估RAG模型的度量和基准,以及最新的评估框架。最后,本文描述了未来的研究途径,包括识别挑战、扩展多模态以及RAG基础设施及其生态系统的进展。 |
Large language models (LLMs) such as the GPT se-ries [Brown et al., 2020, OpenAI, 2023] and the LLama se-ries [Touvron et al., 2023], along with other models like Gemini [Google, 2023], have achieved remarkable suc-cess in natural language processing, demonstrating supe-rior performance on various benchmarks including Super-GLUE [Wang et al., 2019], MMLU [Hendrycks et al., 2020], and BIG-bench [Srivastava et al., 2022]. Despite these advancements, LLMs exhibit notable limitations, par-ticularly in handling domain-specific or highly special-ized queries [Kandpal et al., 2023]. A common issue is the generation of incorrect information, or ”hallucina-tions” [Zhang et al., 2023b], especially when queries extend beyond the model’s training data or necessitate up-to-date in-formation. These shortcomings underscore the impractical-ity of deploying LLMs as black-box solutions in real-world production environments without additional safeguards. One promising approach to mitigate these limitations is Retrieval-Augmented Generation (RAG), which integrates external data retrieval into the generative process, thereby enhancing the model’s ability to provide accurate and relevant responses. | 大型语言模型(llm),如GPT系列[Brown等人,2020,OpenAI, 2023]和LLama系列[Touvron等人,2023],以及Gemini [Google, 2023]等其他模型,在自然语言处理方面取得了显著的成功,在各种基准测试中表现出卓越的性能,包括Super-GLUE [Wang等人,2019],MMLU [Hendrycks等人,2020]和BIG-bench [Srivastava等人,2022]。尽管取得了这些进步,llm仍然表现出明显的局限性,特别是在处理特定领域或高度专业化的查询方面[Kandpal等人,2023]。一个常见的问题是产生不正确的信息,或“幻觉”[Zhang等人,2023b],特别是当查询超出模型的训练数据或需要最新信息时。这些缺点强调了在没有额外保障的情况下将llm作为黑盒解决方案部署到实际生产环境中的不可行性。缓解这些限制的一种有希望的方法是检索增强生成(retrieve - augmented Generation, RAG),它将外部数据检索集成到生成过程中,从而增强模型提供准确和相关响应的能力。 |
RAG, introduced by Lewis et al. [Lewis et al., 2020] in mid-2020, stands as a paradigm within the realm of LLMs, enhancing generative tasks. Specifically, RAG involves an initial retrieval step where the LLMs query an external data source to obtain relevant information before proceeding to an-swer questions or generate text. This process not only informs the subsequent generation phase but also ensures that the re-sponses are grounded in retrieved evidence, thereby signif-icantly enhancing the accuracy and relevance of the output. The dynamic retrieval of information from knowledge bases during the inference phase allows RAG to address issues such as the generation of factually incorrect content, commonly referred to as “hallucinations.” The integration of RAG into LLMs has seen rapid adoption and has become a pivotal tech-nology in refining the capabilities of chatbots and rendering LLMs more viable for practical applications. | 由Lewis et al. [Lewis et al., 2020]在2020年年中引入的RAG是法学硕士领域的一个范例,增强了生成任务。具体来说,RAG涉及一个初始检索步骤,llm在此步骤中查询外部数据源以获取相关信息,然后再继续回答问题或生成文本。这个过程不仅通知了后续的生成阶段,而且还确保了响应是基于检索到的证据,从而显著提高了输出的准确性和相关性。在推理阶段从知识库中动态检索信息使RAG能够解决诸如生成事实不正确的内容(通常称为“幻觉”)之类的问题。将RAG集成到法学硕士中已经得到了迅速的采用,并已成为改进聊天机器人功能和使法学硕士在实际应用中更可行的关键技术。 |
The evolutionary trajectory of RAG unfolds across four distinctive phases, as illustrated in Figure 1. In its in-ception in 2017, aligned with the emergence of the Trans-former architecture, the primary thrust was on assimilating additional knowledge through Pre-Training Models (PTM) to augment language models. This epoch witnessed RAG’s foundational efforts predominantly directed at optimizing pre-training methodologies. | RAG的进化轨迹在四个不同的阶段展开,如图1所示。在2017年的初始阶段,与Trans-former架构的出现相一致,其主要目的是通过预训练模型(PTM)吸收额外的知识,以增强语言模型。这个时代见证了RAG的基础努力,主要是针对优化预训练方法。 |
Following this initial phase, a period of relative dormancy ensued before the advent of chatGPT, during which there was minimal advancement in related research for RAG. The sub-sequent arrival of chatGPT marked a pivotal moment in the trajectory, propelling LLMs into the forefront. The com-munity’s focal point shifted towards harnessing the capabil-ities of LLMs to attain heightened controllability and ad-dress evolving requirements. Consequently, the lion’s share of RAG endeavors concentrated on inference, with a minor-ity dedicated to fine-tuning processes. As LLM capabili-ties continued to advance, especially with the introduction of GPT-4, the landscape of RAG technology underwent a sig-nificant transformation. The emphasis evolved into a hybrid approach, combining the strengths of RAG and fine-tuning, alongside a dedicated minority continuing the focus on opti-mizing pre-training methodologies. | 在这个初始阶段之后,在chatGPT出现之前,有一段相对的休眠期,在此期间,对RAG的相关研究进展甚微。随后,chatGPT的到来标志着这一发展轨迹的关键时刻,将法学硕士推向了前沿。社区的焦点转向利用法学硕士的能力,以获得更高的可控性,并解决不断变化的需求。因此,RAG的大部分努力都集中在推理上,只有一小部分致力于微调过程。随着法学硕士技术的不断发展,尤其是GPT-4的引入,RAG技术的前景发生了重大变化。重点发展成为一种混合方法,结合RAG和微调的优势,以及专门的少数人继续专注于优化预训练方法。 |
Despite the rapid growth of RAG research, there has been a lack of systematic consolidation and abstraction in the field, which poses challenges in understanding the comprehensive landscape of RAG advancements. This survey aims to out-line the entire RAG process and encompass the current and future directions of RAG research, by providing a thorough examination of retrieval augmentation in LLMs. | 尽管RAG研究发展迅速,但该领域缺乏系统的整合和抽象,这对理解RAG进展的全面前景提出了挑战。本调查旨在概述整个RAG过程,并通过提供对法学硕士检索增强的彻底检查,涵盖RAG研究的当前和未来方向。 |
Therefore, this paper aims to comprehensively summarize and organize the technical principles, developmental history, content, and, in particular, the relevant methods and applica-tions after the emergence of LLMs, as well as the evaluation methods and application scenarios of RAG. It seeks to provide a comprehensive overview and analysis of existing RAG technologies and offer conclusions and prospects for future development methods. This survey intends to furnish readers and practitioners with a thorough and systematic comprehen-sion of large models and RAG, elucidate the progression and key technologies of retrieval augmentation, clarify the merits and limitations of various technologies along with their suit-able contexts, and forecast potential future developments. | 因此,本文旨在对RAG的技术原理、发展历史、内容,特别是法学硕士出现后的相关方法和应用,以及RAG的评价方法和应用场景进行全面的总结和整理。它试图对现有的RAG技术进行全面的概述和分析,并对未来的发展方法提出结论和展望。本调查旨在使读者和从业者对大型模型和检索增强有一个全面和系统的了解,阐明检索增强的进展和关键技术,阐明各种技术的优点和局限性以及它们的适用背景,并预测潜在的未来发展。 |
Our contributions are as follows: >>We present a thorough and systematic review of the state-of-the-art RAG, delineating its evolution through paradigms including naive RAG, advanced RAG, and modular RAG. This review contextualizes the broader scope of RAG research within the landscape of LLMs. >>We identify and discuss the central technologies integral to the RAG process, specifically focusing on the aspects of “Retrieval”, “Generator” and “Augmentation”, and delve into their synergies, elucidating how these com-ponents intricately collaborate to form a cohesive and effective RAG framework. >>We construct a thorough evaluation framework for RAG, outlining the evaluation objectives and metrics. Our comparative analysis clarifies the strengths and weak-nesses of RAG compared to fine-tuning from various perspectives. Additionally, we anticipate future direc-tions for RAG, emphasizing potential enhancements to tackle current challenges, expansions into multi-modal settings, and the development of its ecosystem. | 我们的贡献如下: >>我们对最先进的RAG进行了全面和系统的回顾,描述了其通过范例的演变,包括幼稚的RAG,先进的RAG和模块化的RAG。这篇综述的背景下,更广泛的范围内的法学硕士研究RAG的景观。 >>我们确定并讨论了RAG过程中不可或缺的核心技术,特别关注“检索”,“生成器”和“增强”方面,并深入研究了它们的协同作用,阐明了这些组件如何复杂地协作以形成一个有凝聚力和有效的RAG框架。 >>我们构建了一个全面的RAG评估框架,概述了评估目标和指标。我们的对比分析从多个角度阐明了RAG与微调相比的优缺点。此外,我们预测了RAG的未来方向,强调潜在的增强以应对当前的挑战,扩展到多模式设置,以及其生态系统的发展。 |
The paper unfolds as follows: Section 2 and 3 define RAG and detail its developmental process. Section 4 through 6 ex-plore core components—Retrieval, “Generation” and “Aug-mentation”—highlighting diverse embedded technologies. Section 7 focuses on RAG’s evaluation system. Section 8 compare RAG with other LLM optimization methods and suggest potential directions for its evolution. The paper con-cludes in Section 9. | 第二节和第三节对RAG进行了定义,并详细介绍了RAG的发展过程。第4节至第6节探讨了核心组件——检索、“生成”和“增强”——重点介绍了各种嵌入式技术。第7节重点介绍RAG的评估体系。第8节将RAG与其他LLM优化方法进行了比较,并提出了其可能的发展方向。本文在第9节结束。 |
The definition of RAG can be summarized from its workflow. Figure 2 depicts a typical RAG application workflow. In this scenario, a user inquires ChatGPT about a recent high-profile event (i.e., the abrupt dismissal and reinstatement of Ope-nAI’s CEO) which generated considerable public discourse. ChatGPT as the most renowned and widely utilized LLM, constrained by its pretraining data, lacks knowledge of re-cent events. RAG addresses this gap by retrieving up-to-date document excerpts from external knowledge bases. In this in-stance, it procures a selection of news articles pertinent to the inquiry. These articles, alongside the initial question, are then amalgamated into an enriched prompt that enables ChatGPT to synthesize an informed response. This example illustrates the RAG process, demonstrating its capability to enhance the model’s responses with real-time information retrieval. | RAG的定义可以从它的工作流程中总结出来。图2描述了一个典型的RAG应用程序工作流。在这个场景中,用户向ChatGPT询问最近发生的一件引人注目的事件(例如,Ope-nAI的首席执行官突然被解雇和复职),该事件引起了相当大的公众讨论。ChatGPT作为最著名和应用最广泛的LLM,受其预训练数据的限制,缺乏对近期事件的了解。RAG通过从外部知识库检索最新的文档摘要来解决这一差距。在这种情况下,它获得了与调查有关的新闻文章的选择。然后,这些文章与最初的问题合并成一个丰富的提示,使ChatGPT能够合成一个知情的响应。这个例子说明了RAG过程,展示了它通过实时信息检索增强模型响应的能力。 |
Technologically, RAG has been enriched through various innovative approaches addressing pivotal questions such as “what to retrieve” “when to retrieve” and “how to use the retrieved information”. For “what to retrieve” research has progressed from simple token [Khandelwal et al., 2019] and entity retrieval [Nishikawa et al., 2022] to more complex structures like chunks [Ram et al., 2023] and knowledge graph [Kang et al., 2023], with studies focusing on the granularity of retrieval and the level of data structur-ing. Coarse granularity brings more information but with lower precision. Retrieving structured text provides more information while sacrificing efficiency. The ques-tion of “when to retrieve” has led to strategies ranging from single [Wang et al., 2023e, Shi et al., 2023] to adap-tive [Jiang et al., 2023b, Huang et al., 2023] and multiple retrieval [Izacard et al., 2022] methods. High frequency of retrieval brings more information and lower efficiency. As for ”how to use” the retrieved data, integration techniques have been developed across various levels of the model architecture, including the input [Khattab et al., 2022], intermediate [Borgeaud et al., 2022], and output lay-ers [Liang et al., 2023]. Although the “intermediate” and “output layers” are more effective, there are problems with the need for training and low efficiency. | 在技术上,RAG通过各种创新方法得到了丰富,这些方法解决了诸如“检索什么”、“何时检索”和“如何使用检索到的信息”等关键问题。对于“检索什么”的研究已经从简单的令牌[Khandelwal等人,2019]和实体检索[Nishikawa等人,2022]发展到更复杂的结构,如块[Ram等人,2023]和知识图谱[Kang等人,2023],研究重点是检索的粒度和数据结构的水平。粗粒度带来更多的信息,但精度较低。检索结构化文本可以在牺牲效率的同时提供更多信息。“何时检索”的问题导致了从单一[Wang等人,2023e, Shi等人,2023]到自适应[Jiang等人,2023b, Huang等人,2023]和多重检索[Izacard等人,2022]方法的策略。检索频率高,信息量大,效率低。至于“如何使用”检索到的数据,已经在模型架构的各个层次上开发了集成技术,包括输入层[Khattab等人,2022]、中间层[Borgeaud等人,2022]和输出层[Liang等人,2023]。虽然“中间层”和“输出层”更有效,但存在需要训练和效率低的问题。 |
RAG is a paradigm that enhances LLMs by integrating ex-ternal knowledge bases. It employs a synergistic approach, combining information retrieval mechanisms and In-Context Learning (ICL) to bolster the LLM’s performance. In this framework, a query initiated by a user prompts the retrieval of pertinent information via search algorithms. This information is then woven into the LLM’s prompts, providing additional context for the generation process. RAG’s key advantage lies in its obviation of the need for retraining of LLMs for task-specific applications. Developers can instead append an ex-ternal knowledge repository, enriching the input and thereby refining the model’s output precision. RAG has become one of the most popular architectures in LLMs’ systems, due to its high practicality and low barrier to entry, with many con-versational products being built almost entirely on RAG. | RAG是一种通过集成外部知识库来增强法学硕士的范例。它采用协同方法,将信息检索机制和上下文学习(ICL)相结合,以提高法学硕士的表现。在这个框架中,用户发起的查询提示通过搜索算法检索相关信息。然后将这些信息编织到LLM的提示中,为生成过程提供额外的上下文。RAG的主要优势在于它避免了针对特定任务应用程序对法学硕士进行再培训的需要。开发人员可以附加一个外部知识库,丰富输入,从而改进模型的输出精度。由于其高实用性和低入门门槛,RAG已成为法学硕士系统中最受欢迎的架构之一,许多会话产品几乎完全基于RAG构建。 |
The RAG workflow comprises three key steps. First, the corpus is partitioned into discrete chunks, upon which vec-tor indices are constructed utilizing an encoder model. Sec-ond, RAG identifies and retrieves chunks based on their vec-tor similarity to the query and indexed chunks. Finally, the model synthesizes a response conditioned on the contextual information gleaned from the retrieved chunks. These steps form the fundamental framework of the RAG process, under-pinning its information retrieval and context-aware genera-tion capabilities. Next, we will provide an introduction to the RAG research framework. | RAG工作流包括三个关键步骤。首先,将语料库划分为离散块,利用编码器模型在其上构建向量索引。其次,RAG根据它们与查询和索引块的向量相似性来标识和检索块。最后,该模型综合了基于从检索块中收集到的上下文信息的响应。这些步骤构成了RAG流程的基本框架,支持其信息检索和上下文感知生成功能。接下来,我们将介绍RAG研究框架。 |
The RAG research paradigm is continuously evolving, and this section primarily delineates its progression. We cate-gorize it into three types: Naive RAG, Advanced RAG, and Modular RAG. While RAG were cost-effective and surpassed the performance of the native LLM, they also exhibited sev-eral limitations. The development of Advanced RAG and Modular RAG was a response to these specific shortcomings in Naive RAG. | RAG研究范式是不断发展的,本节主要描述了它的发展过程。我们将其分为三种类型:初级RAG、高级RAG和模块化RAG。虽然RAG具有成本效益,并且性能超过了原生LLM,但它们也有一些局限性。高级RAG和模块化RAG的开发是对朴素RAG的这些具体缺点的回应。 |
The Naive RAG research paradigm represents the earliest methodology, which gained prominence shortly after the widespread adoption of ChatGPT. The Naive RAG follows a traditional process that includes indexing, retrieval, and gen-eration. It is also characterized as a “Retrieve-Read” frame-work [Ma et al., 2023a]. | 朴素的RAG研究范式代表了最早的方法论,它在ChatGPT被广泛采用后不久就获得了突出的地位。朴素RAG遵循一个传统的过程,包括索引、检索和生成。它也被描述为“检索-读取”框架[Ma et al., 2023a]。 |
Indexing The indexing process is a crucial initial step in data prepara-tion that occurs offline and involves several stages. It begins with data indexing, where original data is cleansed and ex-tracted, and various file formats such as PDF, HTML, Word, and Markdown are converted into standardized plain text. In order to fit within the context limitations of language models, this text is then segmented into smaller, more manageable chunks in a process known as chunking. These chunks are subsequently transformed into vector representations through an embedding model, chosen for its balance between infer-ence efficiency and model size. This facilitates similarity comparisons during the retrieval phase. Finally, an index is created to store these text chunks and their vector embed-dings as key-value pairs, which allows for efficient and scal-able search capabilities. | 索引 索引过程是离线数据准备的关键初始步骤,涉及几个阶段。它从数据索引开始,清理和提取原始数据,并将各种文件格式(如PDF、HTML、Word和Markdown)转换为标准化的纯文本。为了适应语言模型的上下文限制,该文本然后被分割成更小、更易于管理的块,这个过程称为分块。这些块随后通过嵌入模型转换为向量表示,选择嵌入模型是为了在推理效率和模型大小之间取得平衡。这有助于在检索阶段进行相似性比较。最后,创建索引以键值对的形式存储这些文本块及其向量嵌入,从而实现高效且可扩展的搜索功能。 |
Retrieval Upon receipt of a user query, the system employs the same en-coding model utilized during the indexing phase to transcode the input into a vector representation. It then proceeds to compute the similarity scores between the query vector and the vectorized chunks within the indexed corpus. The system prioritizes and retrieves the top K chunks that demonstrate the greatest similarity to the query. These chunks are subse-quently used as the expanded contextual basis for addressing the user’s request. | 检索 在收到用户查询后,系统使用索引阶段使用的相同编码模型将输入转码为矢量表示。然后,它继续计算查询向量和索引语料库中矢量化块之间的相似性分数。系统对与查询最相似的前K个块进行优先级排序并检索。这些块随后被用作扩展的上下文基础,用于处理用户的请求。 |
Generation The posed query and selected documents are synthesized into a coherent prompt to which a large language model is tasked with formulating a response. The model’s approach to an-swering may vary depending on task-specific criteria, allow-ing it to either draw upon its inherent parametric knowledge or restrict its responses to the information contained within the provided documents. In cases of ongoing dialogues, any existing conversational history can be integrated into the prompt, enabling the model to engage in multi-turn dialogue interactions effectively. | 一代 提出的查询和选定的文档被合成为一个连贯的提示,大型语言模型的任务是制定响应。模型的回答方法可能会根据特定于任务的标准而有所不同,允许它利用其固有的参数知识或限制其对所提供文档中包含的信息的响应。在正在进行对话的情况下,任何现有的对话历史都可以集成到提示符中,使模型能够有效地进行多轮对话交互。 |
Drawbacks in Naive RAG Naive RAG faces significant challenges in three key areas: “Retrieval,” “Generation,” and “Augmentation”. | Naive RAG的缺点 Naive RAG在三个关键领域面临重大挑战:“检索”、“生成”和“增强”。 |
Retrieval quality poses diverse challenges, including low precision, leading to misaligned retrieved chunks and po-tential issues like hallucination or mid-air drop. Low recall also occurs, resulting in the failure to retrieve all relevant chunks, thereby hindering the LLMs’ ability to craft comprehensive responses. Outdated information further compounds the problem, potentially yielding inaccurate retrieval results. | 检索质量带来了各种各样的挑战,包括精度低,导致检索块不对齐以及潜在的问题,如幻觉或半空中掉落。低回忆率也会发生,导致无法检索所有相关的块,从而阻碍了法学硕士制定全面回应的能力。过时的信息使问题进一步复杂化,可能产生不准确的检索结果。 |
Response generation quality presents hallucination chal-lenge, where the model generates answers not grounded in the provided context, as well as issues of irrelevant context and potential toxicity or bias in the model’s output. | 响应生成质量呈现幻觉挑战,即模型生成的答案不基于所提供的上下文,以及模型输出中不相关的上下文和潜在的毒性或偏见问题。 |
The augmentation process presents its own challenges in effectively integrating context from retrieved passages with the current generation task, potentially leading to disjointed or incoherent output. Redundancy and repetition are also concerns, especially when multiple retrieved passages con-tain similar information, resulting in repetitive content in the generated response. | 增强过程在有效地将检索段落的上下文与当前生成任务集成方面提出了自己的挑战,可能导致不连贯或不连贯的输出。冗余和重复也是一个问题,特别是当多个检索的段落包含相似的信息时,会导致生成的响应中出现重复的内容。 |
Discerning the importance and relevance of multiple re-trieved passages to the generation task is another challenge, requiring the proper balance of each passage’s value. Addi-tionally, reconciling differences in writing styles and tones to ensure consistency in the output is crucial. | 辨别多个检索段落对生成任务的重要性和相关性是另一个挑战,需要适当平衡每个段落的价值。此外,协调不同的写作风格和语调,以确保输出的一致性是至关重要的。 |
Lastly, there’s a risk of generation models overly depend-ing on augmented information, potentially resulting in out-puts that merely reiterate the retrieved content without pro-viding new value or synthesized information. | 最后,存在生成模型过度依赖于增强信息的风险,这可能导致输出只是重复检索的内容,而没有提供新值或合成信息。 |
Advanced RAG has been developed with targeted enhance-ments to address the shortcomings of Naive RAG. In terms of retrieval quality, Advanced RAG implements pre-retrieval and post-retrieval strategies. To address the indexing chal-lenges experienced by Naive RAG, Advanced RAG has re-fined its indexing approach using techniques such as slid-ing window, fine-grained segmentation, and metadata. It has also introduced various methods to optimize the retrieval pro-cess [ILIN, 2023]. | 高级RAG已被开发,并有针对性地进行了增强,以解决幼稚RAG的缺点。在检索质量方面,Advanced RAG实现了检索前和检索后策略。为了解决Naive RAG遇到的索引挑战,Advanced RAG使用滑动窗口、细粒度分割和元数据等技术重新定义了其索引方法。它还引入了各种方法来优化检索过程[ILIN, 2023]。 |
Pre-Retrieval Process Optimizing Data Indexing.The goal of optimizing data index-ing is to enhance the quality of the content being indexed. This involves five primary strategies: enhancing data gran-ularity, optimizing index structures, adding metadata, align-ment optimization, and mixed retrieval. | Pre-Retrieval过程 优化数据索引。优化数据索引的目标是提高被索引内容的质量。这涉及五种主要策略:增强数据粒度、优化索引结构、添加元数据、对齐优化和混合检索。 |
Enhancing data granularity aims to elevate text standard-ization, consistency, factual accuracy, and rich context to im-prove the RAG system’s performance. This includes remov-ing irrelevant information, dispelling ambiguity in entities and terms, confirming factual accuracy, maintaining context, and updating outdated documents. | 增强数据粒度旨在提高文本的标准化、一致性、事实准确性和丰富的上下文,从而提高RAG系统的性能。这包括删除不相关的信息,消除实体和术语中的歧义,确认事实的准确性,维护上下文和更新过时的文档。 |
Optimizing index structures involves adjusting the size of chunks to capture relevant context, querying across multiple index paths, and incorporating information from the graph structure to capture relevant context by leveraging relation-ships between nodes in a graph data index. | 优化索引结构包括调整块的大小以捕获相关上下文,跨多个索引路径进行查询,以及通过利用图数据索引中节点之间的关系来合并图结构中的信息以捕获相关上下文。 |
Adding metadata information involves integrating refer-enced metadata, such as dates and purposes, into chunks for filtering purposes, and incorporating metadata like chapters and subsections of references to improve retrieval efficiency. | 添加元数据信息包括将引用的元数据(如日期和用途)集成到块中以进行过滤,以及将引用的章节和小节等元数据集成到块中以提高检索效率。 |
Alignment optimization addresses alignment issues and disparities between documents by introducing “hypothetical questions” [Li et al., 2023d] into documents to rectify align-ment issues and differences. | 对齐优化通过在文档中引入“假设问题”[Li等人,2023]来纠正对齐问题和差异,从而解决文档之间的对齐问题和差异。 |
Retrieval During the retrieval stage, the primary focus is on identifying the appropriate context by calculating the similarity between the query and chunks. The embedding model is central to this process. In the advanced RAG, there is potential for op-timization of the embedding models. | 检索 在检索阶段,主要关注的是通过计算查询和块之间的相似性来识别适当的上下文。嵌入模型是这个过程的核心。在高级RAG中,有可能对嵌入模型进行优化。 |
Fine-tuning Embedding. Fine-tuning embedding models significantly impact the relevance of retrieved content in RAG systems. This process involves customizing embedding mod-els to enhance retrieval relevance in domain-specific contexts, especially for professional domains dealing with evolving or rare terms. The BGE embedding model [BAAI, 2023], such as BGE-large-EN developed by BAAI2, is an example of a high-performance embedding model that can be fine-tuned to optimize retrieval relevance. Training data for fine-tuning can be generated using language models like GPT-3.5-turbo to formulate questions grounded on document chunks, which are then used as fine-tuning pairs. | 微调嵌入。微调嵌入模型会显著影响RAG系统中检索内容的相关性。该过程包括自定义嵌入模型,以增强特定领域上下文中的检索相关性,特别是对于处理演化或罕见术语的专业领域。BGE嵌入模型[BAAI, 2023],如BAAI2开发的BGE-large- en,就是一个可以微调以优化检索相关性的高性能嵌入模型的例子。可以使用GPT-3.5-turbo等语言模型生成用于微调的训练数据,以制定基于文档块的问题,然后将其用作微调对。 |
Dynamic Embedding adapts to the context in which words are used, unlike static embedding, which uses a single vec-tor for each word [Karpukhin et al., 2020]. For example, in transformer models like BERT, the same word can have varied embeddings depending on surrounding words. Ope-nAI’s embeddings-ada-02 model3, built upon the principles of LLMs like GPT, is a sophisticated dynamic embedding model that captures contextual understanding. However, it may not exhibit the same sensitivity to context as the latest full-size language models like GPT-4. | 与静态嵌入不同,动态嵌入适应单词使用的上下文,静态嵌入为每个单词使用单个向量[Karpukhin等人,2020]。例如,在像BERT这样的变压器模型中,相同的单词可以根据周围的单词具有不同的嵌入。Ope-nAI的embedding_ada -02模型建立在法学硕士(如GPT)的原理之上,是一个复杂的动态嵌入模型,可以捕获上下文理解。然而,它可能不会像最新的全尺寸语言模型(如GPT-4)那样对上下文表现出同样的敏感性。 |
Post-Retrieval Process After retrieving valuable context from the database, it is es-sential to merge it with the query as an input into LLMs while addressing challenges posed by context window limits. Sim-ply presenting all relevant documents to the LLM at once may exceed the context window limit, introduce noise, and hinder the focus on crucial information. Additional processing of the retrieved content is necessary to address these issues. | Post-Retrieval过程 在从数据库中检索有价值的上下文之后,必须将其与查询合并,作为llm的输入,同时解决上下文窗口限制带来的挑战。简单地将所有相关文件一次性呈现给法学硕士可能会超出上下文窗口限制,引入噪音,并阻碍对关键信息的关注。为了解决这些问题,需要对检索到的内容进行额外处理。 |
Re-Ranking. Re-ranking the retrieved information to re-locate the most relevant content to the edges of the prompt is a key strategy. This concept has been implemented in frameworks such as LlamaIndex4, LangChain5, and HayStack [Blagojevi, 2023]. For example, Diversity Ranker6 prioritizes reordering based on document diversity, while LostInTheMiddleRanker alternates placing the best docu-ment at the beginning and end of the context window. Ad-ditionally, approaches like cohereAI rerank [Cohere, 2023], bge-rerank7, and LongLLMLingua [Jiang et al., 2023a] re-calculate the semantic similarity between relevant text and the query, addressing the challenge of interpreting vector-based simulated searches for semantic similarity. | 重新评估。对检索到的信息重新排序以将最相关的内容重新定位到提示的边缘是一个关键策略。这个概念已经在LlamaIndex4、LangChain5和HayStack等框架中实现[Blagojevi, 2023]。例如,Diversity Ranker6根据文档多样性对重新排序进行优先级排序,而LostInTheMiddleRanker则交替将最佳文档放在上下文窗口的开头和结尾。此外,cohereAI rerank [Cohere, 2023]、big -rerank7和LongLLMLingua [Jiang等人,2023]等方法重新计算了相关文本与查询之间的语义相似度,解决了解释基于向量的模拟搜索语义相似度的挑战。 |
Prompt Compression. Research indicates that noise in re-trieved documents adversely affects RAG performance. In post-processing, the emphasis lies in compressing irrelevant context, highlighting pivotal paragraphs, and reducing the overall context length. Approaches such as Selective Context and LLMLingua [Litman et al., 2020, Anderson et al., 2022] utilize small language models to calculate prompt mu-tual information or perplexity, estimating element impor-tance. Recomp [Xu et al., 2023a] addresses this by train-ing compressors at different granularities, while Long Context [Xu et al., 2023b] and “Walking in the Memory Maze” [Chen et al., 2023a] design summarization techniques to enhance LLM’s key information perception, particularly in dealing with extensive contexts. | 提示压缩。研究表明,检索文档中的噪声会对RAG性能产生不利影响。在后处理中,重点在于压缩不相关的上下文,突出关键段落,减少整体上下文长度。选择性语境(Selective Context)和LLMLingua等方法[Litman et al., 2020, Anderson et al., 2022]利用小语言模型来计算提示互信息或困惑,从而估计元素的重要性。Recomp [Xu等人,2023a]通过在不同粒度上训练压缩器来解决这个问题,而Long Context [Xu等人,2023b]和“在记忆迷宫中行走”[Chen等人,2023a]设计了总结技术来增强LLM的关键信息感知,特别是在处理广泛的上下文时。 |
The modular RAG structure diverges from the tradi-tional Naive RAG framework, providing greater versatil-ity and flexibility. It integrates various methods to en-hance functional modules, such as incorporating a search module for similarity retrieval and applying a fine-tuning approach in the retriever [Lin et al., 2023]. Restructured RAG modules [Yu et al., 2022] and iterative methodologies like [Shao et al., 2023] have been developed to address spe-cific issues. The modular RAG paradigm is increasingly be-coming the norm in the RAG domain, allowing for either a serialized pipeline or an end-to-end training approach across multiple modules. The comparison of three RAG paradigms is depicted in Figure 3. However, Modular RAG is not stan-dalone. Advanced RAG is a specialized form of modular RAG, and further, Naive RAG itself is a special case of Ad-vanced RAG. The relationship among the three paradigms is one of inheritance and development. | 模块化的RAG结构与传统的朴素RAG框架不同,提供了更大的通用性和灵活性。它集成了各种方法来增强功能模块,例如在检索器中加入相似检索的搜索模块和应用微调方法[Lin et al., 2023]。重构RAG模块[Yu et al., 2022]和迭代方法(如[Shao et al., 2023])已被开发用于解决特定问题。模块化的RAG范例正日益成为RAG领域的规范,它允许序列化的管道或跨多个模块的端到端训练方法。图3描述了三个RAG范例的比较。然而,模块化RAG并不是独立的。高级RAG是模块化RAG的一种特殊形式,此外,幼稚RAG本身是高级RAG的一种特殊情况。三种范式之间是一种继承与发展的关系。 |
New Modules Search Module. In contrast to the similarity retrieval in Naive/Advanced RAG, the Search Module is tailored to spe-cific scenarios and incorporates direct searches on additional corpora. This integration is achieved using code generated by the LLM, query languages such as SQL or Cypher, and other custom tools. The data sources for these searches can include search engines, text data, tabular data, and knowledge graphs [Wang et al., 2023d]. | 新模块 搜索模块。与Naive/Advanced RAG中的相似度检索相比,Search模块针对特定场景进行了定制,并结合了对其他语料库的直接搜索。这种集成是使用LLM生成的代码、查询语言(如SQL或Cypher)以及其他自定义工具来实现的。这些搜索的数据源可以包括搜索引擎、文本数据、表格数据和知识图谱[Wang et al., 2023]。 |
Memory Module. This module harnesses the memory ca-pabilities of the LLM to guide retrieval. The approach in-volves identifying memories most similar to the current input. Selfmem [Cheng et al., 2023b] utilizes a retrieval-enhanced generator to create an unbounded memory pool iteratively, combining the “original question” and “dual question”. By employing a retrieval-enhanced generative model that uses its own outputs to improve itself, the text becomes more aligned with the data distribution during the reasoning process. Con-sequently, the model’s own outputs are utilized instead of the training data [Wang et al., 2022a]. | 内存模块。该模块利用LLM的内存功能来指导检索。这种方法包括识别与当前输入最相似的记忆。Selfmem [Cheng et al., 2023b]利用检索增强生成器迭代创建无界内存池,将“原始问题”和“双重问题”结合起来。通过使用检索增强的生成模型,该模型使用自己的输出来改进自己,文本在推理过程中与数据分布更加一致。因此,使用模型自身的输出来代替训练数据[Wang et al., 2022a]。 |
Fusion. RAG-Fusion [Raudaschl, 2023]enhances tradi-tional search systems by addressing their limitations through a multi-query approach that expands user queries into multiple, diverse perspectives using an LLM. This approach not only captures the explicit information users seek but also un-covers deeper, transformative knowledge. The fusion pro-cess involves parallel vector searches of both original and expanded queries, intelligent re-ranking to optimize results, and pairing the best outcomes with new queries. This sophis-ticated method ensures search results that align closely with both the explicit and implicit intentions of the user, leading to more insightful and relevant information discovery. | 融合。RAG-Fusion [Raudaschl, 2023]通过使用LLM将用户查询扩展到多个不同角度的多查询方法来解决传统搜索系统的局限性,从而增强了传统搜索系统。这种方法不仅捕获了用户所寻求的明确信息,而且还揭示了更深层次的、具有变革性的知识。融合过程包括对原始查询和扩展查询进行并行向量搜索,智能重新排序以优化结果,并将最佳结果与新查询配对。这种复杂的方法确保搜索结果与用户的显性和隐性意图紧密结合,从而导致更有洞察力和相关的信息发现。 |
Routing. The RAG system’s retrieval process utilizes di-verse sources, differing in domain, language, and format, which can be either alternated or merged based on the sit-uation [Li et al., 2023b]. Query routing decides the subse-quent action to a user’s query, with options ranging from summarization, searching specific databases, or merging dif-ferent pathways into a single response. The query router also chooses the appropriate data store for the query, which may include various sources like vector stores, graph databases, or relational databases, or a hierarchy of indices—for instance, a summary index and a document block vector index for multi-document storage. The query router’s decision-making is pre-defined and executed via LLMs calls, which direct the query to the chosen index. | 路由。RAG系统的检索过程利用了多种来源,这些来源在领域、语言和格式上都有所不同,可以根据情况进行交替或合并[Li et al., 2023b]。查询路由决定用户查询的后续操作,其选项包括汇总、搜索特定数据库或将不同的路径合并到单个响应中。查询路由器还为查询选择适当的数据存储,其中可能包括各种来源,如矢量存储、图形数据库或关系数据库,或者索引层次结构——例如,用于多文档存储的摘要索引和文档块向量索引。查询路由器的决策是预先定义的,并通过llm调用执行,llm调用将查询定向到所选的索引。 |
Predict . It addresses the common issues of redundancy and noise in retrieved content. Instead of directly retrieving from a data source, this module utilizes the LLM to generate the necessary context [Yu et al., 2022]. The content produced by the LLM is more likely to contain pertinent information compared to that obtained through direct retrieval. | 预测。它解决了检索内容中的冗余和噪声等常见问题。该模块不是直接从数据源中检索,而是利用LLM生成必要的上下文[Yu et al., 2022]。与通过直接检索获得的内容相比,法学硕士产生的内容更有可能包含相关信息。 |
Task Adapter. This module focuses on adapting RAG to a variety of downstream tasks. UPRISE automates the retrieval of prompts for zero-shot task inputs from a pre-constructed data pool, thereby enhancing universality across tasks and models [Cheng et al., 2023a]. Meanwhile, PROMPTAGA-TOR [Dai et al., 2022] utilizes LLM as a few-shot query gen-erator and, based on the generated data, creates task-specific retrievers. By leveraging the generalization capability of LLMs, it enables the development of task-specific end-to-end retrievers with minimal examples. | 任务适配器。本模块侧重于使RAG适应各种下游任务。UPRISE自动从预构建的数据池中检索零shot任务输入的提示,从而增强了任务和模型之间的通用性[Cheng等人,2023a]。同时,PROMPTAGA-TOR [Dai et al., 2022]利用LLM作为少量查询生成器,并基于生成的数据创建特定于任务的检索器。通过利用llm的泛化能力,它可以用最少的示例开发特定于任务的端到端检索器。 |
New Patterns The organizational structure of Modular RAG is highly adapt-able, allowing for the substitution or rearrangement of mod-ules within the RAG process to suit specific problem contexts. | 新模式 模块化RAG的组织结构具有高度的适应性,允许在RAG过程中替换或重新排列模块以适应特定的问题上下文。 |
Naive RAG and Advanced RAG can both be considered as being composed of some fixed modules. As illustrated in the figure 3, Naive RAG primarily consists of the “Retrieve” and “Read” modules. A typical pattern of Advanced RAG builds upon the foundation of Naive RAG by adding “Rewrite” and “Rerank” modules. However, on the whole, modular RAG enjoys greater diversity and flexibility. | 初级RAG和高级RAG都可以认为是由一些固定的模块组成的。如图3所示,Naive RAG主要由“Retrieve”和“Read”模块组成。高级RAG的典型模式建立在朴素RAG的基础上,通过添加“重写”和“重新排序”模块。但总体而言,模块化RAG具有更大的多样性和灵活性。 |
Current research primarily explores two organizational paradigms. The first involves adding or replacing modules, while the second focuses on adjusting the organizational flow between modules. This flexibility enables tailoring the RAG process to effectively address a wide array of tasks. | 目前的研究主要探讨了两种组织范式。前者涉及添加或替换模块,而后者侧重于调整模块之间的组织流程。这种灵活性使RAG过程能够有效地处理各种任务。 |
Adding or Replacing Modules.The strategy of introducing or substituting modules involves maintaining the core struc-ture of the Retrieval-Read process while integrating addi-tional modules to enhance specific functionalities. The RRR model [Ma et al., 2023a] introduces the Rewrite-Retrieve-Read process, utilizing the LLM performance as a reinforce-ment learning incentive for a rewriting module. This enables the rewriter to fine-tune retrieval queries, thereby improving the downstream task performance of the reader. | 增加或更换模块。引入或替换模块的策略包括维护检索-读取过程的核心结构,同时集成其他模块以增强特定功能。RRR模型[Ma et al., 2023a]引入了重写-检索-读取过程,利用LLM性能作为重写模块的强化学习激励。这使重写器能够微调检索查询,从而提高读取器的下游任务性能。 |
Similarly, modules can be selectively swapped in method-ologies like Generate-Read [Yu et al., 2022], where the LLM’s generation module takes the place of the retrieval module. The Recite-Read approach [Sun et al., 2022] trans-forms external retrieval into retrieval from model weights, requiring the LLM to initially memorize task-specific infor-mation and subsequently produce output capable of handling knowledge-intensive natural language processing tasks. | 类似地,模块可以在Generate-Read [Yu et al., 2022]等方法中选择性地交换,其中LLM的生成模块取代了检索模块。背诵-阅读方法[Sun et al., 2022]将外部检索转换为从模型权重中检索,要求LLM首先记住特定于任务的信息,然后产生能够处理知识密集型自然语言处理任务的输出。 |
Adjusting the Flow between Modules. zheIn the realm of module flow adjustment, there is a focus on enhancing the interaction between language models and retrieval mod-els. DSP [Khattab et al., 2022] introduces the Demonstrate-Search-Predict framework, treating the context learning sys-tem as an explicit program rather than a final task prompt, leading to more effective handling of knowledge-intensive tasks. The ITER-RETGEN [Shao et al., 2023] approach uti-lizes generated content to guide retrieval, iteratively im-plementing “retrieval-enhanced generation” and “generation-enhanced retrieval” within a Retrieve-Read-Retrieve-Read flow. This method demonstrates an innovative way of using one module’s output to improve the functionality of another. | 调整模块间的流程。在模块流调整领域,重点是加强语言模型和检索模型之间的交互。DSP [Khattab等人,2022]引入了演示-搜索-预测框架,将上下文学习系统视为一个明确的程序,而不是最终的任务提示,从而更有效地处理知识密集型任务。ITER-RETGEN [Shao等人,2023]方法利用生成的内容来指导检索,在检索-读取-检索-读取流程中迭代实现“检索增强生成”和“生成增强检索”。这种方法展示了一种使用一个模块的输出来改进另一个模块的功能的创新方法。 |
Optimizing the RAG Pipeline The optimization of the retrieval process aims to enhance the efficiency and quality of information in RAG systems. Cur-rent research focuses on integrating diverse search technolo-gies, refining retrieval steps, incorporating cognitive back-tracking, implementing versatile query strategies, and lever-aging embedding similarity. These efforts collectively strive to achieve a balance between retrieval efficiency and the depth of contextual information in RAG systems. | RAG管道优化 优化检索过程的目的是提高检索效率和检索质量。目前的研究主要集中在整合多种搜索技术、优化检索步骤、结合认知回溯、实现通用查询策略以及利用老化嵌入相似度等方面。这些努力共同努力实现检索效率和上下文信息深度在RAG系统之间的平衡。 |
Hybrid Search Exploration. The RAG system optimizes its performance by intelligently integrating various techniques, including keyword-based search, semantic search, and vec-tor search. This approach leverages the unique strengths of each method to accommodate diverse query types and infor-mation needs, ensuring consistent retrieval of highly relevant and context-rich information. The use of hybrid search serves as a robust supplement to retrieval strategies, thereby enhanc-ing the overall efficacy of the RAG pipeline. | 混合搜索探索。RAG系统通过智能集成各种技术来优化其性能,包括基于关键字的搜索、语义搜索和向量搜索。这种方法利用每种方法的独特优势来适应不同的查询类型和信息需求,确保对高度相关和上下文丰富的信息进行一致的检索。使用混合搜索作为检索策略的强大补充,从而提高了RAG管道的整体效率。 |
Recursive Retrieval and Query Engine. Recursive retrieval involves acquiring smaller chunks during the initial retrieval phase to capture key semantic meanings. Subsequently, larger chunks containing more contextual information are provided to the LLM in later stages of the process. This two-step re-trieval method helps to strike a balance between efficiency and the delivery of contextually rich responses. | 递归检索和查询引擎。递归检索涉及在初始检索阶段获取较小的块以捕获关键语义。随后,在流程的后期阶段,将向法学硕士提供包含更多上下文信息的大块。这种两步检索方法有助于在效率和提供上下文丰富的响应之间取得平衡。 |
StepBack-prompt approach encourages the LLM to move away from specific instances and engage in reasoning around broader concepts and principles [Zheng et al., 2023]. Experi-mental results demonstrate a significant performance increase in various challenging, inference-based tasks when backward prompts are used, highlighting their natural adaptability to the RAG process. These retrieval-enhancing steps can be applied both in generating responses to backward prompts and in the final question-answering process. | 退步提示方法鼓励法学硕士从具体实例中转移出来,围绕更广泛的概念和原则进行推理[Zheng等人,2023]。实验结果表明,当使用向后提示时,在各种具有挑战性的、基于推理的任务中,性能显著提高,突出了它们对RAG过程的自然适应性。这些增强检索的步骤既可以应用于生成对向后提示的响应,也可以应用于最终的问答过程。 |
Sub-Queries. Depending on the scenario, various query strategies can be employed, such as using query engines provided by frameworks like LlamaIndex, leveraging tree queries, utilizing vector queries, or executing simple sequen-tial querying of chunks. | 子查询。根据场景的不同,可以采用各种查询策略,例如使用LlamaIndex等框架提供的查询引擎、利用树查询、利用向量查询或执行简单的块顺序查询。 |
Hypothetical Document Embeddings. HyDE operates on the belief that the answers generated might be closer in the embedding space than a direct query. Using the LLM, HyDE creates a hypothetical document (answer) in response to a query, embeds this document, and uses the resulting em-bedding to retrieve real documents similar to the hypotheti-cal one. Instead of seeking embedding similarity based on the query, this approach focuses on the embedding similar-ity from one answer to another [Gao et al., 2022]. However, it might not consistently produce desirable outcomes, espe-cially when the language model is unfamiliar with the subject matter, potentially leading to more instances with errors. | 假设的文档嵌入。HyDE相信生成的答案在嵌入空间中可能比直接查询更接近。使用LLM, HyDE为响应查询创建一个假设文档(答案),嵌入该文档,并使用生成的嵌入来检索与假设文档相似的真实文档。该方法不是基于查询寻求嵌入相似度,而是侧重于从一个答案到另一个答案的嵌入相似度[Gao et al., 2022]。然而,它可能不会始终产生理想的结果,特别是当语言模型不熟悉主题时,可能会导致更多带有错误的实例。 |
In the context of RAG, it is crucial to efficiently retrieve rel-evant documents from the data source. However, creating a proficient retriever presents significant challenges. This sec-tionelves into three fundamental questions: 1) How can we achieve accurate semantic representations? 2) What methods can align the semantic spaces of queries and documents? 3) How can the retriever’s output be aligned with the preferences of the Large Language Model? | 在RAG上下文中,从数据源中有效地检索相关事件文档是至关重要的。然而,创造一只熟练的寻回犬面临着巨大的挑战。本节分为三个基本问题:1)我们如何实现准确的语义表示?2)什么方法可以对齐查询和文档的语义空间?3)如何使检索器的输出与大语言模型的偏好保持一致? |
In RAG, the semantic space is essential as it involves the mul-tidimensional mapping of queries and documents. Retrieval accuracy in this semantic space significantly impacts RAG outcomes. This section will present two methods for building accurate semantic spaces. | 在RAG中,语义空间是必不可少的,因为它涉及查询和文档的多维映射。语义空间的检索精度显著影响RAG结果。本节将介绍构建准确语义空间的两种方法。 |
Chunk optimization When managing external documents, the initial step involves breaking them down into smaller chunks to extract fine-grained features, which are then embedded to represent their semantics. However, embedding overly large or excessively small text chunks may lead to sub-optimal outcomes. There-fore, identifying the optimal chunk size for documents within the corpus is crucial to ensuring the accuracy and relevance of the retrieved results. | 块优化 在管理外部文档时,最初的步骤包括将它们分解为更小的块,以提取细粒度的特性,然后嵌入这些特性以表示它们的语义。然而,嵌入过大或过小的文本块可能会导致次优结果。因此,确定语料库中文档的最佳块大小对于确保检索结果的准确性和相关性至关重要。 |
Choosing an appropriate chunking strategy requires care-ful consideration of several vital factors, such as the nature of the indexed content, the embedding model and its opti-mal block size, the expected length and complexity of user queries, and the specific application’s utilization of the re-trieved results. For instance, the selection of a chunking model should be based on the content’s length—whether it is longer or shorter. Additionally, different embedding mod-els demonstrate distinct performance characteristics at vary-ing block sizes. For example, sentence-transformer performs better with single sentences, while text-embedding-ada-002 excels with blocks containing 256 or 512 tokens. | 选择适当的分块策略需要仔细考虑几个重要因素,例如索引内容的性质、嵌入模型及其最优块大小、用户查询的预期长度和复杂性,以及特定应用程序对检索结果的利用。例如,分块模型的选择应该基于内容的长度——是长还是短。此外,不同的嵌入模型在不同块大小下表现出不同的性能特征。例如,句子转换器在处理单个句子时表现更好,而text-embedding-ada-002在处理包含256或512个令牌的块时表现出色。 |
Additionally, factors like the length and complexity of user input questions, and the specific needs of the application (e.g., semantic search or question answering), have effect on the choice of a chunking strategy. This choice can be directly in-fluenced by the token limits of the selected LLMs, requiring adjustments to the block size. In reality, getting precise query results involves flexibly applying different chunking strate-gies. There is no one-size-fits-all ”best” strategy, only the most appropriate one for a particular context. | 此外,用户输入问题的长度和复杂性以及应用程序的特定需求(例如,语义搜索或问题回答)等因素也会影响分块策略的选择。这种选择可能直接受到所选llm的令牌限制的影响,需要调整块大小。在现实中,获得精确的查询结果需要灵活地应用不同的分块策略。没有放之四海而皆准的“最佳”策略,只有最适合特定环境的策略。 |
Current research in RAG explores various block optimiza-tion techniques aimed at improving both retrieval efficiency and accuracy. One such approach involves the use of slid-ing window technology, enabling layered retrieval by merg-ing globally related information across multiple retrieval pro-cesses. Another strategy, known as the “small2big” method, utilizes small text blocks during the initial search phase and subsequently provides larger related text blocks to the lan-guage model for processing. | 当前RAG的研究探索了各种块优化技术,旨在提高检索效率和准确性。其中一种方法涉及使用滑动窗口技术,通过跨多个检索过程合并全局相关信息来实现分层检索。另一种策略,称为“small2big”方法,在初始搜索阶段利用小文本块,随后向语言模型提供更大的相关文本块进行处理。 |
The abstract embedding technique prioritizes top K re-trieval based on document abstracts (or summaries), offering a comprehensive understanding of the entire document con-text. Additionally, the metadata filtering technique leverages document metadata to enhance the filtering process. An in-novative approach, the graph indexing technique, transforms entities and relationships into nodes and connections, sig-nificantly improving relevance, particularly in the context of multi-hop problems. | 摘要嵌入技术根据文档摘要(或摘要)对top K检索进行优先级排序,从而提供对整个文档上下文的全面理解。此外,元数据过滤技术利用文档元数据来增强过滤过程。一种创新的方法,图索引技术,将实体和关系转换为节点和连接,显著提高相关性,特别是在多跳问题的背景下。 |
The combination of these diverse methods has led to no-table advancements, resulting in enhanced retrieval outcomes and improved performance for RAG. | 这些不同方法的组合导致了无表的进步,从而增强了检索结果并改进了RAG的性能。 |
Fine-tuning Embedding Models Once the appropriate size of chunks is determined, the next crucial step involves embedding these chunks and the query into the semantic space using an embedding model. The effectiveness of the embedding is critical as it impacts the model’s ability to represent the corpus. Recent re-search has introduced prominent embedding models such as AngIE, Voyage, BGE,etc [Li and Li, 2023, VoyageAI, 2023, BAAI, 2023]. These models have undergone pre-training on extensive corpora. However, their capability to accurately capture domain-specific information may be limited when ap-plied to specialized domains. | 微调嵌入模型 一旦确定了适当的块大小,下一个关键步骤是使用嵌入模型将这些块和查询嵌入到语义空间中。嵌入的有效性至关重要,因为它影响模型表示语料库的能力。最近的研究引入了AngIE、Voyage、BGE等突出的嵌入模型[Li and Li, 2023, VoyageAI, 2023, BAAI, 2023]。这些模型在广泛的语料库上进行了预训练。然而,当应用于特定领域时,它们准确捕获特定领域信息的能力可能会受到限制。 |
Moreover, task-specific fine-tuning of embedding models is essential to ensure that the model comprehends the user query in terms of content relevance. A model without fine-tuning may not adequately address the requirements of a spe-cific task. Consequently, fine-tuning an embedding model be-comes crucial for downstream applications. There are two primary paradigms in embedding fine-tuning methods. | 此外,嵌入模型的特定任务微调对于确保模型从内容相关性方面理解用户查询至关重要。没有微调的模型可能无法充分满足特定任务的需求。因此,对嵌入模型进行微调对于下游应用程序至关重要。在嵌入微调方法中有两种主要的范式。 |
Domain Knowledge Fine-tuning. To ensure that an embed-ding model accurately captures domain-specific information, it is imperative to utilize domain-specific datasets for fine-tuning. This process diverges from standard language model fine-tuning, chiefly in the nature of the datasets involved. Typically, the dataset for embedding model fine-tuning en-compasses three principal elements: queries, a corpus, and relevant documents. The model employs these queries to identify pertinent documents within the corpus. The effi-cacy of the model is then gauged based on its ability to re-trieve these relevant documents in response to the queries. The dataset construction, model fine-tuning, and evalua-tion phases each present distinct challenges. The LlamaIn-dex [Liu, 2023] introduces a suite of pivotal classes and func-tions designed to enhance the embedding model fine-tuning workflow, thereby simplifying these intricate processes. By curating a corpus infused with domain knowledge and lever-aging the methodologies offered, one can adeptly fine-tune an embedding model to align closely with the specific require-ments of the target domain. | 领域知识微调。为了确保嵌入模型准确地捕获特定于领域的信息,必须利用特定于领域的数据集进行微调。这个过程与标准语言模型微调不同,主要在于所涉及的数据集的性质。通常,用于嵌入模型微调的数据集包含三个主要元素:查询、语料库和相关文档。该模型使用这些查询来识别语料库中的相关文档。然后,根据响应查询而重新检索这些相关文档的能力来衡量模型的有效性。数据集构建、模型微调和评估阶段各有不同的挑战。LlamaIn-dex [Liu, 2023]引入了一套关键类和函数,旨在增强嵌入模型微调工作流程,从而简化这些复杂的过程。通过管理充满领域知识的语料库并利用所提供的方法,可以熟练地微调嵌入模型,使其与目标领域的特定需求紧密结合。 |
Fine-tuning for Downstream Tasks. Fine-tuning embed-ding models for downstream tasks is a critical step in en-hancing model performance. In the realm of utilizing RAG for these tasks, innovative methods have emerged to fine-tune embedding models by harnessing the capabilities of LLMs. For example, PROMPTAGATOR [Dai et al., 2022] utilizes the LLM as a few-shot query generator to cre-ate task-specific retrievers, addressing challenges in super-vised fine-tuning, particularly in data-scarce domains. An-other approach, LLM-Embedder [Zhang et al., 2023a], ex-ploits LLMs to generate reward signals for data across mul-tiple downstream tasks. The retriever is fine-tuned with two types of supervised signals: hard labels for the dataset and soft rewards from the LLMs. This dual-signal approach fos-ters a more effective fine-tuning process, tailoring the embed-ding model to diverse downstream applications. | 对下游任务进行微调。对下游任务的嵌入模型进行微调是提高模型性能的关键步骤。在利用RAG完成这些任务的领域中,通过利用llm的功能来微调嵌入模型的创新方法已经出现。例如,PROMPTAGATOR [Dai等人,2022]利用LLM作为少量查询生成器来创建特定于任务的检索器,解决了监督微调中的挑战,特别是在数据稀缺领域。另一种方法是LLM-Embedder [Zhang等,2023a],利用llm为跨多个下游任务的数据生成奖励信号。检索器使用两种类型的监督信号进行微调:数据集的硬标签和来自llm的软奖励。这种双信号方法实现了更有效的微调过程,使嵌入模型适应不同的下游应用。 |
While these methods improve semantic representation by incorporating domain knowledge and task-specific fine-tuning, retrievers may not always exhibit optimal compatibil-ity with certain LLMs. To address this, some researchers have explored direct supervision of the fine-tuning process using feedback from LLMs. This direct supervision seeks to align the retriever more closely with the LLM, thereby improving performance on downstream tasks. A more comprehensive discussion on this topic is presented in Section 4.3. | 虽然这些方法通过结合领域知识和特定于任务的微调来改进语义表示,但检索器可能并不总是表现出与某些llm的最佳兼容性。为了解决这个问题,一些研究人员探索了利用法学硕士的反馈直接监督微调过程。这种直接监督旨在使检索器更紧密地与LLM保持一致,从而提高下游任务的性能。关于这个主题的更全面的讨论将在第4.3节中介绍。 |
In the context of RAG applications, retrievers may utilize a single embedding model for encoding both the query and the documents, or employ separate models for each. Addi-tionally, the user’s original query may suffer from imprecise phrasing and lack of semantic information. Therefore, it is crucial to align the semantic space of the user’s query with those of the documents. This section introduces two funda-mental techniques aimed at achieving this alignment. | 在RAG应用程序的上下文中,检索器可以使用单个嵌入模型对查询和文档进行编码,或者为每个模型使用单独的模型。此外,用户的原始查询可能会受到措辞不精确和缺乏语义信息的影响。因此,将用户查询的语义空间与文档的语义空间保持一致是至关重要的。本节将介绍两种旨在实现这种一致性的基本技术。 |
Query Rewriting Query rewriting is a fundamental approach for aligning the semantics of a query and a document. Methods such as Query2Doc and ITER-RETGEN leverage LLMs to create a pseudo-document by combining the origi-nal query with additional guidance [Wang et al., 2023c, Shao et al., 2023]. HyDE constructs query vectors using textual cues to generate a “hypothetical” document captur-ing essential patterns [Gao et al., 2022]. RRR introduces a framework that reverses the traditional retrieval and read-ing order, focusing on query rewriting [Ma et al., 2023a]. STEP-BACKPROMPTING enables LLMs to perform ab-stract reasoning and retrieval based on high-level con-cepts [Zheng et al., 2023]. Additionally, the multi-query re-trieval method utilizes LLMs to generate and execute multiple search queries simultaneously, advantageous for addressing complex problems with multiple sub-problems. | 查询重写 查询重写是对齐查询和文档语义的基本方法。Query2Doc和ITER-RETGEN等方法利用llm通过将原始查询与附加指导相结合来创建伪文档[Wang et al., 2023c, Shao et al., 2023]。HyDE使用文本线索构建查询向量,以生成捕获基本模式的“假设”文档[Gao等人,2022]。RRR引入了一个框架,该框架逆转了传统的检索和读取顺序,重点是查询重写[Ma et al., 2023a]。step - backprompts使llm能够基于高级概念执行抽象推理和检索[Zheng等,2023]。此外,多查询重新检索方法利用llm同时生成和执行多个搜索查询,有利于解决包含多个子问题的复杂问题。 |
Embedding Transformation Beyond broad strategies such as query rewriting, there exist more granular techniques specifically designed for embed-ding transformations. LlamaIndex [Liu, 2023] exemplifies this by introducing an adapter module that can be integrated following the query encoder. This adapter facilitates fine-tuning, thereby optimizing the representation of query em-beddings to map them into a latent space that is more closely aligned with the intended tasks. | 嵌入转换 除了诸如查询重写之类的广泛策略之外,还有专门为嵌入转换设计的更细粒度的技术。LlamaIndex [Liu, 2023]通过引入一个可以集成在查询编码器之后的适配器模块来举例说明这一点。这个适配器促进了微调,从而优化了查询嵌入的表示,将它们映射到与预期任务更紧密结合的潜在空间中。 |
The challenge of aligning queries with structured exter-nal documents, particularly when addressing the incongruity between structured and unstructured data, is addressed by SANTA [Li et al., 2023d]. It enhances the retriever’s sen-sitivity to structured information through two pre-training strategies: first, by leveraging the intrinsic alignment between structured and unstructured data to inform contrastive learn-ing in a structured-aware pre-training scheme; and second, by implementing Masked Entity Prediction. The latter utilizes an entity-centric masking strategy that encourages language models to predict and fill in the masked entities, thereby fos-tering a deeper understanding of structured data. | 将查询与结构化外部文档对齐的挑战,特别是在处理结构化和非结构化数据之间的不一致性时,SANTA解决了这个问题[Li等人,2023]。它通过两种预训练策略来提高检索器对结构化信息的敏感性:第一,利用结构化和非结构化数据之间的内在一致性,在结构化感知预训练方案中通知对比学习;第二,通过实现屏蔽实体预测。后者利用以实体为中心的屏蔽策略,鼓励语言模型预测和填充被屏蔽的实体,从而促进对结构化数据的更深入理解。 |
The issue of aligning queries with structured exter-nal documents, especially when dealing with the dispar-ity between structured and unstructured data, is tackled by SANTA [Li et al., 2023d]. This approach improves the re-triever’s ability to recognize structured information through two pre-training strategies: firstly, by utilizing the inher-ent alignment between structured and unstructured data to guide contrastive learning in a structured-aware pre-training scheme; and secondly, by employing Masked Entity Predic-tion. The latter uses an entity-centric masking strategy to prompt language models to predict and complete the masked entities, thus promoting a more profound comprehension of structured data. | 将查询与结构化外部文档对齐的问题,特别是在处理结构化和非结构化数据之间的差异时,由SANTA解决[Li等人,2023]。该方法通过两种预训练策略提高了检索器识别结构化信息的能力:第一,利用结构化和非结构化数据之间的内在一致性来指导结构化感知预训练方案中的对比学习;其次,采用屏蔽实体预测。后者使用以实体为中心的掩蔽策略来提示语言模型预测和完成掩蔽实体,从而促进对结构化数据的更深刻理解。 |
In the RAG pipeline, enhancing retrieval hit rate through var-ious techniques may not necessarily improve the final out-come, as the retrieved documents may not align with the spe-cific requirements of the LLMs. Therefore, this section in-troduces two methods aimed at aligning the retriever outputs with the preferences of the LLMs. | 在RAG管道中,通过各种技术提高检索命中率不一定会改善最终结果,因为检索的文档可能与llm的特定需求不一致。因此,本节将介绍两种方法,旨在使检索器输出与llm的首选项保持一致。 |
Fine-tuning Retrievers Several studies utilize feedback signals from LLMs to refine retrieval models. For instance, AAR [Yu et al., 2023b] intro-duces supervisory signals for a pre-trained retriever using an encoder-decoder architecture. This is achieved by identifying the LM’s preferred documents through FiD cross-attention scores. Subsequently, the retriever undergoes fine-tuning with hard negative sampling and standard cross-entropy loss. Ultimately, the refined retriever can be directly applied to en-hance unseen target LMs, resulting in improved performance in the target task. Additionally, it is suggested that LLMs may have a preference for focusing on readable rather than information-rich documents. | 微调猎犬 一些研究利用llm的反馈信号来完善检索模型。例如,AAR [Yu等人,2023b]使用编码器-解码器架构为预训练的检索器引入监视信号。这是通过FiD交叉注意分数来识别LM的首选文档来实现的。随后,通过硬负采样和标准交叉熵损失对寻回犬进行微调。最终,改进后的检索器可以直接用于增强未见目标lm,从而提高目标任务的性能。此外,有人建议法学硕士可能更倾向于关注可读而不是信息丰富的文档。 |
REPLUG [Shi et al., 2023] utilizes a retriever and an LLM to calculate the probability distributions of the retrieved doc-uments and then performs supervised training by computing the KL divergence. This straightforward and effective train-ing method enhances the performance of the retrieval model by using an LM as the supervisory signal, eliminating the need for specific cross-attention mechanisms. | REPLUG [Shi et al., 2023]利用检索器和LLM计算检索文档的概率分布,然后通过计算KL散度进行监督训练。这种简单有效的训练方法通过使用LM作为监督信号来提高检索模型的性能,消除了对特定交叉注意机制的需要。 |
UPRISE [Cheng et al., 2023a] also employs frozen LLMs to fine-tune the prompt retriever. Both the LLM and the re-triever take prompt-input pairs as inputs and utilize the scores provided by the LLM to supervise the retriever’s training, ef-fectively treating the LLM as a dataset labeler. In addition, Atlas [Izacard et al., 2022] proposes four methods of super-vised fine-tuning embedding models: >>Attention Distillation. This approach employs cross-attention scores generated by the LLM during output to distill the model’s knowledge. >>EMDR2. By using the Expectation-Maximization algo-rithm, this method trains the model with retrieved docu-ments as latent variables. >>Perplexity Distillation directly trains the model using the perplexity of generated tokens as an indicator. >>LOOP. This method presents a novel loss function based on the impact of document deletion on LLM prediction, offering an efficient training strategy to better adapt the model to specific tasks. | UPRISE [Cheng et al., 2023a]也使用冻结llm对提示检索器进行微调。LLM和寻回犬都将提示输入对作为输入,并利用LLM提供的分数来监督寻回犬的训练,有效地将LLM视为数据集标注器。此外,Atlas [Izacard et al., 2022]提出了四种监督微调嵌入模型的方法: > >注意蒸馏。该方法利用LLM在输出过程中生成的交叉注意分数来提取模型的知识。 > > EMDR2。该方法采用期望最大化算法,以检索到的文档作为潜在变量对模型进行训练。 Perplexity Distillation直接使用生成的token的Perplexity作为指标来训练模型。 > >循环。该方法提出了一种新的基于文档删除对LLM预测影响的损失函数,提供了一种有效的训练策略,使模型更好地适应特定的任务。 |
These approaches aim to improve the synergy between the retriever and the LLM, leading to enhanced retrieval perfor-mance and more accurate responses to user inquiries. | 这些方法旨在提高检索器和LLM之间的协同作用,从而提高检索性能并更准确地响应用户查询。 |
Adapters Fine-tuning models may present challenges, such as integrat-ing functionality through an API or addressing constraints arising from limited local computational resources. Con-sequently, some approaches opt to incorporate an external adapter to aid in alignment. | 适配器 微调模型可能会带来挑战,例如通过API集成功能或解决由有限的本地计算资源引起的约束。因此,一些方法选择合并外部适配器来帮助校准。 |
PRCA trains the adapter through a context extraction phase and a reward-driven phase. The retriever’s out-put is then optimized using a token-based autoregres-sive strategy [Yang et al., 2023b]. The token filtering ap-proach employs cross-attention scores to efficiently fil-ter tokens, selecting only the highest-scoring input to-kens [Berchansky et al., 2023].RECOMP introduces both ex-tractive and generative compressors for summary generation. These compressors either select relevant sentences or syn-thesize document information, creating summaries tailored to multi-document queries [Xu et al., 2023a]. | PRCA通过上下文提取阶段和奖励驱动阶段训练适配器。然后使用基于令牌的自回归策略对检索器的输出进行优化[Yang等人,2023b]。令牌过滤方法采用交叉注意分数来有效地过滤令牌,只选择得分最高的输入令牌[Berchansky等人,2023]。RECOMP引入了抽取压缩器和生成压缩器来生成摘要。这些压缩器要么选择相关句子,要么合成文档信息,创建适合多文档查询的摘要[Xu等人,2023a]。 |
Furthermore, PKG introduces an innovative method for in-tegrating knowledge into white-box models via directive fine-tuning [Luo et al., 2023]. In this approach, the retriever mod-ule is directly substituted to generate relevant documents ac-cording to a query. This method assists in addressing the dif-ficulties encountered during the fine-tuning process and en-hances model performance. | 此外,PKG引入了一种通过指令微调将知识集成到白盒模型中的创新方法[Luo等人,2023]。在这种方法中,直接替换检索器模块,根据查询生成相关文档。该方法有助于解决在微调过程中遇到的困难,并提高模型性能。 |
A crucial component of RAG is its generator, which is re-sponsible for converting retrieved information into coherent and fluent text. Unlike traditional language models, RAG’s generator sets itself apart by improving accuracy and rele-vance via the incorporation of retrieved data. In RAG, the generator’s input encompasses not only typical contextual in-formation but also relevant text segments obtained through the retriever. This comprehensive input enables the generator to gain a deep understanding of the question’s context, result-ing in more informative and contextually relevant responses. | RAG的一个关键组件是它的生成器,它负责将检索到的信息转换成连贯流畅的文本。与传统的语言模型不同,RAG的生成器通过整合检索到的数据来提高准确性和相关性,从而使自己与众不同。在RAG中,生成器的输入不仅包括典型的上下文信息,还包括通过检索器获得的相关文本片段。这种全面的输入使生成器能够深入了解问题的上下文,从而产生更多信息和上下文相关的响应。 |
Furthermore, the generator is guided by the retrieved text to ensure coherence between the generated content and the ob-tained information. The diverse input data has led to targeted efforts during the generation phase, all aimed at refining the adaptation of the large model to the input data derived from queries and documents. In the following subsections, we will explore the introduction of the generator by delving into as-pects of post-retrieval processing and fine-tuning. | 此外,生成器由检索文本引导,以确保生成的内容与获取的信息之间的一致性。不同的输入数据导致在生成阶段进行有针对性的工作,所有这些工作都旨在改进大型模型对来自查询和文档的输入数据的适应。在接下来的小节中,我们将通过深入研究检索后处理和微调的各个方面来探讨生成器的介绍。 |
In the realm of untunable LLMs , many studies rely on well-established models like GPT-4 [OpenAI, 2023] to harness their comprehensive internal knowledge for systematically synthesizing retrieved information from various documents. | 在不可调法学硕士领域,许多研究依赖于完善的模型,如GPT-4 [OpenAI, 2023]来利用其全面的内部知识,系统地综合从各种文档中检索到的信息。 |
However, challenges persist with these large models, includ-ing limitations on context length and susceptibility to redun-dant information. To tackle these issues, certain research en-deavors have turned their focus to post-retrieval processing. | 然而,这些大型模型仍然存在挑战,包括上下文长度的限制和对冗余信息的敏感性。为了解决这些问题,一些研究人员将重点转向了检索后处理。 |
Post-retrieval processing involves treating, filtering, or op-timizing the relevant information retrieved by the retriever from a large document database. Its main goal is to enhance the quality of retrieval results, aligning them more closely with user needs or subsequent tasks. It can be viewed as a reprocessing of the documents obtained during the retrieval phase. Common operations in post-retrieval processing typi-cally include information compression and result reranking. | 检索后处理包括处理、过滤或优化检索器从大型文档数据库检索到的相关信息。它的主要目标是提高检索结果的质量,使它们更贴近用户需求或后续任务。它可以看作是对检索阶段获得的文档的再处理。检索后处理中的常见操作通常包括信息压缩和结果重新排序。 |
Information Compression The retriever excels at retrieving relevant information from a vast knowledge base, but managing the substantial amount of information within retrieval documents is a challenge. Ongo-ing research aims to extend the context length of large lan-guage models to tackle this issue. However, current large models still struggle with context limitations. Therefore, there are scenarios where condensing information becomes necessary. Information condensation is significant for reduc-ing noise, addressing context length restrictions, and enhanc-ing generation effects. | 信息压缩 检索器擅长从庞大的知识库中检索相关信息,但是管理检索文档中的大量信息是一个挑战。正在进行的研究旨在扩展大型语言模型的上下文长度来解决这个问题。然而,当前的大型模型仍然与上下文限制作斗争。因此,在某些情况下,压缩信息是必要的。信息凝聚对于降低噪声、解决上下文长度限制和增强生成效果具有重要意义。 |
PRCA tackled this issue by training an information ex-tractor [Yang et al., 2023b]. In the context extraction phase, when provided with an input text Sinput, it is capable of producing an output sequence Cextracted that represents the condensed context from the input document. The train-ing process is designed to minimize the difference between Cextracted and the actual context Ctruth. | PRCA通过培训信息提取拖拉机解决了这个问题[Yang等,2023b]。在上下文提取阶段,当提供输入文本Sinput时,它能够生成一个输出序列,该序列表示从输入文档中提取的浓缩上下文。训练过程的目的是尽量减少提取和实际上下文之间的差异。 |
Similarly, RECOMP adopts a comparable approach by training an information condenser using contrastive learn-ing [Xu et al., 2023a]. Each training data point consists of one positive sample and five negative samples, and the en-coder undergoes training using contrastive loss throughout this process [Karpukhin et al., 2020] . | 类似地,RECOMP采用了一种类似的方法,即使用对比学习来训练信息收集器[Xu et al., 2023a]。每个训练数据点由一个正样本和五个负样本组成,编码器在整个过程中使用对比损失进行训练[Karpukhin et al., 2020]。 |
Another study has taken a different approach by aim-ing to reduce the number of documents in order to im-prove the accuracy of the model’s answers. In the study by [Ma et al., 2023b], they propose the “Filter-Reranker” paradigm, which combines the strengths of LLMs and Small Language Models (SLMs). In this paradigm, SLMs serve as filters, while LLMs function as reordering agents. The re-search shows that instructing LLMs to rearrange challeng-ing samples identified by SLMs leads to significant improve-ments in various Information Extraction (IE) tasks. | 另一项研究采取了不同的方法,旨在减少文件的数量,以提高模型答案的准确性。在[Ma et al., 2023b]的研究中,他们提出了“Filter-Reranker”范式,该范式结合了llm和小语言模型(Small Language Models, slm)的优势。在这个范例中,slm充当过滤器,而llm充当重新排序代理。研究表明,指导llm重新排列由slm识别的具有挑战性的样本可以显著改善各种信息提取(IE)任务。 |
Reranking The re-ranking model is pivotal in optimizing the document set retrieved from the retriever. Language models often face performance declines when additional context is introduced, and re-ranking effectively addresses this issue. The core con-cept involves rearranging document records to prioritize the most relevant items at the top, thereby limiting the total num-ber of documents. This not only resolves the challenge of context window expansion during retrieval but also enhances retrieval efficiency and responsiveness. | Reranking 重新排序模型是优化从检索器检索到的文档集的关键。当引入额外的上下文时,语言模型经常面临性能下降的问题,重新排序可以有效地解决这个问题。核心概念包括重新排列文档记录,将最相关的项放在最上面,从而限制文档的总数。这既解决了检索过程中上下文窗口展开的难题,又提高了检索效率和响应速度。 |
The re-ranking model assumes a dual role throughout the information retrieval process, functioning as both an optimizer and a refiner. It provides more effective and accurate input for subsequent language model process-ing [Zhuang et al., 2023]. | 重新排序模型在整个信息检索过程中扮演双重角色,既充当优化器,又充当精炼器。它为后续的语言模型处理提供了更有效和准确的输入[Zhuang等,2023]。 |
Contextual compression is incorporated into the reorder-ing process to offer more precise retrieval information. This method entails reducing the content of individual documents and filtering the entire document, with the ultimate goal of presenting the most relevant information in the search results for a more focused and accurate display of pertinent content. | 上下文压缩被整合到重新排序过程中,以提供更精确的检索信息。这种方法需要减少单个文档的内容并过滤整个文档,其最终目标是在搜索结果中显示最相关的信息,以便更集中、更准确地显示相关内容。 |
Optimizing the generator within the RAG model is a critical aspect of its architecture. The generator’s role is to take the retrieved information and produce relevant text, forming the final output of the model. The optimization of the generator aims to ensure that the generated text is both natural and ef-fectively leverages the retrieved documents to better meet the user’s query needs. | 在RAG模型中优化生成器是其体系结构的一个关键方面。生成器的作用是获取检索到的信息并生成相关文本,形成模型的最终输出。生成器的优化旨在确保生成的文本既自然又有效地利用检索到的文档来更好地满足用户的查询需求。 |
In standard LLMs generation tasks, the input typically consists of a query. RAG stands out by incorporating not only a query but also various retrieved documents (struc-tured/unstructured) by the retriever into the input. This ad-ditional information can significantly influence the model’s understanding, particularly for smaller models. In such cases, fine-tuning the model to adapt to the input of both query and retrieved documents becomes crucial. Before presenting the input to the fine-tuned model, post-retrieval processing usu-ally occurs for the documents retrieved by the retriever. It is essential to note that the fine-tuning method for the genera-tor in RAG aligns with the general fine-tuning approach for LLMs. In the following, we will briefly describe some rep-resentative works involving data (formatted/unformatted) and optimization functions. | 在标准llm生成任务中,输入通常由查询组成。RAG的突出之处在于,它不仅将查询,还将检索器检索到的各种文档(结构化/非结构化)合并到输入中。这些附加信息可以显著地影响模型的理解,特别是对于较小的模型。在这种情况下,对模型进行微调以适应查询和检索文档的输入变得至关重要。在将输入呈现给微调模型之前,通常会对检索器检索到的文档进行检索后处理。必须注意的是,RAG中用于genera-tor的微调方法与用于llm的通用微调方法是一致的。下面,我们将简要介绍一些涉及数据(格式化/未格式化)和优化函数的代表性工作。 |
General Optimization Process As part of the general optimization process, the training data typically consists of input-output pairs, aiming to train the model to produce the output y given the input x. In the work of Self-Mem [Cheng et al., 2023b], a traditional training process is employed, where given the input x, relevant documents z are retrieved (selecting Top-1 in the paper), and after integrating (x, z), the model generates the output y. The paper utilizes two common paradigms for fine-tuning, namely Joint-Encoder and Dual-Encoder [Arora et al., 2023, Wang et al., 2022b, Lewis et al., 2020, Xia et al., 2019, Cai et al., 2021, Cheng et al., 2022]. | 一般优化过程 作为一般优化过程的一部分,训练数据通常由输入输出对组成,目的是训练模型在给定输入x的情况下产生输出y。在Self-Mem [Cheng et al., 2023b]的工作中,采用了传统的训练过程,给定输入x,检索相关文档z(在本文中选择Top-1),在对(x, z)进行积分后,模型生成输出y。本文采用了两种常见的范式进行微调:即联合编码器和双编码器[Arora等,2023,Wang等,2022b, Lewis等,2020,Xia等,2019,Cai等,2021,Cheng等,2022]。 |
In the Joint-Encoder paradigm, a standard model based on an encoder-decoder is used. Here, the encoder initially en-codes the input, and the decoder, through attention mecha-nisms, combines the encoded results to generate tokens in an autoregressive manner. On the other hand, in the Dual-Encoder paradigm, the system sets up two independent en-coders, with each encoder encoding the input (query, con-text) and the document, respectively. The resulting out-puts undergo bidirectional cross-attention processing by the decoder in sequence. Both architectures utilize the Trans-former [Vaswani et al., 2017] as the foundational block and optimize with Negative Log-Likelihood loss. | 在联合编码器范例中,使用了基于编码器-解码器的标准模型。在这里,编码器最初对输入进行编码,而解码器通过注意机制组合编码结果,以自回归的方式生成标记。另一方面,在双编码器范例中,系统设置了两个独立的编码器,每个编码器分别编码输入(查询、上下文)和文档。由此产生的输出由解码器按顺序进行双向交叉注意处理。这两种架构都使用transformer [Vaswani等人,2017]作为基础块,并使用负对数似然损失进行优化。 |
Utilizing Contrastive Learning In the phase of preparing training data for language mod-els, interaction pairs of input and output are usually created. This traditional method can lead to ”exposure bias,” where the model is only trained on individual, correct output ex-amples, thus restricting its exposure to a range of possible outputs citesequence. This limitation can hinder the model’s real-world performance by causing it to overfit to the partic-ular examples in the training set, thereby reducing its ability to generalize across various contexts. | 运用对比学习 在为语言模型准备训练数据的阶段,通常会创建输入和输出的交互对。这种传统方法可能导致“暴露偏差”,即模型只在单个正确的输出样本上进行训练,从而限制了其暴露于一系列可能的输出序列。这种限制可能会导致模型过度拟合训练集中的特定示例,从而降低其在各种上下文中泛化的能力,从而阻碍模型的实际性能。 |
To mitigate exposure bias, SURGE [Kang et al., 2023] proposes the use of graph-text contrastive learning. This method includes a contrastive learning objective that prompts the model to produce a range of plausible and coherent re-sponses, expanding beyond the instances encountered in the training data. This approach is crucial in reducing overfitting and strengthening the model’s ability to generalize. | 为了减轻暴露偏差,SURGE [Kang等人,2023]提出使用图文对比学习。这种方法包括一个对比学习目标,促使模型产生一系列合理和连贯的响应,扩展到训练数据中遇到的实例之外。这种方法对于减少过拟合和增强模型的泛化能力至关重要。 |
For retrieval tasks that engage with structured data, the SANTA framework [Li et al., 2023d] implements a tripartite training regimen to effectively encapsulate both structural and semantic nuances. The initial phase focuses on the retriever, where contrastive learning is harnessed to refine the query and document embeddings. | 对于涉及结构化数据的检索任务,SANTA框架[Li et al., 2023]实现了一个三方训练方案,以有效地封装结构和语义的细微差别。初始阶段关注检索器,利用对比学习来细化查询和文档嵌入。 |
Subsequently, the generator’s preliminary training stage employs contrastive learning to align the structured data with its unstructured document descriptions. In a further stage of generator training, the model acknowledges the critical role of entity semantics in the representation learning of textual data for retrieval, as highlighted by [Sciavolino et al., 2021, Zhang et al., 2019]. This process commences with the identi-fication of entities within the structured data, followed by the application of masks over these entities within the generator’s input data, thus setting the stage for the model to anticipate and predict these masked elements. | 随后,生成器的初步训练阶段采用对比学习将结构化数据与其非结构化文档描述对齐。在生成器训练的进一步阶段,该模型承认实体语义在文本数据的表示学习中起着关键作用,如[Sciavolino等人,2021,Zhang等人,2019]所强调的那样。这个过程从识别结构化数据中的实体开始,然后在生成器的输入数据中对这些实体应用掩码,从而为模型预测和预测这些掩码元素奠定基础。 |
The training regimen progresses with the model learning to reconstruct the masked entities by leveraging contextual information. This exercise cultivates the model’s comprehen-sion of the textual data’s structural semantics and facilitates the alignment of pertinent entities within the structured data. The overarching optimization goal is to train the language model to accurately restore the obscured spans, thereby en-riching its understanding of entity semantics [Ye et al., 2020]. | 训练方案随着模型学习的进展,利用上下文信息重构被掩盖的实体。这个练习培养了模型对文本数据的结构语义的理解,并促进了结构化数据中相关实体的对齐。总体优化目标是训练语言模型准确地恢复模糊的跨度,从而丰富其对实体语义的理解[Ye et al., 2020]。 |
This section is structured around three key aspects: the aug-mentation stage, sources of augmentation data, and the aug-mentation process. These facets elucidate the critical tech-nologies pivotal to RAG’s development. A taxonomy of RAG’s core components is presented in Figure 4. | 本节围绕三个关键方面展开:增强阶段、增强数据的来源和增强过程。这些方面阐明了对RAG发展至关重要的关键技术。RAG的核心组件的分类如图4所示。 |
RAG, a knowledge-intensive endeavor, incorporates a vari-ety of technical methodologies across the pre-training, fine-tuning, and inference stages of language model training. | RAG是一项知识密集型的工作,它在语言模型训练的预训练、微调和推理阶段整合了各种技术方法。 |
Pre-training Stage During the pre-training stage, researchers have investigated methods to bolster PTMs for open-domain QA through retrieval-based strategies. The REALM model adopts a struc-tured, interpretable method for knowledge embedding, fram-ing pre-training, and fine-tuning as a retrieve-then-predict workflow within the masked language model (MLM) frame-work [Arora et al., 2023] . | 训练的阶段 在预训练阶段,研究人员研究了通过基于检索的策略来支持开放域QA的ptm的方法。REALM模型采用结构化、可解释的方法进行知识嵌入、框架预训练和微调,作为掩模语言模型(MLM)框架内的检索-预测工作流[Arora等人,2023]。 |
RETRO [Borgeaud et al., 2022] leverages retrieval aug-mentation for large-scale pre-training from scratch, achieving a reduction in model parameters while surpassing standard GPT models in terms of perplexity. RETRO distinguishes it-self with an additional encoder designed to process features of entities retrieved from an external knowledge base, build-ing on the foundational structure of GPT models. | RETRO [Borgeaud等人,2022]利用检索增强从头开始进行大规模预训练,实现了模型参数的减少,同时在困惑度方面超过了标准GPT模型。RETRO的独特之处在于它有一个额外的编码器,该编码器设计用于处理从外部知识库检索到的实体的特征,建立在GPT模型的基础结构上。 |
Atlas[Izacard et al., 2022] also incorporates a retrieval mechanism into the T5 architecture [Raffel et al., 2020] in both the pre-training and fine-tuning stages. It uses a pre-trained T5 to initialize the encoder-decoder language model and a pre-trained Contriever for the dense retriever, improv-ing its efficiency for complex language modeling tasks. | Atlas[Izacard等人,2022]还在预训练和微调阶段将检索机制纳入T5架构[rafael等人,2020]。它使用预训练的T5来初始化编码器-解码器语言模型,使用预训练的Contriever来初始化密集检索器,从而提高了复杂语言建模任务的效率。 |
Furthermore, COG [Lan et al., 2022] introduces a novel text generation methodology that emulates copying text frag-ments from pre-existing collections. Utilizing efficient vector search tools, COG computes and indexes contextually mean-ingful representations of text fragments, demonstrating supe-rior performance in domains such as question-answering and domain adaptation when compared to RETRO. | 此外,COG [Lan等人,2022]引入了一种新的文本生成方法,该方法模拟从预先存在的集合中复制文本片段。利用高效的向量搜索工具,COG计算和索引文本片段的上下文有意义的表示,与RETRO相比,在问答和领域适应等领域表现出卓越的性能。 |
The advent of scaling laws has catalyzed the growth of model parameters, propelling autoregressive models into the mainstream. Researchers are expanding the RAG approach to pretrained larger models, with RETRO++ exemplifying this trend by scaling up the model parameters while preserving or enhancing performance [Wang et al., 2023b]. | 标度定律的出现促进了模型参数的增长,推动自回归模型成为主流。研究人员正在将RAG方法扩展到预训练更大的模型,RETRO++通过在保持或增强性能的同时扩大模型参数来体现这一趋势[Wang等人,2023b]。 |
Empirical evidence underscores marked improvements in text generation quality, factual accuracy, reduced toxicity, and downstream task proficiency, especially in knowledge-intensive applications like open-domain QA. These results imply that integrating retrieval mechanisms into the pretraining of autoregressive language models constitutes a promising avenue, marrying sophisticated retrieval tech-niques with expansive language models to yield more precise and efficient language generation. | 经验证据强调了在文本生成质量、事实准确性、降低毒性和下游任务熟练程度方面的显著改进,特别是在像开放领域QA这样的知识密集型应用中。这些结果表明,将检索机制集成到自回归语言模型的预训练中是一条很有前途的途径,将复杂的检索技术与广泛的语言模型相结合,以产生更精确和有效的语言生成。 |
The benefits of augmented pre-training include a robust foundational model that outperforms standard GPT models in perplexity, text generation quality, and task-specific per-formance, all while utilizing fewer parameters. This method is particularly adept at handling knowledge-intensive tasks and facilitates the development of domain-specific models through training on specialized corpora. | 增强预训练的好处包括一个健壮的基础模型,该模型在困惑度、文本生成质量和特定任务性能方面优于标准GPT模型,同时使用更少的参数。这种方法特别擅长处理知识密集型任务,并通过对专门语料库的训练促进特定领域模型的开发。 |
Nonetheless, this approach faces challenges such as the necessity for extensive pre-training datasets and resources, as well as diminished update frequencies with increasing model sizes. Despite these hurdles, the approach offers significant advantages in model resilience. Once trained, retrieval-enhanced models can operate independently of ex-ternal libraries, enhancing generation speed and operational efficiency. The potential gains identified render this method-ology a compelling subject for ongoing investigation and in-novation in artificial intelligence and machine learning. | 尽管如此,这种方法面临着挑战,例如需要广泛的预训练数据集和资源,以及随着模型大小的增加而减少的更新频率。尽管存在这些障碍,但该方法在模型弹性方面提供了显著的优势。经过训练后,检索增强模型可以独立于外部库运行,从而提高了生成速度和操作效率。所确定的潜在收益使这种方法成为人工智能和机器学习领域正在进行的研究和创新的引人注目的主题。 |
Fine-tuning Stage RAG and Fine-tuning are powerful tools for enhancing LLMs, and combining the two can meet the needs of more specific scenarios. On one hand, fine-tuning allows for the retrieval of documents with a unique style, achieving bet-ter semantic expression and aligning the differences between queries and documents. This ensures that the output of the retriever is more aptly suited to the scenario at hand. On the other hand, fine-tuning can fulfill the generation needs of making stylized and targeted adjustments. Furthermore, fine-tuning can also be used to align the retriever and generator for improved model synergy. | 微调阶段 RAG和Fine-tuning是增强llm的强大工具,将两者结合起来可以满足更具体场景的需求。一方面,微调允许检索具有独特样式的文档,实现更好的语义表达,并调整查询和文档之间的差异。这确保了检索器的输出更适合手头的场景。另一方面,微调可以满足进行风格化和针对性调整的生成需求。此外,微调还可以用于对齐检索器和生成器,以改进模型协同。 |
The main goal of fine-tuning the retriever is to improve the quality of semantic representations, achieved by directly fine-tuning the Embedding model using a corpus [Liu, 2023]. By aligning the retriever’s capabilities with the prefer-ences of the LLMs through feedback signals, both can be better coordinated [Yu et al., 2023b, Izacard et al., 2022, Yang et al., 2023b, Shi et al., 2023]. Fine-tuning the retriever for specific downstream tasks can lead to improved adapt-ability [cite]. The introduction of task-agnostic fine-tuning aims to enhance the retriever’s versatility in multi-task sce-narios [Cheng et al., 2023a]. | 微调检索器的主要目标是通过使用语料库直接微调嵌入模型来提高语义表示的质量[Liu, 2023]。通过反馈信号使寻回犬的能力与llm的偏好一致,可以更好地协调两者[Yu et al., 2023b, Izacard et al., 2022, Yang et al., 2023b, Shi et al., 2023]。为特定的下游任务微调检索器可以提高适应能力[引用]。引入任务不可知微调的目的是增强寻回犬在多任务场景中的多功能性[Cheng等人,2023a]。 |
Fine-tuning generator can result in outputs that are more stylized and customized. On one hand, it allows for specialized adaptation to different input data formats. For example, fine-tuning LLMs to fit the structure of knowledge graphs [Kang et al., 2023], the structure of text pairs [Kang et al., 2023, Cheng et al., 2023b], and other spe-cific structures [Li et al., 2023d]. On the other hand, by con-structing directive datasets, one can demand LLMs to gen-erate specific formats content. For instance, in adaptive or iterative retrieval scenarios, LLMs are fine-tuned to generate content that will help determine the timing for the next step of action [Jiang et al., 2023b, Asai et al., 2023]. | 微调生成器可以产生更加风格化和定制的输出。一方面,它允许专门适应不同的输入数据格式。例如,微调llm以拟合知识图的结构[Kang等人,2023]、文本对的结构[Kang等人,2023,Cheng等人,2023b]和其他特定结构[Li等人,2023d]。另一方面,通过构建指令数据集,可以要求llm生成特定格式的内容。例如,在自适应或迭代检索场景中,llm被微调以生成有助于确定下一步行动时间的内容[Jiang等人,2023b, Asai等人,2023]。 |
By synergistically fine-tuning both the retriever and the generator, we can enhance the model’s generalization capabilities and avoid overfitting that may arise from training them separately. However, joint fine-tuning also leads to increased resource consumption. RA-DIT [Lin et al., 2023] presents a lightweight, dual-instruction tuning framework that can effectively add retrieval capabilities to any LLMs. The retrieval-enhanced directive fine-tuning updates the LLM, guiding it to make more efficient use of the information re-trieved and to disregard distracting content. | 通过协同微调检索器和生成器,我们可以增强模型的泛化能力,并避免单独训练它们可能产生的过拟合。然而,联合微调也会导致资源消耗增加。RA-DIT [Lin等,2023]提出了一种轻量级的双指令调优框架,可以有效地为任何llm添加检索功能。检索增强指令微调更新LLM,指导它更有效地利用检索到的信息,并忽略分散注意力的内容。 |
Despite its advantages, fine-tuning has limitations, includ-ing the need for specialized datasets for RAG fine-tuning and the requirement for significant computational resources. However, this stage allows for customizing models to specific needs and data formats, potentially reducing resource usage compared to the pre-training phase while still being able to fine-tune the model’s output style. | 尽管有其优点,但微调也有局限性,包括需要专门的数据集进行RAG微调以及需要大量的计算资源。然而,这个阶段允许根据特定的需求和数据格式定制模型,与预训练阶段相比,潜在地减少了资源使用,同时仍然能够微调模型的输出样式。 |
In summary, the fine-tuning stage is essential for the adap-tation of RAG models to specific tasks, enabling the refine-ment of both retrievers and generators. This stage enhances the model’s versatility and adaptability to various tasks, de-spite the challenges presented by resource and dataset re-quirements. The strategic fine-tuning of RAG models is therefore a critical component in the development of efficient and effective retrieval-augmented systems. | 总之,微调阶段对于使RAG模型适应特定的任务是必不可少的,从而可以对检索器和生成器进行细化。这一阶段增强了模型的通用性和对各种任务的适应性,尽管存在资源和数据集需求带来的挑战。因此,RAG模型的战略性微调是开发高效和有效的检索增强系统的关键组成部分。 |
Inference Stage The inference stage in RAG models is crucial, as it in-volves extensive integration with LLMs. Traditional RAG approaches, also known as Naive RAG, involve incorporating retrieval content at this stage to guide the generation process. | 推理阶段 RAG模型中的推理阶段是至关重要的,因为它涉及到与llm的广泛集成。传统的RAG方法,也称为朴素RAG,涉及在此阶段合并检索内容以指导生成过程。 |
To overcome the limitations of Naive RAG, advanced tech-niques introduce more contextually rich information dur-ing inference. The DSP framework [Khattab et al., 2022] utilizes a sophisticated exchange of natural language text between fronzen LMs and retrieval models (RMs), en-riching the context and thereby improving generation out-comes. The PKG [Luo et al., 2023] method equips LLMs with a knowledge-guided module that allows for the retrieval of pertinent information without modifying the LMs’ pa-rameters, enabling more complex task execution. CREA-ICL [Li et al., 2023b] employs a synchronous retrieval of cross-lingual knowledge to enhance context, while RE-CITE [Sun et al., 2022] generates context by sampling para-graphs directly from LLMs. | 为了克服朴素RAG的局限性,先进的技术在推理过程中引入了更多上下文丰富的信息。DSP框架[Khattab等人,2022]利用前沿lm和检索模型(rm)之间复杂的自然语言文本交换,丰富了上下文,从而改善了生成结果。PKG [Luo等人,2023]方法为llm配备了一个知识引导模块,该模块允许在不修改LMs的pa参数的情况下检索相关信息,从而能够执行更复杂的任务。CREA-ICL [Li et al., 2023b]采用跨语言知识的同步检索来增强上下文,而RE-CITE [Sun et al., 2022]通过直接从llm中采样段落来生成上下文。 |
Further refinement of the RAG process during infer-ence is seen in approaches that cater to tasks necessi-tating multi-step reasoning. ITRG [Feng et al., 2023] it-eratively retrieves information to identify the correct rea-soning paths, thereby improving task adaptability. ITER-RETGEN [Shao et al., 2023] follows an iterative strat-egy, merging retrieval and generation in a cyclical pro-cess that alternates between “retrieval-enhanced generation” and “generation-enhanced retrieval”. For non-knowledge-intensive (NKI) tasks, PGRA [Guo et al., 2023] proposes a two-stage framework, starting with a task-agnostic retriever followed by a prompt-guided reranker to select and priori-tize evidence. In contrast, IRCOT [Trivedi et al., 2022] com-bines RAG with Chain of Thought (CoT) methodologies, al-ternating CoT-guided retrievals with retrieval-informed CoT processes, significantly boosting GPT-3’s performance across various question-answering tasks. | 在推理过程中,RAG过程的进一步细化可以在满足需要多步骤推理的任务的方法中看到。ITRG [Feng et ., 2023]通过迭代检索信息来识别正确的推理路径,从而提高任务适应性。ITER-RETGEN [Shao et al., 2023]采用迭代策略,在“检索增强生成”和“生成增强检索”之间交替的循环过程中合并检索和生成。对于非知识密集型(NKI)任务,PGRA [Guo等人,2023]提出了一个两阶段框架,首先是任务不可知的检索器,然后是提示引导的重新排序器,以选择和优先排序证据。相比之下,IRCOT [Trivedi等人,2022]将RAG与思维链(CoT)方法相结合,将思维链引导的检索与检索通知的CoT过程相结合,显著提高了GPT-3在各种问答任务中的表现。 |
In essence, these inference-stage enhancements provide lightweight, cost-effective alternatives that leverage the ca-pabilities of pre-trained models without necessitating further training. The principal advantage is maintaining static LLM parameters while supplying contextually relevant information to meet specific task demands. Nevertheless, this approach is not without limitations, as it requires meticulous data pro-cessing and optimization, and is bound by the foundational model’s intrinsic capabilities. To address diverse task require-ments effectively, this method is often paired with procedural optimization techniques such as step-wise reasoning, iterative retrieval, and adaptive retrieval strategies. | 从本质上讲,这些推理阶段的增强提供了轻量级的、经济有效的替代方案,可以利用预训练模型的功能,而不需要进一步的训练。其主要优点是在提供上下文相关信息以满足特定任务需求的同时维护静态LLM参数。然而,这种方法并非没有局限性,因为它需要细致的数据处理和优化,并且受到基础模型固有能力的约束。为了有效地解决不同的任务需求,这种方法通常与过程优化技术相结合,如分步推理、迭代检索和自适应检索策略。 |
The effectiveness of RAG models is heavily impacted by the selection of data sources for augmentation. Different levels of knowledge and dimensions require distinct processing tech-niques. They are categorized as unstructured data, structured data, and content generated by LLMs. The technology tree of representative RAG research with different augmentation aspects is depicted in Figure 5. The leaves, colored in three different shades, represent enhancements using various types of data: unstructured data, structured data, and content gener-ated by LLMs. The diagram clearly shows that initially, aug-mentation was mainly achieved through unstructured data, such as pure text. This approach later expanded to include the use of structured data (e.g. knowledge graph) for further improvement. More recently, there has been a growing trend in research that utilizes content generated by the LLMs them-selves for retrieval and augmentation purposes. | 扩充数据源的选择严重影响RAG模型的有效性。不同的知识层次和维度需要不同的处理技术。它们分为非结构化数据、结构化数据和法学硕士生成的内容。具有代表性的不同增强方面的RAG研究技术树如图5所示。叶子以三种不同的深浅颜色表示使用不同类型数据的增强:非结构化数据、结构化数据和llm生成的内容。图表清楚地表明,最初,增强主要是通过非结构化数据,如纯文本来实现的。这种方法后来扩展到包括使用结构化数据(例如知识图)以进一步改进。最近,在研究中有一种日益增长的趋势,即利用llm本身生成的内容进行检索和增强。 |
Augmented with Unstructured Data Unstructured text, is gathered from corpora, such as prompt data for fine-tuning large models [Cheng et al., 2023a] and cross-lingual data [Li et al., 2023b]. Retrieval units vary from tokens (e.g., kNN-LM [Khandelwal et al., 2019]) to phrases (e.g., NPM, COG [Lee et al., 2020, Lan et al., 2022]) and document paragraphs, with finer granularities offering pre-cision at the cost of increased retrieval complexity. | 扩充非结构化数据 非结构化文本从语料库中收集,例如用于微调大型模型的提示数据[Cheng等人,2023a]和跨语言数据[Li等人,2023b]。检索单元从令牌(例如kNN-LM [Khandelwal等人,2019])到短语(例如NPM, COG [Lee等人,2020,Lan等人,2022])和文档段落不等,更细的粒度以增加检索复杂性为代价提供了精确的决策。 |
FLARE [Jiang et al., 2023b] introduces an active re-trieval approach, triggered by the LM’s generation of low-probability words. It creates a temporary sentence for doc-ument retrieval, then regenerates the sentence with the re-trieved context to predict subsequent sentences. RETRO uses the previous chunk to retrieve the nearest neighbor at the chunk level, combined with the previous chunk’s context, it guides the generation of the next chunk. To preserve causal-ity, the generation of the next block Ci only utilizes the near-est neighbor of the previous block N(Ci−1) and not N(Ci). | FLARE [Jiang等人,2023b]引入了一种主动重新检索方法,该方法由LM生成的低概率词触发。它为文档检索创建一个临时句子,然后使用检索到的上下文重新生成该句子,以预测后续的句子。RETRO使用前一个块来检索块级别上最近的邻居,结合前一个块的上下文,它指导下一个块的生成。为了保持因果关系,下一个块Ci的生成只利用前一个块的最近邻居N(Ci−1)而不是N(Ci)。 |
Augmented with Structured Data Structured data, such as knowledge graphs (KGs), pro-vide high-quality context and mitigate model hallucina-tions. RET-LLMs [Modarressi et al., 2023] constructs a knowledge graph memory from past dialogues for future ref-erence. SUGRE [Kang et al., 2023] employs Graph Neu-ral Networks (GNNs) to encode relevant KG subgraphs, ensuring consistency between retrieved facts and gener-ated text through multi-modal contrastive learning. KnowledGPT [Wang et al., 2023d] generates KB search queries and stores knowledge in a personalized base, enhancing the RAG model’s knowledge richness and contextuality. | 增强结构化数据 结构化数据,如知识图(KGs),提供了高质量的背景,减轻了模型幻觉。RET-LLMs [Modarressi et al., 2023]从过去的对话中构建了一个知识图记忆,以供将来参考。SUGRE [Kang et al., 2023]使用图神经网络(Graph neural Networks, gnn)对相关KG子图进行编码,通过多模态对比学习确保检索事实与生成文本之间的一致性。KnowledGPT [Wang et al., 2023]生成知识库搜索查询,并将知识存储在个性化库中,增强了RAG模型的知识丰富度和上下文性。 |
LLMs-Generated Content in RAG Addressing the limitations of external auxiliary information in RAG, some research has focused on exploiting LLMs’ in-ternal knowledge. SKR [Wang et al., 2023e] classifies ques-tions as known or unknown, applying retrieval enhancement selectively. GenRead [Yu et al., 2022] replaces the retriever with an LLM generator, finding that LLM-generated con-texts often contain more accurate answers due to better align-ment with the pre-training objectives of causal language mod-eling. Selfmem [Cheng et al., 2023b] iteratively creates an unbounded memory pool with a retrieval-enhanced genera-tor, using a memory selector to choose outputs that serve as dual problems to the original question, thus self-enhancing the generative model. | 法学硕士生成的内容在RAG 针对外部辅助信息在RAG中的局限性,一些研究侧重于利用法学硕士的内部知识。SKR [Wang et al., 2023e]将问题分类为已知或未知,有选择地应用检索增强。GenRead [Yu et al., 2022]用LLM生成器取代了检索器,发现LLM生成的上下文通常包含更准确的答案,因为它与因果语言建模的预训练目标更一致。Selfmem [Cheng et al., 2023b]使用检索增强的genera-tor迭代创建无界内存池,使用内存选择器选择作为原始问题的双重问题的输出,从而自我增强生成模型。 |
These methodologies underscore the breadth of innovative data source utilization in RAG, striving to improve model per-formance and task effectiveness. | 这些方法强调了RAG中创新数据源利用的广度,努力提高模型性能和任务有效性。 |
In the domain of RAG, the standard practice often involves a singular retrieval step followed by generation, which can lead to inefficiencies. A notable issue, termed the “lost in the middle” phenomenon, arises when a single retrieval yields redundant content that may dilute or contradict es-sential information, thereby degrading the generation qual-ity [Liu et al., 2023a]. Furthermore, such singular retrieval is typically insufficient for complex problems demanding multi-step reasoning, as it provides a limited scope of informa-tion [Yoran et al., 2023]. | 在RAG领域中,标准实践通常涉及单个检索步骤,然后是生成,这可能导致效率低下。一个值得注意的问题被称为“中间丢失”现象,当单个检索产生冗余内容时,可能会稀释或矛盾基本信息,从而降低生成质量[Liu et al., 2023a]。此外,这种奇异检索通常不足以解决需要多步推理的复杂问题,因为它提供的信息范围有限[Yoran等人,2023]。 |
As illustrated in Figure 5, to circumvent these challenges, contemporary research has proposed methods for refining the retrieval process: iterative retrieval, recursive retrieval and adaptive retrieval. Iterative retrieval allows the model to en-gage in multiple retrieval cycles, enhancing the depth and relevance of the information obtained. Recursive retrieval process where the results of one retrieval operation are used as the input for the subsequent retrieval. It helps to delve deeper into relevant information, particularly when dealing with complex or multi-step queries. Recursive retrieval is of-ten used in scenarios where a gradual approach is needed to converge on a final answer, such as in academic research, le-gal case analysis, or certain types of data mining tasks. Adap-tive retrieval, on the other hand, offers a dynamic adjustment mechanism, tailoring the retrieval process to the specific de-mands of varying tasks and contexts. | 如图5所示,为了规避这些挑战,当代研究提出了改进检索过程的方法:迭代检索、递归检索和自适应检索。迭代检索允许模型参与多个检索周期,增强所获得信息的深度和相关性。递归检索过程,其中一次检索操作的结果用作后续检索的输入。它有助于深入研究相关信息,特别是在处理复杂或多步骤查询时。递归检索通常用于需要逐步收敛于最终答案的场景,例如在学术研究、法律案例分析或某些类型的数据挖掘任务中。另一方面,自适应检索提供了一种动态调整机制,使检索过程适应不同任务和上下文的具体要求。 |
Iterative Retrieval Iterative retrieval in RAG models is a process where doc-uments are repeatedly collected based on the initial query and the text generated thus far, providing a more compre-hensive knowledge base for LLMs [Borgeaud et al., 2022, Arora et al., 2023]. This approach has been shown to en-hance the robustness of subsequent answer generation by of-fering additional contextual references through multiple re-trieval iterations. However, it may suffer from semantic dis-continuity and the accumulation of irrelevant information, as it typically relies on a sequence of n tokens to demarcate the boundaries between generated text and retrieved documents. | 迭代的检索 RAG模型中的迭代检索是基于初始查询和迄今为止生成的文本重复收集文档的过程,为法学硕士提供了更全面的知识库[Borgeaud等人,2022,Arora等人,2023]。这种方法已被证明可以通过多次重新检索迭代提供额外的上下文引用来增强后续答案生成的鲁棒性。然而,它可能会受到语义不连续性和不相关信息积累的影响,因为它通常依赖于n个令牌序列来划定生成文本和检索文档之间的边界。 |
To address specific data scenarios, recursive retrieval and multi-hop retrieval techniques are utilized. Recursive re-trieval involves a structured index to process and retrieve data in a hierarchical manner, which may include summa-rizing sections of a document or lengthy PDF before per-forming a retrieval based on this summary. Subsequently, a secondary retrieval within the document refines the search, embodying the recursive nature of the process. In contrast, multi-hop retrieval is designed to delve deeper into graph-structured data sources, extracting interconnected informa-tion [Li et al., 2023c]. | 为了解决特定的数据场景,使用了递归检索和多跳检索技术。递归重新检索涉及到以分层方式处理和检索数据的结构化索引,其中可能包括在基于该摘要执行检索之前对文档或冗长PDF的各个部分进行汇总。随后,文档中的二次检索细化了搜索,体现了该过程的递归性质。相比之下,多跳检索旨在更深入地挖掘图结构数据源,提取相互关联的信息[Li et al., 2023c]。 |
Additionally, some methodologies integrate the steps of re-trieval and generation. ITER-RETGEN [Shao et al., 2023] employs a synergistic approach that leverages “retrieval-enhanced generation” alongside “generation-enhanced re-trieval” for tasks that necessitate the reproduction of specific information. The model harnesses the content required to ad-dress the input task as a contextual basis for retrieving per-tinent knowledge, which in turn facilitates the generation of improved responses in subsequent iterations. | 此外,一些方法集成了重新检索和生成的步骤。ITER-RETGEN [Shao等人,2023]采用了一种协同方法,在需要复制特定信息的任务中,利用“检索增强生成”和“生成增强检索”。该模型利用处理输入任务所需的内容作为检索各大洲知识的上下文基础,这反过来又促进了在随后的迭代中生成改进的响应。 |
Recursive Retrieval Recursive Retrieval is often used in information retrieval and NLP to improve the depth and relevance of search results. The process involves iteratively refining search queries based on the results obtained from previous searches. Recursive Retrieval aims to enhance the search experience by gradu-ally converging on the most pertinent information through a feedback loop. IRCoT [Trivedi et al., 2022] uses chain-of-thought to guide the retrieval process and refines the CoT with the obtained retrieval results. ToC [Kim et al., 2023] creates a clarification tree that systematically optimizes the ambiguous parts in the Query. It can be particularly useful in complex search scenarios where the user’s needs are not en-tirely clear from the outset or where the information sought is highly specialized or nuanced. The recursive nature of the process allows for continuous learning and adaptation to the user’s requirements, often resulting in improved satisfaction with the search outcomes. | 递归检索 递归检索常用于信息检索和自然语言处理,以提高搜索结果的深度和相关性。该过程涉及基于从以前的搜索中获得的结果迭代地改进搜索查询。递归检索旨在通过反馈循环逐步收敛到最相关的信息,从而增强搜索体验。IRCoT [Trivedi et al., 2022]使用思维链(chain-of-thought)来指导检索过程,并利用获得的检索结果对CoT进行细化。ToC [Kim等人,2023]创建了一个澄清树,系统地优化查询中的模糊部分。在复杂的搜索场景中,如果用户的需求从一开始就不完全清楚,或者所搜索的信息非常专门化或微妙,那么它特别有用。该过程的递归性质允许不断学习和适应用户的需求,通常会提高对搜索结果的满意度。 |
Adaptive Retrieval Adaptive retrieval methods, exemplified by Flare and Self-RAG [Jiang et al., 2023b, Asai et al., 2023], refine the RAG framework by enabling LLMs to actively determine the op-timal moments and content for retrieval, thus enhancing the efficiency and relevance of the information sourced. | 自适应的检索 自适应检索方法,如Flare和Self-RAG [Jiang等人,2023b, Asai等人,2023],通过使llm能够主动确定检索的最优时刻和内容,从而提高信息源的效率和相关性,从而完善了RAG框架。 |
These methods are part of a broader trend wherein LLMs employ active judgment in their operations, as seen in model agents like AutoGPT, Toolformer, and Graph-Toolformer [Yang et al., 2023c, Schick et al., 2023,Zhang, 2023]. Graph-Toolformer, for instance, divides its re-trieval process into distinct steps where LLMs proactively use retrievers, apply Self-Ask techniques, and employ few-shot prompts to initiate search queries. This proactive stance al-lows LLMs to decide when to search for necessary informa-tion, akin to how an agent utilizes tools. | 这些方法是llm在其操作中采用主动判断的更广泛趋势的一部分,正如在AutoGPT, Toolformer和Graph-Toolformer等模型代理中所看到的那样[Yang等人,2023c, Schick等人,2023,Zhang, 2023]。例如,Graph-Toolformer将其检索过程划分为不同的步骤,其中llm主动使用检索器,应用Self-Ask技术,并使用少量提示来启动搜索查询。这种主动的姿态允许llm决定何时搜索必要的信息,类似于代理如何利用工具。 |
WebGPT [Nakano et al., 2021] integrates a reinforcement learning framework to train the GPT-3 model in au-tonomously using a search engine during text generation. It navigates this process using special tokens that facili-tate actions such as search engine queries, browsing results, and citing references, thereby expanding GPT-3’s capabilities through the use of external search engines. | WebGPT [Nakano等人,2021]集成了一个强化学习框架,在文本生成过程中使用搜索引擎自主训练GPT-3模型。它使用特殊的令牌来导航这个过程,这些令牌促进了诸如搜索引擎查询、浏览结果和引用引用等操作,从而通过使用外部搜索引擎扩展了GPT-3的功能。 |
Flare automates timing retrieval by monitoring the confi-dence of the generation process, as indicated by the probabil-ity of generated terms [Jiang et al., 2023b]. When the prob-ability falls below a certain threshold would activates the re-trieval system to collect relevant information, thus optimizing the retrieval cycle. | 耀斑通过监测生成过程的置信度来自动获取时间,如生成项的概率所示[Jiang等,2023b]。当概率低于一定阈值时,将激活检索系统收集相关信息,从而优化检索周期。 |
Self-RAG [Asai et al., 2023] introduces “reflection to-kens” that allow the model to introspect its outputs. These tokens come in two varieties: “retrieve” and “critic”. The model autonomously decides when to activate retrieval, or alternatively, a predefined threshold may trigger the pro-cess. During retrieval, the generator conducts a fragment-level beam search across multiple paragraphs to derive the most coherent sequence. Critic scores are used to update the subdivision scores, with the flexibility to adjust these weights during inference, tailoring the model’s behavior. Self-RAG’s design obviates the need for additional classifiers or reliance on Natural Language Inference (NLI) models, thus stream-lining the decision-making process for when to engage re-trieval mechanisms and improving the model’s autonomous judgment capabilities in generating accurate responses. | Self-RAG [Asai等人,2023]引入了“反射因子”,允许模型自省其输出。这些标记有两种:“检索”和“批评”。模型自主地决定何时激活检索,或者,预定义的阈值可能触发该流程。在检索过程中,生成器跨多个段落进行片段级波束搜索,以获得最连贯的序列。评论家分数用于更新细分分数,在推理过程中可以灵活地调整这些权重,从而调整模型的行为。Self-RAG的设计不需要额外的分类器或依赖于自然语言推理(NLI)模型,从而简化了何时使用重新检索机制的决策过程,并提高了模型在生成准确响应方面的自主判断能力。 |
LLM optimization has received significant attention due to its increasing prevalence. Techniques such as prompt engi-neering, Fine-Tuning (FT), and RAG each have distinct char-acteristics, visually represented in Figure 6. While prompt engineering leverages a model’s inherent capabilities, opti-mizing LLMs often requires the application of both RAG and FT methods. The choice between RAG and FT should be based on the specific requirements of the scenario and the in-herent properties of each approach. A detailed comparison of RAG and FT is presented in Table 1. | LLM优化由于其日益普及而受到了极大的关注。诸如提示工程、微调(FT)和RAG等技术各有不同的特征,如图6所示。虽然快速工程利用了模型的固有功能,但优化llm通常需要同时应用RAG和FT方法。RAG和FT之间的选择应该基于场景的特定需求和每种方法的固有属性。表1给出了RAG和FT的详细比较。 |
RAG is like giving a model a textbook for tailored informa-tion retrieval, perfect for specific queries. On the other hand, FT is like a student internalizing knowledge over time, bet-ter for replicating specific structures, styles, or formats. FT can improve model performance and efficiency by reinforc-ing base model knowledge, adjusting outputs, and teaching complex instructions. However, it is not as good for integrat-ing new knowledge or rapidly iterating new use cases. | RAG就像给模型提供了一本教科书,用于定制信息检索,非常适合特定查询。另一方面,《金融时报》就像一个学生,随着时间的推移将知识内化,更适合复制特定的结构、风格或格式。FT可以通过强化基础模型知识、调整输出和教授复杂指令来提高模型性能和效率。然而,它不适合集成新知识或快速迭代新用例。 |
The two methods, RAG and FT, are not mutually exclusive and can be complementary, augmenting a model’s capabil-ities at different levels. In some cases, their combined use may yield optimal performance. The optimization process involving RAG and FT can necessitate multiple iterations to achieve satisfactory results. | 这两种方法,RAG和FT,并不是相互排斥的,而是可以互补的,可以在不同层次上增强模型的能力。在某些情况下,它们的组合使用可能产生最佳性能。涉及RAG和FT的优化过程可能需要多次迭代才能获得满意的结果。 |
The rapid advancement and growing adoption of RAG in the field of Natural Language Processing (NLP) have propelled the evaluation of RAG models to the forefront of research in the LLMs community. The primary objective of this evalua-tion is to comprehend and optimize the performance of RAG models across diverse application scenarios. | RAG在自然语言处理(NLP)领域的快速发展和越来越多的采用,将RAG模型的评估推向了法学硕士社区研究的前沿。该评估的主要目标是理解和优化RAG模型跨不同应用程序场景的性能。 |
Historically, RAG models assessments have centered on their execution in specific downstream tasks. These evaluations employ established metrics suitable to the tasks at hand. For instance, question answering evaluations might rely on EM and F1 scores [Wang et al., 2023a, Shi et al., 2023, Feng et al., 2023, Ma et al., 2023a], whereas fact-checking tasks often hinge on accuracy as the pri-mary metric [Lewis et al., 2020, Izacard et al., 2022, Shao et al., 2023]. Tools like RALLE, designed for the auto-matic evaluation of RAG applications, similarly base their as-sessments on these task-specific metrics [Hoshi et al., 2023]. Despite this, there is a notable paucity of research dedicated to evaluating the distinct characteristics of RAG models, with only a handful of related studies. | 从历史上看,RAG模型评估集中在它们在特定下游任务中的执行。这些评估采用适合手头任务的既定指标。例如,问答评估可能依赖于EM和F1分数[Wang等人,2023a, Shi等人,2023,Feng等人,2023,Ma等人,2023a],而事实核查任务通常依赖于准确性作为主要指标[Lewis等人,2020,Izacard等人,2022,Shao等人,2023]。为RAG应用程序的自动评估而设计的工具,如RALLE,同样基于这些特定于任务的指标进行评估[Hoshi等人,2023]。尽管如此,致力于评估RAG模型独特特征的研究明显缺乏,只有少数相关研究。 |
The following section shifts the focus from task-specific evaluation methods and metrics to provide a synthesis of the existing literature based on their unique attributes. This ex-ploration covers the objectives of RAG evaluation, the aspects along which these models are assessed, and the benchmarks and tools available for such evaluations. The aim is to offer a comprehensive overview of RAG model evaluation, outlining the methodologies that specifically address the unique aspects of these advanced generative systems. | 以下部分将重点从特定于任务的评估方法和度量转移到基于其独特属性的现有文献的综合。本文探讨了RAG评估的目标、评估这些模型的各个方面,以及可用于此类评估的基准和工具。目的是提供RAG模型评估的全面概述,概述了具体解决这些先进生成系统独特方面的方法。 |
The assessment of RAG models mainly revolves around two key components: the retrieval and generation modules. This division ensures a thorough evaluation of both the quality of context provided and the quality of content produced. | RAG模型的评估主要围绕两个关键组件进行:检索和生成模块。这种划分确保了对所提供的上下文质量和所产生的内容质量的全面评估。 |
Retrieval Quality Evaluating the retrieval quality is crucial for determining the effectiveness of the context sourced by the retriever com-ponent. Standard metrics from the domains of search en-gines, recommendation systems, and information retrieval systems are employed to measure the performance of the RAG retrieval module. Metrics such as Hit Rate, MRR, and NDCG are commonly utilized for this purpose [Liu, 2023, Nguyen, 2023]. | 检索的质量 评估检索质量对于确定检索器组件来源的上下文的有效性至关重要。使用来自搜索引擎、推荐系统和信息检索系统领域的标准度量来度量RAG检索模块的性能。命中率、MRR和NDCG等指标通常用于此目的[Liu, 2023, Nguyen, 2023]。 |
Generation Quality The assessment of generation quality centers on the gener-ator’s capacity to synthesize coherent and relevant answers from the retrieved context. This evaluation can be catego-rized based on the content’s objectives: unlabeled and la-beled content. For unlabeled content, the evaluation encom-passes the faithfulness, relevance, and non-harmfulness of the generated answers. In contrast, for labeled content, the fo-cus is on the accuracy of the information produced by the model [Liu, 2023]. Additionally, both retrieval and genera-tion quality assessments can be conducted through manual or automatic evaluation methods [Liu, 2023, Lan et al., 2022, Leng et al., 2023]. | 一代质量 发电质量的评估集中在发电机从检索上下文合成连贯和相关答案的能力上。这种评估可以根据内容的目标进行分类:未标记和标记的内容。对于未标记的内容,评估包括生成答案的可靠性、相关性和非危害性。相比之下,对于标记的内容,重点是模型产生的信息的准确性[Liu, 2023]。此外,检索和生成质量评估都可以通过手动或自动评估方法进行[Liu, 2023, Lan等,2022,Leng等,2023]。 |
Contemporary evaluation practices of RAG models empha-size three primary quality scores and four essential abilities, which collectively inform the evaluation of the two principal targets of the RAG model: retrieval and generation. | 当代RAG模型的评估实践强调三个主要质量分数和四个基本能力,它们共同通知了RAG模型的两个主要目标的评估:检索和生成。 |
Quality Scores Quality scores include context relevance, answer faith-fulness, and answer relevance. These quality scores evaluate the efficiency of the RAG model from differ-ent perspectives in the process of information retrieval and generation [Es et al., 2023, Saad-Falcon et al., 2023, Jarvis and Allard, 2023]. The quality scores—context rele-vance, answer faithfulness, and answer relevance—assess the RAG model’s efficiency from various angles throughout the information retrieval and generation process [Es et al., 2023, Saad-Falcon et al., 2023, Jarvis and Allard, 2023]. | 质量分数 质量分数包括上下文相关性、答案真实性和答案相关性。这些质量分数从不同角度评价RAG模型在信息检索和生成过程中的效率[Es et al., 2023; Saad-Falcon et al., 2023; Jarvis and Allard, 2023]。质量分数——上下文相关性、答案忠实度和答案相关性——在整个信息检索和生成过程中从不同角度评估RAG模型的效率[Es等人,2023;Saad-Falcon等人,2023;Jarvis和Allard, 2023]。 |
Context Relevance evaluates the precision and specificity of the retrieved context, ensuring relevance and minimizing processing costs associated with extraneous content. | 上下文相关性评估检索上下文的准确性和特异性,确保相关性并最大限度地减少与无关内容相关的处理成本。 |
Answer Faithfulness ensures that the generated answers re-main true to the retrieved context, maintaining consistency and avoiding contradictions. | 答案忠实确保生成的答案与检索的上下文保持一致,保持一致性并避免矛盾。 |
Answer Relevance requires that the generated answers are directly pertinent to the posed questions, effectively address-ing the core inquiry. | 答案相关性要求生成的答案与提出的问题直接相关,有效地解决核心问题。 |
Required Abilities RAG evaluation also encompasses four abilities indicative of its adaptability and efficiency: noise robustness, negative re-jection, information integration, and counterfactual robust-ness [Chen et al., 2023b, Liu et al., 2023b]. These abilities are critical for the model’s performance under various chal-lenges and complex scenarios, impacting the quality scores. | 所需的能力 RAG评估还包括表明其适应性和效率的四种能力:噪声鲁棒性、负面拒绝、信息整合和反事实鲁棒性[Chen et al., 2023b, Liu et al., 2023b]。这些能力对于模型在各种挑战和复杂场景下的性能至关重要,影响质量分数。 |
Noise Robustness appraises the model’s capability to man-age noise documents that are question-related but lack sub-stantive information. | 噪声鲁棒性评价模型管理与问题相关但缺乏实质性信息的噪声文件的能力。 |
Negative Rejection assesses the model’s discernment in re-fraining from responding when the retrieved documents do not contain the necessary knowledge to answer a question. | 当检索到的文档不包含回答问题所需的知识时,负面拒绝评估模型在重新训练时的识别能力。 |
Information Integration evaluates the model’s proficiency in synthesizing information from multiple documents to ad-dress complex questions. | 信息集成评估模型从多个文档中综合信息以解决复杂问题的熟练程度。 |
Counterfactual Robustness tests the model’s ability to rec-ognize and disregard known inaccuracies within documents, even when instructed about potential misinformation. | 反事实鲁棒性测试模型识别和忽略文档中已知不准确的能力,即使在被告知可能存在错误信息的情况下也是如此。 |
Context relevance and noise robustness are important for evaluating the quality of retrieval, while answer faithfulness, answer relevance, negative rejection, information integration, and counterfactual robustness are important for evaluating the quality of generation. | 上下文相关性和噪声鲁棒性对于评估检索质量很重要,而答案忠实度、答案相关性、负面拒绝、信息整合和反事实鲁棒性对于评估生成质量很重要。 |
The specific metrics for each evaluation aspect are summa-rized in Table 2. It is essential to recognize that these metrics, derived from related work, are traditional measures and do not yet represent a mature or standardized approach for quan-tifying RAG evaluation aspects. Custom metrics tailored to the nuances of RAG models, though not included here, have also been developed in some evaluation studies. | 表2总结了每个评估方面的具体指标。必须认识到,这些源自相关工作的度量标准是传统的度量标准,尚未代表对RAG评价方面进行量化的成熟或标准化的方法。针对RAG模型的细微差别量身定制的度量标准,虽然没有包括在这里,但也在一些评估研究中得到了开发。 |
This section delineates the evaluation framework for RAG models, comprising benchmark tests and automated eval-uation tools. These instruments furnish quantitative met-rics that not only gauge RAG model performance but also enhance comprehension of the model’s capabilities across various evaluation aspects. Prominent benchmarks such as RGB and RECALL [Chen et al., 2023b, Liu et al., 2023b] focus on appraising the essential abilities of RAG mod-els. Concurrently, state-of-the-art automated tools like RA-GAS [Es et al., 2023], ARES [Saad-Falcon et al., 2023], and TruLens8 employ LLMs to adjudicate the quality scores. These tools and benchmarks collectively form a robust frame-work for the systematic evaluation of RAG models, as sum-marized in Table 3. | 本节描述RAG模型的评估框架,包括基准测试和自动评估工具。这些工具提供了定量的度量标准,不仅衡量RAG模型的性能,而且还增强了对模型跨各种评估方面的能力的理解。突出的基准,如RGB和RECALL [Chen et al., 2023b, Liu et al., 2023b]侧重于评估RAG模型的基本能力。同时,最先进的自动化工具,如RA-GAS [Es等人,2023],ARES [Saad-Falcon等人,2023]和TruLens8使用法学硕士来评判质量分数。这些工具和基准共同构成了一个健壮的框架,用于对RAG模型进行系统评估,如表3所示。 |
This section explores three future prospects for RAG: future challenges, modality expansion, and the RAG ecosystem. | 本节探讨了RAG的三个未来前景:未来的挑战、模式扩展和RAG生态系统。 |
Despite the considerable progress in RAG technology, several challenges persist that warrant in-depth research: | 尽管RAG技术取得了长足的进步,但仍存在一些需要深入研究的挑战: |
Context Length. RAG’s efficacy is limited by the context window size of Large Language Models (LLMs). Balancing the trade-off between a window that is too short, risking insuf-ficient information, and one that is too long, risking informa-tion dilution, is crucial. With ongoing efforts to expand LLM context windows to virtually unlimited sizes, the adaptation of RAG to these changes presents a significant research ques-tion [Xu et al., 2023c, Packer et al., 2023, Xiao et al., 2023]. | 上下文的长度。RAG的有效性受到大型语言模型(llm)的上下文窗口大小的限制。在窗口太短(可能导致信息不足)和窗口太长(可能导致信息稀释)之间取得平衡至关重要。随着人们不断努力将LLM上下文窗口扩展到几乎无限的大小,RAG对这些变化的适应提出了一个重要的研究问题[Xu等人,2023c, Packer等人,2023,Xiao等人,2023]。 |
Robustness. The presence of noise or contradictory infor-mation during retrieval can detrimentally affect RAG’s output quality. This situation is figuratively referred to as “Mis-information can be worse than no information at all”. Im-proving RAG’s resistance to such adversarial or counterfac-tual inputs is gaining research momentum and has become a key performance metric [Yu et al., 2023a, Glass et al., 2021, Baek et al., 2023]. | 鲁棒性。在检索过程中,噪声或矛盾信息的存在会对RAG的输出质量产生不利影响。这种情况被比喻为“错误的信息可能比根本没有信息更糟糕”。提高RAG对这种对抗性或反事实输入的抵抗力正在获得研究势头,并已成为关键的绩效指标[Yu等,2023a, Glass等,2021,Baek等,2023]。 |
Hybrid Approaches (RAG+FT). Combining RAG with fine-tuning is emerging as a leading strategy. Determining the optimal integration of RAG and fine-tuning whether sequen-tial, alternating, or through end-to-end joint training—and how to harness both parameterized and non-parameterized advantages are areas ripe for exploration [Lin et al., 2023]. | 混合方法(RAG+FT)。将RAG与微调相结合正在成为领先的策略。确定RAG和微调的最佳集成,无论是顺序的、交替的还是通过端到端联合训练,以及如何利用参数化和非参数化优势,都是成熟的探索领域[Lin等,2023]。 |
Expanding LLM Roles. Beyond generating final answers, LLMs are leveraged for retrieval and evaluation within RAG frameworks. Identifying ways to further unlock LLMs poten-tial in RAG systems is a growing research direction. | 扩展法学硕士角色。除了生成最终答案之外,llm还用于在RAG框架内进行检索和评估。确定进一步释放RAG系统中llm潜力的方法是一个日益增长的研究方向。 |
Scaling Laws. While scaling laws [Kaplan et al., 2020] are established for LLMs, their applicability to RAG remains uncertain. Initial studies [Wang et al., 2023b] have begun to ad-dress this, yet the parameter count in RAG models still lags behind that of LLMs. The possibility of an Inverse Scaling Law9, where smaller models outperform larger ones, is par-ticularly intriguing and merits further investigation. | 比例法。虽然已经为法学硕士建立了标度定律[Kaplan et al., 2020],但它们对RAG的适用性仍然不确定。初步研究[Wang et al., 2023b]已经开始解决这个问题,但RAG模型的参数计数仍然落后于llm。逆缩放定律的可能性,即较小的模型优于较大的模型,特别有趣,值得进一步研究。 |
Production-Ready RAG. RAG’s practicality and alignment with engineering requirements have facilitated its adoption. However, enhancing retrieval efficiency, improving document recall in large knowledge bases, and ensuring data secu-rity—such as preventing inadvertent disclosure of document sources or metadata by LLMs—are critical engineering chal-lenges that remain to be addressed [Alon et al., 2022]. | 生产使用的抹布。RAG的实用性和与工程需求的一致性促进了它的采用。然而,提高检索效率,提高大型知识库中的文档召回率,并确保数据安全(如防止法学硕士无意中泄露文档源或元数据)是仍有待解决的关键工程挑战[Alon等人,2022]。 |
Modality Extension of RAG RAG has transcended its initial text-based question-answering confines, embracing a diverse array of modal data. This expansion has spawned innovative multimodal models that integrate RAG concepts across various domains: | RAG的情态扩展 RAG已经超越了它最初基于文本的问答限制,包含了多种模态数据。这种扩展产生了创新的多模态模型,将RAG概念集成到各个领域: |
Image. RA-CM3 [Yasunaga et al., 2022] stands as a pio-neering multimodal model of both retrieving and generating text and images. BLIP-2 [Li et al., 2023a] leverages frozen image encoders alongside LLMs for efficient visual language pre-training, enabling zero-shot image-to-text conversions. The “Visualize Before You Write” method [Zhu et al., 2022] employs image generation to steer the LM’s text generation, showing promise in open-ended text generation tasks. | 的形象。RA-CM3 [Yasunaga等人,2022]是一种检索和生成文本和图像的并行多模态模型。BLIP-2 [Li等,2023a]利用冻结图像编码器和llm进行有效的视觉语言预训练,实现零镜头图像到文本的转换。“在你写之前可视化”方法[Zhu等人,2022]使用图像生成来引导LM的文本生成,在开放式文本生成任务中显示出前景。 |
Audio and Video. The GSS method retrieves and stitches together audio clips to convert machine-translated data into speech-translated data [Zhao et al., 2022]. UEOP marks a significant advancement in end-to-end automatic speech recognition by incorporating external, offline strategies for voice-to-text conversion [Chan et al., 2023]. Additionally, KNN-based attention fusion leverages audio embeddings and semantically related text embeddings to refine ASR, thereby accelerating domain adaptation. Vid2Seq augments language models with specialized temporal markers, facilitating the prediction of event boundaries and textual descriptions within a unified output sequence [Yang et al., 2023a]. | 音频和视频。GSS方法检索并拼接音频片段,将机器翻译数据转换为语音翻译数据[Zhao et al., 2022]。UEOP通过结合外部离线策略进行语音到文本转换,标志着端到端自动语音识别的重大进步[Chan等人,2023]。此外,基于knn的注意力融合利用音频嵌入和语义相关的文本嵌入来改进ASR,从而加速领域适应。Vid2Seq用专门的时间标记增强了语言模型,便于在统一的输出序列中预测事件边界和文本描述[Yang等,2023a]。 |
Code. RBPS [Nashid et al., 2023] excels in small-scale learning tasks by retrieving code examples that align with de-velopers’ objectives through encoding and frequency analy-sis. This approach has demonstrated efficacy in tasks such as test assertion generation and program repair. For structured knowledge, the CoK method [Li et al., 2023c] first extracts facts pertinent to the input query from a knowledge graph, then integrates these facts as hints within the input, enhancing performance in knowledge graph question-answering tasks. | 代码。RBPS [Nashid等人,2023]通过编码和频率分析检索与开发人员目标一致的代码示例,在小规模学习任务中表现出色。这种方法在测试断言生成和程序修复等任务中已被证明是有效的。对于结构化知识,CoK方法[Li et al., 2023c]首先从知识图中提取与输入查询相关的事实,然后将这些事实作为提示集成到输入中,从而提高知识图问答任务的性能。 |
Downstream Tasks and Evaluation RAG has shown considerable promise in enriching language models with the capacity to handle intricate queries and pro-duce detailed responses by leveraging extensive knowledge bases. Empirical evidence suggests that RAG excels in a variety of downstream tasks, including open-ended question answering and fact verification. The integration of RAG not only bolsters the precision and relevance of responses but also their diversity and depth. | 下游任务及评估 通过利用广泛的知识库,RAG在丰富语言模型,处理复杂查询和生成详细响应的能力方面显示出了相当大的前景。经验证据表明,RAG在各种下游任务中表现出色,包括开放式问题回答和事实验证。RAG的整合不仅提高了响应的准确性和相关性,而且提高了响应的多样性和深度。 |
The scalability and versatility of RAG across multiple do-mains warrant further investigation, particularly in special-ized fields such as medicine, law, and education. In these ar-eas, RAG could potentially reduce training costs and enhance performance compared to traditional fine-tuning approaches in professional domain knowledge question answering. | RAG跨多个主要领域的可伸缩性和多功能性值得进一步研究,特别是在医学、法律和教育等特殊领域。在这些领域,与专业领域知识问答的传统微调方法相比,RAG可以潜在地降低培训成本并提高性能。 |
Concurrently, refining the evaluation framework for RAG is essential to maximize its efficacy and utility across different tasks. This entails the development of nuanced metrics and assessment tools that can gauge aspects such as contextual relevance, creativity of content, and non-maleficence. | 同时,细化RAG的评估框架对于最大限度地提高其跨不同任务的效率和效用是必不可少的。这需要开发细微的度量标准和评估工具,这些工具可以衡量诸如上下文相关性、内容的创造性和非恶意性等方面。 |
Furthermore, improving the interpretability of RAG-driven models continues to be a key goal. Doing so would allow users to understand the reasoning behind the responses gener-ated by the model, thereby promoting trust and transparency in the use of RAG applications. | 此外,改进rag驱动模型的可解释性仍然是一个关键目标。这样做将允许用户理解模型生成的响应背后的原因,从而促进RAG应用程序使用中的信任和透明度。 |
Technical Stack The development of the RAG ecosystem is greatly impacted by the progression of its technical stack. Key tools like LangChain and LLamaIndex have quickly gained popularity with the emergence of ChatGPT, providing extensive RAG-related APIs and becoming essential in the realm of LLMs. | 技术堆栈 RAG生态系统的发展很大程度上受到其技术堆栈进步的影响。随着ChatGPT的出现,LangChain和LLamaIndex等关键工具迅速流行起来,提供了大量与rag相关的api,并成为llm领域必不可少的工具。 |
Emerging technical stacks, while not as feature-rich as LangChain and LLamaIndex, distinguish themselves with specialized offerings. For instance, Flowise AI10 prioritizes a low-code approach, enabling users to deploy AI applications, including RAG, through a user-friendly drag-and-drop inter-face. Other technologies like HayStack, Meltano11, and Co-here Coral12 are also gaining attention for their unique con-tributions to the field. | 新兴的技术栈虽然不像LangChain和LLamaIndex那样功能丰富,但它们以专门的产品脱颖而出。例如,Flowise AI10优先考虑低代码方法,使用户能够通过用户友好的拖放界面部署AI应用程序,包括RAG。干草堆、Meltano11和Co-here Coral12等其他技术也因其对该领域的独特贡献而受到关注。 |
In addition to AI-focused providers, traditional software and cloud service providers are expanding their offerings to include RAG-centric services. Verba13 from Weaviate is de-signed for personal assistant applications, while Amazon’s Kendra14 provides an intelligent enterprise search service, al-lowing users to navigate through various content repositories using built-in connectors. During the evolution of the RAG technology landscape, there has been a clear divergence to-wards different specializations, such as: 1) Customization. Tailoring RAG to meet a specific requirements. 2) Simpli-fication. Making RAG easier to use, thereby reducing the ini-tial learning curve. 3) Specialization. Refining RAG to serve production environments more effectively. | 除了专注于人工智能的提供商外,传统的软件和云服务提供商也在扩大他们的产品,包括以rag为中心的服务。Weaviate的Verba13是为个人助理应用程序设计的,而亚马逊的Kendra14提供了智能企业搜索服务,允许用户使用内置连接器浏览各种内容存储库。在RAG技术领域的发展过程中,已经出现了明显的分化,趋向于不同的专门化,例如:1)定制。裁剪RAG以满足特定要求。2) Simpli-fication。使RAG更容易使用,从而减少最初的学习曲线。3)专业化。改进RAG以更有效地服务于生产环境。 |
The mutual growth of RAG models and their technical stack is evident; technological advancements consistently es-tablish new standards for the existing infrastructure. In turn, enhancements to the technical stack drive the evolution of RAG capabilities. The RAG toolkit is converging into a foun-dational technical stack, laying the groundwork for advanced enterprise applications. However, the concept of a fully in-tegrated, comprehensive platform remains on the horizon, pending further innovation and development. | RAG模型及其技术栈的相互增长是显而易见的;技术进步不断为现有的基础设施建立新的标准。反过来,对技术堆栈的增强推动了RAG功能的发展。RAG工具包正在聚合成一个基础技术堆栈,为高级企业应用程序奠定基础。然而,一个完全集成的综合平台的概念仍然在地平线上,等待进一步的创新和发展。 |
The summary of this paper, as depicted in Figure 7, high-lights RAG’s significant advancement in enhancing the ca-pabilities of LLMs through the integration of parameter-ized knowledge from language models with extensive non-parameterized data from external knowledge bases. Our sur-vey illustrates the evolution of RAG technologies and their impact on knowledge-intensive tasks. Our analysis delin-eates three developmental paradigms within the RAG frame-work: Naive, Advanced, and Modular RAG, each marking a progressive enhancement over its predecessors. The Ad-vanced RAG paradigm extends beyond the Naive approach by incorporating sophisticated architectural elements, includ-ing query rewriting, chunk reranking, and prompt summariza-tion. These innovations have led to a more nuanced and mod-ular architecture that enhances both the performance and the interpretability of LLMs. RAG’s technical integration with other AI methodologies, such as fine-tuning and reinforce-ment learning, has further expanded its capabilities. In con-tent retrieval, a hybrid methodology that leverages both struc-tured and unstructured data sources is emerging as a trend, providing a more enriched retrieval process. Cutting-edge re-search within the RAG framework is exploring novel con-cepts such as self-retrieval from LLMs and the dynamic tim-ing of information retrieval. | 如图7所示,本文的总结强调了RAG通过集成语言模型的参数化知识和来自外部知识库的大量非参数化数据,在增强llm的计算能力方面取得的重大进展。我们的调查说明了RAG技术的演变及其对知识密集型任务的影响。我们的分析在RAG框架中划分了三种发展范式:朴素的、高级的和模块化的RAG,每一种都标志着对其前身的逐步增强。高级RAG范例通过合并复杂的体系结构元素,包括查询重写、块重新排序和提示摘要,扩展了朴素方法。这些创新带来了更加细致和模块化的体系结构,增强了llm的性能和可解释性。RAG与其他人工智能方法(如微调和强化学习)的技术集成进一步扩展了其功能。在内容检索中,利用结构化和非结构化数据源的混合方法正在成为一种趋势,它提供了更丰富的检索过程。RAG框架内的前沿研究正在探索新的概念,如法学硕士的自我检索和信息检索的动态时序。 |
Despite the strides made in RAG technology, research op-portunities abound in improving its robustness and its abil-ity to manage extended contexts. RAG’s application scope is also widening into multimodal domains, adapting its principles to interpret and process diverse data forms such as im-ages, videos, and code. This expansion underscores RAG’s significant practical implications for AI deployment, attract-ing interest from both academic and industrial sectors. The growing ecosystem of RAG is underscored by an increase in RAG-centric AI applications and the ongoing development of supportive tools. However, as RAG’s application land-scape expands, there is an imperative need to refine evaluation methodologies to keep pace with its evolution. Ensuring that performance assessments remain accurate and representative is crucial for capturing the full extent of RAG’s contributions to the AI research and development community. | 尽管RAG技术取得了长足的进步,但在改进其健壮性和管理扩展上下文的能力方面,研究机会仍然很多。RAG的应用范围也扩展到多模式领域,调整其原理来解释和处理不同的数据形式,如图像、视频和代码。这一扩展凸显了RAG对人工智能部署的重要实际意义,吸引了学术界和工业界的兴趣。以RAG为中心的人工智能应用程序的增加和支持性工具的持续开发强调了RAG生态系统的不断发展。然而,随着RAG应用程序领域的扩展,有必要改进评估方法以跟上其发展的步伐。确保绩效评估保持准确和代表性对于充分了解RAG对人工智能研究和开发社区的贡献至关重要。 |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。