向量最近邻节点
概述
Vector KNN节点接收一个向量嵌入并搜索K个相似向量。
概述
向量K最近邻(KNN)节点用于对存储在已配置向量数据库集成中的向量执行k最近邻搜索。它接收一个向量并返回k个最接近的向量及其对应的数据。
该节点在处理如Pinecone等向量数据库时非常有用,您可能希望找到数据库中与给定输入向量最相似的向量。
- 输入
- 输出
- 编辑器设置
输入项
标题 | 数据类型 | 描述 | 默认值 | 备注 |
---|---|---|---|---|
Vector | vector | The vector to find the nearest neighbors for. | (required) | The input will be coerced into a vector if it is not a vector. |
Integration | string | The name of the vector database integration to use. | (optional) | Only required if Use Integration Input is enabled in the editor settings. |
K | number | The number of nearest neighbors to find. | (optional) | Only required if Use K Input is enabled in the editor settings. |
Collection ID | string | The 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. |
输出
标题 | 数据类型 | 描述 | 备注 |
---|---|---|---|
Results | any[] | The k nearest neighbors to the input vector, along with their corresponding data. | If the value is not found, this port is not ran. |
编辑器设置
设置 | 描述 | 默认值 | 使用输入切换 | 输入数据类型 |
---|---|---|---|---|
Integration | The name of the vector database integration to use. | (empty) | Yes | string |
K | The number of nearest neighbors to find. | 10 | Yes | number |
Collection ID | The ID of the collection in the vector database to search for the nearest neighbors. | (empty) | Yes | string |
示例1:在Pinecone数据库中查找向量的最近邻
- 创建一个文本节点,其中包含您想要搜索最近邻的文本。
- 将文本节点连接到Get Embedding Node,将文本转换为向量。
- 创建一个Vector KNN节点,并将Vector节点连接到其
Vector
输入。将Integration
设置为pinecone
,K
设置为10
,并将Collection ID
设置为您Pinecone集合的ID。 - 运行图形。Vector KNN节点应输出Pinecone集合中输入向量的10个最近邻。
错误处理
如果输入向量不是向量类型,或者找不到指定的向量数据库集成,Vector KNN节点将抛出错误。如果在向量数据库中找不到指定的集合ID,该节点将返回空数组。
常见问题
问:我可以将Vector KNN节点与其他向量数据库集成一起使用吗?
A: 是的,您可以将Vector KNN节点与Rivet支持的任何向量数据库集成(如Pinecone)一起使用。您只需在节点的Integration
设置中指定集成的名称即可。
问:我可以一次性查找多个向量的最近邻吗?
A: 不,Vector KNN节点一次只能查找单个向量的最近邻。如果您需要查找多个向量的最近邻,则需要使用多个Vector KNN节点,每个向量对应一个节点。