An agent provenance memory compilation and retrieval method based on intermediate representation
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2026-04-29
- Publication Date
- 2026-08-04
AI Technical Summary
[0006]为解决现有智能体记忆系统中存在的检索不可控、缺乏溯源证据的缺点,本发明提出了一种基于中间表示(RAMem)的智能体溯源记忆编译与检索方法
(1)极高的结果可信度与审计溯源能力:本发明强制要求多流形结构中的每一条记忆都带有指向底层“原始证据归档”的链接。系统输出的不再仅仅是单薄的答案,而是“答案+支撑证据”的组合,解决了大模型产生幻觉和答案缺乏根据的问题,极大地提高了智能体记忆系统的可靠性。
Smart Images

Figure CN122507828A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, specifically to a method for compiling and retrieving the source memory of AI intelligent agents. Background Technology
[0002] With the widespread application of large language model (LLM) agents, these agents increasingly need persistent memory capabilities to answer factual, relational, temporal, and procedural questions based on past experience during long-term interactions. Existing persistent memory systems (such as classic RAG models or context engineering) typically combine text archiving, vector embedding retrieval, and partial structured graphs.
[0003] However, existing technical solutions have the following obvious drawbacks: 1. Over-reliance on retrieval-time processing: Existing semantic similarity-first retrieval systems often leave key decisions such as entity identity resolution, relationship and time constraint satisfaction, and evidence verification to the retrieval stage. This leads to a significant decrease in the reliability of pure semantic retrieval when faced with complex queries that have type constraints or require multi-step evidence combination.
[0004] 2. Lack of traceability and factual constraints: Existing systems often lack an auditable citation chain that can be traced back to the original experience records when returning answers. This makes it difficult for the system to verify whether candidate answers are truly supported by underlying evidence, easily leading to unfounded "illusionary" answers.
[0005] 3. Disconnect between memory storage and retrieval access: Traditional methods treat memory merely as a passive accumulation of data. As the memory grows, the lack of preprocessing for various query patterns (such as fact lookup, event timelines, and program rules) severely limits retrieval efficiency and accuracy. Summary of the Invention
[0006] To address the shortcomings of existing intelligent agent memory systems, such as uncontrollable retrieval and lack of source evidence, this invention proposes an intelligent agent source memory compilation and retrieval method based on intermediate representation (RAMem).
[0007] This invention proposes a memory intermediate representation (RAMem) architecture with source graph features, which transforms unstructured text into a controllable, multi-manifold structured memory, and combines it with a query compilation framework to achieve highly reliable source memory retrieval.
[0008] This invention views the writing and accessing of memory as a strongly coupled process, and the overall process is mainly divided into the "experience compilation stage" during writing and the "query compilation and execution stage" during retrieval.
[0009] A method for compiling and retrieving source memory of intelligent agents based on intermediate representations includes the following steps: Step 1: Receive the natural language experience stream, compile the natural language experience into a structured memory intermediate representation with source links, the memory intermediate representation includes the original evidence archive, registry and memory manifold, and complete the writing and compilation of memory; Step 2: Receive the user's natural language query and compile the natural language query into an explicit search intent; Step 3: Based on the explicit search intent, initialize the search state, and perform a stateful, multi-path evidence acquisition process on the memory manifold and the original evidence archive to collect supporting evidence; Step 4: Generate candidate answers using the acquired supporting evidence, and verify the consistency of evidence for the candidate answers based on the original evidence archive. Finally, output the search results containing natural language answers and source-tracing supporting evidence sets.
[0010] Step 1 includes: Step 1.1: Establish an original evidence archive, store the received natural language experience in its original form in the original evidence archive, and provide a stable source identity identifier for derived memory entries; Step 1.2: Parse the natural language experience into an intermediate form containing candidate entities and pattern elements, and match and align it with the system's existing entity registry and pattern registry. The entity registry is used to persist entity identities and types, and the pattern registry is used to normalize relationships and attribute keys. Step 1.3: Construct or update the memoized manifold using the parsed aligned objects; Step 1.4: During the construction of the memory manifold, all generated structured memory entries are required to retain the source links to the source data blocks in the original evidence archive.
[0011] Furthermore, the memory manifold in step 1.3 specifically includes four complementary manifold structures: a descriptive manifold, used to store the attributes and factual characteristics of entities; an associative manifold, used to store the relationship edge information between entities with type; a narrative manifold, used to store event record information with time anchors; and a procedural manifold, used to store the rule constraints or trigger information that guides retrieval and interpretation.
[0012] In step 2, the natural language query is compiled into an explicit retrieval intent, which specifically defines the following characteristic parameters: question type, expected answer form, anchor mention, time or contextual constraints, and evidence acquisition requirements.
[0013] Step 3 includes: Step 3.1: Based on the explicit search intent generated by compilation, initialize the search state, which records the currently parsed entities and pattern elements, accumulated evidence, candidate answers, and missing information of explicit tags; Step 3.2: The retrieval controller dynamically selects and combines the corresponding evidence acquisition paths based on the current retrieval status and explicit retrieval intent; the evidence acquisition paths include structured retrieval for descriptive and relational manifolds, event retrieval for narrative manifolds, rule retrieval for procedural manifolds, and plain text search for original evidence archives. Step 3.3: Each evidence acquisition path works in concert, continuously updating the retrieval status through iterative execution until the acquired evidence meets the evidence acquisition requirements in the explicit retrieval intent.
[0014] Step 4 includes: Step 4.1: Using the "expand first, verify later" strategy, preliminary candidate answers are generated based on the supporting evidence collected in Step 3; Step 4.2: Perform evidence-based verification checks on the candidate answers, including citation loop checks, source consistency checks, and compatibility checks with contextual constraints implicit in the query. Step 4.3: If the candidate answer fails the verification check or lacks supporting content from the original evidence archive, then suppress the candidate answer or trigger the controller to perform an additional round of evidence collection; Step 4.4: After accumulating a sufficient and verified set of evidence, construct the final natural language answer and output the natural language answer along with the supporting set of evidence that can be traced back to the original evidence archive.
[0015] In the technical solution of the present invention, step 1 is a writing and compilation method based on natural language experience to construct four memory manifolds (description, association, narrative, and procedure) that include archiving of original evidence and maintain traceability links; step 2 is a compilation process that transforms the user's natural language query into an explicit retrieval intent; step 3 is a stateful evidence acquisition mechanism that dynamically selects the search path among multiple memory manifolds based on the current retrieval state and intent; and step 4 is an answer construction method that performs consistency verification on candidate answers based on the underlying original evidence archive and outputs the results with supporting evidence sets.
[0016] The innovation of this invention is: 1. RAMem Memory Intermediate Representation Architecture: A novel memory storage architecture is proposed that decouples the natural language experience of an agent into an original evidence archive, a dual registry (entity and schema), and four memory manifolds (description, association, narrative, and procedure).
[0017] 2. Decoupled Compilation Mechanism for Read and Write: Innovatively, memory processing is divided into "experience-based compilation" during writing and "query intent compilation" during reading, reducing the real-time computational pressure during the retrieval phase.
[0018] 3. Stateful multi-path evidence acquisition: It can dynamically schedule retrieval paths for different memory manifolds in an explicit retrieval state loop, enabling collaborative querying of unstructured and structured data.
[0019] 4. Strongly constrained tracing and verification logic: The generation of structured memory and the output of the final answer are both subject to strict constraints and verification filtering of the underlying original archived evidence.
[0020] The advantages of this invention are: (1) Extremely high reliability of results and audit traceability: This invention mandates that each memory in the multi-manifold structure has a link to the underlying "original evidence archive". The system output is no longer just a simple answer, but a combination of "answer + supporting evidence", which solves the problems of illusion generated by large models and lack of basis for answers, and greatly improves the reliability of the intelligent agent memory system.
[0021] (2) Significant improvement in retrieval efficiency and quality: This invention moves the difficult tasks of entity parsing and structure extraction, which are required to be processed temporarily in traditional retrieval, to the "writing and compilation stage". Through the pre-built registry and four memory manifolds, the original text is transformed into a pre-prepared intermediate representation that can be directly queried, so that the retrieval system can focus on the selection and combination of evidence and avoid the huge overhead of repeatedly building memory structures from scratch.
[0022] (3) Fully supports complex multi-dimensional query intents: Existing single-vector retrieval systems have difficulty handling issues such as time context and logical rules. The architecture of this invention is designed with four memory manifolds, including descriptive, associative, narrative, and procedural aspects. Combined with "query intent compilation" and "stateful multi-path acquisition" technologies, the system can accurately handle extremely complex heterogeneous query requirements such as factual attributes, entity relationships, events with time anchors, and procedural rules. Attached Figure Description
[0023] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0024] The technical solution of the present invention will be further described below with reference to the accompanying drawings.
[0025] Example 1
[0026] like Figure 1This embodiment provides a method for agent-based source memory compilation and retrieval based on intermediate representation, which is an answer retrieval method for a question-answering system. This method compiles the experience received by the agent into an intermediate representation with source links, and introduces intent compilation and state control during retrieval to achieve highly reliable memory retrieval. The specific implementation steps of this method are as follows: Step 1: Receive the natural language experience stream and compile it into a structured memory intermediate representation with source links. This memory intermediate representation includes an archive of original evidence, a registry, and a memory manifold, completing the writing and compilation of the memory. This step is accomplished through the underlying write operator $M_t = Write(M_{t-1}, x_t)$, and specifically includes the following sub-steps: Step 1.1: Establish the original evidence archive. Store the received natural language experience stream $X = \{x_1, x_2,..., x_t\}$ in its original form in the original evidence archive, providing a stable source identity identifier (such as a unique hash value or block ID assigned by the system) for the derived memory entries.
[0027] Step 1.2: Parse the natural language experience into an intermediate form containing candidate entities and pattern elements, and match and align it with the system's existing entity registry and pattern registry. The entity registry is used to persist entity identities and types to eliminate ambiguity between entities with the same name; the pattern registry is used to standardize relations and attribute keys to ensure semantic consistency of the global graph representation.
[0028] Step 1.3: Construct or update the memory manifold using the parsed aligned objects. To support the structured representation of heterogeneous data, the memory manifold specifically includes four complementary manifold structures: (1) a descriptive manifold, which uses key-value storage or attribute table structure to store the attributes and factual features of entities; (2) an associative manifold, which is constructed as a directed relational graph to store the relationship edge information between entities with type; (3) a narrative manifold, which is constructed according to temporal serialization to store event record information with time anchors; and (4) a procedural manifold to store rule constraints or trigger information that guides retrieval and interpretation.
[0029] Step 1.4: During the construction of the memory manifold, all generated structured memory entries are required to retain provenance links pointing to source data blocks in the original evidence archive. This mechanism ensures that, in memory space, high-level semantic abstractions never physically deviate from the underlying original text.
[0030] Step 2: Receive the user's natural language query and compile the natural language query into an explicit search intent.
[0031] For unstructured query statements $q$ input by users, the system does not directly use vector similarity for matching calculations. Instead, it calls the intent compiler to parameterize it into an explicit retrieval intent set $I$. The explicit retrieval intent $I$ specifically defines the following feature parameters: question type, expected answer form, anchor references (a set of entities bound to the core concept of the query), time or context constraints (defining the time window and logical limitations of the retrieval), and evidence acquisition requirements (setting a threshold for judging the completeness of supporting materials).
[0032] Step 3: Based on the explicit search intent, initialize the search state and perform a stateful, multi-path evidence acquisition process on the memory manifold and original evidence archive to collect supporting evidence. Specifically, this includes: Step 3.1: Initialize the search state $S_0$ based on the explicit search intent $I$ generated by compilation. The search state is a dynamically updated data structure that records the currently parsed entities and pattern elements, accumulated evidence, candidate answers, and explicitly marked missing information (Information Gaps).
[0033] Step 3.2: The retrieval controller dynamically selects and combines corresponding evidence acquisition paths based on the current retrieval state $S_k$ and the explicit retrieval intent $I$. The evidence acquisition paths are designed as multiple concurrent and sequential operators, including: structured retrieval for descriptive and relational manifolds, event retrieval for narrative manifolds, rule retrieval for procedural manifolds, and plain text search for original evidence archives.
[0034] Step 3.3: Each evidence acquisition path works in concert, continuously updating the retrieval status through iterative execution (i.e., $S_{k+1} = Update(S_k, Evidence)$) until the system determines that the acquired evidence fully meets the evidence acquisition requirements in the explicit retrieval intent, and then ends this round of multi-path collection loop.
[0035] Step 4: Generate candidate answers using the acquired supporting evidence, and verify the consistency of evidence for the candidate answers based on the original evidence archive. Finally, output the retrieval results, which include the natural language answer and the source-tracing supporting evidence set. Mathematically, the retrieval process is ultimately mapped to the equation $(y,C)=Retrieve(q,M_t)$, specifically including the following operations: Step 4.1: Using the "Expand-then-verify" algorithm strategy, a preliminary candidate answer $y_{candidate}$ is generated based on the supporting evidence collected in Step 3.
[0036] Step 4.2: Perform evidence-based verification checks on the candidate answer $y_{candidate}$. The system verification process specifically includes: a citation loop check (verifying whether each factual statement in the answer carries a valid source pointer), a source consistency check (comparing the generated manifold features with the semantics of the source text), and a compatibility check with the contextual constraints implicit in the query.
[0037] Step 4.3: If the candidate answer fails the verification check or lacks supporting content from the original evidence archive, then suppress the candidate answer (block its output) or trigger the controller to perform an additional round of evidence collection (the state machine returns to the execution loop of Step 3).
[0038] Step 4.4: After accumulating a sufficient and verified evidence set $C$, construct the final natural language answer $y_{final}$, and output the natural language answer along with the supporting evidence set that can be traced back to the original evidence archive to the system caller, thus completely completing the closed loop of the entire lifecycle of source tracing retrieval.
[0039] Example 2
[0040] like Figure 1 This embodiment provides a method for intelligent agent source memory compilation and retrieval based on intermediate representation, which is an answer retrieval method for a question-answering system. The implementation steps are as follows: Step 1: Receive the natural language experience stream, compile the natural language experience into a structured memory intermediate representation (RAMem) with source links, and complete the writing and compilation of memory.
[0041] In this embodiment, the agent's memory construction is modeled as a write operation: $M_t = Write(M_{t-1}, x_t)$, where $M_{t-1}$ represents the memory state at the previous time step, $x_t$ represents the natural language experience received at the current time step $t$, and $M_t$ represents the updated memory intermediate representation (RAMem).
[0042] Specific implementation examples are as follows: Step 1.1 Establishing the Raw Evidence Archive: Suppose that at time $t$, the agent receives a user experience $x_t$: "Alice told me yesterday that she has a severe peanut allergy, her doctor is Dr. Smith, and they are scheduled for a follow-up appointment at the downtown hospital next Tuesday." The system first stores this raw text verbatim in the underlying "Raw Evidence Archive" and assigns it a globally unique source data block identifier (e.g., Chunk_ID_1024).
[0043] Step 1.2 Parsing Entities and Patterns: Using a pre-trained large-scale language model (such as Llama-3 or GPT-4) as the parser, candidate entities are extracted: "Alice", "Peanut", "Dr. Smith", and "City Center Hospital". The system queries the existing "Entity Registry". If "Alice" already exists, it is bound to its unique ID (e.g., Entity_001); if "Dr. Smith" is a new entity, it is assigned a new ID (e.g., Entity_089).
[0044] Step 1.3 Construct four memory manifolds: Write the parsed information into four different data manifolds: Descriptive manifold: Records entity attributes. For example, writing (Entity_001, has_allergy, "Peanut").
[0045] Associative manifold: Records the graph relationships between entities. For example, writing (Entity_001, has_doctor, Entity_089).
[0046] Narrative manifold: Records time-anchored events. For example, writing (Event_305: "Follow-up Examination", Time: "Next Tuesday", Location: "City Center Hospital", Participants: [Entity_001, Entity_089]).
[0047] Procedural manifold: Records rules and constraints. For example, writing (Rule_012: "IFplanning meals FOR Entity_001, THEN exclude peanuts").
[0048] Step 1.4 Constructing Source Links: All structured entries generated in the manifold above must be given a metadata pointer source_id: Chunk_ID_1024 to ensure that all extracted knowledge can be traced back to the original text.
[0049] Step 2: Receive the user's natural language query and compile the natural language query into an explicit search intent.
[0050] In this embodiment, the retrieval process is represented as: $(y, C) = Retrieve(q, M_t)$, where $q$ is the user's natural language query, $y$ is the output answer, and $C$ is the source tracing support evidence set.
[0051] Specific implementation example: Suppose that one day, a user asks the agent a query $q$: "I need to prepare dinner for Alice tomorrow, what should I pay attention to?".
[0052] The system will not directly use this statement to perform a fuzzy search in the vector database; instead, it will compile it into an explicit search intent. The compiled intent includes: Target entity anchor points: Entity_001 (Alice).
[0053] Question Type: Procedural / Constraint.
[0054] Context constraint: Cooking / Meals.
[0055] Evidence requirements: A specific list of unsuitable foods and their sources must be returned.
[0056] Step 3: Based on the explicit search intent, initialize the search state, and perform a stateful, multi-path evidence acquisition process on the memory manifold and the original evidence archive to collect supporting evidence.
[0057] Step 3.1 Initialize the state: The retrieval controller records the current known information as "Target: Alice, Task: Prepare dinner", and the missing information is "Dietary restrictions or related rules".
[0058] Step 3.2 Dynamic execution via multiple paths: Path 1 (Procedural Search): The controller first accesses the "Procedural Manifold" and matches Rule_012 (excluding peanuts) which is related to "Alice" and "prepare food".
[0059] Path 2 (Descriptive Retrieval): To supplement the details, the controller accesses the "descriptive manifold", queries Alice's properties, and obtains (Entity_001, has_allergy, "Peanut").
[0060] Path 3 (Original Text Backtracking): Based on the source pointer Chunk_ID_1024 that comes with the acquired rules and attributes, the controller retrieves the original experience text from the "Original Evidence Archive": "Alice told me yesterday that she has a severe peanut allergy...".
[0061] Step 3.3 State Update: The controller determines that the collected evidence has fully satisfied the "intent requirements" compiled in Step 2 and ends the evidence collection loop.
[0062] Step 4: Generate candidate answers using the acquired supporting evidence, verify the consistency of evidence for the candidate answers based on the original evidence archive, and finally output the search results.
[0063] Step 4.1 Candidate Answer Generation: Adopting a "expand first, then verify" strategy, the system combines a large language model to generate preliminary candidate answers based on the collected rules and attributes. For example, the large model might generate: "When preparing dinner for Alice, you can make a salad with nuts, but please absolutely avoid using peanuts because she is severely allergic to them."
[0064] Step 4.2 Evidence Consistency Verification: The system performs an evidence-centric verification check on the candidate answer: Reference closure and traceability consistency check: Verify whether "severe allergy" and "cannot use peanuts" are explicitly supported in the source data block Chunk_ID_1024 (verification passed).
[0065] Context constraint compatibility check: Verify whether the candidate answer fits the context of "preparing dinner" (verification passed).
[0066] Step 4.3 Exception Interception and Retry (Suppression / Recollection): Suppose that in Step 4.1, the large language model generated the suggestion "You can make her a Kung Pao Chicken (with a small amount of peanuts)" due to an "illusion". During the verification in Step 4.2, the system will find that this suggestion seriously conflicts with the procedural rule (Rule_012) and cannot be supported in the original archive. At this point, the system will suppress the incorrect answer and trigger the controller to regenerate a safe recipe suggestion.
[0067] Step 4.4 Output the final result: After accumulating a sufficient and verified set of evidence, the system constructs the final natural language answer and outputs it along with supporting materials that can be traced back to the original evidence archive.
[0068] Answer ($y$): "When preparing dinner for Alice, please be careful not to use any ingredients that contain peanuts, as she is severely allergic to peanuts."
[0069] Citation ($C$): [Evidence source: Chunk_ID_1024 - "Alice told me yesterday that she has a severe peanut allergy..."].
[0070] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.
Claims
1. A method for intelligent agent source tracing memory compilation and retrieval based on intermediate representation, characterized in that, Includes the following steps: Step 1: Receive the natural language experience stream, compile the natural language experience into a structured memory intermediate representation with source links, the memory intermediate representation includes the original evidence archive, registry and memory manifold, and complete the writing and compilation of memory; Step 2: Receive the user's natural language query and compile the natural language query into an explicit search intent; Step 3: Based on the explicit search intent, initialize the search state, and perform a stateful, multi-path evidence acquisition process on the memory manifold and the original evidence archive to collect supporting evidence; Step 4: Generate candidate answers using the acquired supporting evidence, and verify the consistency of evidence for the candidate answers based on the original evidence archive. Finally, output the search results containing natural language answers and source-tracing supporting evidence sets.
2. The method for intelligent agent source tracing memory compilation and retrieval based on intermediate representation according to claim 1, characterized in that, Step 1 includes: Step 1.1: Establish an original evidence archive, store the received natural language experience in its original form in the original evidence archive, and provide a stable source identity identifier for the derived memory entries; Step 1.2: Parse the natural language experience into an intermediate form containing candidate entities and pattern elements, and match and align it with the system's existing entity registry and pattern registry. The entity registry is used to persist entity identities and types, and the pattern registry is used to normalize relationships and attribute keys. Step 1.3: Construct or update the memoized manifold using the parsed aligned objects; Step 1.4: During the construction of the memory manifold, all generated structured memory entries are required to retain the source links to the source data blocks in the original evidence archive.
3. The method for intelligent agent source tracing memory compilation and retrieval based on intermediate representation according to claim 2, characterized in that, The memory manifold in step 1.3 specifically includes four complementary manifold structures: a descriptive manifold, used to store the attributes and factual characteristics of entities; and an associative manifold, used to store the type-related relationship edge information between entities. Narrative manifolds are used to store event logs with time anchors. A procedural manifold is used to store rule constraints or trigger information that guides retrieval and interpretation.
4. The method for intelligent agent source tracing memory compilation and retrieval based on intermediate representation according to claim 1, characterized in that, In step 2, the natural language query is compiled into an explicit search intent, which specifically defines the following characteristic parameters: question type, expected answer form, anchor mention, time or contextual constraints, and evidence acquisition requirements.
5. The method for intelligent agent source tracing memory compilation and retrieval based on intermediate representation according to claim 1, characterized in that, Step 3 includes: Step 3.1: Based on the explicit search intent generated by compilation, initialize the search state, which records the currently parsed entities and pattern elements, accumulated evidence, candidate answers, and missing information of explicit tags; Step 3.2: The retrieval controller dynamically selects and combines the corresponding evidence acquisition paths based on the current retrieval status and explicit retrieval intent; the evidence acquisition paths include structured retrieval for descriptive and relational manifolds, event retrieval for narrative manifolds, rule retrieval for procedural manifolds, and plain text search for original evidence archives. Step 3.3: Each evidence acquisition path works in concert, continuously updating the retrieval status through iterative execution until the acquired evidence meets the evidence acquisition requirements in the explicit retrieval intent.
6. The method for intelligent agent source tracing memory compilation and retrieval based on intermediate representation according to claim 1, characterized in that, Step 4 includes: Step 4.1: Using the "expand first, verify later" strategy, preliminary candidate answers are generated based on the supporting evidence collected in Step 3; Step 4.2: Perform evidence-based verification checks on the candidate answers, including citation loop checks, source consistency checks, and compatibility checks with contextual constraints implicit in the query. Step 4.3: If the candidate answer fails the verification check or lacks supporting content from the original evidence archive, then suppress the candidate answer or trigger the controller to perform an additional round of evidence collection; Step 4.4: After accumulating a sufficient and verified set of evidence, construct the final natural language answer and output the natural language answer along with the supporting set of evidence that can be traced back to the original evidence archive.