--- id: ai.vector-db.index title: 向量数据库 type: index domain: ai stack: [vector-db] tags: [向量数据库, HNSW, pgvector, Chroma, Milvus] week: [5, 6] --- # 向量数据库 RAG 的检索基础设施。重点是讲清楚**距离度量、近似索引的召回和延迟取舍、带过滤的检索、选型理由**,而不是背某个产品的 API。项目里使用 pgvector(复用第 3~4 周学的 PostgreSQL)。 ## 学习路线 | 顺序 | 课程 | 级别 | 预计 | | --- | --- | --- | --- | | 1 | [向量检索原理:距离度量、暴力检索、HNSW / IVF 近似索引](01-ann-metrics.md) | 基础 | 2.5 小时 | | 2 | [向量库选型和 pgvector 实战:Chroma / pgvector / Milvus / Elasticsearch](02-selection-pgvector.md) | 进阶 | 3 小时 | ## 企业场景 - [多租户知识库的向量索引:隔离、过滤召回和增量更新](scenarios/multi-tenant-index.md) ## 面试题 - [向量数据库面试题](interview.md) ## 示例代码 - [examples/vector-stores](examples/vector-stores/):`chroma_demo.py`(内存模式,自带向量,元数据过滤、更新删除,和暴力检索对比召回率);`pgvector_demo.py`(HNSW 索引、过滤查询、执行计划,需要 `TEST_DATABASE_URL` 和 pgvector 扩展,否则跳过) ## 在 16 周计划中 - [第 5 周:RAG(一)](../../../plan/week05-rag-1.md)、[第 6 周:RAG(二)](../../../plan/week06-rag-2.md) ## 官方资料 产品更新很快,接口和参数以官方文档为准: - pgvector:https://github.com/pgvector/pgvector - Chroma:https://docs.trychroma.com/ - Milvus:https://milvus.io/docs - Elasticsearch 向量检索:https://www.elastic.co/docs/solutions/search/vector