首页/AI/AI 应用速查/RAG 全流程(检索增强生成)

RAG 全流程(检索增强生成)

RAG 的五段流水线:解析 → 切分 → 向量化 → 检索(含重排)→ 生成。质量杠杆排序通常是:切分与重排 > 向量模型 > 生成模型。

AI 应用速查AI更新于 2026-10-12
五段load → split → embed → retrieve → generate
检索侧粗排 top50 → 重排 top5 是常用配比
生成侧上下文注入 + 引用要求 + 拒答约束
评测召回率与答案忠实度分开度量

端到端伪代码(结构示意)

端到端伪代码(结构示意)
docs = load_documents("docs/")                 # 解析
chunks = split(docs, size=800, overlap=100)    # 切分
store.add(embed(chunks), chunks)               # 向量化入库
hits = store.search(embed(query), top_k=50)    # 召回
hits = rerank(query, hits)[:5]                 # 重排
answer = llm(query, contexts=hits)             # 生成(带引用)
先修检索再换大模型:召回里没有的内容,再强的生成模型也变不出来。

易错点

  • 跳过评测直接调参,问题出在切分却在换模型
  • 把预算全花在生成模型上,召回质量没人管

数据来源与参考

  • Lewis et al. Retrieval-Augmented Generation(arXiv 2005.11401);RAG 工程通行实践

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌