简单向量存储节点#
¥Simple Vector Store node
使用“简单向量存储”节点在 n8n 的应用内内存中存储和检索 embeddings。
¥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.
This node is different from AI memory nodes
此处描述的简单向量存储与 Simple Memory 等 AI 内存节点不同。
¥The simple vector storage described here is different to the AI memory nodes such as Simple Memory.
此节点会在应用内存中创建一个 矢量数据库。
¥This node creates a vector database in the app memory.
数据安全限制#
¥Data safety limitations
在使用“简单向量存储”节点之前,了解其限制和工作原理至关重要。
¥Before using the Simple Vector Store node, it's important to understand its limitations and how it works.
Warning
n8n 建议仅在开发环境中使用 Simple Vector 存储。
¥n8n recommends using Simple Vector store for development use only.
向量存储数据不持久#
¥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
你可以将简单向量存储节点作为常规节点用于插入或获取文档。此模式将 Simple 向量存储置于常规连接流程中,无需使用代理。
¥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 向量存储节点直接连接到 AI 代理 的 tool 连接器,以便在响应查询时使用向量存储作为资源。
¥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 代理(工具连接器)-> Simple 向量存储节点。
¥Here, the connection would be: AI agent (tools connector) -> Simple Vector Store node.
使用检索器获取文档#
¥Use a retriever to fetch documents
你可以将 Vector Store 检索器 节点与 Simple Vector Store 节点配合使用,从 Simple Vector Store 节点获取文档。这通常与 Question and Answer 链 节点一起使用,用于从向量存储中获取与给定聊天输入匹配的文档。
¥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,但模式相同)如下所示:问答链(检索器连接器)-> 向量存储检索器(向量存储连接器)-> Simple 向量存储。
¥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 问答工具 来汇总来自 Simple 向量存储节点的结果并回答问题。此模式并非直接连接 Simple 向量存储作为工具,而是使用专门用于汇总向量存储中数据的工具。
¥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 代理(工具连接器)-> Vector Store 问答工具(Vector Store 连接器)-> Simple Vector Store。
¥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:
- 内存压力增加时自动清理旧的矢量存储
¥Automatically cleans up old vector stores when memory pressure increases
- 移除长时间未访问的非活跃商店(时间可配置)。
¥Removes inactive stores that haven't been accessed for a configurable amount of time
配置选项#
¥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
- 内存键:选择或创建一个包含要查询的向量内存的键。
¥Memory Key: Select or create the key containing the vector memory you want to query.
- 提示:输入搜索查询。
¥Prompt: Enter the search query.
- 限制:输入要从向量存储中检索的结果数量。例如,将其设置为
10以获取十个最佳结果。
¥Limit: Enter how many results to retrieve from the vector store. For example, set this to 10 to get the ten best results.
插入文档参数#
¥Insert Documents parameters
- 内存键:选择或创建一个用于存储向量内存的键。
¥Memory Key: Select or create the key you want to store the vector memory as.
- 清除存储:使用此参数控制是否在插入数据之前清除此工作流中给定内存键的向量存储(已启用)。
¥Clear Store: Use this parameter to control whether to wipe the vector store for the given memory key for this workflow before inserting data (turned on).
检索文档(作为链/工具的向量存储)参数#
¥Retrieve Documents (As Vector Store for Chain/Tool) parameters
- 内存键:选择或创建一个包含要查询的向量内存的键。
¥Memory Key: Select or create the key containing the vector memory you want to query.
检索文档(作为工具) (适用于 AI 代理)参数#
¥Retrieve Documents (As Tool for AI Agent) parameters
- 名称:向量存储的名称。
¥Name: The name of the vector store.
- 描述:向 LLM 解释此工具的功能。良好的、具体的描述有助于 LLM 更频繁地生成预期结果。
¥Description: Explain to the LLM what this tool does. A good, specific description allows LLMs to produce expected results more often.
- 内存键:选择或创建一个包含要查询的向量内存的键。
¥Memory Key: Select or create the key containing the vector memory you want to query.
- 限制:输入要从向量存储中检索的结果数量。例如,将其设置为
10以获取十个最佳结果。
¥Limit: Enter how many results to retrieve from the vector store. For example, set this to 10 to get the ten best results.
模板和示例#
¥Templates and examples
相关资源#
¥Related resources
有关服务的更多信息,请参阅 LangChains 的 Memory Vector Store 文档。
¥Refer to LangChains's Memory Vector Store documentation for more information about the service.
View n8n's Advanced AI documentation.