← 中文资源

简体中文版本

检索增强生成(RAG)

检索增强生成把模型回答建立于检索到的文档之上,使回复反映你的私有数据而非仅训练期知识。

阅读英文原文

概念概述

检索增强生成(RAG)(Retrieval-Augmented Generation)指的是:检索增强生成把模型回答建立于检索到的文档之上,使回复反映你的私有数据而非仅训练期知识。

从更严格的定义看,Retrieval-augmented generation is a technique that retrieves relevant passages from an external corpus and supplies them to a language model as context, so the generated answer can cite and use knowledge outside the model’s parameters. 该概念在工程实践中的价值,在于它能帮助团队用统一的语言描述一个具体的质量属性或设计约束,从而在评审与协作中减少歧义。

为什么需要它

It is used for question answering over private documents, support assistants, and any application needing current or proprietary facts. 它与 Vector Databases、Semantic Search、Text Embeddings 等概念经常一起出现,用于解决相近的工程问题。理解它的适用场景,有助于在多种备选方案之间做出有依据的取舍,而不是凭直觉选择技术方案。

常见误解

  • retrieval guarantees the answer is factually correct
  • a larger model removes the need for retrieval

需要避免的反模式

  • retrieving passages without regard to the question’s intent
  • passing retrieved text to the model without delimiting it from instructions

实践要点

  1. The quality ceiling is set by retrieval: if the relevant passage is never fetched, no amount of generation skill can recover it, so ranking and recall come first.
  2. Chunking, embedding choice, and reranking all influence which passages surface, making the retrieval pipeline the primary lever for accuracy.
  3. Retrieved content is untrusted input, so it must be separated from system instructions to reduce prompt injection through documents.

参考来源

https://arxiv.org/abs/2005.11401