---
title: "Vector database — 向量数据库"
source: "https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93"
wiki: "systems-analysis.info/int"
article: "Vector_database_—_向量数据库"
language: "zh"
categories:
  - "Category:Chinese"
  - "Category:Large language models"
  - "Category:Machine learning"
revision_id: 8405
wiki_created_at: 2026-09-07T01:16:56Z
wiki_modified_at: 2026-09-07T01:16:56Z
downloaded_at: 2026-09-07T23:25:12Z
---

# Vector database — 向量数据库

**向量数据库**（Vector Databases）是专门用于处理非结构化数据的高维数值表示（向量）的存储和检索系统<sup>[\[1\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-cloudraft_whatis-1)</sup>。在大语言模型（LLM）的背景下，向量数据库能够实现高效的语义搜索，是现代人工智能系统（尤其是在 RAG 架构中）的关键组成部分。

与专注于精确匹配的传统关系型数据库不同，向量数据库专门从事近似最近邻（*Approximate Nearest Neighbor, ANN*）搜索，旨在高维空间中找到语义上相近的对象<sup>[\[2\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-qdrant_whatis-2)</sup>。

## 向量数据库基础

### Embeddings - 向量表示

**向量表示**（*embeddings*）是指将文本、图像、音频等数据类型以向量形式进行的数值化表示。其核心原则是，语义上相近的对象（例如，含义相似的词语）在此向量空间中的位置也相互靠近<sup>[\[3\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-lakefs_embeddings-3)</sup>。

现代的文本嵌入是使用基于 Transformer 架构的模型创建的，这些模型利用自注意力（*self-attention*）机制来理解上下文。对于大多数现代模型而言，这类表示的维度范围从 256 到 1024 维甚至更高<sup>[\[4\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-zilliz_embeddings-4)</sup>。

### 相似度度量

为了衡量向量之间的“距离”或相似度，使用了多种度量方法：

- **余弦相似度**（*cosine similarity*）：测量两个向量之间的夹角余弦值。这种方法对文本嵌入尤其有效，因为它关注向量的方向而非其大小<sup>[\[5\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-sahoo2025-5)</sup>。
- **欧几里得距离 (L2)**：空间中两点间的标准直线距离。
- **点积**（*dot product*）：与余弦相似度类似，但未经归一化<sup>[\[6\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-elastic_metrics-6)</sup>。

## 索引算法

为了在高维空间中实现快速搜索，向量数据库使用了专门的 ANN 算法。

### HNSW (Hierarchical Navigable Small World) - 分层可导航小世界

**HNSW** 算法采用了“小世界”网络的概念和多层级图结构。上层包含长距离链接，用于在空间中快速跳转（粗略搜索），而下层则包含短距离链接，用于精确定位近邻。HNSW 的时间复杂度为对数级 *O(log N)*，是大多数现代向量数据库的首选<sup>[\[7\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-hnsw_paper-7)</sup>。

### IVF (Inverted File) - 倒排文件

**IVF** 算法使用 k-means 聚类算法将向量空间划分为多个簇。搜索仅在有限数量的最近簇中进行，从而显著加快了处理速度。簇的数量通常选择为 √N，其中 N 是数据集中的向量总数<sup>[\[8\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-faiss_ivf-8)</sup>。

### LSH (Locality-Sensitive Hashing) - 局部敏感哈希

**LSH** 算法使用一组哈希函数，这些函数能够以高概率为相近的向量生成相同的哈希值。这使得相似的对象可以被快速地分组<sup>[\[9\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-datar2004-9)</sup>。

## 主流向量数据库

- **Pinecone**：一个完全托管的云原生向量数据库，采用 *serverless* 架构。
- **Qdrant**：一个用 Rust 编写的高性能数据库，支持高级过滤和 ACID 兼容事务。
- **Milvus**：一个可扩展的开源数据库，采用云原生架构。支持包括 GPU 加速在内的多种索引类型。
- **Weaviate**：一个开源向量数据库，提供 GraphQL API 并支持知识图谱。
- **Chroma**：一个轻量级开源数据库，专为快速原型设计和实验而优化。
- **FAISS**：由 Meta 开发的一个库，虽然不是一个完整的数据库，但为静态数据提供了高性能的索引算法。

## 与 LLM 的结合应用：RAG 架构

**检索增强生成（Retrieval-Augmented Generation, RAG）**是一种架构，其中 LLM 通过向量检索从外部知识库获取信息作为补充。RAG 系统包含两个主要组件<sup>[\[10\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-rag_lewis2020-10)</sup>：

1.  **检索器 (Retriever)**：该搜索组件使用向量数据库根据用户查询查找相关信息。
2.  **生成器 (Generator)**：一个 LLM，它利用原始查询和检索器找到的信息来生成答案。

为了实现 RAG 的高效运作，通常采用**混合搜索**——即结合语义（向量）搜索和词法（关键词，如 BM25）搜索，以确保结果更准确、更相关。

## 趋势与未来发展

向量数据库市场正在经历爆炸式增长，预计将从 2023 年的 19.8 亿美元增长到 2029 年的 71.3 亿美元（复合年增长率为 23.7%）<sup>[\[11\]](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_note-tbrc_market-11)</sup>。关键发展方向包括：

- **多模态系统：**支持在统一的向量空间中同时对文本、图像、音频和视频进行搜索。
- **自动优化：**利用ML自动选择最优的索引和参数。
- **边缘计算 (Edge computing)：**为移动和物联网（IoT）设备开发紧凑型解决方案。
- **量子计算**：有望实现相似度搜索的指数级加速。
- **神经形态芯片：**模拟大脑工作方式，以超低功耗执行搜索任务。

## 外部链接

- <a href="https://pinecone.io/" class="external text" rel="nofollow">Pinecone 官网</a>
- <a href="https://qdrant.tech/" class="external text" rel="nofollow">Qdrant 官网</a>
- <a href="https://milvus.io/" class="external text" rel="nofollow">Milvus 官网</a>
- <a href="https://weaviate.io/" class="external text" rel="nofollow">Weaviate 官网</a>

## 参考文献

- Malkov, Y.A.; Yashunin, D.A. (2016). *Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs*. <a href="https://arxiv.org/abs/1603.09320" class="external text" rel="nofollow">arXiv:1603.09320</a>.
- Johnson, J.; Douze, M.; Jégou, H. (2017). *Billion-Scale Similarity Search with GPUs*. <a href="https://arxiv.org/abs/1702.08734" class="external text" rel="nofollow">arXiv:1702.08734</a>.
- Datar, M. et al. (2004). *Locality-Sensitive Hashing Scheme Based on p-Stable Distributions*. <a href="http://www.mit.edu/~andoni/LSH/papers/vldb04.pdf" class="external text" rel="nofollow">SoCG 2004 paper</a>.
- Guo, N. et al. (2020). *ScaNN: Efficient Vector Similarity Search at Scale*. In: *Proc. ACM SIGKDD 2020*, pp. 1571-1580. <a href="https://dl.acm.org/doi/10.1145/3394486.3403339" class="external text" rel="nofollow">DOI:10.1145/3394486.3403339</a>.
- Lewis, P. et al. (2020). *Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks*. <a href="https://arxiv.org/abs/2005.11401" class="external text" rel="nofollow">arXiv:2005.11401</a>.
- Wang, X. et al. (2021). *Milvus: A Purpose-Built Vector Data Management System*. In: *SIGMOD 2021*. <a href="https://dl.acm.org/doi/10.1145/3448016.3457550" class="external text" rel="nofollow">DOI:10.1145/3448016.3457550</a>.
- Lee, J. et al. (2022). *OOD-DiskANN: Efficient and Scalable Graph ANNS for Out-of-Distribution Queries*. <a href="https://arxiv.org/abs/2211.12850" class="external text" rel="nofollow">arXiv:2211.12850</a>.
- Fan, D. et al. (2023). *Survey of Vector Database Management Systems*. <a href="https://arxiv.org/abs/2310.14021" class="external text" rel="nofollow">arXiv:2310.14021</a>.
- Ren, R. et al. (2024). *Survey of Filtered Approximate Nearest Neighbor Search over Vector-Scalar Hybrid Data*. <a href="https://arxiv.org/abs/2505.06501" class="external text" rel="nofollow">arXiv:2505.06501</a>.
- Zhao, H. et al. (2024). *Starling: An I/O-Efficient Disk-Resident Graph Index Framework for High-Dimensional Vector Similarity Search*. <a href="https://arxiv.org/abs/2401.02116" class="external text" rel="nofollow">arXiv:2401.02116</a>.
- Liu, Y. et al. (2025). *Memory-Efficient Similarity Search at Billion-Scale: A Taxonomy and Analysis of Vector Compression Techniques*. <a href="https://www.researchgate.net/publication/392469816" class="external text" rel="nofollow">ResearchGate preprint</a>.

## 注释

1.  <span id="cite_note-cloudraft_whatis-1">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-cloudraft_whatis_1-0) “What Is a Vector Database?”. *CloudRaft*. <a href="https://www.cloudraft.io/what-is-vector-database/" class="external autonumber" rel="nofollow">[1]</a></span>
2.  <span id="cite_note-qdrant_whatis-2">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-qdrant_whatis_2-0) “What is a Vector Database?”. *Qdrant Blog*. <a href="https://qdrant.tech/articles/what-is-vector-database/" class="external autonumber" rel="nofollow">[2]</a></span>
3.  <span id="cite_note-lakefs_embeddings-3">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-lakefs_embeddings_3-0) “What Are Vector Embeddings?”. *LakeFS*. <a href="https://lakefs.io/blog/vector-embeddings/" class="external autonumber" rel="nofollow">[3]</a></span>
4.  <span id="cite_note-zilliz_embeddings-4">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-zilliz_embeddings_4-0) “What are embeddings?”. *Zilliz*. <a href="https://zilliz.com/learn/what-are-embeddings/" class="external autonumber" rel="nofollow">[4]</a></span>
5.  <span id="cite_note-sahoo2025-5">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-sahoo2025_5-0) Sahoo, A., Maiti, J. «A Comparative Study of Similarity Metrics for Textual Embeddings». *arXiv:2501.01234*. <a href="https://arxiv.org/abs/2501.01234" class="external autonumber" rel="nofollow">[5]</a></span>
6.  <span id="cite_note-elastic_metrics-6">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-elastic_metrics_6-0) “Vector search and dense vector fields”. *Elastic*. <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/knn-search.html" class="external autonumber" rel="nofollow">[6]</a></span>
7.  <span id="cite_note-hnsw_paper-7">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-hnsw_paper_7-0) Malkov, Y. A., Yashunin, D. A. «Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs». *arXiv:1603.09320*. <a href="https://arxiv.org/abs/1603.09320" class="external autonumber" rel="nofollow">[7]</a></span>
8.  <span id="cite_note-faiss_ivf-8">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-faiss_ivf_8-0) “The index IVF”. *FAISS Wiki*. <a href="https://github.com/facebookresearch/faiss/wiki/The-index-IVF" class="external autonumber" rel="nofollow">[8]</a></span>
9.  <span id="cite_note-datar2004-9">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-datar2004_9-0) Datar, M., et al. «Locality-Sensitive Hashing Scheme Based on p-Stable Distributions». *Symposium on Computational Geometry*. <a href="http://www.mit.edu/~andoni/LSH/papers/vldb04.pdf" class="external autonumber" rel="nofollow">[9]</a></span>
10. <span id="cite_note-rag_lewis2020-10">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-rag_lewis2020_10-0) Lewis, P., et al. «Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks». *arXiv:2005.11401*. <a href="https://arxiv.org/abs/2005.11401" class="external autonumber" rel="nofollow">[10]</a></span>
11. <span id="cite_note-tbrc_market-11">[↑](https://systems-analysis.info/int/Vector_database_%E2%80%94_%E5%90%91%E9%87%8F%E6%95%B0%E6%8D%AE%E5%BA%93#cite_ref-tbrc_market_11-0) “Vector Database Global Market Report 2024”. *The Business Research Company*. <a href="https://www.thebusinessresearchcompany.com/report/vector-database-global-market-report" class="external autonumber" rel="nofollow">[11]</a></span>
