Auto-sync

This commit is contained in:
2026-04-15 15:02:52 +08:00
parent bb2f9b2b3a
commit d3e7fcf81f
71 changed files with 2549 additions and 0 deletions

43
wiki/concepts/RAG.md Normal file
View File

@@ -0,0 +1,43 @@
---
title: "RAG"
type: concept
tags: [rag, llm, retrieval-augmented-generation]
sources: ["RAG从入门到精通系列1基础RAG", "LLMs、RAG、AI Agent 三个到底什么区别?"]
last_updated: 2026-04-15
---
## Definition
Retrieval Augmented Generation检索增强生成一种将 LLM 与外部数据源(私有数据或最新数据)连接的通用方法。通过先检索后生成的模式,让 LLM 的回答有时事实依据。
## Architecture
三阶段管道:
1. **Indexing索引**:文档加载→文本切分→向量化→存入向量数据库
2. **Retrieval检索**:问题向量化→按相似度检索 Top-k 知识片段
3. **Generation生成**:问题+知识片段→PromptTemplate→LLM 生成答案
## Key Components
| 组件 | 作用 | 示例工具 |
|------|------|---------|
| Document Loader | 加载外部文档 | LangChain 160+ 加载器 |
| Text Splitter | 切分文档为 Split | RecursiveCharacterTextSplitter |
| Embedding Model | 文本→向量 | BAAI BGE 系列 |
| Vector Store | 存储+相似度检索 | Qdrant、Pinecone、Chroma |
| LLM | 答案生成 | GPT-4、Claude、Qwen |
## Technical Details
- Embedding Model Context Window 通常 512~8192 token需将长文档切分成满足长度限制的 Split
- 相似度衡量方法:余弦相似度、点积、欧氏距离等
- Retriever 可通过 LangChain 的 Retriever 接口统一抽象
## Related Concepts
- [[LLM]]RAG 的生成层载体
- [[Embedding]]RAG 的核心技术,将文本转为数值表示
- [[向量数据库]]RAG 的存储层
- [[AI知识库]]RAG 的上层应用形态
- [[Indexing]]RAG 第一阶段
- [[Retrieval]]RAG 第二阶段
- [[Generation]]RAG 第三阶段
## Sources
- [[RAG从入门到精通系列1基础RAG]]
- [[LLMs、RAG、AI Agent 三个到底什么区别?]]