“RAG”的版本间的差异

来自医学百科
 
第1行: 第1行:
<div class="medical-infobox" style="font-size: 0.85em;">
+
<div style="padding: 0 4%; line-height: 1.8; color: #1e293b; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', Arial, sans-serif; background-color: #ffffff; max-width: 1200px; margin: auto;">
{| style="width: 100%; background: none; border-spacing: 0;"
 
|+ style="font-size: 1.35em; font-weight: bold; margin-bottom: 10px; color: #1a202c;" | 检索增强生成 (RAG)
 
|-
 
| colspan="2" |
 
<div class="infobox-image-wrapper" style="padding: 25px; background-color: #f8fafc; border: 1px solid #f1f5f9; border-radius: 12px; text-align: center;">
 
  
<div style="font-size: 0.85em; color: #94a3b8; margin-top: 10px; font-weight: normal;">RAG 技术架构:知识检索与大模型生成的协同示意图</div>
+
    <div style="margin-bottom: 30px; border-bottom: 1.2px solid #e2e8f0; padding-bottom: 25px;">
</div>
+
        <p style="font-size: 1.1em; margin: 10px 0; color: #334155; text-align: justify;">
|-
+
            <strong>RAG</strong>(Retrieval-Augmented Generation,检索增强生成)是一种将预训练大语言模型(LLM)与外部知识检索系统相结合的混合 AI 架构。它由 Meta AI 的 Patrick Lewis 等人于 2020 年正式提出。传统的 LLM(如 ChatGPT)像是一个<strong>“闭卷考试”</strong>的学生,依靠记忆(预训练权重)作答,容易产生<strong>幻觉 (Hallucination)</strong> 且无法获取最新信息;而 RAG 则赋予了模型<strong>“开卷考试”</strong>的能力——在回答问题前,先从外部知识库(如企业文档、互联网、医学指南)中检索相关信息,作为“参考资料”喂给模型,从而生成准确、可溯源且实时的回答。目前,RAG 已成为构建垂直领域 AI 应用(如法律、医疗助手)的主流范式。
! style="text-align: left; padding: 6px 0; border-bottom: 1px solid #f1f5f9; color: #64748b; font-weight: normal;" | 全称
+
        </p>
| style="padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-weight: 600; text-align: right;" | Retrieval-Augmented Generation
+
    </div>
|-
 
! style="text-align: left; padding: 6px 0; border-bottom: 1px solid #f1f5f9; color: #64748b; font-weight: normal;" | 核心价值
 
| style="padding: 6px 0; border-bottom: 1px solid #f1f5f9; text-align: right;" | 抑制幻觉、动态更新知识
 
|-
 
! style="text-align: left; padding: 6px 0; border-bottom: 1px solid #f1f5f9; color: #64748b; font-weight: normal;" | 知识源示例
 
| style="padding: 6px 0; border-bottom: 1px solid #f1f5f9; text-align: right;" | [[医学百科]] (yixue.com)
 
|-
 
! style="text-align: left; padding: 6px 0; color: #64748b; font-weight: normal;" | 应用领域
 
| style="padding: 6px 0; text-align: right;" | AI 诊疗决策、个体化用药
 
|}
 
</div>
 
  
'''检索增强生成'''(Retrieval-Augmented Generation, RAG)是一种结合了**外部知识库检索**与**大语言模型(LLM)生成**能力的混合人工智能框架。它通过在模型生成应答前,先从可靠的知识源(如结构化的[[医学百科]])中检索相关事实,并将其作为“上下文”输入给模型,从而显著提升生成内容的准确性与权威性。
+
    <div class="medical-infobox mw-collapsible mw-collapsed" style="width: 100%; max-width: 320px; margin: 0 auto 35px auto; border: 1.2px solid #bae6fd; border-radius: 12px; background-color: #ffffff; box-shadow: 0 8px 20px rgba(0,0,0,0.05); overflow: hidden;">
 +
       
 +
        <div style="padding: 15px; color: #1e40af; background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%); text-align: center; cursor: pointer;">
 +
            <div style="font-size: 1.2em; font-weight: bold; letter-spacing: 1.2px;">RAG</div>
 +
            <div style="font-size: 0.7em; opacity: 0.85; margin-top: 4px; white-space: nowrap;">Retrieval-Augmented Generation (点击展开)</div>
 +
        </div>
 +
       
 +
        <div class="mw-collapsible-content">
 +
            <div style="padding: 25px; text-align: center; background-color: #f8fafc;">
 +
                <div style="width: 100px; height: 100px; background-color: #e2e8f0; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 0.8em;">
 +
                   
 +
                </div>
 +
                <div style="font-size: 0.8em; color: #64748b; margin-top: 12px; font-weight: 600;">核心:检索 + 生成</div>
 +
            </div>
  
 +
            <table style="width: 100%; border-spacing: 0; border-collapse: collapse; font-size: 0.85em;">
 +
                <tr>
 +
                    <th colspan="2" style="padding: 8px 12px; background-color: #e0f2fe; color: #1e40af; text-align: left; font-size: 0.9em; border-top: 1px solid #bae6fd;">技术参数</th>
 +
                </tr>
 +
                <tr>
 +
                    <th style="text-align: left; padding: 6px 12px; background-color: #f8fafc; color: #475569; border-bottom: 1px solid #e2e8f0; width: 40%;">提出时间</th>
 +
                    <td style="padding: 6px 12px; border-bottom: 1px solid #e2e8f0; color: #0f172a;">2020 年 (NeurIPS)</td>
 +
                </tr>
 +
                <tr>
 +
                    <th style="text-align: left; padding: 6px 12px; background-color: #f8fafc; color: #475569; border-bottom: 1px solid #e2e8f0;">核心组件</th>
 +
                    <td style="padding: 6px 12px; border-bottom: 1px solid #e2e8f0; color: #0f172a;">向量数据库, LLM</td>
 +
                </tr>
 +
                <tr>
 +
                    <th style="text-align: left; padding: 6px 12px; background-color: #f8fafc; color: #475569; border-bottom: 1px solid #e2e8f0;">解决痛点</th>
 +
                    <td style="padding: 6px 12px; border-bottom: 1px solid #e2e8f0; color: #16a34a;"><strong>幻觉, 知识过时</strong></td>
 +
                </tr>
 +
                <tr>
 +
                    <th style="text-align: left; padding: 6px 12px; background-color: #f8fafc; color: #475569; border-bottom: 1px solid #e2e8f0;">关键技术</th>
 +
                    <td style="padding: 6px 12px; border-bottom: 1px solid #e2e8f0; color: #0f172a;">Vector Embeddings (嵌入)</td>
 +
                </tr>
 +
                <tr>
 +
                    <th style="text-align: left; padding: 6px 12px; background-color: #f8fafc; color: #475569;">典型应用</th>
 +
                    <td style="padding: 6px 12px; color: #1e40af;">Open Evidence, Bing Chat</td>
 +
                </tr>
 +
            </table>
 +
        </div>
 +
    </div>
  
 +
    <h2 style="background: #f1f5f9; color: #0f172a; padding: 10px 18px; border-radius: 0 6px 6px 0; font-size: 1.25em; margin-top: 40px; border-left: 6px solid #0f172a; font-weight: bold;">工作原理:三步走战略</h2>
 +
   
 +
    <p style="margin: 15px 0; text-align: justify;">
 +
        RAG 的运行流程可以形象地比喻为“先查资料,再写论文”。其标准流程包含三个核心阶段:
 +
    </p>
  
在“智慧医生”AI 诊疗系统中,RAG 是实现精准医疗决策的核心。由于医学领域对数据时效性(如最新的临床试验数据)和准确性要求极高,RAG 能够避免通用大模型常见的“幻觉”现象,确保每一条关于[[联合用药决策]]或[[新抗原筛选]]的建议都有据可查,实现诊疗逻辑的透明化与可追溯化。
+
    <div style="background-color: #f8fafc; border: 1px solid #e2e8f0; padding: 15px; border-radius: 8px; font-size: 0.95em;">
 +
        <ol style="margin: 0; padding-left: 20px; color: #334155;">
 +
            <li style="margin-bottom: 10px;"><strong>检索 (Retrieval):</strong> 当用户提问时,系统首先将问题转化为<strong>向量 (Vector)</strong>,然后在外部知识库(向量数据库)中搜索语义最相似的文档片段。</li>
 +
            <li style="margin-bottom: 10px;"><strong>增强 (Augmentation):</strong> 将检索到的“事实片段”与用户的原始问题拼接在一起,构建一个包含上下文的 Prompt(提示词)。
 +
                <br><span style="color: #64748b; font-size: 0.9em;"> ➤ 提示词示例:<em>"基于以下参考资料:[资料A, 资料B...],请回答用户的问题:[用户提问]"</em></span>
 +
            </li>
 +
            <li><strong>生成 (Generation):</strong> LLM 接收到这个增强后的提示词,像做阅读理解题一样生成答案,并注明引用来源。</li>
 +
        </ol>
 +
    </div>
  
== 技术实现与工作流 ==
+
    <h2 style="background: #f1f5f9; color: #0f172a; padding: 10px 18px; border-radius: 0 6px 6px 0; font-size: 1.25em; margin-top: 40px; border-left: 6px solid #0f172a; font-weight: bold;">技术路线之争:RAG vs. Fine-tuning</h2>
RAG 将静态的模型推理转化为动态的知识匹配过程,其核心流程如下:
+
   
 +
    <div style="background-color: #fff7ed; border-left: 5px solid #ea580c; padding: 15px 20px; margin: 20px 0; border-radius: 4px;">
 +
        <p style="margin: 0; text-align: justify; font-size: 0.95em; color: #334155;">
 +
            <strong>选型指南:</strong> 如果你需要模型学习一种“新的说话风格”或“特定任务格式”,用 <strong>Fine-tuning (微调)</strong>;如果你需要模型掌握“海量的新知识”或“实时更新的事实”,必须用 <strong>RAG</strong>。
 +
        </p>
 +
    </div>
  
<div style="text-align: center; margin: 30px 0; padding: 15px; background: #fdfdfd; border-top: 1px solid #eee; border-bottom: 1px solid #eee;">
+
    <div style="overflow-x: auto; margin: 20px auto;">
    <span style="font-family: 'Times New Roman', serif; font-size: 1.1em; font-weight: bold; color: #2563eb;">向量化索引 (yixue.com 知识沉淀)</span>
+
        <table style="width: 100%; border-collapse: collapse; border: 1.2px solid #cbd5e1; font-size: 0.9em; text-align: left;">
    <span style="margin: 0 15px; color: #94a3b8; font-size: 1.4em;"></span>
+
            <tr style="background-color: #f1f5f9; border-bottom: 2px solid #0f172a;">
    <span style="font-family: 'Times New Roman', serif; font-size: 1.1em; color: #d93025; font-weight: bold;">实时检索 (精准匹配临床问题)</span>
+
                <th style="padding: 12px; border: 1px solid #cbd5e1; color: #0f172a; width: 25%;">维度</th>
    <span style="margin: 0 15px; color: #94a3b8; font-size: 1.4em;"></span>
+
                <th style="padding: 12px; border: 1px solid #cbd5e1; color: #1e40af; width: 35%;">RAG (外挂知识库)</th>
    <span style="font-family: 'Times New Roman', serif; font-size: 1.2em; font-weight: bold; color: #059669;">约束生成 (基于证据的决策输出)</span>
+
                <th style="padding: 12px; border: 1px solid #cbd5e1; color: #475569;">Fine-tuning (微调模型)</th>
</div>
+
            </tr>
 +
            <tr>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; font-weight: 600;">知识更新</td>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; color: #16a34a;"><strong>实时 (Real-time)</strong><br>只需更新数据库,无需重训。</td>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; color: #e11d48;"><strong>静态 (Static)</strong><br>知识固化在权重中,更新需重训。</td>
 +
            </tr>
 +
            <tr>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; font-weight: 600;">可解释性</td>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; color: #16a34a;"><strong>高 (Verifiable)</strong><br>可提供引用来源,便于核查。</td>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1;">低 (Black Box)<br>无法准确知道知识来自哪。</td>
 +
            </tr>
 +
            <tr>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; font-weight: 600;">幻觉问题</td>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; color: #16a34a;">大幅降低</td>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1;">依然存在</td>
 +
            </tr>
 +
            <tr>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; font-weight: 600; background-color: #eff6ff;">成本</td>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; background-color: #eff6ff;">较低 (架构搭建)</td>
 +
                <td style="padding: 10px; border: 1px solid #cbd5e1; background-color: #eff6ff;">较高 (算力消耗)</td>
 +
            </tr>
 +
        </table>
 +
    </div>
  
== 医学 AI 场景下的性能客观评估 ==
+
    <h2 style="background: #f1f5f9; color: #0f172a; padding: 10px 18px; border-radius: 0 6px 6px 0; font-size: 1.25em; margin-top: 40px; border-left: 6px solid #0f172a; font-weight: bold;">生态系统:向量数据库的崛起</h2>
基于目前垂直领域大模型的研究标准,RAG 与传统微调(Fine-tuning)技术的特征对比分析如下。
+
   
 +
    <div style="display: flex; flex-wrap: wrap; gap: 20px; margin: 20px 0;">
 +
        <div style="flex: 1; min-width: 280px; background-color: #f0f9ff; border-left: 5px solid #1e40af; padding: 15px; border-radius: 4px;">
 +
            <h3 style="margin-top: 0; color: #1e40af; font-size: 1.1em;">Vector Database (向量数据库)</h3>
 +
            <p style="margin-bottom: 0; text-align: justify; font-size: 0.9em; color: #334155;">
 +
                RAG 的兴起直接带火了向量数据库赛道(如 Pinecone, Milvus, Chroma)。因为 RAG 的核心在于“检索”,而传统的关键词匹配(Keyword Match)无法理解语义,只有通过<strong>Embeddings (向量嵌入)</strong> 才能实现“意图理解”。
 +
            </p>
 +
        </div>
 +
    </div>
  
<div style="overflow-x: auto; width: 90%; margin: 25px auto;">
+
    <div style="font-size: 0.92em; line-height: 1.6; color: #1e293b; margin-top: 50px; border-top: 2px solid #0f172a; padding: 15px 25px; background-color: #f8fafc; border-radius: 0 0 10px 10px;">
{| class="wikitable" style="width: 100%; border-collapse: collapse; border: none; box-shadow: 0 4px 15px rgba(0,0,0,0.08); font-size: 0.95em; background-color: #fff;"
+
        <span style="color: #0f172a; font-weight: bold; font-size: 1.05em; display: inline-block; margin-bottom: 15px;">学术参考文献 [Academic Review]</span>
|+ style="font-weight: bold; font-size: 1.1em; margin-bottom: 12px; color: #2c3e50; text-align: center;" | RAG 在医学诊疗系统中的核心价值分析
+
       
|- style="background-color: #eaeff5; color: #2c3e50; border-bottom: 2px solid #dce4ec;"
+
        <p style="margin: 12px 0; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px;">
! style="text-align: left; padding: 12px 15px; width: 22%;" | 评估维度
+
            [1] <strong>Lewis P, et al. (2020).</strong> <em>Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks.</em> <strong>[[NeurIPS]]</strong>. <br>
! style="text-align: left; padding: 12px 15px;" | 临床客观表现与技术特征
+
            <span style="color: #475569;">[点评]:RAG 的奠基之作。文章首次提出将参数化记忆(Generator)与非参数化记忆(Retriever)结合,刷新了多项 QA 任务的 SOTA。</span>
|- style="border-bottom: 1px solid #f1f5f9;"
+
        </p>
| style="text-align: left; padding: 12px 15px; font-weight: 600; color: #546e7a; background-color: #fcfdfe;" | 幻觉抑制能力
 
| style="text-align: left; padding: 12px 15px; color: #374151; line-height: 1.6;" | RAG 强制模型在生成前审阅检索到的原文(如 NCCN 指南或百科条目)。这种“开卷考试”模式极大降低了模型自行编造医学术语或药量的风险。
 
|- style="border-bottom: 1px solid #f1f5f9;"
 
| style="text-align: left; padding: 12px 15px; font-weight: 600; color: #546e7a; background-color: #fcfdfe;" | 知识更新效率
 
| style="text-align: left; padding: 12px 15px; color: #374151; line-height: 1.6;" | 无需重新训练大模型。当 [[yixue.com]] 更新了最新的 [[卡匹色替]] 适应症或临床数据时,RAG 系统仅需更新外部索引即可实现诊疗逻辑的实时同步,响应速度达到秒级。
 
|- style="border-bottom: 1px solid #f1f5f9;"
 
| style="text-align: left; padding: 12px 15px; font-weight: 600; color: #546e7a; background-color: #fcfdfe;" | 结果可追溯性
 
| style="text-align: left; padding: 12px 15px; color: #374151; line-height: 1.6;" | 每个 AI 建议均可附带原始知识来源的超链接。这不仅为临床医生提供了审核依据,也符合当前监管机构对“可解释性 AI(XAI)”的合规性要求。
 
|- style="border-bottom: 1px solid #f1f5f9;"
 
| style="text-align: left; padding: 12px 15px; font-weight: 600; color: #546e7a; background-color: #fcfdfe;" | 复杂逻辑推理
 
| style="text-align: left; padding: 12px 15px; color: #374151; line-height: 1.6;" | 针对如 [[联合用药决策]] 等复杂任务,RAG 能同时检索多个维度的知识(如药物相互作用、分子突变特征),辅助大模型在多因素约束下输出最优解。
 
|}
 
</div>
 
  
== 核心关联概念 ==
+
        <p style="margin: 12px 0; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px;">
* **[[向量数据库]] (Vector Database)**:用于存储和快速检索知识片段(Chunk)的物理基础。
+
            [2] <strong>Gao Y, et al. (2023).</strong> <em>Retrieval-Augmented Generation for Large Language Models: A Survey.</em> <strong>[[arXiv preprint]]</strong>. <br>
* **[[医学百科]] (yixue.com)**:为系统提供权威、结构化的医学语料来源。
+
            <span style="color: #475569;">[点评]:全面综述了 RAG 的进化路线,包括 Naive RAG, Advanced RAG 和 Modular RAG 等变体。</span>
* **[[幻觉]] (Hallucination)**:大模型在缺乏事实依据时产生的虚假内容,是 RAG 重点治理的对象。
+
        </p>
* **[[私有医学大模型]]**:通过 RAG 技术加持,实现在特定医疗机构或领域的专业化运行。
 
  
== 参考文献 ==
+
        <p style="margin: 12px 0;">
* [1] Lewis P, et al. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. NeurIPS, 2020. (RAG 奠基性论文).
+
            [3] <strong>Kandpal N, et al. (2023).</strong> <em>Large Language Models Struggle to Learn Long-Tail Knowledge.</em> <strong>[[ICML]]</strong>. <br>
* [2] Topol EJ. High-performance medicine: the convergence of human and artificial intelligence. Nature Medicine, 2019.
+
            <span style="color: #475569;">[点评]:研究指出 LLM 很难记住长尾(罕见)知识,从理论上证明了外挂知识库(RAG)对专业领域的必要性。</span>
* [3] 聂凌虎等. 基于 yixue.com 知识库的 RAG 架构在 AI 诊疗决策中的应用路径研究. 北京微九九科技有限公司, 2025.
+
        </p>
* [4] Shuster K, et al. Retrieval Augmentation Reduces Hallucination in Conversation. Findings of EMNLP, 2021.
+
    </div>
* [5] 医疗大语言模型应用安全性评价准则(2025 修订版):检索增强生成与事实校验的一致性规范。
 
  
{{reflist}}
+
    <div style="margin: 40px 0; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 0.9em;">
 +
        <div style="background-color: #eff6ff; color: #1e40af; padding: 8px 15px; font-weight: bold; text-align: center; border-bottom: 1px solid #dbeafe;">
 +
            AI 架构 · 知识图谱
 +
        </div>
 +
        <table style="width: 100%; border-collapse: collapse; background-color: #ffffff;">
 +
            <tr style="border-bottom: 1px solid #f1f5f9;">
 +
                <td style="width: 85px; background-color: #f8fafc; color: #334155; font-weight: 600; padding: 10px 12px; text-align: right; vertical-align: middle;">核心组件</td>
 +
                <td style="padding: 10px 15px; color: #334155;">[[Vector Database]] (向量库) • [[Embeddings]] (嵌入) • [[Prompt Engineering]]</td>
 +
            </tr>
 +
            <tr style="border-bottom: 1px solid #f1f5f9;">
 +
                <td style="width: 85px; background-color: #f8fafc; color: #334155; font-weight: 600; padding: 10px 12px; text-align: right; vertical-align: middle;">竞争路线</td>
 +
                <td style="padding: 10px 15px; color: #334155;">[[Fine-tuning]] (微调) • [[Long Context Window]] (长上下文)</td>
 +
            </tr>
 +
            <tr>
 +
                <td style="width: 85px; background-color: #f8fafc; color: #334155; font-weight: 600; padding: 10px 12px; text-align: right; vertical-align: middle;">应用实例</td>
 +
                <td style="padding: 10px 15px; color: #334155;">[[Open Evidence]] (医疗) • [[Perplexity]] (搜索) • [[Chat with PDF]]</td>
 +
            </tr>
 +
        </table>
 +
    </div>
  
<div style="clear: both; margin-top: 40px; border: 1px solid #a2a9b1; background-color: #f8f9fa; border-radius: 4px; overflow: hidden;">
 
<div style="background-color: #dee2e6; text-align: center; font-weight: bold; padding: 6px; border-bottom: 1px solid #a2a9b1; color: #374151;">智慧医疗技术与 AI 核心算法导航</div>
 
{| style="width: 100%; background: transparent; border-spacing: 0; font-size: 0.85em;"
 
|-
 
! style="width: 15%; padding: 8px; background-color: #f1f5f9; text-align: right; border-bottom: 1px solid #fff;" | 核心算法
 
| style="padding: 8px; border-bottom: 1px solid #fff;" | [[RAG]] • [[提示词工程]] • [[思维链]] • [[知识图谱]] • [[多模态融合]]
 
|-
 
! style="width: 15%; padding: 8px; background-color: #f1f5f9; text-align: right; border-bottom: 1px solid #fff;" | 知识工程
 
| style="padding: 8px; border-bottom: 1px solid #fff;" | [[医学百科]] • [[向量化]] • [[文档切片]] • [[数据清洗]] • [[本体建模]]
 
|-
 
! style="width: 15%; padding: 8px; background-color: #f1f5f9; text-align: right;" | 临床输出
 
| style="padding: 8px;" | [[精准分型]] • [[联合用药建议]] • [[文献溯源]] • [[不良反应预警]]
 
|}
 
 
</div>
 
</div>
 
[[Category:医疗人工智能]]
 
[[Category:计算机科学]]
 
[[Category:精准医疗]]
 
[[Category:自然语言处理]]
 

2026年2月3日 (二) 07:38的最新版本

RAG(Retrieval-Augmented Generation,检索增强生成)是一种将预训练大语言模型(LLM)与外部知识检索系统相结合的混合 AI 架构。它由 Meta AI 的 Patrick Lewis 等人于 2020 年正式提出。传统的 LLM(如 ChatGPT)像是一个“闭卷考试”的学生,依靠记忆(预训练权重)作答,容易产生幻觉 (Hallucination) 且无法获取最新信息;而 RAG 则赋予了模型“开卷考试”的能力——在回答问题前,先从外部知识库(如企业文档、互联网、医学指南)中检索相关信息,作为“参考资料”喂给模型,从而生成准确、可溯源且实时的回答。目前,RAG 已成为构建垂直领域 AI 应用(如法律、医疗助手)的主流范式。

RAG
Retrieval-Augmented Generation (点击展开)
核心:检索 + 生成
技术参数
提出时间 2020 年 (NeurIPS)
核心组件 向量数据库, LLM
解决痛点 幻觉, 知识过时
关键技术 Vector Embeddings (嵌入)
典型应用 Open Evidence, Bing Chat

工作原理:三步走战略

RAG 的运行流程可以形象地比喻为“先查资料,再写论文”。其标准流程包含三个核心阶段:

  1. 检索 (Retrieval): 当用户提问时,系统首先将问题转化为向量 (Vector),然后在外部知识库(向量数据库)中搜索语义最相似的文档片段。
  2. 增强 (Augmentation): 将检索到的“事实片段”与用户的原始问题拼接在一起,构建一个包含上下文的 Prompt(提示词)。
    ➤ 提示词示例:"基于以下参考资料:[资料A, 资料B...],请回答用户的问题:[用户提问]"
  3. 生成 (Generation): LLM 接收到这个增强后的提示词,像做阅读理解题一样生成答案,并注明引用来源。

技术路线之争:RAG vs. Fine-tuning

选型指南: 如果你需要模型学习一种“新的说话风格”或“特定任务格式”,用 Fine-tuning (微调);如果你需要模型掌握“海量的新知识”或“实时更新的事实”,必须用 RAG

维度 RAG (外挂知识库) Fine-tuning (微调模型)
知识更新 实时 (Real-time)
只需更新数据库,无需重训。
静态 (Static)
知识固化在权重中,更新需重训。
可解释性 高 (Verifiable)
可提供引用来源,便于核查。
低 (Black Box)
无法准确知道知识来自哪。
幻觉问题 大幅降低 依然存在
成本 较低 (架构搭建) 较高 (算力消耗)

生态系统:向量数据库的崛起

Vector Database (向量数据库)

RAG 的兴起直接带火了向量数据库赛道(如 Pinecone, Milvus, Chroma)。因为 RAG 的核心在于“检索”,而传统的关键词匹配(Keyword Match)无法理解语义,只有通过Embeddings (向量嵌入) 才能实现“意图理解”。

       学术参考文献 [Academic Review]
       

[1] Lewis P, et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. NeurIPS.
[点评]:RAG 的奠基之作。文章首次提出将参数化记忆(Generator)与非参数化记忆(Retriever)结合,刷新了多项 QA 任务的 SOTA。

[2] Gao Y, et al. (2023). Retrieval-Augmented Generation for Large Language Models: A Survey. arXiv preprint.
[点评]:全面综述了 RAG 的进化路线,包括 Naive RAG, Advanced RAG 和 Modular RAG 等变体。

[3] Kandpal N, et al. (2023). Large Language Models Struggle to Learn Long-Tail Knowledge. ICML.
[点评]:研究指出 LLM 很难记住长尾(罕见)知识,从理论上证明了外挂知识库(RAG)对专业领域的必要性。

           AI 架构 · 知识图谱
核心组件 Vector Database (向量库) • Embeddings (嵌入) • Prompt Engineering
竞争路线 Fine-tuning (微调) • Long Context Window (长上下文)
应用实例 Open Evidence (医疗) • Perplexity (搜索) • Chat with PDF