Files

37 lines
1020 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
tags: [rag, llm, search, embedding]
---
## RAG 检索增强生成
RAG(Retrieval-Augmented Generation)是一种将外部知识库与大语言模型结合的技术范式。
## RAG 的核心流程
### 1. 索引阶段(Indexing)
- 加载文档(Document Loader)
- 文本分块(Chunking)
- 向量化(Embedding)
- 存入向量数据库(Indexer)
### 2. 检索阶段(Retrieval)
- 用户查询向量化
- 向量相似度搜索
- 返回 Top-K 相关文档
### 3. 生成阶段(Generation)
- 将检索结果注入 Prompt
- LLM 基于上下文生成回答
## 混合检索
结合语义搜索(向量相似度)和关键词搜索(BM25),取长补短:
- 语义搜索:理解用户意图,找到表述不同但意思相近的内容
- 关键词搜索:精确匹配专业术语和专有名词
## 向量数据库选型
- **Milvus**:分布式,适合大规模生产环境
- **Chroma**:轻量级,适合原型开发
- **内存实现**:最简单,适合小规模和个人项目