Files
md-vector-db/md_docs/test-guide.md
T

36 lines
792 B
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.
# 向量数据库入门指南
## 什么是向量数据库
向量数据库是一种专门用于存储和检索向量嵌入的数据库。
## 为什么需要向量数据库
传统的数据库只能做精确匹配,而向量数据库可以做语义相似度搜索。
## 常用的向量数据库
- ChromaDB:轻量级,适合小项目
- Qdrant:高性能,适合生产环境
- Milvus:分布式,适合大规模数据
## ChromaDB 快速上手
安装 ChromaDB
```bash
pip install chromadb
```
创建 collection 并添加数据:
```python
import chromadb
client = chromadb.PersistentClient(path="./data")
collection = client.get_or_create_collection("my_docs")
collection.add(
documents=["这是第一篇文档", "这是第二篇文档"],
ids=["doc1", "doc2"],
)
```