跳至主要内容

向量最近邻节点

概述

Vector KNN节点接收一个向量嵌入并搜索K个相似向量。

Chat Node Screenshot

概述

向量K最近邻(KNN)节点用于对存储在已配置向量数据库集成中的向量执行k最近邻搜索。它接收一个向量并返回k个最接近的向量及其对应的数据。

该节点在处理如Pinecone等向量数据库时非常有用,您可能希望找到数据库中与给定输入向量最相似的向量。

输入项

标题数据类型描述默认值备注
VectorvectorThe vector to find the nearest neighbors for.(required)The input will be coerced into a vector if it is not a vector.
IntegrationstringThe name of the vector database integration to use.(optional)Only required if Use Integration Input is enabled in the editor settings.
KnumberThe number of nearest neighbors to find.(optional)Only required if Use K Input is enabled in the editor settings.
Collection IDstringThe ID of the collection in the vector database to search for the nearest neighbors.(optional)Only required if Use Collection ID Input is enabled in the editor settings.

示例1:在Pinecone数据库中查找向量的最近邻

  1. 创建一个文本节点,其中包含您想要搜索最近邻的文本。
  2. 将文本节点连接到Get Embedding Node,将文本转换为向量。
  3. 创建一个Vector KNN节点,并将Vector节点连接到其Vector输入。将Integration设置为pineconeK设置为10,并将Collection ID设置为您Pinecone集合的ID。
  4. 运行图形。Vector KNN节点应输出Pinecone集合中输入向量的10个最近邻。

Vector KNN Node Example 1

错误处理

如果输入向量不是向量类型,或者找不到指定的向量数据库集成,Vector KNN节点将抛出错误。如果在向量数据库中找不到指定的集合ID,该节点将返回空数组。

常见问题

问:我可以将Vector KNN节点与其他向量数据库集成一起使用吗?

A: 是的,您可以将Vector KNN节点与Rivet支持的任何向量数据库集成(如Pinecone)一起使用。您只需在节点的Integration设置中指定集成的名称即可。

问:我可以一次性查找多个向量的最近邻吗?

A: 不,Vector KNN节点一次只能查找单个向量的最近邻。如果您需要查找多个向量的最近邻,则需要使用多个Vector KNN节点,每个向量对应一个节点。

另请参阅