Files
nexus/wiki/concepts/Indexing.md

48 lines
1.8 KiB
Markdown
Raw 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.
---
title: "Indexing"
type: concept
tags: [RAG, 向量数据库, 文档处理]
sources: [rag从入门到精通系列1-基础rag]
last_updated: 2025-01-16
---
## Definition
Indexing索引阶段是 RAG检索增强生成管道的第一阶段负责将外部文档转换为可检索的向量表示并存入向量数据库。
## Core Process
```
原始文档 → 文档加载器 → 文本切分(Split) → Embedding向量化 → 存入Vector Store
```
1. **文档加载Loading**:通过 LangChain 等框架的 Document Loader 从多种来源(网页/本地文件/数据库等)加载原始文档
2. **文本切分Splitting**:将长文档切分成适合 Embedding Model Context Window 的小块Split通常 512~4096 token
3. **向量化Embedding**:使用 Embedding Model如 BAAI/bge 系列)将文本块转换为固定长度的向量表示
4. **存入向量数据库**:将 Embedding Vector 存入 Vector Store如 Qdrant、Chroma、Milvus 等)
## Key Parameters
- **Chunk Size**:每个 Split 的 token 数量,需平衡上下文完整性和模型限制
- **Chunk Overlap**:相邻 Split 之间的重叠 token 数,防止信息在切分边界丢失
- **Embedding Model**:决定向量质量和检索效果的模型(如 BAAI、OpenAI text-embedding-3、BGE 等)
## Tools
- **LangChain**:提供 160+ 文档加载器和向量存储集成
- **LlamaIndex**:专注数据连接和索引的 LLM 应用框架
- **Qdrant**Rust 编写的开源向量数据库,支持过滤和混合检索
## Connections
- [[Indexing]] ← part_of ← [[RAG]]
- [[Indexing]] ← uses ← [[Embedding]]
- [[Indexing]] ← produces ← [[Vector-Store]]
- [[Indexing]] ← depends_on ← [[Context-Window]]
## Aliases
- Document Indexing
- Chunking
- 文档索引