RAG的三个阶段:Naive RAG、Advanced RAG和Modular RAG

📌
前言: 本文主要描述RAG的三个阶段:Naive RAG、Advanced RAG和Modular RAG。
notion image
一个典型的问答 RAG 方法,是这样的,包含存储阶段和查询阶段:
存储阶段:
  1. 将文本分割成小块
  1. 然后使用某种 Transformer Encoder 模型将这些小块转换为向量
  1. 存储到VectorDB中
查询阶段:
  1. 我们用相同的 Encoder 模型将用户的查询(Query)转化为向量
  1. 然后对这个查询向量进行搜索,与索引进行匹配,找出最相关的前 k 个结果
  1. 从我们的数据库中提取相应的文本块,并将其作为上下文输入 LLM 进行处理。
在实际运行中:

🥇 Naive RAG

notion image

简介

Naive RAG(Naive Retrieval-Augmented Generation)研究范式是一种早期的方法论代表。这个范式在ChatGPT被广泛采用之后不久就变得流行起来。
包括三个主要步骤:索引(Indexing)、检索(Retrieval)和生成(Generation)。具体来说:
  1. 索引(Indexing)
    1. 在这一步中,大量的文本数据被处理和存储,以便能够快速检索。
      首先要清理和提取 PDF、HTML、Word 和 Markdown 等不同格式的原始数据,然后将其转换为统一的纯文本格式。为了适应语言模型的上下文限制,文本被分割成更小的、易于消化的块。然后,使用嵌入模型将语块编码为矢量表示,并存储到矢量数据库中。这一步骤对于在随后的检索阶段进行高效的相似性搜索至关重要。
  1. 检索(Retrieval)
    1. 这一步涉及到从索引的数据库中检索出与查询相关的信息或文档。
      收到用户查询后,RAG 系统会使用索引阶段使用的相同编码模型将查询转换为向量表示。然后,系统会计算查询向量与索引语料库中的语块向量之间的相似度得分。系统会优先检索与查询相似度最高的 K 个语块。这些语块随后会被用作提示中的扩展上下文。
  1. 生成(Generation)
    1. 最后一步是利用检索到的信息来生成回答或内容。
      提出的查询和选定的文档被合成为一个连贯的提示,而大型语言模型的任务就是对此作出回应。该模型的回答方法可根据特定任务的标准而有所不同,使其既能利用固有的参数知识,也能根据所提供文档中包含的信息进行回答。在持续对话的情况下,任何现有的对话历史都可以整合到提示中,使模型能够有效地参与多轮对话互动。
这三个步骤共同构成了“检索-读取”(Retrieve-Read)框架的模型[7]。这个框架是指系统首先检索相关信息,然后“读取”这些信息以生成响应的过程。是对话系统和文本生成领域中的一个重要概念,它强调了在生成回答之前先进行信息检索的重要性。

遇到了显著的问题

Retrieval Challenges. The retrieval phase often struggles with precision and recall, leading to the selection of misaligned or irrelevant chunks, and the missing of crucial information.
检索主要有两个挑战:提高精确度(precision)和召回率(recall)。这可能导致选出不相关的内容或遗漏关键信息。系统常常难以同时保持高精确度和高召回率。这可能导致两个问题:
  • 选择错位或不相关的块。这意味着检索系统可能会返回与查询不匹配或不相关的信息块,这可能是因为系统错误地将某些信息识别为相关,或者未能正确理解查询的意图。
  • 丢失关键信息。这表示检索系统可能未能检索到所有相关的重要信息,导致用户无法获得完整的、有助于解决问题的信息。
Generation Difficulties. In generating responses, the model may face the issue of hallucination, where it produces content not supported by the retrieved context. This phase can also suffer from irrelevance, toxicity, or bias in the outputs, detracting from the quality and reliability of the responses.
生成回答时遇到的挑战。具体来说,模型可能会遇到以下几个问题:
  • 幻觉问题(Hallucination):这是指模型生成的内容并不是基于检索到的上下文信息,也就是说,模型可能会“想象”出一些实际上并不存在或者与给定信息不符的内容。
  • 不相关性(Irrelevance):模型生成的回答可能与用户的问题或者上下文不相关,这会导致用户得到的信息并不是他们所需要的。
  • 有害性(Toxicity):这指的是模型可能会生成包含攻击性、侮辱性或者不恰当的内容。
  • 偏差(Bias):模型的回答可能会受到某些偏见的影响,比如性别、种族或者文化偏见,这可能会导致回答不公平或者不准确。
这些问题都会影响到模型生成回答的质量和可靠性,使得用户得到的响应可能不够准确或者不够有用。因此,为了提高模型的响应质量,需要不断优化和调整模型,以减少这些问题的发生。
Augmentation Hurdles. Integrating retrieved information with the different task can be challenging, sometimes resulting in disjointed or incoherent outputs. The process may also encounter redundancy when similar information is retrieved from multiple sources, leading to repetitive responses. Determining the significance and relevance of various passages and ensuring stylistic and tonal consistency add further complexity. Facing complex issues, a single retrieval based on the original query may not suffice to acquire adequate context information.
信息增强(Augmentation)过程中遇到的障碍。信息增强是指将检索到的信息整合到不同的任务中,以提高输出的质量和相关性。具体有下面的几个方面:
  • 集成挑战:将检索到的信息与不同的任务集成可能是一个挑战,有时会导致输出内容脱节或不连贯。这意味着,尽管检索到了相关信息,但在将其融入到特定任务或问题中时,可能会出现信息不匹配或逻辑不连贯的情况。
  • 冗余问题:当从多个来源检索到相似的信息时,可能会导致冗余,即重复的响应。这不仅降低了效率,还可能使得最终输出显得啰嗦和重复。
  • 重要性和相关性评估:确定各个段落的重要性和相关性是一个复杂的过程,需要评估哪些信息是关键的,哪些是次要的,以及它们与任务的相关程度。
  • 风格和语气一致性:确保输出的风格和语气一致也是一个挑战,尤其是在处理来自不同来源的信息时,需要保持整体的协调性和一致性。
  • 复杂问题的单一检索不足:面对复杂的问题,基于原始查询的单一检索可能不足以获取足够的上下文信息。这意味着,为了充分理解和解决复杂问题,可能需要多次检索和分析,以获得更全面的上下文信息。
在信息增强过程中,需要克服的一系列挑战,包括信息的集成、冗余处理、重要性评估、风格和语气的一致性,以及在面对复杂问题时单一检索的局限性。
Moreover, there’s a concern that generation models might overly rely on augmented information, leading to outputs that simply echo retrieved content without adding insightful or synthesized information.
最后还担心生成模型可能会变成简单的信息复制器,而不是创造性或分析性的信息生产者。这些模型可能会过分依赖于额外添加的信息(增强信息)。这种依赖可能导致模型的输出仅仅是重复或回显(echo)它们检索到的内容,而没有提供新的、有洞察力的或者经过综合分析的信息。

🥈 Advanced RAG

简介

Advanced RAG introduces specific improvements to overcome the limitations of Naive RAG. Focusing on enhancing retrieval quality, it employs pre-retrieval and post-retrieval strategies. To tackle the indexing issues, Advanced RAG refines its indexing techniques through the use of a sliding window approach, fine-grained segmentation, and the incorporation of metadata. Additionally, it incorporates several optimization methods to streamline the retrieval process[8]
“Advanced RAG”(高级检索增强生成模型)相比于“Naive RAG”(基础检索增强生成模型)所做的一些改进。具体体现在下面几个方面:
  1. 克服Naive RAG的局限性:Advanced RAG是为了解决Naive RAG在功能和性能上的一些限制而设计的。
  1. 提高检索质量:Advanced RAG的主要目标是提升检索结果的质量。
  1. 检索前和检索后策略:为了提高检索质量,Advanced RAG采用了两种策略,即在检索发生之前(检索前)和检索发生之后(检索后)的策略。
  1. 解决索引问题:Advanced RAG通过改进索引技术来解决索引过程中遇到的问题。
  1. 滑动窗口方法:这是一种索引技术,通过在数据流上滑动一个固定大小的窗口来处理和比较数据。
  1. 细粒度分段:这种方法允许对数据进行更细致的分割,以便更精确地索引和检索信息。
  1. 合并元数据:通过将元数据(关于数据的数据)整合到索引过程中,可以提高检索的准确性和效率。
  1. 优化方法:Advanced RAG还结合了多种优化方法,这些方法有助于简化和加速检索过程。
通过这些改进,旨在提供比Naive RAG更高效、更准确的检索体验。

优化的细节

Pre-retrieval process. In this stage, the primary focus is on optimizing the indexing structure and the original query. The goal of optimizing indexing is to enhance the quality of the content being indexed. This involves strategies: enhancing data granularity, optimizing index structures, adding metadata, alignment optimization, and mixed retrieval. While the goal of query optimization is to make the user’s original question clearer and more suitable for the retrieval task. Common methods include query rewriting query transformation, query expansion and other techniques [791011].
预检索处理(Pre-retrieval process,这是一个信息检索系统中的阶段,主要关注点在于优化索引结构和原始查询。下面是对这段话的详细解释:
  1. 预检索过程(Pre-retrieval process):这是信息检索流程中的一个阶段,发生在实际检索之前。
  1. 优化索引结构和原始查询:在预检索阶段,主要目标是优化索引结构和用户的原始查询。
  1. 优化索引的目标:优化索引的目的是为了提高被索引内容的质量。
  1. 涉及的策略
      • 增强数据粒度:这意味着提高数据的详细程度,以便更精确地索引和检索。
      • 优化索引结构:调整索引的结构,使其更有效地存储和检索数据。
      • 添加元数据:元数据提供了关于数据的额外信息,有助于改善索引和检索过程。
      • 对齐优化:确保索引中的数据与查询需求对齐,以提高检索的相关性。
      • 混合检索:结合不同的检索技术,以提高检索结果的质量和相关性。
  1. 查询优化的目标:查询优化的目的是使用户的原始问题更加清晰,更适合检索任务。
  1. 常见的方法
      • 查询重写:根据用户的原始查询,生成一个更有效的查询表达式。
      • 查询变换:改变查询的形式,以适应不同的检索系统或提高检索效果。
      • 查询扩展:通过添加相关词汇或概念来扩展原始查询,以提高检索结果的相关性和覆盖面。
Post-Retrieval Process. Once relevant context is retrieved, it’s crucial to integrate it effectively with the query. The main methods in post-retrieval process include rerank chunks and context compressing. Re-ranking the retrieved information to relocate the most relevant content to the edges of the prompt is a key strategy. This concept has been implemented in frameworks such as LlamaIndex2, LangChain3, and HayStack [12]. Feeding all relevant documents directly into LLMs can lead to information overload, diluting the focus on key details with irrelevant content. To mitigate this, post-retrieval efforts concentrate on selecting the essential information, emphasizing critical sections, and shortening the context to be processed.
检索后处理(Post-Retrieval Process),一旦检索到相关上下文,将其有效地与查询(query)整合是非常关键的。从而提高检索结果的相关性和准确性。通过重新排名和压缩上下文来优化信息的整合,从而提高检索增强生成的整体效果。
  1. 检索后处理的主要方法
      • 重新排名(Rerank chunks):重新对检索到的信息进行排名,将最相关的信息重新定位到提示(prompt)的边缘,这是一种关键策略。
      • 上下文压缩(Context compressing):通过选择关键信息、强调重要部分和缩短待处理的上下文,来减轻信息过载问题,避免关键细节被无关内容冲淡。
  1. 实际应用框架:这种概念已经在一些框架中得到实现,例如LlamaIndex、LangChain和HayStack。
  1. 信息过载问题:直接将所有相关文档输入到大型语言模型(LLMs)可能会导致信息过载,使得关键细节被无关内容淹没。
  1. 缓解信息过载的措施:后检索工作集中于选择关键信息、强调关键部分,并缩短待处理的上下文。

🥉 Modular RAG

简介

The modular RAG architecture advances beyond the former two RAG paradigms, offering enhanced adaptability and versatility. It incorporates diverse strategies for improving its components, such as adding a search module for similarity searches and refining the retriever through fine-tuning. Innovations like restructured RAG modules [13] and rearranged RAG pipelines [14] have been introduced to tackle specific challenges. The shift towards a modular RAG approach is becoming prevalent, supporting both sequential processing and integrated end-to-end training across its components. Despite its distinctiveness, Modular RAG builds upon the foundational principles of Advanced and Naive RAG, illustrating a progression and refinement within the RAG family.
模块化RAG架构是一种高度可扩展和可重构的RAG系统,它通过将复杂的RAG系统分解为独立的模块和专门的算子,超越了传统的线性架构,支持顺序处理和端到端训练,为RAG系统的概念化和部署提供了创新机会。

新模块

The Modular RAG framework introduces additional specialized components to enhance retrieval and processing capabilities. The Search module adapts to specific scenarios, enabling direct searches across various data sources like search engines, databases, and knowledge graphs, using LLM-generated code and query languages [15]. RAG-Fusion addresses traditional search limitations by employing a multi-query strategy that expands user queries into diverse perspectives, utilizing parallel vector searches and intelligent re-ranking to uncover both explicit and transformative knowledge [16]. The Memory module leverages the LLM’s memory to guide retrieval, creating an unbounded memory pool that aligns the text more closely with data distribution through iterative self-enhancement [1718]. Routing in the RAG system navigates through diverse data sources, selecting the optimal pathway for a query, whether it involves summarization, specific database searches, or merging different information streams [19]. The Predict module aims to reduce redundancy and noise by generating context directly through the LLM, ensuring relevance and accuracy [13]. Lastly, the Task Adapter module tailors RAG to various downstream tasks, automating prompt retrieval for zero-shot inputs and creating task-specific retrievers through few-shot query generation [2021] . This comprehensive approach not only streamlines the retrieval process but also significantly improves the quality and relevance of the information retrieved, catering to a wide array of tasks and queries with enhanced precision and flexibility.
Modular RAG(模块化RAG)框架是一种先进的机器学习架构,通过引入额外的专门组件来增强检索和处理能力。
  1. Search模块:这个模块能够适应特定的场景,允许直接在各种数据源(如搜索引擎、数据库和知识图谱)中进行搜索。它使用由大型语言模型(LLM)生成的代码和查询语言来执行搜索。
  1. RAG-Fusion:这个组件针对传统搜索的局限性,采用了多查询策略,将用户查询扩展到不同的视角。它利用并行向量搜索和智能重新排名来发现显性和变革性的知识。
  1. Memory模块:这个模块利用LLM的内存来指导检索,创建一个无界的内存池,通过迭代自我增强使文本更紧密地与数据分布对齐。
  1. Routing:在RAG系统中,Routing负责在不同的数据源中导航,为查询选择最优路径,无论是涉及摘要、特定数据库搜索还是合并不同的信息流。
  1. Predict模块:这个模块旨在通过LLM直接生成上下文来减少冗余和噪声,确保相关性和准确性。
  1. Task Adapter模块:这个模块使RAG能够适应各种下游任务,自动化零样本输入的提示检索,并通过对少量样本查询的生成来创建特定任务的检索器。
这种全面的方法不仅简化了检索过程,还显著提高了检索信息的质量和相关性,能够以更高的精确度和灵活性满足广泛的任务和查询需求。

新范式

Modular RAG offers remarkable adaptability by allowing module substitution or reconfiguration to address specific challenges. This goes beyond the fixed structures of Naive and Advanced RAG, characterized by a simple “Retrieve” and “Read” mechanism. Moreover, Modular RAG expands this flexibility by integrating new modules or adjusting interaction flow among existing ones, enhancing its applicability across different tasks.
模块化RAG(Retrieval-Augmented Generation,检索增强生成)提供了显著的适应性,它允许通过模块替换或重新配置来应对特定的挑战。这超越了简单和高级RAG的固定结构,后者的特点是简单的“检索”和“阅读”机制。此外,模块化RAG通过整合新模块或调整现有模块之间的交互流程,进一步扩展了这种灵活性,增强了其在不同任务中的适用性。
简单来说,模块化RAG是一种灵活的技术,它可以通过改变或替换组件来适应不同的需求和挑战。这与那些只有固定检索和阅读步骤的技术不同,模块化RAG可以添加新的模块或者改变模块之间的工作流程,使其能够更好地适应各种不同的任务。
Innovations such as the Rewrite-Retrieve-Read [7]model leverage the LLM’s capabilities to refine retrieval queries through a rewriting module and a LM-feedback mechanism to update rewriting model, improving task performance. Similarly, approaches like Generate-Read [13] replace traditional retrieval with LLM-generated content, while Recite-Read [22] emphasizes retrieval from model weights, enhancing the model’s ability to handle knowledge-intensive tasks. Hybrid retrieval strategies integrate keyword, semantic, and vector searches to cater to diverse queries. Additionally, employing sub-queries and hypothetical document embeddings (HyDE) [11] seeks to improve retrieval relevance by focusing on embedding similarities between generated answers and real documents.
模块化RAG(Retrieval-Augmented Generation)模型的创新和优势。
  1. Rewrite-Retrieve-Read模型:这是一种创新模型,它利用大型语言模型(LLM)的能力来优化检索查询。这个模型通过一个重写模块和一个基于语言模型反馈的机制来更新重写模型,从而提高任务性能。
  1. Generate-Read方法:这种方法取代了传统的检索方式,转而使用LLM生成的内容。这意味着模型不再从外部数据源检索信息,而是直接生成所需的信息。
  1. Recite-Read方法:这种方法强调从模型权重中检索信息,增强了模型处理知识密集型任务的能力。这可能意味着模型能够更好地利用其内部知识来回答问题。
  1. 混合检索策略:这种策略结合了关键词搜索、语义搜索和向量搜索,以适应不同类型的查询。这种方法可以提供更多样化的检索结果,以满足不同用户的需求。
  1. 子查询和假设文档嵌入(HyDE):这种方法通过关注生成答案和真实文档之间的嵌入相似性来提高检索的相关性。这可能涉及到使用更复杂的算法来确定最相关的文档,从而提高检索的准确性。
模块化RAG模型具有灵活性和适应性,以及通过集成新模块和调整模块间交互来提高性能的能力。这些创新使得RAG模型能够更好地适应不同的任务和查询类型,提高了检索的效率和准确性。
Adjustments in module arrangement and interaction, such as the Demonstrate-Search-Predict (DSP) [23] framework and the iterative Retrieve-Read-Retrieve-Read flow of ITER-RETGEN [14], showcase the dynamic use of module outputs to bolster another module’s functionality, illustrating a sophisticated understanding of enhancing module synergy. The flexible orchestration of Modular RAG Flow showcases the benefits of adaptive retrieval through techniques such as FLARE [24] and Self-RAG [25]. This approach transcends the fixed RAG retrieval process by evaluating the necessity of retrieval based on different scenarios. Another benefit of a flexible architecture is that the RAG system can more easily integrate with other technologies (such as fine-tuning or reinforcement learning) [26]. For example, this can involve fine-tuning the retriever for better retrieval results, fine-tuning the generator for more personalized outputs, or engaging in collaborative fine-tuning [27].
模块化RAG(Retrieval-Augmented Generation)框架中模块排列和交互的调整,以及这种灵活性如何增强模块间的协同作用。
  1. 模块排列和交互的调整:文中提到了两种特定的框架——Demonstrate-Search-Predict (DSP) [23] 和 ITER-RETGEN [14]。DSP框架和ITER-RETGEN的迭代检索-阅读-检索-阅读流程展示了如何动态使用一个模块的输出来增强另一个模块的功能,这表明了对增强模块协同作用的深刻理解。
  1. 模块化RAG流程的灵活性:模块化RAG流程的灵活性展示了通过自适应检索技术(如FLARE [24] 和 Self-RAG [25])来增强模块协同作用的好处。这种方法超越了固定的RAG检索过程,通过根据不同情境评估检索的必要性。
  1. 灵活架构的另一个好处:RAG系统可以更容易地与其他技术(如微调或强化学习)集成。例如,这可能包括对检索器进行微调以获得更好的检索结果,对生成器进行微调以产生更个性化的输出,或者进行协作微调。

🤗 总结

notion image
RAG(Retrieval-Augmented Generation)的三个发展阶段的比较,具体如下:
Naive RAG(基础RAG)
Advanced RAG(高级RAG)
Modular RAG(模块化RAG)
这是最早期的方法论,主要包含三个部分:索引(Indexing)、检索(Retrieval)和生成(Generation)。索引阶段涉及将文档分割成小块,编码成向量,并存储在向量数据库中。检索阶段是根据语义相似性检索与问题最相关的前K个块。生成阶段是将原始问题和检索到的块一起输入到大型语言模型(LLM)中,以生成最终答案。
在基础RAG的基础上,高级RAG提出了多个优化策略,主要围绕检索前(Pre-retrieval)和检索后(Post-retrieval)进行。尽管过程与基础RAG相似,仍然遵循链式结构,但是通过这些优化策略来提高检索的质量。
模块化RAG从之前的范式中继承并发展而来,展现出更大的灵活性。这体现在引入了多个特定的功能模块以及替换现有模块的能力。整个过程不仅限于顺序检索和生成,还包括迭代和自适应检索等方法。
这三个阶段展示了RAG从基础到高级再到模块化的发展过程,每个阶段都在前一个阶段的基础上进行了改进和优化,以提高检索的质量和灵活性。

🆚 RAG vs Fine-tuning

图 4: RAG 与其他模型优化方法在 "所需外部知识" 和 "所需模型调整" 方面的比较。
图 4: RAG 与其他模型优化方法在 "所需外部知识" 和 "所需模型调整" 方面的比较。
在大型语言模型(LLMs)的优化方法中,检索增强生成(RAG)与其他方法(如提示工程和微调)的比较。具体来说,它提到了在两个维度上比较这些方法:对外部知识的需求和对模型适应性的需求。
  1. 提示工程(Prompt Engineering):这种方法对模型和外部知识的修改需求很低,主要侧重于利用LLMs自身的能力。
  1. 微调(Fine-tuning,FT):这种方法涉及对模型进行进一步的训练。
  1. 检索增强生成(RAG)
      • 在RAG的早期阶段(被称为Naive RAG),对模型修改的需求很低。
      • 随着研究的进展,模块化的RAG(Modular RAG)越来越多地与微调技术相结合。
它们在不同优化方法的特点和不同维度上的需求差异。提示工程侧重于利用模型的内在能力,而微调则需要对模型进行额外的训练。RAG在早期阶段对模型修改的需求较低,但随着技术的发展,它开始更多地融入微调技术,以提高模型的性能和适应性。
The augmentation of LLMs has attracted considerable attention due to their growing prevalence. Among the optimization methods for LLMs, RAG is often compared with Fine-tuning (FT) and prompt engineering. Each method has distinct characteristics as illustrated in Figure 4. We used a quadrant chart to illustrate the differences among three methods in two dimensions: external knowledge requirements and model adaption requirements. Prompt engineering leverages a model’s inherent capabilities with minimum necessity for external knowledge and model adaption. RAG can be likened to providing a model with a tailored textbook for information retrieval, ideal for precise information retrieval tasks. In contrast, FT is comparable to a student internalizing knowledge over time, suitable for scenarios requiring replication of specific structures, styles, or formats.
这段文字讨论了大型语言模型(LLMs)的增强技术,特别是 检索增强生成(RAG)微调(Fine-tuning,FT)以及提示工程(Prompt Engineering)这三种优化方法。以下是对这段文字的解释:
  1. LLMs的增强技术受到关注:由于大型语言模型(LLMs)的普及度不断增加,它们的增强技术吸引了相当多的关注。
  1. 优化方法的比较:在LLMs的优化方法中,检索增强生成(RAG)经常与微调(FT)和提示工程进行比较。
  1. 不同方法的特点:每种方法都有其独特的特点,这些特点在图4中有所展示。
  1. 四象限图的说明:作者使用了一个四象限图来展示这三种方法在两个维度上的差异:外部知识需求和模型适应需求。
  1. 提示工程:提示工程利用模型的固有能力,对外部知识和模型适应的需求最小。
  1. RAG的比喻:RAG可以被比喻为给模型提供一本定制的教科书,用于信息检索,这对于精确的信息检索任务来说是理想的。
  1. FT的比喻:相比之下,FT可以比作学生随时间吸收知识,适用于需要复制特定结构、风格或格式的场景。
这段文字强调了每种方法在优化LLMs时的独特优势和适用场景。
RAG excels in dynamic environments by offering real-time knowledge updates and effective utilization of external knowledge sources with high interpretability. However, it comes with higher latency and ethical considerations regarding data retrieval. On the other hand, FT is more static, requiring retraining for updates but enabling deep customization of the model’s behavior and style. It demands significant computational resources for dataset preparation and training, and while it can reduce hallucinations, it may face challenges with unfamiliar data.
这段内容讨论了两种优化大型语言模型(LLMs)的方法:Retrieval-Augmented Generation(RAG)和Fine-tuning(FT),并比较了它们在动态环境中的表现和特点。
  1. RAG(检索增强生成)在动态环境中表现出色,原因如下:
      • 提供实时知识更新:RAG能够快速获取和整合最新的外部知识,使模型保持最新状态。
      • 有效利用外部知识源:RAG通过检索相关信息来辅助生成,提高了知识的利用效率。
      • 高解释性:RAG的检索过程相对透明,有助于理解模型的决策过程。
      然而,RAG也有一些缺点:
      • 更高的延迟:RAG需要检索和处理外部信息,可能导致响应速度变慢。
      • 数据检索的伦理问题:RAG可能会涉及敏感数据的处理,需要考虑隐私和合规性问题。
  1. FT(微调)的特点:
      • 静态:FT主要通过调整模型参数来适应特定任务,不涉及实时更新知识。
      • 需要重新训练以更新:FT模型需要定期重新训练以适应新的知识或数据。
      • 深度定制:FT允许对模型的行为和风格进行深度定制,以适应特定需求。
      • 计算资源需求高:FT需要大量的计算资源来准备数据集和训练模型。
      • 减少幻觉:FT有助于减少模型生成不真实或错误信息的情况。
      • 面临不熟悉数据的挑战:FT模型可能在处理训练中未遇到的新数据时表现不佳。
RAG和FT各有优势和局限,选择哪种方法取决于具体应用的需求、数据动态性、定制化程度和计算能力。在某些情况下,将RAG和FT结合使用可能会取得最佳效果。
In multiple evaluations of their performance on various knowledge-intensive tasks across different topics, [28] revealed that while unsupervised fine-tuning shows some improvement, RAG consistently outperforms it, for both existing knowledge encountered during training and entirely new knowledge. Additionally, it was found that LLMs struggle to learn new factual information through unsupervised fine-tuning. The choice between RAG and FT depends on the specific needs for data dynamics, customization, and computational capabilities in the application context. RAG and FT are not mutually exclusive and can complement each other, enhancing a model’s capabilities at different levels. In some instances, their combined use may lead to optimal performance. The optimization process involving RAG and FT may require multiple iterations to achieve satisfactory results.
这段内容讨论了在多种知识密集型任务中,对于大型语言模型(LLMs)的不同优化方法——特别是检索增强生成(RAG)和无监督微调(FT)——的性能评估结果。以下是对这段内容的解释:
  1. 性能评估:在多个不同主题的知识密集型任务中进行的多次评估显示,尽管无监督微调(FT)显示出一些改进,但RAG在处理训练中遇到的知识以及全新的知识方面始终优于FT。
  1. LLMs的挑战:研究发现,LLMs在通过无监督微调学习新的事实信息方面存在困难。
  1. RAG与FT的选择:选择RAG还是FT取决于应用环境中对数据动态性、定制化和计算能力的具体需求。RAG和FT并不是相互排斥的,它们可以互补,增强模型在不同层面的能力。
  1. 联合使用:在某些情况下,RAG和FT的联合使用可能会带来最优的性能。
  1. 优化过程:涉及RAG和FT的优化过程可能需要多次迭代才能达到满意的结果。
简而言之,这段内容强调了RAG在处理新知识和现有知识方面的优势,以及LLMs在无监督微调中学习新信息的困难。同时,它也指出了RAG和FT可以根据特定应用的需求相互补充,并且优化这两种方法可能需要多次尝试和调整。

📎 参考

声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。

Previous

JDK8垃圾回收器调优指南

Next

分布式技术1:概述和历史