---
title: "什么是 RAG (检索增强生成)？"
canonical: https://wavect.io/zh/glossary/rag/
language: zh
description: "在运行时把相关上下文注入 LLM Prompt，这些上下文来自你自己的数据，让模型基于你的知识回答，而不是它训练数据里的知识。"
image: "https://wavect.io/img/general/bak/open_graph_preview.jpg"
---

技术

# RAG

检索增强生成

在运行时把相关上下文注入 LLM Prompt，这些上下文来自你自己的数据，让模型基于你的知识回答，而不是它训练数据里的知识。

最近审阅: 2026-05-24 审阅人 [Kevin Riedl](/zh/team/kevin-riedl/) [wiki ↗](https://www.wikidata.org/wiki/Q139796365)

RAG 是让 LLM 能回答它没被训练过的数据相关问题的架构。机制很直接：拿用户的问题，从你的语料里检索出最相关的片段（通过向量检索、关键词检索，或一种混合），把它们塞进 Prompt，让模型回答。它是大多数有用的 [AI Agent](/zh/glossary/ai-agents/) 底下的那层接地。

RAG 之所以存在：用你的私有数据训练一个模型既贵又慢，而且你的数据一变它就过时。RAG 通过把数据当作运行时上下文来回避这一点。代价是检索质量成了瓶颈：一个拿到坏上下文的模型会自信地产出错误答案。

经典失败，举个实际例子：一家公司在它的帮助文档之上构建了一个客服机器人，Demo 令人印象深刻，然后在生产中它自信地引用了错误的退款政策。本能反应是怪模型并试一个更大的。答案依旧错，因为问题在上游：文档在句子中间被切块，Embedding 分不清「退款」和「退货」，而且没有一个 Reranker 把正确的段落推到顶部。换上更好的切块、混合搜索和一个 Reranker，同一个模型突然就显得聪明了。这个教训可以推广：当 RAG 出错时，几乎每次都先怀疑检索，再怀疑生成。

诚实的取舍以及 RAG 崩溃的地方：它在「能从少数几个段落里回答的查找式问题」上表现出色，而在「答案需要跨许多文档综合、或需要调和语料里的矛盾」时退化。到那个点上，你要的是一个更小的精选语料、一条逐步推理的 Agent 式流水线，或微调，而不是一个更大的检索器。不性感的真相是：80% 的工作是把检索做好（切块、Embedding、Rerank、混合搜索），20% 才是模型。把你的数据源封装成 [MCP](/zh/glossary/mcp/) 服务器会让检索层可移植，但不会让它变好。把 RAG 当作一键式功能来卖的供应商，卖的是容易的那一部分。

// FAQ

## 常见问题

### 为什么我的 RAG 系统给出错误答案？

几乎总是检索，而不是生成。切块差、Embedding 弱、没有 Rerank，或者一个模型无法消歧的语料。换模型，答案照样错；修好检索，同一个模型突然就显得聪明了。

### 向量检索还是混合检索？

在我们跑过的几乎每一个生产基准上，混合检索（向量 + 关键词 + Reranker）都胜过纯向量。纯向量检索在精确匹配、缩写词和生僻词上会失手。多接那一层管道是值得的。

### RAG 什么时候会崩？

当答案需要跨许多文档综合、当语料里有大量矛盾、或当用户的查询更偏概念而非查找式时。到那个点上，你要的是微调、一条 Agent 式流水线，或一个更小、更精选的语料，而不是一个更大的检索器。

相关术语

- [AI Agents](/zh/glossary/ai-agents/)
- [MCP](/zh/glossary/mcp/)

相关服务

- [人工智能](/zh/services/artificial-intelligence/)

相关案例研究

- [Quivr](/zh/case-studies/quivr/)
- [PromptID](/zh/case-studies/promptid/)

相关指南

- [如何为 MVP 选择技术栈](/zh/software-development-guide/how-to-choose-a-tech-stack-for-mvp/)

相关博客文章

- [RAG、微调与长上下文对比（2026）](/zh/blog/rag-vs-finetune-vs-longcontext-2026/)
- [面向欧盟的 RAG 生产就绪清单](/zh/blog/rag-production-readiness-checklist-eu/)

聊聊

## Structured Data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@id": "https://wavect.io/#organization",
      "@type": [
        "Organization",
        "ProfessionalService",
        "LocalBusiness"
      ],
      "employee": [
        {
          "@id": "https://wavect.io/team/kevin-riedl/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Kevin Riedl",
          "url": "https://wavect.io/team/kevin-riedl/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        },
        {
          "@id": "https://wavect.io/team/christof-jori/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Christof Jori",
          "url": "https://wavect.io/team/christof-jori/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        }
      ],
      "founder": [
        {
          "@id": "https://wavect.io/team/kevin-riedl/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Kevin Riedl",
          "url": "https://wavect.io/team/kevin-riedl/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        },
        {
          "@id": "https://wavect.io/team/christof-jori/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Christof Jori",
          "url": "https://wavect.io/team/christof-jori/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        }
      ],
      "legalRepresentative": [
        {
          "@id": "https://wavect.io/team/kevin-riedl/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Kevin Riedl",
          "url": "https://wavect.io/team/kevin-riedl/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        },
        {
          "@id": "https://wavect.io/team/christof-jori/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Christof Jori",
          "url": "https://wavect.io/team/christof-jori/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        }
      ],
      "name": "Wavect GmbH",
      "subjectOf": {
        "@id": "https://wavect.io/verified-claims.json#dataset",
        "@type": "Dataset",
        "creator": {
          "@id": "https://wavect.io/#organization",
          "@type": [
            "Organization",
            "ProfessionalService",
            "LocalBusiness"
          ]
        },
        "description": "A machine-readable registry of quantitative and qualitative claims published by Wavect, with review dates, localized page appearances and public third-party citations where available.",
        "inLanguage": "en",
        "isAccessibleForFree": true,
        "license": "https://creativecommons.org/licenses/by/4.0/",
        "name": "Wavect verified publication claims",
        "url": "https://wavect.io/verified-claims.json"
      },
      "url": "https://wavect.io/"
    },
    {
      "@id": "https://wavect.io/team/kevin-riedl/#person",
      "@type": "Person",
      "jobTitle": "Managing Director",
      "name": "Kevin Riedl",
      "sameAs": [
        "https://www.wikidata.org/wiki/Q139796365",
        "https://www.linkedin.com/in/wsdt",
        "https://github.com/wsdt"
      ],
      "url": "https://wavect.io/team/kevin-riedl/",
      "worksFor": {
        "@id": "https://wavect.io/#organization",
        "@type": [
          "Organization",
          "ProfessionalService",
          "LocalBusiness"
        ]
      }
    },
    {
      "@id": "https://wavect.io/team/christof-jori/#person",
      "@type": "Person",
      "jobTitle": "Managing Director",
      "name": "Christof Jori",
      "sameAs": [
        "https://www.wikidata.org/wiki/Q139796367",
        "https://www.linkedin.com/in/jocr77/",
        "https://github.com/jo-chris"
      ],
      "url": "https://wavect.io/team/christof-jori/",
      "worksFor": {
        "@id": "https://wavect.io/#organization",
        "@type": [
          "Organization",
          "ProfessionalService",
          "LocalBusiness"
        ]
      }
    },
    {
      "@id": "https://wavect.io/#website",
      "@type": "WebSite",
      "inLanguage": [
        "en",
        "de",
        "es",
        "zh"
      ],
      "name": "Wavect",
      "potentialAction": {
        "@type": "SearchAction",
        "query-input": "required name=search_term_string",
        "target": {
          "@type": "EntryPoint",
          "urlTemplate": "https://wavect.io/search/?q={search_term_string}"
        }
      },
      "publisher": {
        "@id": "https://wavect.io/#organization",
        "@type": [
          "Organization",
          "ProfessionalService",
          "LocalBusiness"
        ]
      },
      "url": "https://wavect.io/"
    }
  ]
}
```

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@id": "https://wavect.io/zh/glossary/rag/#term",
      "@type": "DefinedTerm",
      "alternateName": [],
      "description": "在运行时把相关上下文注入 LLM Prompt，这些上下文来自你自己的数据，让模型基于你的知识回答，而不是它训练数据里的知识。",
      "inDefinedTermSet": "https://wavect.io/zh/glossary/#termset",
      "name": "RAG",
      "termCode": "rag",
      "url": "https://wavect.io/zh/glossary/rag/"
    },
    {
      "@id": "https://wavect.io/zh/glossary/rag/#webpage",
      "@type": "WebPage",
      "about": {
        "@id": "https://wavect.io/#organization",
        "@type": [
          "Organization",
          "ProfessionalService",
          "LocalBusiness"
        ]
      },
      "author": {
        "@id": "https://wavect.io/team/kevin-riedl/#person",
        "@type": "Person",
        "name": "Kevin Riedl",
        "url": "https://wavect.io/team/kevin-riedl/"
      },
      "dateModified": "2026-05-24",
      "description": "在运行时把相关上下文注入 LLM Prompt，这些上下文来自你自己的数据，让模型基于你的知识回答，而不是它训练数据里的知识。",
      "headline": "RAG",
      "inLanguage": "zh",
      "isPartOf": {
        "@id": "https://wavect.io/#website",
        "@type": "WebSite"
      },
      "lastReviewed": "2026-05-24",
      "mainEntity": {
        "@id": "https://wavect.io/zh/glossary/rag/#term"
      },
      "mentions": [
        {
          "@id": "https://wavect.io/#organization",
          "@type": [
            "Organization",
            "ProfessionalService",
            "LocalBusiness"
          ]
        },
        {
          "@type": "Service",
          "name": "人工智能",
          "url": "https://wavect.io/zh/services/artificial-intelligence/"
        }
      ],
      "name": "RAG",
      "reviewedBy": {
        "@id": "https://wavect.io/team/christof-jori/#person",
        "@type": "Person",
        "name": "Christof Jori",
        "url": "https://wavect.io/team/christof-jori/"
      },
      "speakable": {
        "@type": "SpeakableSpecification",
        "cssSelector": [
          ".gls-single__h1",
          ".gls-single__tldr"
        ]
      },
      "url": "https://wavect.io/zh/glossary/rag/"
    },
    {
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "item": "https://wavect.io/zh/",
          "name": "首页",
          "position": 1
        },
        {
          "@type": "ListItem",
          "item": "https://wavect.io/zh/glossary/",
          "name": "技术、产品与合作模式术语表",
          "position": 2
        },
        {
          "@type": "ListItem",
          "item": "https://wavect.io/zh/glossary/rag/",
          "name": "RAG",
          "position": 3
        }
      ]
    }
  ]
}
```

```json
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "几乎总是检索，而不是生成。切块差、Embedding 弱、没有 Rerank，或者一个模型无法消歧的语料。换模型，答案照样错；修好检索，同一个模型突然就显得聪明了。"
      },
      "name": "为什么我的 RAG 系统给出错误答案？"
    },
    {
      "@type": "Question",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "在我们跑过的几乎每一个生产基准上，混合检索（向量 + 关键词 + Reranker）都胜过纯向量。纯向量检索在精确匹配、缩写词和生僻词上会失手。多接那一层管道是值得的。"
      },
      "name": "向量检索还是混合检索？"
    },
    {
      "@type": "Question",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "当答案需要跨许多文档综合、当语料里有大量矛盾、或当用户的查询更偏概念而非查找式时。到那个点上，你要的是微调、一条 Agent 式流水线，或一个更小、更精选的语料，而不是一个更大的检索器。"
      },
      "name": "RAG 什么时候会崩？"
    }
  ],
  "speakable": {
    "@type": "SpeakableSpecification",
    "cssSelector": [
      ".faq-question",
      ".faq-answer"
    ]
  }
}
```
