Skip to content

pkgs/store/vecstore

pkgs/store/vecstore 定义 vector similarity index,并提供精确内存索引和 HNSW approximate nearest-neighbor 实现。Agent memory 与 recall 使用它按 embedding 搜索相近内容。

Go API References

核心结构与实现

符号作用
Index定义 vector add、search、delete 和 index lifecycle。
Match表达匹配 ID、distance 与 metadata。
Memory / NewMemory提供进程内精确 vector search。
HNSW / NewHNSW提供 HNSW approximate index。
HNSWConfig配置 dimension、distance 与 graph parameters。
OpenHNSW从 Object Store 打开或创建持久化 HNSW index。
LoadHNSW / LoadHNSWWithOptions从 serialized stream 恢复 HNSW。
CosineDistance计算 cosine distance。

Ownership 边界

VecStore 不生成 embedding,也不决定模型、chunk 或 recall policy。Embedding dimension、normalization、resource ID、结果重排、object name 和保存时机属于调用方。