Skip to content

简单向量存储节点(Simple Vector Store node)#

使用简单向量存储节点在 n8n 的应用内存中存储和检索嵌入

🌐 Use the Simple Vector Store node to store and retrieve embeddings in n8n's in-app memory.

本页提供简单向量存储节点的参数以及更多资源的链接。

🌐 On this page, you'll find the node parameters for the Simple Vector Store node, and links to more resources.

Parameter resolution in sub-nodes

Sub-nodes behave differently to other nodes when processing multiple items using an expression.

Most nodes, including root nodes, take any number of items as input, process these items, and output the results. You can use expressions to refer to input items, and the node resolves the expression for each item in turn. For example, given an input of five name values, the expression {{ $json.name }} resolves to each name in turn.

In sub-nodes, the expression always resolves to the first item. For example, given an input of five name values, the expression {{ $json.name }} always resolves to the first name.

这个节点不同于 AI 内存节点

这里描述的简单向量存储不同于像 Simple Memory 这样的 AI 内存节点。

该节点在应用内存中创建一个 向量数据库

数据安全限制(Data safety limitations)#

在使用“简单向量存储”节点之前,了解其限制和工作原理至关重要。

🌐 Before using the Simple Vector Store node, it's important to understand its limitations and how it works.

/// 警告 n8n 建议仅在开发中使用 Simple Vector 存储。 ///

向量存储数据不持久(Vector store data isn't persistent)#

此节点仅将数据存储在内存中。所有数据在 n8n 重启时会丢失,在内存不足的情况下也可能被清除。

🌐 This node stores data in memory only. All data is lost when n8n restarts and may also be purged in low-memory conditions.

所有实例用户均可访问向量存储数据(All instance users can access vector store data)#

简单向量存储节点的内存键是全局的,不限定于单个工作流。

🌐 Memory keys for the Simple Vector Store node are global, not scoped to individual workflows.

这意味着实例的所有用户都可以通过添加一个简单向量存储节点并选择内存键来访问向量存储数据,而不考虑为原始工作流设置的访问控制。在使用简单向量存储节点导入数据时,请注意不要泄露敏感信息。

🌐 This means that all users of the instance can access vector store data by adding a Simple Vector Store node and selecting the memory key, regardless of the access controls set for the original workflow. Take care not to expose sensitive information when ingesting data with the Simple Vector Store node.

节点使用模式(Node usage patterns)#

你可以在以下模式下使用简单向量存储节点。

🌐 You can use the Simple Vector Store node in the following patterns.

作为常规应用使用用于插入和检索文档的节点(Use as a regular node to insert and retrieve documents)#

您可以将简单向量存储用作常规节点来插入或获取文档。这种模式将简单向量存储放在常规连接流程中,而不使用代理。

🌐 You can use the Simple Vector Store as a regular node to insert or get documents. This pattern places the Simple Vector Store in the regular connection flow without using an agent.

你可以在此模板的第2步中看到一个例子。

🌐 You can see an example of in step 2 of this template.

直接连接到 AI 代理作为工具(Connect directly to an AI agent as a tool)#

你可以将 Simple Vector Store 节点直接连接到 AI agenttool 连接器,以在回答查询时将向量存储用作资源。

🌐 You can connect the Simple Vector Store node directly to the tool connector of an AI agent to use a vector store as a resource when answering queries.

这里,连接将是:AI 代理(工具连接器)-> 简单向量存储节点。

🌐 Here, the connection would be: AI agent (tools connector) -> Simple Vector Store node.

使用检索器获取文档(Use a retriever to fetch documents)#

您可以将 Vector Store Retriever 节点与 Simple Vector Store 节点一起使用,从 Simple Vector Store 节点获取文档。这通常与 Question and Answer Chain 节点一起使用,以从向量存储中获取与给定聊天输入匹配的文档。

🌐 You can use the Vector Store Retriever node with the Simple Vector Store node to fetch documents from the Simple Vector Store node. This is often used with the Question and Answer Chain node to fetch documents from the vector store that match the given chat input.

一个连接流程示例(链接的示例使用了 Pinecone,但模式是相同的)可能是:问答链(检索器连接器)-> 向量存储检索器(向量存储连接器)-> 简单向量存储。

🌐 An example of the connection flow (the linked example uses Pinecone, but the pattern is the same) would be: Question and Answer Chain (Retriever connector) -> Vector Store Retriever (Vector Store connector) -> Simple Vector Store.

使用 Vector Store 问答工具回答问题(Use the Vector Store Question Answer Tool to answer questions)#

另一种模式使用 Vector Store Question Answer Tool 来总结结果并回答来自 Simple Vector Store 节点的问题。与其将 Simple Vector Store 直接连接为工具,这种模式使用一个专门设计来总结向量存储中数据的工具。

🌐 Another pattern uses the Vector Store Question Answer Tool to summarize results and answer questions from the Simple Vector Store node. Rather than connecting the Simple Vector Store directly as a tool, this pattern uses a tool specifically designed to summarizes data in the vector store.

在这种情况下,连接流程 看起来如下:AI 代理(工具连接器)-> 向量存储问答工具(向量存储连接器)-> 简单向量存储。

🌐 The connections flow in this case would look like this: AI agent (tools connector) -> Vector Store Question Answer Tool (Vector Store connector) -> Simple Vector store.

内存管理(Memory Management)#

简单向量存储实现了内存管理,以防止内存使用过量:

🌐 The Simple Vector Store implements memory management to prevent excessive memory usage:

  • 内存压力增加时自动清理旧的矢量存储
  • 移除长时间未访问的非活跃商店(时间可配置)。

配置选项(Configuration Options)#

你可以使用以下环境变量控制内存使用情况:

🌐 You can control memory usage with these environment variables:

变量 类型 默认值 描述
N8N_VECTOR_STORE_MAX_MEMORY 数字 -1 所有向量存储允许的最大内存(以 MB 为单位)(-1 表示不限制)。
N8N_VECTOR_STORE_TTL_HOURS 数字 -1 存储在非活动多少小时后被移除(-1 表示禁用 TTL)。

在 n8n Cloud 上,这些值分别预设为 100MB(约 8,000 个文档,取决于文档大小和元数据)和 7 天。对于自托管实例,这两个值的默认值都是 -1(没有内存限制或基于时间的清理)。

🌐 On n8n Cloud, these values are preset to 100MB (about 8,000 documents, depending on document size and metadata) and 7 days respectively. For self-hosted instances, both values default to -1(no memory limits or time-based cleanup).

节点参数(Node parameters)#

Operation Mode#

This Vector Store node has four modes: Get Many, Insert Documents, Retrieve Documents (As Vector Store for Chain/Tool), and Retrieve Documents (As Tool for AI Agent). The mode you select determines the operations you can perform with the node and what inputs and outputs are available.

Get Many#

In this mode, you can retrieve multiple documents from your vector database by providing a prompt. The prompt is embedded and used for similarity search. The node returns the documents that are most similar to the prompt with their similarity score. This is useful if you want to retrieve a list of similar documents and pass them to an agent as additional context.

Insert Documents#

Use insert documents mode to insert new documents into your vector database.

Retrieve Documents (as Vector Store for Chain/Tool)#

Use Retrieve Documents (As Vector Store for Chain/Tool) mode with a vector-store retriever to retrieve documents from a vector database and provide them to the retriever connected to a chain. In this mode you must connect the node to a retriever node or root node.

Retrieve Documents (as Tool for AI Agent)#

Use Retrieve Documents (As Tool for AI Agent) mode to use the vector store as a tool resource when answering queries. When formulating responses, the agent uses the vector store when the vector store name and description match the question details.

重新排序结果(Rerank Results)#

Enables reranking. If you enable this option, you must connect a reranking node to the vector store. That node will then rerank the results for queries. You can use this option with the Get Many, Retrieve Documents (As Vector Store for Chain/Tool) and Retrieve Documents (As Tool for AI Agent) modes.

获取多个参数(Get Many parameters)#

  • 内存键:选择或创建包含你想要查询的向量内存的键。
  • 提示:请输入搜索查询。
  • 限制:输入要从向量存储中获取的结果数量。例如,将其设置为 10 可获取十个最佳结果。

插入文档参数(Insert Documents parameters)#

  • 记忆键:选择或创建你要将向量记忆存储为的键。
  • 清除存储:使用此参数可以控制在插入数据之前是否清除此工作流对应记忆键的向量存储(已开启)。

检索文档(作为链/工具的向量存储)参数(Retrieve Documents (As Vector Store for Chain/Tool) parameters)#

  • 内存键:选择或创建包含你想要查询的向量内存的键。

检索文档(作为工具) (适用于 AI 代理)参数(Retrieve Documents (As Tool for AI Agent) parameters)#

  • 名称:向量存储的名称。
  • 描述:向大型语言模型(LLM)解释此工具的功能。具体而清晰的描述可以让大型语言模型更频繁地产生预期的结果。
  • 内存键:选择或创建包含你想要查询的向量内存的键。
  • 限制:输入要从向量存储中获取的结果数量。例如,将其设置为 10 可获取十个最佳结果。

模板和示例(Templates and examples)#

Template widget placeholder.

有关该服务的更多信息,请参阅 LangChains 的记忆向量存储文档

🌐 Refer to LangChains's Memory Vector Store documentation for more information about the service.

View n8n's Advanced AI documentation.