title, type, tags, sources, last_updated
| title |
type |
tags |
sources |
last_updated |
| RAG |
concept |
| rag |
| llm |
| retrieval-augmented-generation |
|
| RAG从入门到精通系列1:基础RAG |
| LLMs、RAG、AI Agent 三个到底什么区别? |
|
2026-04-15 |
Definition
Retrieval Augmented Generation(检索增强生成),一种将 LLM 与外部数据源(私有数据或最新数据)连接的通用方法。通过先检索后生成的模式,让 LLM 的回答有时事实依据。
Architecture
三阶段管道:
- Indexing(索引):文档加载→文本切分→向量化→存入向量数据库
- Retrieval(检索):问题向量化→按相似度检索 Top-k 知识片段
- 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
Sources