AI memory automatic integration method and system based on semantic clustering

By using an AI memory automatic integration method based on semantic clustering, the problems of memory duplication and difficulty in fusion in existing technologies are solved, achieving efficient and structured AI memory management, and improving memory utilization efficiency and system stability.

CN123030615APending Publication Date: 2026-11-03SHENZHEN LUOSHU INTELLIGENT COMPUTING TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611218474.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-12
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

Existing AI memory management solutions lack the ability to actively organize long-term accumulated memories, resulting in the repetition of memory information under the same topic, making it difficult to automatically merge them, and failing to effectively link information that is semantically similar but has no entity relationship, leading to low memory utilization efficiency.

Method used

An AI-based automatic memory integration method based on semantic clustering is adopted. Through seed memory collection, semantic similarity search, candidate cluster construction, large language model decision and decision verification, the method realizes the active integration and structured storage of discrete memories, and retains source information by combining integration lifeline records.

Benefits of technology

It improves the accuracy and efficiency of AI memory management, reduces redundant memory storage, enables the automatic fusion of different expressions of the same fact, and ensures system stability and traceability through a multi-layered fault-tolerance mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123030615A_ABST
    Figure CN123030615A_ABST
Patent Text Reader

Abstract

The application discloses an AI memory automatic integration method and system based on semantic clustering, and relates to the technical field of artificial intelligence. The method comprises the following steps: collecting seed memories and recently accessed memories within a preset time window; generating a seed memory vector based on an embedding model, and obtaining candidate neighbor memories through semantic similarity search; constructing candidate clustering clusters according to a similarity threshold, a memory state and a scope constraint; inputting the candidate clustering clusters into a large language model for integration judgment, and outputting integration or skip decisions; performing structured verification and fault tolerance processing on the decision results; generating a structured long-term memory according to effective integration decisions, archiving original memories, and establishing an integration life line record; and constructing functional modules of the system based on the above method. The application can realize automatic aggregation and structured management of discrete AI memories, reduce repeated memories, improve memory utilization efficiency, and ensure the traceability and reliability of the integration process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, specifically to an AI memory automatic integration method and system based on semantic clustering. Background Technology

[0002] With the development of Large Language Models (LLM) and AI Agent technologies, artificial intelligence systems are gradually evolving from single-turn interaction modes to intelligent agent modes with long-term memory capabilities. In application scenarios such as meeting assistants, personal knowledge management, and work collaboration, AI agents need to continuously extract information with long-term value from multiple conversations, meeting minutes, and task execution processes, and provide users with continuous intelligent services based on historical information. Currently, existing AI memory management solutions mainly adopt the Retrieval Augmentation (RAG) method based on vector retrieval, which converts user dialogues or meeting content into vector embeddings and stores them in a vector database. When a user queries, relevant memory fragments are returned through vector similarity matching. However, this type of solution mainly focuses on the retrieval and retrieval of memory content, lacking the ability to actively organize long-term accumulated memory. This results in memory information under the same topic existing repeatedly in the form of multiple discrete entries, and similar memories generated at different times cannot be automatically merged. At the same time, it is easy to return a large amount of nearly duplicate content during the retrieval process, occupying model context space and reducing the efficiency of long-term memory utilization.

[0003] On the other hand, some existing solutions achieve structured memory management by constructing knowledge graphs. However, these solutions typically rely on predefined entity relationship models and fixed data patterns, requiring the design of knowledge graph structures for specific domains. This makes it difficult to adapt to the personalized memory needs of different users and project scenarios. Furthermore, for information such as user preferences and experience summaries that are semantically similar but lack clear entity relationships, effective association is difficult to achieve. In addition, when multiple memories exhibit partial consistency, partial conflict, or different levels of expression, existing technologies often lack intelligent judgment mechanisms. They cannot determine whether multiple memories belong to the same fact, nor can they retain information about the original memory source during the integration process, resulting in a lack of traceability in the integrated memories.

[0004] Therefore, for the large number of discrete memories generated during the long-term operation of AI Agents, there is an urgent need for a method and system that can automatically discover similar memories based on semantic relationships, form candidate clusters, and combine intelligent decision-making mechanisms to determine whether memories need to be integrated, so as to realize the automatic organization, structured storage and source tracking of long-term memories, and improve the accuracy and effectiveness of AI Agent memory management. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides an AI-based automatic memory integration method and system based on semantic clustering to solve the problems mentioned in the background.

[0006] To achieve the above objectives, the present invention provides the following technical solution:

[0007] In a first aspect, the present invention provides an AI memory automatic integration method based on semantic clustering, comprising the following steps:

[0008] S1. Seed memory acquisition: Obtain candidate seed memories and recently accessed memories from a preset time window, and filter the acquired raw memories according to the memory scope to obtain a set of memories to be processed that meet the integration conditions.

[0009] S2. Semantic similarity search: Based on the seed memory in the memory set to be processed, the seed memory is converted into a vector embedding through an embedding model, and a similarity search is performed in the original memory bank based on the vector embedding to obtain the candidate neighbor memory corresponding to the seed memory;

[0010] S3. Candidate cluster construction: Using the seed memory as the central node, the candidate neighbor memories are processed by activity state filtering, semantic similarity threshold filtering, similarity ranking, and duplicate memory removal to construct candidate clusters corresponding to the seed memory.

[0011] S4. Large Language Model Decision: The memory information in the candidate clusters is constructed into structured input information and input into the large language model. The large language model performs semantic judgment on the memory content in the candidate clusters and outputs the memory integration decision result. The memory integration decision result includes the normalize decision to perform the integration operation and the skip decision to skip the integration operation.

[0012] S5. Decision verification and fault tolerance: The memory integration decision results output by the large language model are structured and verified. When the verification does not meet the preset requirements, the memory integration decision results are adjusted to skip decisions.

[0013] S6. Structured memory writing: When the memory integration decision result is the normalize decision, a structured long-term memory is generated according to the integrated content output by the large language model, a corresponding vector embedding is generated for the integrated content, and the time range, scope, number of sources and source role mapping information are generated based on the member information in the candidate cluster, and the generated structured long-term memory is written into the memory bank.

[0014] S7. Archiving and Lifeline Recording of Original Memories: Mark the original memories involved in the integration as archived and establish an integration lifeline record to record the relationship between the structured long-term memory and each original memory, as well as the source role of each original memory in the structured long-term memory.

[0015] To further optimize this technical solution, in S1, the candidate seed memory includes newly created original memories within a preset time range, and the recently accessed memory includes original memories accessed within a preset time range; the memory scope includes the user's global scope and the project-limited scope, and only memories with valid scopes and meeting scope compatibility conditions are retained to participate in subsequent integration processing.

[0016] To further optimize this technical solution, in step S2, when performing semantic similarity search, self-matching memories with the same identifier as the current seed memory are excluded, and the source window type is marked for candidate neighbor memories to distinguish between similar neighbor memories and recently visited memories.

[0017] To further optimize this technical solution, in step S3, the candidate cluster includes at least one seed memory and one candidate neighbor memory. When the number of memories in the candidate cluster is less than a preset threshold, the corresponding candidate cluster is discarded. Furthermore, when a memory has been archived by other candidate clusters, subsequent candidate clusters containing that memory are automatically skipped.

[0018] To further optimize this technical solution, in step S4, the structured input information includes at least the candidate memory index, memory identifier, memory type, similarity to the seed memory, memory content, and source context information.

[0019] To further optimize this technical solution, in S4, when multiple memories in a candidate cluster represent the same fact and there are only differences in expression or information granularity, a normalize decision is output; when memories in a candidate cluster contain conflicting information, insufficient information value, or cannot be determined whether they belong to the same fact, a skip decision is output.

[0020] To further optimize this technical solution, in S5, the structured verification includes at least JSON format parsing verification, field integrity verification, index range verification, and numerical range verification. When any verification item fails to meet the preset requirements, the memory integration decision result is adjusted to a skip decision.

[0021] To further optimize this technical solution, in S6, the structured long-term memory includes at least the integrated memory content, vector embedding, memory type, importance parameter, retrieval weight parameter, number of sources, time range, scope information, item identifier, and integrated operation identifier.

[0022] To further optimize this technical solution, in S7, the integrated lifeline record includes at least a target structured long-term memory identifier, a source original memory identifier, and a source role, wherein the source role includes a primary source role and a secondary source role.

[0023] The AI-based automatic memory integration system, built upon the aforementioned AI automatic memory integration method, includes the following functional modules:

[0024] The memory acquisition module is used to acquire candidate seed memories and recently accessed memories from a preset time window, and to filter the acquired raw memories according to the memory scope to obtain a set of memories to be processed that meet the integration conditions.

[0025] The semantic search module, connected to the memory acquisition module, is used to vectorize the seed memories in the memory set to be processed. It converts the text content of the seed memories into corresponding vector embeddings through an embedding model, and performs semantic similarity search in the original memory bank based on the vector embeddings to obtain candidate neighbor memories corresponding to the seed memories.

[0026] A candidate clustering construction module, connected to the semantic search module, is used to perform clustering and filtering on the candidate neighbor memories with the seed memory as the central node, to obtain the corresponding candidate clusters.

[0027] The large language model decision module is connected to the candidate clustering construction module. It is used to receive the structured description information corresponding to the candidate clusters, input the structured description information into the large language model, perform semantic analysis on multiple memory contents in the candidate clusters through the large language model, and output the memory integration decision result.

[0028] The decision verification and fault tolerance module is connected to the large language model decision module and is used to verify the memory integration decision results output by the large language model.

[0029] The structured memory generation module, connected to the decision verification and fault tolerance module, is used to generate structured long-term memory based on the memory integration decision results after receiving the normalization decision.

[0030] The archiving management and lifeline recording module is connected to the structured memory generation module. It is used to perform archiving processing on the original memories involved in the integration and to establish an integrated lifeline record to preserve the association between structured long-term memory and original memory.

[0031] In a second aspect, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program instructions are executed by the processor, they implement the steps of the AI ​​memory automatic integration method and system based on semantic clustering as described in the first aspect of the present invention.

[0032] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program instructions are executed by a processor, they implement the steps of the AI ​​memory automatic integration method and system based on semantic clustering as described in the first aspect of the present invention.

[0033] Compared with existing technologies, this invention provides an AI-based automatic memory integration method and system based on semantic clustering, which has the following beneficial effects:

[0034] This AI memory automatic integration method and system based on semantic clustering can actively analyze and integrate discrete memories generated during the operation of AI Agent. It is no longer limited to the passive calling mode in the traditional retrieval enhancement generation scheme. Instead, it identifies relevant memory content through semantic vector search, constructs candidate clusters, and then uses a large language model to perform contextual semantic judgment on the candidate clusters. This enables the automatic fusion of memories of different expressions of the same fact, reduces redundant memory storage, and improves the structuring degree of long-term memory.

[0035] Meanwhile, by setting up decision verification and fault tolerance mechanisms, the output results of the large language model are subjected to format parsing, field integrity verification, index range verification, and numerical range verification. When the output is abnormal, it is automatically downgraded to skip processing to avoid writing error information into the memory and improve the stability of system operation.

[0036] Furthermore, by establishing an integrated lifeline record, the integrated structured long-term memory is mapped to the original memory involved in the integration, preserving the source and role information of the original memory, so that the integration result can be traced back to the corresponding historical source; at the same time, by performing archiving management on the original memory that has been integrated, duplicate retrieval and redundant storage are avoided, realizing the life cycle management of AI memory, and improving the memory utilization efficiency and management capability of AI Agent in the long-term operation process. Attached Figure Description

[0037] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1This is a flowchart illustrating an AI memory automatic integration method based on semantic clustering proposed in this invention.

[0039] Figure 2 This invention presents a flowchart of an AI memory automatic integration method based on semantic clustering and the construction of candidate clusters in the system.

[0040] Figure 3 This invention presents a method for automatic AI memory integration based on semantic clustering and a diagram of the LLM decision-making process and fault tolerance mechanism in the system.

[0041] Figure 4 This invention presents an AI memory automatic integration method based on semantic clustering and a data model relationship diagram in the system. Detailed Implementation

[0042] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0043] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0044] Secondly, the term "an embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places throughout this specification does not necessarily refer to the same embodiment, nor is it a single embodiment or an embodiment selectively excluded from other embodiments.

[0045] Example 1:

[0046] An AI-based method for automatic memory integration based on semantic clustering includes the following steps:

[0047] S1. Seed memory acquisition: Obtain candidate seed memories and recently accessed memories from a preset time window, and filter the acquired raw memories according to the memory scope to obtain a set of memories to be processed that meet the integration conditions.

[0048] S2. Semantic similarity search: Based on the seed memory in the memory set to be processed, the seed memory is converted into a vector embedding through an embedding model, and a similarity search is performed in the original memory bank based on the vector embedding to obtain the candidate neighbor memory corresponding to the seed memory.

[0049] S3. Candidate cluster construction: Using the seed memory as the central node, the candidate neighbor memories are filtered by activity status, semantic similarity threshold, similarity ranking, and duplicate memory removal to construct candidate clusters corresponding to the seed memory.

[0050] S4. Large Language Model Decision: The memory information in the candidate clusters is constructed into structured input information and input into the large language model. The large language model performs semantic judgment on the memory content in the candidate clusters and outputs the memory integration decision result. The memory integration decision result includes the normalize decision to perform the integration operation and the skip decision to skip the integration operation.

[0051] S5. Decision Verification and Fault Tolerance: The memory integration decision result output by the large language model is subjected to structured verification. The structured verification includes at least JSON format parsing verification, field integrity verification, index range verification, and numerical range verification. When any verification item fails to meet the preset requirements, the memory integration decision result is adjusted to a skip decision.

[0052] S6. Structured Memory Writing: When the memory integration decision result is a normalize decision, a structured long-term memory is generated based on the integrated content output by the large language model. A corresponding vector embedding is generated for the integrated content, and the time range, scope, number of sources, and source role mapping information are generated based on the member information in the candidate cluster. The generated structured long-term memory is then written into the memory bank.

[0053] S7. Archiving and Lifeline Recording of Original Memories: Mark the original memories involved in the integration as archived and establish an integration lifeline record to record the relationship between the structured long-term memory and each original memory, as well as the source role of each original memory in the structured long-term memory.

[0054] Furthermore, in S1, the candidate seed memory includes newly created original memories within a preset time range, and the recently accessed memory includes original memories accessed within a preset time range; the memory scope includes the user's global scope and the project-limited scope, and only memories with valid scopes and meeting scope compatibility conditions are retained to participate in subsequent integration processing.

[0055] Furthermore, in S2, when performing semantic similarity search, self-matching memories with the same identifier as the current seed memory are excluded, and the source window type is marked for candidate neighbor memories to distinguish between similar neighbor memories and recently visited memories.

[0056] Furthermore, in S3, the candidate cluster includes at least one seed memory and one candidate neighbor memory. When the number of memories in the candidate cluster is less than a preset threshold, the corresponding candidate cluster is discarded. Also, when a memory has been archived by other candidate clusters, the subsequent candidate clusters containing that memory are automatically skipped.

[0057] Furthermore, in S4, the structured input information includes at least candidate memory index, memory identifier, memory type, similarity to seed memory, memory content, and source context information; when multiple memories in a candidate cluster represent the same fact and only differ in expression or information granularity, a normalize decision is output; when memories in a candidate cluster contain conflicting information, insufficient information value, or cannot be determined whether they belong to the same fact, a skip decision is output.

[0058] Furthermore, in S6, the structured long-term memory includes at least the integrated memory content, vector embedding, memory type, importance parameter, retrieval weight parameter, number of sources, time range, scope information, item identifier, and integrated operation identifier.

[0059] Furthermore, in S7, the integrated lifeline record includes at least a target structured long-term memory identifier, a source original memory identifier, and a source role, wherein the source role includes a primary source role and a secondary source role.

[0060] An AI-based automatic memory integration system based on semantic clustering includes:

[0061] The memory acquisition module is used to acquire candidate seed memories and recently accessed memories from a preset time window, and to filter the acquired raw memories according to the memory scope to obtain a set of memories to be processed that meet the integration conditions. The memory scope includes the user's global scope and the project-limited scope. Raw memories with unresolved or invalid scopes are filtered so that memories that do not meet the integration conditions do not participate in the subsequent integration process.

[0062] A semantic search module, connected to the memory acquisition module, is used to vectorize the seed memories in the memory set to be processed. It converts the text content of the seed memories into corresponding vector embeddings through an embedding model, and performs semantic similarity search in the original memory bank based on the vector embeddings to obtain candidate neighbor memories corresponding to the seed memories. The semantic search module is also used to exclude self-matching memories with the same identifier as the seed memories, and to verify the scope compatibility relationship between the candidate neighbor memories and the seed memories.

[0063] The candidate clustering construction module, connected to the semantic search module, is used to perform clustering and filtering on the candidate neighbor memories with the seed memory as the central node to obtain the corresponding candidate clusters. The candidate clustering construction module is used to perform active state filtering, semantic similarity threshold filtering, similarity sorting, and memory identifier deduplication on the candidate neighbor memories, and to determine whether to retain the corresponding candidate clusters according to the preset clustering quantity constraint.

[0064] The large language model decision module, connected to the candidate clustering construction module, is used to receive the structured description information corresponding to the candidate clusters, input the structured description information into the large language model, perform semantic analysis on multiple memory contents in the candidate clusters through the large language model, and output memory integration decision results; wherein, the memory integration decision results include a normalize decision for generating structured long-term memory and a skip decision for maintaining the original memory state.

[0065] The decision verification and fault tolerance module, connected to the large language model decision module, is used to verify the memory integration decision results output by the large language model. The decision verification and fault tolerance module includes a JSON parsing unit, a field integrity verification unit, an index range verification unit, and a numerical range verification unit. These units are used to determine whether the memory integration decision results meet preset format requirements. If any verification result fails to meet the requirements, the corresponding memory integration decision result is adjusted to a skip decision, and the corresponding downgrade reason is recorded.

[0066] A structured memory generation module, connected to the decision verification and fault tolerance module, is used to generate structured long-term memory based on the memory integration decision result after receiving the normalization decision. The structured memory generation module generates vector embeddings for the integrated content, determines the time range based on the memory creation time in the candidate clusters, determines the scope information based on the seed memory, and determines the primary and secondary source roles corresponding to each original memory in the candidate clusters based on the source index output by the large language model.

[0067] The archiving management and lifeline recording module is connected to the structured memory generation module. It is used to perform archiving processing on the original memories participating in the integration and to establish an integration lifeline record to preserve the association between the structured long-term memory and the original memory. The archiving management and lifeline recording module is used to record integration operation information, original memory state change information, and the source role information of the original memory in the structured long-term memory.

[0068] Example 2:

[0069] Reference Figures 1-4Based on the semantic clustering-based AI memory automatic integration method described in Embodiment 1, the method will be further explained.

[0070] S1. Seed memory acquisition: Obtain candidate seed memories to be integrated and recently accessed memories from a preset time window, and filter the memories to be processed according to the memory scope.

[0071] Specifically, the process begins by periodically integrating the raw memory records generated during the operation of the AI ​​Agent, identifying candidate memories that may have semantic connections within a set timeframe. These candidate memories include newly created raw memories as well as recently accessed raw memories. By simultaneously considering both newly generated memories and memories that the user has recently focused on, the subsequent integration process can target memories with high timeliness.

[0072] In this step, two memory filtering ranges are set: a seed window and a recently accessed window. The seed window is used to collect original memories newly created within the last 24 hours as new memory materials that may need to be integrated, and the maximum number of seed memories collected is set to 8. The recently accessed window is used to collect original memories that have been accessed within the last 24 hours as auxiliary matching objects that may have semantic associations with seed memories, and the maximum number of recently accessed memories collected is set to 16.

[0073] Furthermore, after acquiring candidate memories, a memory governance filtering process is performed on them, retaining only memory data that meets the preset scope requirements. The memory scope includes the user's global scope (global_user) and the project-specific scope (project_scoped). When a memory's scope is unresolved or invalid, the corresponding memory is directly excluded and does not participate in subsequent semantic search and clustering processing. This filtering method ensures that memories entering the subsequent processing flow have a clear data ownership relationship, avoiding erroneous merging of memories from different user scopes or different project scopes.

[0074] After this step, the output is a set of seed memories and a set of recently visited memories that satisfy the scope constraints, providing input data for subsequent semantic vector-based similarity search.

[0075] S2. Semantic similarity search: Generate vector embeddings for seed memories and retrieve neighbor memories related to seed memories from the original memory bank based on vector similarity.

[0076] Specifically, based on the seed memory set obtained in step S1, semantic feature transformation processing is performed on each seed memory. First, the embedding model is invoked to convert the text content in the seed memory into the corresponding vector embedding representation, so that memory content with different expressions but similar semantic meanings can form a similar distribution in the vector space.

[0077] After obtaining the vector embedding corresponding to the seed memory, this vector is used as a query vector and input into the original memory bank. Candidate memories with a high degree of semantic relevance to the seed memory are then searched using vector similarity search. Specifically, based on the vector distance or similarity calculation results, the memory entries in the original memory bank are sorted, and the eight candidate memories with the highest similarity are returned as neighbor memories.

[0078] Furthermore, to avoid duplicate matching, self-matches with the same ID as the current seed memory are excluded from the search results. Simultaneously, the scope relationship between candidate neighbor memories and the seed memory is validated, allowing only memories with compatible scopes to enter the subsequent clustering process. For example, when the seed memory belongs to the user's global scope, only memories from other users' global scopes are allowed to participate in clustering; when the seed memory belongs to the project-limited scope, only memories belonging to the same project are allowed to participate in clustering.

[0079] After completing the candidate neighbor screening, each candidate memory is labeled with its source window type, including SimilarNeighbor and RecentAccess, so that memory information from different sources can be distinguished when constructing candidate clusters.

[0080] After this step, a set of candidate neighbor memories corresponding to each seed memory is output, providing basic data for subsequent cluster construction.

[0081] S3. Candidate Cluster Construction: Centered on the seed memory, candidate neighbor memories are filtered, sorted, and deduplicated according to the semantic similarity threshold to form candidate clusters.

[0082] Specifically, based on the candidate neighbor memory set obtained in step S2, each seed memory is used as the central node, and neighbor memories with high semantic relevance to the seed memory are combined to form candidate clusters.

[0083] First, an activity state filter is applied to candidate neighbor memories, retaining only those currently in the "Active" state to prevent historical memories that have already been archived or deleted from participating in the integration process again. Then, a threshold is applied to the semantic similarity between candidate neighbor memories and seed memories, retaining only candidate memories with a similarity greater than or equal to 0.85. This threshold can be configured according to actual application requirements.

[0084] Furthermore, candidate memories selected through similarity screening are sorted in descending order of similarity, prioritizing memories with the strongest semantic relationship to the seed memory for inclusion in candidate clusters. Simultaneously, memory IDs within each cluster are deduplicated to ensure that the same original memory does not appear repeatedly in the same cluster. Each candidate cluster contains a maximum of the seed memory and 6 neighbor memories, and must contain at least 2 neighbor memories; otherwise, the cluster is considered unsuitable for integration and is discarded.

[0085] Furthermore, during a single integration run, a maximum of eight candidate clusters are processed for each user. When a memory has already been absorbed and archived by a previous cluster, subsequent candidate clusters containing that memory are automatically skipped to avoid the same memory being repeatedly integrated.

[0086] After this step, multiple candidate clusters that satisfy quantity constraints, similarity constraints, and state constraints are formed, and each candidate cluster is used as the input object for subsequent large language model decisions.

[0087] S4. Large Language Model Decision: Convert candidate clusters into structured input information and use the large language model to determine whether to perform memory integration.

[0088] Specifically, based on the candidate clusters formed in step S3, each memory information within a cluster is constructed into an input prompt message, which is then sent to the large language model for semantic analysis and integration decision-making.

[0089] The input large language model prompt information includes a list of candidate memories. Each candidate memory contains the fields source_index, memory_id, memory_type, similarity_to_seed, content, and source_context. The source_context is used to describe the context of the memory source and is truncated to 240 characters.

[0090] During the decision-making process, the output of the large language model is constrained, allowing only two decision types: normalize (integrate) or skip (skip). When multiple memories in a candidate cluster essentially describe the same fact, differing only in expression or information granularity, a normalize decision is output. When there are semantic conflicts, insufficient information value, or it cannot be confirmed whether the candidate memories belong to the same fact, a skip decision is output.

[0091] When outputting a normalize decision, the large language model further generates fields such as memory_type, content, importance, retrieval_weight, primary_source_index, and supporting_source_indices; when outputting a skip decision, it generates the corresponding skip reason. The large language model's call parameters are set to temperature=0.1 and max_tokens=800 to ensure stable output results.

[0092] After this step, the integrated decision results for each candidate cluster are output, providing a basis for subsequent verification and writing processes.

[0093] S5. Decision Validation and Fault Tolerance: Perform structured validation of the output results of the large language model, and determine whether to perform integration based on the validation results.

[0094] Specifically, based on the decision results of the large language model obtained in step S4, the model output text is first processed by JSON format extraction. The JSON text between the first "{" and the last "}" is extracted from the output content and attempted to be parsed into a structured decision object.

[0095] After completing the JSON parsing, the decision object undergoes field integrity verification, checking the existence of necessary fields such as action, content, memory_type, importance, retrieval_weight, and primary_source_index. Simultaneously, the index ranges in primary_source_index and supporting_source_indices are validated to determine if the corresponding indexes are within the valid range of the candidate memory list.

[0096] Furthermore, numerical range validation is performed on the output parameters, where the importance parameter must be within the range of 0.0 to 1.0, and the retrieval_weight parameter must be within the range of 0.0 to 2.0. If any validation step fails, the current decision is automatically downgraded to skip, and the corresponding reason for failure is recorded to avoid incorrect memory writing due to abnormal output format of the large language model.

[0097] After this step, the output is either a validated and effective integrated decision or a safe skip result.

[0098] S6. Structured Memory Writing: Generate structured long-term memory based on the validated integration decision and complete vectorized storage.

[0099] Specifically, when the decision result output by step S5 is normalize, the embedding model is called to generate the corresponding vector embedding for the integrated content generated by the large language model, and the earliest and latest times are extracted from the creation time of the candidate cluster members to form the time range corresponding to the integrated memory.

[0100] Furthermore, based on the seed memory inheritance, the corresponding scope information, including global_user or project_scoped, is used. Simultaneously, the number of memories originating from conferences in the candidate clusters is counted, and duplicate conference IDs are removed to obtain source conference statistics. Based on the primary_source_index and supporting_source_indices output by the large language model, cluster members are labeled with primary and supporting roles.

[0101] Subsequently, a Normalized Memory structured long-term memory record is created, which includes information such as the integrated content, vector embedding, memory type, importance, retrieval weight, number of sources, time range, scope, item identifier, and integration run ID. Simultaneously, an integration lifeline record is established for each integrated original memory to record its role in the new memory and its associated integration run ID.

[0102] S7. Archiving of Original Memories and Recording of Lifelines: Archiving of integrated original memories and recording information about the integration process.

[0103] Specifically, based on the new structured long-term memory generated in step S6, archiving processing is performed on the original memories participating in the integration, and the corresponding memory status is modified to "Archived" to avoid repeatedly returning already integrated historical memories during subsequent retrieval processes. The archived metadata also records the integration decision type and the corresponding seed memory ID.

[0104] Furthermore, a ConsolidationRun log is generated for the entire integration process. This log includes information such as the number of seed memories, the number of clusters, the number of successful integrations, the number of skipped clusters, the number of archived source memories, the number of failed clusters, and the running status. The running status is determined based on the integration process results: no seed memories are marked as no_seeds, all clusters are successfully processed as completed, some clusters fail but some succeed, and all clusters fail as failed.

[0105] Through the above steps, AI memory integration based on semantic clustering is achieved, enabling discrete memories to form a traceable, low-redundancy long-term memory structure through semantic search, cluster construction, large language model judgment, structured writing, and lifecycle management.

[0106] In summary, compared with the prior art, the present invention has the following beneficial effects:

[0107] (1) Active integration rather than passive retrieval: Unlike the passive retrieval mode of traditional RAG schemes, this invention can automatically identify semantically related discrete memories, actively integrate them, and generate high-quality structured long-term memories. Each integrated memory corresponds to a clear semantic topic, eliminating redundancy.

[0108] (2) LLM-driven intelligent decision-making: Leveraging the semantic understanding advantages of large language models, context-aware decisions are made for normalization / skip for each cluster, rather than relying on fixed rules or thresholds. LLM can understand that "the user works at the Shanghai headquarters on Monday" and "the user usually works at the Shanghai headquarters on Monday" are different expressions of the same fact and should be integrated; while "the user likes Shanghai" and "the user works in Shanghai" are both related to Shanghai, but have different semantics and should be skipped.

[0109] (3) Multi-layer fault tolerance mechanism: Through four layers of protection—JSON structure validation, field integrity check, index range validation, and numerical range validation—the LLM output is guaranteed not to cause system crashes or data anomalies even if it does not conform to the expected format. When validation fails, it automatically degrades to a safe skip operation.

[0110] (4) Complete traceability chain: By integrating the lifeline record, the complete mapping relationship between each integrated memory and the original memory is preserved (primary / supporting), supporting the tracing back from the integrated memory to the original meeting source.

[0111] (5) Lifecycle Management: The integrated original memory is automatically archived to avoid redundant storage and repeated retrieval. The memory has lifecycle attributes such as decay_score, access_count, and status, which support subsequent decay calculation and expiration cleanup.

[0112] (6) Scope-aware clustering: The clustering process considers the scope of memory (global / item) to ensure that information from different items is not incorrectly clustered together, thus guaranteeing the quality and accuracy of the integration.

[0113] (7) Absorption and deduplication mechanism: During batch processing, archived memories are automatically excluded from subsequent clusters to avoid the same memory being integrated into different clusters multiple times.

[0114] Example 3:

[0115] This embodiment also provides a computer device applicable to the case of an AI memory automatic integration method and system based on semantic clustering, including a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to realize the AI ​​memory automatic integration method and system based on semantic clustering as proposed in the above embodiment.

[0116] This embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements an AI memory automatic integration method and system based on semantic clustering as proposed in the above embodiments.

[0117] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.

[0118] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0119] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0120] More specific examples (a non-exhaustive list) of computer-readable media include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0121] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0122] It should be noted that 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 preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. An AI-based automatic memory integration method based on semantic clustering, characterized in that, Includes the following steps: S1. Seed memory acquisition: Obtain candidate seed memories and recently accessed memories from a preset time window, and filter the acquired raw memories according to the memory scope to obtain a set of memories to be processed that meet the integration conditions. S2. Semantic similarity search: Based on the seed memory in the memory set to be processed, the seed memory is converted into a vector embedding through an embedding model, and a similarity search is performed in the original memory bank based on the vector embedding to obtain the candidate neighbor memory corresponding to the seed memory; S3. Candidate cluster construction: Using the seed memory as the central node, the candidate neighbor memories are processed by activity state filtering, semantic similarity threshold filtering, similarity ranking, and duplicate memory removal to construct candidate clusters corresponding to the seed memory. S4. Large Language Model Decision: The memory information in the candidate clusters is constructed into structured input information and input into the large language model. The large language model performs semantic judgment on the memory content in the candidate clusters and outputs the memory integration decision result. The memory integration decision result includes the normalize decision to perform the integration operation and the skip decision to skip the integration operation. S5. Decision verification and fault tolerance: The memory integration decision results output by the large language model are structured and verified. When the verification does not meet the preset requirements, the memory integration decision results are adjusted to skip decisions. S6. Structured memory writing: When the memory integration decision result is the normalize decision, a structured long-term memory is generated according to the integrated content output by the large language model, a corresponding vector embedding is generated for the integrated content, and the time range, scope, number of sources and source role mapping information are generated based on the member information in the candidate cluster, and the generated structured long-term memory is written into the memory bank. S7. Archiving and Lifeline Recording of Original Memories: Mark the original memories involved in the integration as archived and establish an integration lifeline record to record the relationship between the structured long-term memory and each original memory, as well as the source role of each original memory in the structured long-term memory.

2. The AI ​​memory automatic integration method based on semantic clustering according to claim 1, characterized in that, In S1, the candidate seed memory includes newly created original memories within a preset time range, and the recently accessed memory includes original memories that have been accessed within a preset time range; The memory scope includes the user's global scope and the project-limited scope. Only memories with valid scopes and that meet the scope compatibility conditions are retained for subsequent integration processing.

3. The AI ​​memory automatic integration method based on semantic clustering according to claim 1, characterized in that, In step S2, when performing semantic similarity search, self-matching memories with the same identifier as the current seed memory are excluded, and the source window type is marked for candidate neighbor memories to distinguish between similar neighbor memories and recently visited memories.

4. The AI ​​memory automatic integration method based on semantic clustering according to claim 1, characterized in that, In step S3, each candidate cluster includes at least one seed memory and one candidate neighbor memory. When the number of memories in a candidate cluster is less than a preset threshold, the corresponding candidate cluster is discarded. Furthermore, when a memory has been archived by other candidate clusters, subsequent candidate clusters containing that memory are automatically skipped.

5. The AI ​​memory automatic integration method based on semantic clustering according to claim 1, characterized in that, In step S4, the structured input information includes at least candidate memory index, memory identifier, memory type, similarity to seed memory, memory content, and source context information.

6. The AI ​​memory automatic integration method based on semantic clustering according to claim 1, characterized in that, In S4, when multiple memories in a candidate cluster represent the same fact and there are only differences in expression or information granularity, a normalize decision is output. When memories in a candidate cluster contain conflicting information, insufficient information value, or cannot be determined whether they belong to the same fact, a skip decision is output.

7. The AI ​​memory automatic integration method based on semantic clustering according to claim 1, characterized in that, In S5, the structured verification includes at least JSON format parsing verification, field integrity verification, index range verification, and numerical range verification. When any verification item fails to meet the preset requirements, the memory integration decision result is adjusted to a skip decision.

8. The AI ​​memory automatic integration method based on semantic clustering according to claim 1, characterized in that, In S6, the structured long-term memory includes at least the integrated memory content, vector embedding, memory type, importance parameter, retrieval weight parameter, number of sources, time range, scope information, item identifier, and integrated operation identifier.

9. The AI ​​memory automatic integration method based on semantic clustering according to claim 1, characterized in that, In S7, the integrated lifeline record includes at least a target structured long-term memory identifier, a source original memory identifier, and a source role, wherein the source role includes a primary source role and a secondary source role.

10. An AI-based automatic memory integration system based on semantic clustering, constructed based on the AI-based automatic memory integration method according to any one of claims 1-9, characterized in that, The system includes the following functional modules: The memory acquisition module is used to acquire candidate seed memories and recently accessed memories from a preset time window, and to filter the acquired raw memories according to the memory scope to obtain a set of memories to be processed that meet the integration conditions. The semantic search module, connected to the memory acquisition module, is used to vectorize the seed memories in the memory set to be processed. It converts the text content of the seed memories into corresponding vector embeddings through an embedding model, and performs semantic similarity search in the original memory bank based on the vector embeddings to obtain candidate neighbor memories corresponding to the seed memories. A candidate clustering construction module, connected to the semantic search module, is used to perform clustering and filtering on the candidate neighbor memories with the seed memory as the central node, to obtain the corresponding candidate clusters. The large language model decision module is connected to the candidate clustering construction module. It is used to receive the structured description information corresponding to the candidate clusters, input the structured description information into the large language model, perform semantic analysis on multiple memory contents in the candidate clusters through the large language model, and output the memory integration decision result. The decision verification and fault tolerance module is connected to the large language model decision module and is used to verify the memory integration decision results output by the large language model. The structured memory generation module, connected to the decision verification and fault tolerance module, is used to generate structured long-term memory based on the memory integration decision results after receiving the normalization decision. The archiving management and lifeline recording module is connected to the structured memory generation module. It is used to perform archiving processing on the original memories involved in the integration and to establish an integrated lifeline record to preserve the association between structured long-term memory and original memory.