Intelligent agent interaction method, system, device and medium based on multi-layer memory driving
By employing a multi-layered memory-driven agent interaction method, which combines a medium-term memory bank and a long-term memory bank, personalized responses to agent interactions are achieved. This solves the problem of low interaction efficiency in existing technologies and improves the accuracy and timeliness of interactions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN SDMC TECH CO LTD
- Filing Date
- 2026-03-10
- Publication Date
- 2026-05-12
Smart Images

Figure CN121808025B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of smart home technology, specifically relating to a method, system, device, and medium for intelligent agent interaction based on multi-layer memory driving. Background Technology
[0002] With the rapid development of artificial intelligence technology, intelligent agents have been widely applied in human-computer dialogue scenarios, aiming to provide personalized and efficient response services by accurately understanding user needs and combining historical interaction information. Currently, the implementation methods of human-computer dialogue for intelligent agents mostly focus on one or more combinations of conversation-level context memory, knowledge base retrieval, and simple user profile construction. However, these methods still have many limitations in practical applications and are difficult to meet users' needs for personalized and precise interaction with intelligent agents.
[0003] Specifically, existing conversation-level context memory methods can only maintain short-term dialogue history within the current conversation round. Once the conversation ends, the relevant memory information is lost, failing to achieve cross-conversation continuation of user needs and reuse of preferences. While knowledge base retrieval methods can return historical discourse similar to the current question through vector retrieval, they lack topic-level aggregation and merging of multi-turn dialogue information and do not introduce a timeliness management mechanism, leading to problems such as duplicate and low relevance in search results. Simple user profile construction methods mostly form static profiles based on user click behavior or preferences, failing to collaboratively model dialogue semantic information, device operating parameters, and user behavior temporal characteristics, making it difficult to accurately capture dynamic user habits and contextual needs. Summary of the Invention
[0004] The technical problem that the existing technology needs to solve is to overcome the shortcomings of existing intelligent agent interaction methods, which cannot effectively process memory data, resulting in low interaction efficiency and difficulty in accurately meeting personalized needs. In order to provide an intelligent agent interaction method, system, device and medium based on multi-layer memory driving.
[0005] A method for intelligent agent interaction based on multi-layer memory includes the following steps:
[0006] Enter the user query and user ID;
[0007] Convert user queries into query vectors;
[0008] Filter topics corresponding to the user ID in the intermediate memory;
[0009] Obtain a preset number of topics from the intermediate memory that have the highest similarity between the summary vector and the query vector, and form a pre-selected topic set;
[0010] For topics in the pre-selected topic set, a mid-term memory score is calculated based on similarity, time decay, and popularity.
[0011] Select the topics with the highest scores from the intermediate memory bank (a preset number) and return them as the intermediate memory results; along with the corresponding device parameters;
[0012] Retrieve user profile information from the long-term memory based on the user ID;
[0013] Perform a similarity search on the query vector in the long-term memory and return a summary of device preferences;
[0014] The user profile information and device preference summary are returned as long-term memory results;
[0015] Input the user query, the intermediate memory result, and the long-term memory result into the agent, and obtain the agent's response.
[0016] Furthermore, it also includes the following steps:
[0017] For multi-turn dialogues involving intelligent agents, multiple rounds of user queries and intelligent agent responses are concatenated to form text, which is then vectorized to form multi-turn dialogue vectors.
[0018] Calculate the similarity between the multi-turn dialogue vectors, and connect two multi-turn dialogue vectors with a similarity greater than a preset threshold.
[0019] Define the multi-turn dialogue vectors of the connected edges as the same multi-turn dialogue group;
[0020] The text of the multi-turn dialogues within the same multi-turn dialogue group is concatenated and quantized to form a multi-turn dialogue group vector;
[0021] Recall candidate topics by user ID in the intermediate memory;
[0022] Calculate the similarity between the candidate topic and the multi-turn dialogue group vector; if the similarity is greater than a preset threshold, merge the candidate topic and the multi-turn dialogue group; if the similarity is less than the preset threshold, form a new topic from the multi-turn dialogue group and store it in the intermediate memory.
[0023] Furthermore, the method for calculating the intermediate memory score is expressed as follows:
[0024] ;
[0025] in, Represents the query vector. A vector representing a summary of a topic. Indicate the theme, Indicates similarity. Indicates the degree of time decay. Indicates popularity. , and Represents the coefficient.
[0026] Furthermore, the method for calculating the time decay of the topic is expressed as follows:
[0027] Recency(m) = ;
[0028] Where Δt represents the time interval between the last interaction of the topic and the current time; The hyperparameter representing time decay.
[0029] Furthermore, the method for calculating the popularity of a topic is expressed as follows:
[0030] ;
[0031] Where DetailsLength represents the cumulative number of historical dialogue rounds for the topic, RecentTurns represents the number of dialogue rounds for the topic within a preset time period, and Δt represents the time interval between the topic's last interaction and the current moment. The hyperparameter representing time decay.
[0032] Furthermore, merging the candidate topics with the multi-turn dialogue groups includes the following steps:
[0033] Obtain the text of the multi-turn dialogues and the text of candidate topics within the multi-turn dialogue group, and use them as the content of the updated topic;
[0034] The text of the multi-turn dialogues, the text of the candidate topics, and the summaries within the multi-turn dialogue groups are processed to obtain updated topic summaries.
[0035] Furthermore, it also includes the following steps:
[0036] When the popularity of a topic in the intermediate memory is less than a preset threshold, the topic is deleted.
[0037] When the popularity of a topic in the intermediate memory exceeds a preset threshold, the text of the topic is obtained, input into a large language model, user basic information and user device preferences are extracted, and then input into the long-term memory.
[0038] A multi-layer memory-driven intelligent agent interaction system is provided for realizing intelligent agent interaction through the aforementioned multi-layer memory-driven intelligent agent interaction method, including a medium-term memory bank and a long-term memory bank.
[0039] A computer device includes a processor and a memory connected to the processor. The memory stores one or more programs that are executed by the processor to perform the steps in the multi-layer memory-driven intelligent agent interaction method described above.
[0040] A computer-readable storage medium storing one or more programs that are executed by a processor to implement the steps in the multi-layer memory-driven intelligent agent interaction method described above.
[0041] Beneficial Effects: The multi-layer memory-driven intelligent agent interaction method of this invention stores user profile information and device preference summaries in a long-term memory bank. Combined with user IDs, it accurately associates exclusive memories, enabling the intelligent agent to respond to problems based on stable user preferences and device adaptation needs, significantly improving the targeting of personalized services and providing strong personalized support for the interaction process. The medium-term memory bank uses topics as the core unit. It filters pre-selected topic sets through user ID filtering and similarity matching, and then calculates scores based on similarity, time decay, and popularity to select the optimal topic. This achieves topic-level aggregation and precise filtering of multi-turn dialogue information, improving the efficiency and accuracy of memory retrieval.
[0042] This invention introduces time decay and popularity indicators into the calculation of intermediate memory scores, giving higher priority to recently high-frequency topic information and allowing older information to decay naturally. This effectively solves the problems of lack of timeliness management and conflicting new and old information in existing technologies, ensuring that the agent's response is based on the user's current core needs and improving the timeliness and rationality of interaction. By collaboratively inputting intermediate and long-term memory results into the agent, it takes into account the contextual relevance of the current conversation and recent topics, incorporates the user's long-term stable characteristics and device adaptation habits, making the agent's response more comprehensive and tailored to the user's actual needs. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 This is a schematic flowchart illustrating the main method steps of the present invention. Detailed Implementation
[0045] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the specific embodiments of this application are described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of this application. Therefore, this application is not limited to the specific embodiments disclosed below.
[0046] In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. Those skilled in the art can understand the specific meaning of the terms in this application based on the specific circumstances.
[0047] This embodiment provides an intelligent agent interaction method based on multi-layer memory, including the following steps:
[0048] Enter the user query and user ID;
[0049] Convert the user query into a query vector (query_vector);
[0050] Filter the topics corresponding to the user ID in the intermediate memory; thereby obtaining all topics in the intermediate memory related to the user ID;
[0051] A preset number of topics with the highest similarity between the summary vector and the query vector in the intermediate memory are obtained to form a pre-selected topic set; in this embodiment, 10 topics with the highest similarity are obtained from the intermediate memory to form the pre-selected topic set.
[0052] For topic m in the pre-selected topic set, the mid-term memory score is calculated based on similarity, time decay, and popularity.
[0053] Select the topics with the highest scores from the intermediate memory bank (a preset number) and return them as the intermediate memory results; along with the corresponding device parameters;
[0054] Retrieve user profile information from the long-term memory based on the user ID;
[0055] The query vector is searched for similarity in the long-term memory to return a summary of device preferences. In this embodiment, the user query is searched for similarity in the user device preference vector library to return the summary of device preferences with the highest similarity.
[0056] The user profile information and device preferences are summarized as long-term memory results and returned. The memory retrieval step vectorizes the user query, filters it by user, and performs coarse and fine ranking based on similarity in the vector database, returning the medium-term memory topics and long-term memory preferences.
[0057] Input the user query, the intermediate memory result, and the long-term memory result into the agent, and obtain the agent's response ai_response.
[0058] In this embodiment, each user ID has at least one device ID, and each device ID is bound to one user ID.
[0059] Specifically, the user profile information in the long-term memory bank includes basic user information, preferences, region, and name; and device preference summaries such as "living room light brightness 60%" and "often listens to XX style music".
[0060] In this embodiment, the medium-term memory uses topics as the basic unit, aggregating multi-turn dialogue details and related device parameters, and is dynamically maintained by decaying with usage frequency and time. Specifically, a topic in the medium-term memory includes a topic summary, vector, dialogue details, device parameters, the time of the last interaction, and a popularity value. The long-term memory includes stable facts and rules based on basic user information and device preferences, used for cold starts and strong personalization. Preferably, in this embodiment, each topic is bound to a unique user ID, and topics are not bound to devices.
[0061] Specifically, the device parameters include device ID, operation type, and operation parameters. As an example, for a device that functions as a lamp, the device ID is a unique long string of characters corresponding to that lamp, the operation type includes, for example, adjusting the lamp brightness, and the operation parameters are the specific numerical values for the lamp brightness.
[0062] Specifically, the memory addition step groups and merges / creates new multi-turn dialogues, and updates the popularity; in this embodiment, long-term memories are extracted based on a popularity threshold by a daily timed task and merged with existing long-term memories.
[0063] In this embodiment, the multi-turn dialogue [(query_1, ai_response_1), (query_2, ai_response_2),......(query_i, ai_response_i)] is fed back into the intermediate memory, including the following steps:
[0064] For multi-turn dialogues between intelligent agents, the user query_i and the agent response ai_response_i are concatenated to form text u_i. The text u_i is then vectorized to form the multi-turn dialogue vector v_i.
[0065] Calculate the similarity sim(v_i, v_j) between the multi-turn dialogue vectors v_i, and connect the two multi-turn dialogue vectors whose similarity sim(v_i, v_j) is greater than a preset threshold τ_group to form a connected graph;
[0066] The multi-turn dialogue vectors connected by edges are defined as the same multi-turn dialogue group; in this embodiment, depth-first search (DFS) is used to find several multi-turn dialogue groups G_k in the connected graph, so that the multi-turn dialogues within a multi-turn dialogue group represent the same topic;
[0067] The text of the multi-turn dialogues within the same multi-turn dialogue group G_k is concatenated into U_k and quantized to form a multi-turn dialogue group vector v_k;
[0068] Candidate topics are recalled from the intermediate memory by user ID; in this embodiment, the topic with the highest vector similarity is recalled.
[0069] Calculate the similarity between the candidate topic and the multi-turn dialogue group vector; if the similarity is greater than a preset threshold sim(v_k, v_m) ≥ τ_merge, then merge the candidate topic and the multi-turn dialogue group; if the similarity is less than the preset threshold sim(v_k, v_m) < τ_merge, then form a new topic from the multi-turn dialogue group and store it in the intermediate memory.
[0070] In this embodiment, the specific method of text vectorization can directly adopt conventional methods in the prior art.
[0071] In this embodiment, merging the candidate topics with the multi-turn dialogue groups includes the following steps:
[0072] Obtain the text of the multi-turn dialogues and the text of the candidate topics within the multi-turn dialogue group, and use them as the content of the updated topic; perform summary processing on the text of the multi-turn dialogues, the text of the candidate topics, and the summaries within the multi-turn dialogue group to obtain the summary of the updated topic.
[0073] Specifically, the large language model is invoked to re-summarize the text concatenation U_k of the multi-turn dialogues in the multi-turn dialogue group G_k and the dialogue details and summary vector of the topic m to be merged, generating a new summary S_new. The summary vector of the topic m to be merged is updated with the new summary S_new vectorized. At the same time, the device parameters are merged by overwriting the latest value of the same parameter, and the time statistics and popularity value of topic m are updated, where the time statistics include the most recent time and the frequency of occurrence.
[0074] Specifically, the calculation method for the intermediate memory score is expressed as follows:
[0075] ;
[0076] in, Represents the query vector. A vector representing a summary of a topic. Indicate the theme, Indicates similarity. Indicates the degree of time decay. Indicates popularity. , and Represents the coefficient; in this embodiment, , and As a preferred embodiment, the parameters are those that can be learned or configured. , and The value is a preset empirical value. Preferably, in this embodiment, the similarity is calculated using cosine similarity.
[0077] The method for calculating the time decay of a topic is expressed as follows:
[0078] Recency(m) = ;
[0079] Where Δt represents the time interval between the last interaction of the topic and the current time, which is the number of days in this embodiment; The hyperparameter representing time decay is used to control the decay rate.
[0080] The method for calculating the popularity of a topic is as follows:
[0081] ;
[0082] Where DetailsLength represents the cumulative number of historical dialogue rounds of the topic, RecentTurns represents the number of dialogue rounds of the topic within a preset time period, which in this embodiment is the number of dialogue rounds of the topic in the last 7 days; Δt represents the time interval between the last interaction of the topic and the current moment, which in this embodiment is the number of days; This represents a hyperparameter that indicates time decay and is used to control the rate at which freshness decays.
[0083] In this embodiment, the intermediate memory bank and the long-term memory bank are managed through the following method steps:
[0084] When the popularity of a topic in the intermediate memory is less than a preset threshold, the topic is deleted; specifically, this also includes reducing the popularity / freezing intermediate topics that have not been hit for a long time; and initiating deletion or archiving policies for topics with extremely low popularity and that have been stored for too long.
[0085] When the popularity of a topic in the intermediate memory exceeds a preset threshold (H ≥ H_threshold), the text of that topic is obtained, input into a large language model, and user basic information and user device preferences are extracted and input into the long-term memory. Specifically, user basic information includes preferences, region, and name; if changes occur, they are merged with existing entries, prioritizing new information and retaining source traces. User device preferences include phrases like "living room light brightness 60%" and "often listen to XX style music." For each preference, vector similarity and thresholds are used to compare it with existing preferences, creating or updating user device preferences to increase confidence, refresh the source topic set, and update the time.
[0086] In this embodiment, a large language model is input to extract basic user information and user device preferences. Prompts may include "Extract basic user information including preferences, region, and name; extract user device preferences," along with corresponding formatting requirements. User profile information is updated based on the extracted basic user information, and the user device preference summary is updated based on the extracted user device preferences.
[0087] As a further improvement to this embodiment, during the grouping stage of adding long-term memory, LLM is called to extract user operations, location / room and operation time from the text within the group and write them into the behavior details table.
[0088] Using a week as a cycle, count the number of times N occurs within a fixed time window (±30 minutes). If N > N_Threshold, it is considered a user habit (such as "turn off the air conditioner around 07:10"), and its stability is continuously tracked.
[0089] Based on habit recognition, a small time window (e.g., 5 minutes) is set to collect multiple habits that occur within the window. These habits are then converted into a one-hot encoding event set. The frequent itemset growth algorithm (FP-Growth) is used to mine combination patterns with high support or confidence. The mined combination patterns are then established as combination habits.
[0090] Patterns including behavioral details, user habits, and combination habits are sent to the home automation platform as candidates for proactive prompts or default linkages; user adoption / rejection generates feedback, which in turn feeds into popularity and rule confidence.
[0091] As a further improvement to this embodiment, it also includes cross-user statistics as a cold start strategy, which form a general template based on common behaviors of similar devices and regions, as an initial suggestion.
[0092] In this embodiment, the large language model invoked can be a direct invocation of an existing general-purpose large language model, or an adaptive fine-tuning based on an existing large language model.
[0093] This embodiment also provides a multi-layer memory-driven intelligent agent interaction system, which is used to realize intelligent agent interaction through the above-mentioned multi-layer memory-driven intelligent agent interaction method, including a medium-term memory bank and a long-term memory bank.
[0094] Specifically, in this embodiment, the intelligent agent interaction system based on multi-layer memory driving includes the following modules:
[0095] The vectorization module is used to convert user queries and dialogue text into vectorized representations.
[0096] The intermediate memory is used to store information by topic: topic summaries, vectors, dialogue details, device parameters, time, popularity values, etc.
[0097] Long-term memory is used to store basic user information and device preference entries;
[0098] The retrieval and reordering module is used to implement coarse ranking and time-sensitive / popularity-based fine ranking of medium-term memory vectors; and to control the preference retrieval and merging of long-term memory.
[0099] The memory addition module is used to group new conversations, merge or create new topics, and update popularity.
[0100] The scheduled task and popularity management module is used for daily traversal, time decay, threshold migration, long-term memory extraction and cleanup;
[0101] The pattern mining module is used to extract operations, time, and location from dialogues for habit recognition and combined pattern recognition.
[0102] The permissions and isolation module is used to isolate users by tenant / family / user, enabling record tracing and manual error correction.
[0103] This embodiment also provides a computer device, which includes a processor and a memory. The memory is connected to the processor and stores one or more programs. The one or more programs are executed by the processor to implement the steps in the multi-layer memory-driven intelligent agent interaction method described above.
[0104] This embodiment also provides a computer-readable storage medium storing one or more programs that are executed by a processor to implement the steps in the multi-layer memory-driven intelligent agent interaction method described above.
[0105] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0106] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for intelligent agent interaction based on multi-layer memory, characterized in that, Includes the following steps: Input user query and user ID; convert user query into query vector; filter topics corresponding to the user ID in the intermediate memory; obtain a preset number of topics in the intermediate memory with the highest similarity between the summary vector and the query vector, forming a pre-selected topic set; for topics in the pre-selected topic set, calculate intermediate memory score based on similarity, time decay, and popularity; Select the topics with the highest scores from the intermediate memory bank and return them as intermediate memory results; query user profile information in the long-term memory bank based on user ID; perform a similarity search on the query vector in the long-term memory bank and return a device preference summary; return the user profile information and the device preference summary as long-term memory results. Input the user query, the intermediate memory result, and the long-term memory result into the agent, and obtain the agent's response; For multi-turn dialogues involving intelligent agents, multiple rounds of user queries and intelligent agent responses are concatenated to form text, which is then vectorized to form multi-turn dialogue vectors. Calculate the similarity between the multi-turn dialogue vectors, and connect two multi-turn dialogue vectors with a similarity greater than a preset threshold; define the connected multi-turn dialogue vectors as belonging to the same multi-turn dialogue group; concatenate and quantize the text of the multi-turn dialogues within the same multi-turn dialogue group to form a multi-turn dialogue group vector; recall candidate topics in the mid-term memory by user ID; calculate the similarity between the candidate topics and the multi-turn dialogue group vectors; if the similarity is greater than a preset threshold, merge the candidate topics and the multi-turn dialogue group. If the similarity is less than a preset threshold, the multi-turn dialogue groups will be formed into a new topic and stored in the intermediate memory bank; The method for calculating the intermediate memory score is expressed as follows: ; in, Represents the query vector. A vector representing a summary of a topic. Indicate the theme, Indicates similarity. Indicates the degree of time decay. Indicates popularity. , and Represents the coefficient.
2. The intelligent agent interaction method based on multi-layer memory driving according to claim 1, characterized in that, The method for calculating the time decay of a topic is expressed as follows: Recency(m)= ; Where Δt represents the time interval between the last interaction of the topic and the current time; The hyperparameter representing time decay.
3. The intelligent agent interaction method based on multi-layer memory driving according to claim 1, characterized in that, The method for calculating the popularity of a topic is as follows: ; Where DetailsLength represents the cumulative number of historical dialogue rounds for the topic, RecentTurns represents the number of dialogue rounds for the topic within a preset time period, and Δt represents the time interval between the topic's last interaction and the current moment. The hyperparameter representing time decay.
4. The intelligent agent interaction method based on multi-layer memory driving according to claim 1, characterized in that, Merging the candidate topics with the multi-turn dialogue groups includes the following steps: obtaining the text of the multi-turn dialogues within the multi-turn dialogue group and the text of the candidate topics as the content of the updated topics; performing summary processing on the text of the multi-turn dialogues within the multi-turn dialogue group, the text of the candidate topics, and the summaries to obtain a summary of the updated topics.
5. The intelligent agent interaction method based on multi-layer memory driving according to claim 1, characterized in that, It also includes the following steps: When the popularity of a topic in the intermediate memory is less than a preset threshold, the topic is deleted; when the popularity of a topic in the intermediate memory is greater than the preset threshold, the text of the topic is obtained, input into a large language model, user basic information and user device preferences are extracted, and then input into the long-term memory.
6. A multi-layer memory-driven intelligent agent interaction system, used to realize intelligent agent interaction through the multi-layer memory-driven intelligent agent interaction method according to any one of claims 1-5, characterized in that, It includes a medium-term memory bank and a long-term memory bank.
7. A computer device, characterized in that, The computer device includes a processor and a memory connected to the processor. The memory stores one or more programs, which are executed by the processor to implement the steps in the multi-layer memory-driven intelligent agent interaction method as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, which are executed by a processor to implement the steps in the multi-layer memory-driven intelligent agent interaction method as described in any one of claims 1-5.