Memory management method and device across dialog, computer device and storage medium
Patent Information
- Application Number
- CN202610836959.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-10
- Publication Date
- 2026-10-13
AI Technical Summary
然而,当前主流大语言模型(Large Language Model,LLM)受上下文窗口限制,无法原生保持跨会话记忆,因此需要外部记忆管理系统的支撑
[0016]本申请提供的方法,以异步非阻塞方式提取当前对话的对话转录文本,异步非阻塞方式可以保证后台提取对话转录文本的过程不影响目标用户与目标智能体的对话,保障对话的正常执行。以及,本申请中采用关键词筛选加目标大语言模型精判的两级架构,确定对话记忆数据的目标处理决策,能够减少不必要的模型调用,提高处理效率。以及,本申请设计的三选一(即更新/创建/忽略)去重决策,相比相关技术中的四选一或五选一决策,能够通过极低token上限(比如10 token)实现更低成本的去重判断,提高处理效率。
Smart Images

Figure CN122904878A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and more specifically, to a cross-dialogue memory management method, apparatus, computer device, and storage medium. Background Technology
[0002] With the widespread application of large language model-driven digital humans, such as artificial intelligence (AI) agents, in education, consulting, and companionship, users' expectations for digital humans have expanded from single-conversation question-and-answer capabilities to continuous experiences across conversations. For example, users hope that digital humans can "remember" them, including identity information, preferences, historical decisions, and feedback corrections, thereby providing a personalized and coherent interactive experience in subsequent conversations. However, current mainstream large language models (LLMs) are limited by context windows and cannot natively maintain cross-conversation memory, thus requiring the support of an external memory management system.
[0003] Therefore, it is particularly important to propose a more accurate and efficient memory management method. Summary of the Invention
[0004] In view of this, this application provides a cross-dialogue memory management method, apparatus, computer device, and storage medium.
[0005] Specifically, this application is implemented through the following technical solution: In a first aspect, embodiments of this application provide a cross-dialogue memory management method, including: During the dialogue between the target user and the target agent, when the current dialogue meets the memory storage triggering conditions, the dialogue transcription text of the current dialogue is extracted in an asynchronous and non-blocking manner. Content extraction is performed on the transcribed text of the dialogue to generate at least one current dialogue memory data, and a keyword set is constructed based on the memory description in the current dialogue memory data; The keyword set includes multiple keywords and target entries in the target index file corresponding to the target user under the target agent are matched to determine the number of keyword matches. Each user who has a dialogue with the target agent corresponds to an index file, and each entry in the index file corresponds to a memory file. The memory file is used to store the dialogue memory data between the user and the target agent. When the number of keyword matches is greater than or equal to a preset threshold, based on the set target large language model and the memory file indicated by the target index file, a target processing decision for the current dialogue memory data is determined from three preset decisions, and the current dialogue memory data is processed according to the target processing decision, wherein the three preset decisions include: updating existing entries, creating new entries, and ignoring.
[0006] In an optional implementation, the method further includes: when the number of keyword matches is less than the preset quantity threshold, determining the target processing decision for the current dialogue memory data as creating a new entry.
[0007] In one optional implementation, content extraction is performed on the transcribed dialogue text to generate at least one current dialogue memory data item, including: Determine structured extraction rule information, which includes extraction criteria and exclusion rules; Using the target large language model, content extraction is performed on the transcribed dialogue text based on the extraction rule information to generate at least one current dialogue memory data, wherein the current dialogue memory data includes metadata and memory text, and the metadata includes name, type label and memory description.
[0008] In one optional implementation, the step of detecting that the current conversation meets the memory storage trigger condition includes: determining that the current conversation meets the memory storage trigger condition when the number of messages in the current session is greater than a preset number threshold, the target user has a valid user identifier, and the user identifier is not an anonymous temporary identifier.
[0009] In an optional implementation, when the target processing decision is to update an existing entry or create a new entry, processing the current dialogue memory data according to the target processing decision includes: Obtain the current lock state corresponding to the target lock key, which is composed of the user identifier of the target user and the agent identifier of the target agent; When the current lock state is unlocked, the current dialogue memory data is processed according to the target processing decision.
[0010] In one optional implementation, the method further includes: When the number of stored memory files is determined to be greater than a preset capacity threshold based on the target index file, the target index file is sent to the target large language model; Using the target large language model based on multiple evaluation dimensions, a preset number of entries to be deleted are determined from multiple target entries in the target index file; wherein the multiple evaluation dimensions include at least two of the following: timeliness dimension, specificity dimension, and redundancy dimension; the timeliness dimension is used to evaluate the interval between the update time of the memory file and the current time; the specificity dimension is used to evaluate the information density of the memory content; the redundancy dimension is used to evaluate the degree of duplication of the memory content with other memory files; Delete the memory files corresponding to the preset number of entries to be deleted, and update the target index file.
[0011] In one optional implementation, before extracting the dialogue transcript of the current dialogue in an asynchronous, non-blocking manner, the method further includes: Based on the user identifier of the target user and the agent identifier of the target agent, determine the number of entries in the target index file corresponding to the target user under the target agent; When the number of entries exceeds the target number, a target number of target memory files are selected from multiple memory files indicated by the target index file, based on the dialogue topic of the current dialogue. The target memory file carrying preset behavior instructions is input into the system prompt of the target agent, wherein the preset behavior instructions are used to instruct the target agent to prohibit the memory acquisition behavior.
[0012] In one optional implementation, when there are multiple agents, a storage directory is constructed using a two-dimensional structure consisting of user identifiers and agent identifiers. Different storage directories correspond to different user identifiers and / or agent identifiers. Each storage directory includes an index file and a memory file corresponding to each entry in the index file.
[0013] Secondly, embodiments of this application also provide a cross-dialogue memory management device, comprising: The extraction module is used to extract the transcribed text of the current dialogue in an asynchronous and non-blocking manner when the current dialogue meets the memory storage triggering conditions during the dialogue between the target user and the target agent. The generation module is used to extract content from the transcribed dialogue text, generate at least one current dialogue memory data including the current dialogue, and construct a keyword set based on the memory description in the current dialogue memory data; The matching module is used to perform keyword matching between multiple keywords included in the keyword set and target entries in the target index file corresponding to the target user under the target agent, and to determine the number of keyword matches. Each user who has a dialogue with the target agent corresponds to an index file, and each entry in the index file corresponds to a memory file. The memory file is used to store the dialogue memory data between the user and the target agent. The processing module is used to determine a target processing decision for the current dialogue memory data from three preset decisions based on the set target large language model and the memory file indicated by the target index file when the number of keyword matches is greater than or equal to a preset threshold, and process the current dialogue memory data according to the target processing decision, wherein the three preset decisions include: updating existing entries, creating new entries, and ignoring.
[0014] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described cross-dialogue memory management method.
[0015] This application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-described cross-dialogue memory management method when executing the program.
[0016] The method provided in this application extracts the transcribed text of the current dialogue in an asynchronous, non-blocking manner. This asynchronous, non-blocking approach ensures that the background extraction of the transcribed text does not affect the dialogue between the target user and the target agent, guaranteeing the normal execution of the dialogue. Furthermore, this application employs a two-level architecture of keyword filtering and precise judgment using a large target language model to determine the target processing decision for the dialogue memory data, reducing unnecessary model calls and improving processing efficiency. Finally, the three-choice (update / create / ignore) deduplication decision designed in this application, compared to the four-choice or five-choice decisions in related technologies, achieves lower-cost deduplication judgment with a very low token limit (e.g., 10 tokens), further improving processing efficiency.
[0017] Meanwhile, this application sets up an index file corresponding to each user who has a dialogue with the target intelligent agent, and each entry in the index file corresponds to a memory file. The memory file is used to store the dialogue memory data between the user and the target intelligent agent, so that the dialogue memory data of different users under the same intelligent agent and the same user under different intelligent agents are stored in different directories, thereby realizing the isolation of the dialogue memory of different intelligent agents and / or different users and avoiding data leakage and confusion. Attached Figure Description
[0018] The accompanying drawings, which are included to provide a further understanding of this specification and form part of this specification, illustrate exemplary embodiments and are used to explain this specification, but do not constitute an undue limitation thereof. In the drawings: Figure 1 This is a flowchart illustrating a cross-dialogue memory management method in an exemplary embodiment of this application; Figure 2 This is a schematic diagram of a storage directory in a cross-dialogue memory management method illustrated in an exemplary embodiment of this application; Figure 3 This is a schematic diagram illustrating a cross-dialogue memory management device according to an exemplary embodiment of this application; Figure 4 This is a schematic diagram of the structure of a computer device provided in this application. Detailed Implementation
[0019] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0020] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0021] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0022] With the widespread application of large language model-driven digital humans, such as artificial intelligence (AI) agents, in education, consulting, and companionship, users' expectations for digital humans have expanded from single-conversation question-and-answer capabilities to continuous experiences across conversations. For example, users hope that digital humans can "remember" them, including identity information, preferences, historical decisions, and feedback corrections, thereby providing a personalized and coherent interactive experience in subsequent conversations. However, current mainstream large language models (LLMs) are limited by context windows and cannot natively maintain cross-conversation memory, thus requiring the support of an external memory management system.
[0023] Among related technologies, Mem0 is currently the most popular open-source memory management framework. It uses a four-choice decision model (ADD / UPDATE / DELETE / NOOP) to determine whether each new memory should be added, updated, deleted, or ignored. However, this approach has the following shortcomings: First, each decision in the four-choice process requires a relatively long LLM response time, resulting in significant accumulated costs in high-frequency dialogue scenarios. Second, the DELETE operation grants large models the authority to actively delete memories, which carries the risk of accidental deletion in actual operation, especially when the large model's judgment on "importance" is flawed. Third, it lacks an active eviction mechanism based on storage capacity, which may lead to the memory bank expanding indefinitely after long-term operation.
[0024] For example, MemGPT / Letta proposed a hierarchical memory architecture inspired by operating system virtual memory, dividing memory into core memory and archive memory, with the large model determining the movement of memory between different levels. The shortcomings of this approach are: 1. The hierarchical movement strategy is complex; the large model needs to understand and execute the concept of memory pressure, increasing the complexity of system prompts and inference costs; 2. Archive memory is still retained rather than deleted, essentially shifting storage pressure from the context window to external storage, failing to solve the long-term storage bloat problem; 3. Each dialogue requires the large model to actively manage memory operations, significantly increasing inference overhead.
[0025] For example, A-MEM (2025) proposed an adaptive structured memory system that constructs a knowledge network through dynamic indexing, enabling graph-like relationships between memory entries. While this approach is more advanced in knowledge organization, it has high implementation complexity, and the maintenance and query costs of the graph structure increase significantly with the size of the memory, making it unsuitable for real-time dialogue scenarios requiring low-latency responses.
[0026] In addition, some systems use delayed background processing or nighttime batch processing for memory management, but these methods still have shortcomings in terms of the real-time nature of triggering, the cost efficiency of deduplication judgment, and memory isolation in multi-agent scenarios.
[0027] Based on the above research, this application, during the dialogue between the target user and the target agent, when the current dialogue meets the memory storage triggering conditions, extracts the dialogue transcription text of the current dialogue in an asynchronous and non-blocking manner. The asynchronous and non-blocking manner can ensure that the background extraction of the dialogue transcription text does not affect the dialogue between the target user and the target agent, thus ensuring the normal execution of the dialogue.
[0028] Furthermore, after generating at least one current dialogue memory data entry, this application constructs a keyword set based on the memory description in the current dialogue memory data. It then performs keyword matching between multiple keywords in the keyword set and target entries in the target index file corresponding to the target user under the target agent, determining the number of keyword matches. When the number of keyword matches is greater than or equal to a preset threshold, based on the set target large language model and the memory file indicated by the target index file, it determines a target processing decision for the current dialogue memory data from three preset decisions, and processes the current dialogue memory data according to the target processing decision. The three preset decisions include: updating existing entries, creating new entries, and ignoring. This application employs a two-level architecture of keyword filtering plus target large language model precision judgment to determine the target processing decision for the dialogue memory data, which can reduce unnecessary model calls and improve processing efficiency. Moreover, the three-choice (i.e., update / create / ignore) deduplication decision designed in this application, compared to the four-choice or five-choice decisions in related technologies, can achieve lower-cost deduplication judgment with a very low token limit (e.g., 10 tokens), improving processing efficiency.
[0029] Meanwhile, this application sets up an index file corresponding to each user who has a dialogue with the target intelligent agent, and each entry in the index file corresponds to a memory file. The memory file is used to store the dialogue memory data between the user and the target intelligent agent, so that the dialogue memory data of different users under the same intelligent agent and the same user under different intelligent agents are stored in different directories, thereby realizing the isolation of the dialogue memory of different intelligent agents and / or different users and avoiding data leakage and confusion.
[0030] To facilitate understanding of this embodiment, a detailed description of the cross-dialogue memory management method disclosed in this application embodiment will be provided first. The execution entity of the cross-dialogue memory management method provided in this application embodiment is generally a computer device with a certain computing capability. This computer device may include, for example, a terminal device, a server, or other processing devices. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a computing device, an in-vehicle device, an embedded device, etc. In some possible implementations, this cross-dialogue memory management method can be implemented by the processor calling computer-readable instructions stored in the memory.
[0031] See Figure 1 The diagram shows a flowchart of a cross-dialogue memory management method provided in an embodiment of this application. The method includes steps S101 to S104, wherein: S101. During the dialogue between the target user and the target agent, when the current dialogue is detected to meet the memory storage triggering condition, the dialogue transcription text of the current dialogue is extracted in an asynchronous and non-blocking manner.
[0032] During real-time dialogue between the target user and the target agent, the current dialogue can be monitored in real time, such as the number of messages in the current dialogue. When the number of messages is large, such as exceeding the set threshold, it is determined that the memory storage condition is met, and the memory storage operation is triggered. The background extracts the transcribed text of the current dialogue in an asynchronous and non-blocking manner. The asynchronous and non-blocking method, such as the fire-and-forget method, continues to process subsequent dialogue messages without waiting for the memory retrieval process to complete. This method can ensure that the memory retrieval and storage process is processed asynchronously without blocking the main dialogue process, so that the target user cannot perceive the execution of the memory management operation, thus improving the user's interactive experience.
[0033] In practice, the dialogue can be truncated from the beginning to within the target number of characters (e.g., 6000 characters) to control the input token and improve processing efficiency.
[0034] Optionally, detecting that the current conversation meets the memory storage trigger condition includes: determining that the current conversation meets the memory storage trigger condition when the number of messages in the current session is greater than a preset number threshold, the target user has a valid user identifier, and the user identifier is not an anonymous temporary identifier.
[0035] In practice, the dialogue engine can check whether the memory storage trigger conditions are met after generating each reply, and trigger the memory retrieval process if they are met. The message count setting can avoid unnecessary memory retrieval triggered by short or meaningless conversations, improving the accuracy of memory retrieval. Furthermore, by judging user identifiers, anonymous users are filtered out, avoiding the creation of unrelated memory data for unregistered users and the waste of computing resources.
[0036] This application ensures that memory retrieval is triggered only after a sufficient amount of meaningful content has been accumulated in the dialogue by setting a preset threshold, such as 4 messages. This avoids wasting the large language model's resources on shallow dialogue such as "hello." The fire-and-forget pattern (calling without waiting for a return, only catching exceptions) ensures that memory retrieval does not block the main dialogue response flow. Simultaneously, anonymous user filtering prevents the creation of unassociated memories for unregistered users. These processes ensure the accuracy and effectiveness of the memory retrieval process, avoiding resource waste and disruption to the main dialogue flow.
[0037] S102. Extract content from the transcribed dialogue text to generate at least one current dialogue memory data including the current dialogue, and construct a keyword set based on the memory description in the current dialogue memory data.
[0038] In implementation, the transcribed dialogue text can be sent to the target large language model for content extraction to generate at least one current dialogue memory data entry, and each current dialogue memory data entry can be processed separately. For example, a keyword set can be constructed based on the memory description (i.e., description) in each current dialogue memory data entry. Keyword extraction can employ a bilingual word segmentation strategy, using two-character bigram segmentation for Chinese text and word segmentation for English text to construct the keyword set. The maximum number of tokens that can be output can be set to 10. For instance, if the memory description is: "The user is a graduate student in quantum computing," then the generated keyword set could include: user, quantum, computing, direction, research.
[0039] Optionally, content extraction is performed on the transcribed dialogue text to generate at least one current dialogue memory data including the current dialogue, including: determining structured extraction rule information, the extraction rule information including extraction criteria and exclusion rules; using the target large language model, content extraction is performed on the transcribed dialogue text based on the extraction rule information to generate at least one current dialogue memory data including the current dialogue; wherein the current dialogue memory data includes metadata and memory text, the metadata including name, type label and memory description.
[0040] During implementation, structured extraction rule information can be determined. This information can include extraction criteria and exclusion rules, which can be set according to actual business needs. For example, extraction criteria could include user identity, preferences, decisions, corrections, and important relationships, while exclusion rules could include the intelligent agent's own knowledge domain content, obvious common-sense facts, and temporary or one-time content.
[0041] The transcribed dialogue text and extraction rule information are sent to the target large language model so that the target large language model can extract content from the transcribed dialogue text based on the extraction rule information to generate at least one current dialogue memory data, which includes metadata and memory text. The metadata includes name, type label and memory description.
[0042] The target large language model needs to output each memory in a structured format, meaning that each memory (current dialogue memory data) can include metadata and the memory text in YAML format. The metadata can include a short name, type label, and memory description, as well as creation time, update time, etc. The type label includes, but is not limited to, user identity information, user feedback corrections, user project tasks, and reference preferences.
[0043] If the target large language model determines that there is no content worth remembering in the transcribed dialogue text, the target large language model outputs the NO_MEMORIES flag, and the system terminates the process directly.
[0044] The above process can generate current dialogue memory data more accurately, so as to make subsequent judgments on the processing decisions of the current dialogue memory data and achieve accurate processing of the current dialogue memory data.
[0045] The method further includes S103, performing keyword matching between multiple keywords included in the keyword set and target entries in the target index file corresponding to the target user under the target agent, and determining the number of keyword matches, wherein each user who has a dialogue with the target agent corresponds to an index file, each entry in the index file corresponds to a memory file, and the memory file is used to store dialogue memory data between the user and the target agent.
[0046] S104. When the number of keyword matches is greater than or equal to a preset threshold, based on the set target large language model and the memory file indicated by the target index file, a target processing decision for the current dialogue memory data is determined from three preset decisions, and the current dialogue memory data is processed according to the target processing decision, wherein the three preset decisions include: updating existing entries, creating new entries, and ignoring.
[0047] Before saving newly extracted memories, this application performs a deduplication check. The deduplication process adopts a two-level architecture of "keyword pre-screening + large language model fine judgment" to make a rough decision on the current dialogue memory data more accurately.
[0048] During implementation, the keyword set is matched against multiple keywords and target entries in the target index file corresponding to the target user under the target agent to determine the number of keyword matches. When the number of keyword matches is greater than or equal to a preset threshold, the processing method of the current dialogue memory data is further precisely determined using the target large language model. The preset threshold can be set according to actual needs.
[0049] Specifically, when the number of keyword matches is greater than or equal to a preset threshold, the target large language model is invoked to perform a three-option decision. That is, based on the memory file indicated by the target index file, the target processing decision for the current dialogue memory data is determined from three preset decisions. In other words, the target large language model is restricted to outputting only the identifier corresponding to the target processing decision. For example, if the three preset decisions are A (update existing entries), B (create new entries), and C (ignore), the target large language model only needs to output A, B, or C.
[0050] In this application, a low-cost decision is achieved by setting an upper limit for token output (e.g., setting maxTokens to 10) through calls to the target large language model.
[0051] When the target language model outputs a target processing decision of A (update), the system locates the existing memory file and overwrites its contents in place, synchronously updating the description information in the index file. When the target language model outputs a target processing decision of C (ignore), the memory is skipped directly. A new memory file is created only when the output is a target processing decision of B (create new entry) or when the target language model call fails.
[0052] For example, the target large language model can make accurate judgments based on all memory files in the target index file, or it can make accurate judgments based on specific memory files in the target index file that match the keywords.
[0053] In this application, each user engaging in dialogue with the target agent corresponds to an index file, and each entry in the index file corresponds to a memory file. The memory file stores the dialogue memory data between the user and the target agent. That is, the index file and memory file corresponding to each user under the same target agent are different, and the index file and memory file stored for the dialogue between the same user and different target agents are also different. The target index file is obtained based on the agent identifier of the target agent and the user identifier of the target user.
[0054] Optionally, the method further includes: when the number of keyword matches is less than the preset quantity threshold, determining the target processing decision for the current dialogue memory data as creating a new entry.
[0055] During implementation, when the number of keyword matches is less than the preset threshold, the current dialogue memory data may be entirely new dialogue data. Therefore, the target processing decision for the current dialogue memory data is to create a new entry, without the need for precise judgment using the target large language model.
[0056] In practice, if the preset threshold is set to 2, after matching multiple keywords in the keyword set with the target entries in the target index file corresponding to the target user under the target agent, and determining the number of keyword matches, if the number of keyword matches is less than 2, it means that the probability of the current dialogue memory being new content is high. Therefore, there is no need to call the target large language model for further judgment, and a new entry can be created directly. This makes the computational cost of the above process the string operation of keyword matching, which can effectively reduce the cost of semantic judgment and improve processing efficiency.
[0057] This application achieves low-cost deduplication decision-making through a three-choice judgment using a target large language model (MLM) with keyword pre-screening and output token restrictions (e.g., a maximum of 10 tokens). Research shows that the cost of calling the target large language model for each deduplication decision is only about 1 / 50 of that of related technical solutions (such as Mem0's complete semantic understanding). For example, taking Mem0 as an example, its deduplication judgment for each memory requires a complete LLM semantic understanding call. The input includes the full text of the new memory and the full text of the existing memory, and the output is a complete response containing the decision reason. The typical output length is about 200-500 tokens. In contrast, in the two-level architecture of this application, the first-level keyword pre-screening is a pure string operation with zero LLM call cost, which can filter out the vast majority of obviously non-repeating memory pairs. The second-level LLM judgment is only called on a small number of candidate pairs that pass the pre-screening. By limiting the output length to a preset upper limit (e.g., 10 tokens), a single judgment only needs to output a decision identifier (e.g., A / B / C), and the call cost is about 1 / 50 of Mem0's complete semantic judgment. Therefore, this application has a significant cumulative cost advantage in high-frequency dialogue scenarios.
[0058] Optionally, when there are multiple agents, a storage directory is constructed using a two-dimensional structure consisting of user identifiers and agent identifiers. Different storage directories correspond to different user identifiers and / or agent identifiers. Each storage directory includes an index file and a memory file corresponding to each entry in the index file.
[0059] See Figure 2The storage directory diagram shown illustrates a two-dimensional isolation between users and agents in this application. Specifically, the memory data of different users is stored separately, and the memory data of different agents is also stored separately. The index file and the memory file correspond to each other; when a content file is added, updated, or deleted, the corresponding entries in the index file are simultaneously added, deleted, or updated.
[0060] In implementation, the storage directory is organized in a two-dimensional structure of {User ID} / {Agent ID} / , and each storage directory maintains an index file named MEMORY.md, which can be in Markdown link list format. An example index file is shown below: # Memories of User - [User's Research Direction.md] (User's Research Direction.md) — The user is a graduate student specializing in quantum computing. - [Programming Preferences.md](Programming Preferences.md) — User preference for using Python and Julia Each entry in the index file corresponds to a memory file, where each memory is stored as an independent Markdown file (memory file). The filename of the memory file can be generated by converting the memory name using `snake_case` (Chinese characters are preserved). The content of the memory file is stored in a format of YAML prefix metadata (frontmatter) + Markdown text. For example, the content of a memory file is as follows: --- name: User Research Direction type: user Description: The user is a graduate student specializing in quantum computing. created: 2020-04-10T10:00:00.000Z updated: 2020-04-11T15:30:00.000Z --- The user is a graduate student in the physics department of a university, whose main research area is error correction coding in quantum computing. His advisor is Professor Zhang.
[0061] --- As can be seen, in the aforementioned memory file, name, type, description, created, and updated are metadata, and the Markdown text is "The user is a graduate student in the physics department of a certain university, whose main research direction is error correction coding in quantum computing. His supervisor is Professor Zhang."
[0062] The above design of this application can ensure that each agent maintains an independent memory space for each user, so that the information remembered by agent A will not be leaked to agent B; at the same time, the index file of this application supports fast browsing and keyword matching without reading the entire memory file content, thus improving data processing efficiency.
[0063] In this application, the memory isolation of multiple agents, namely the two-dimensional directory structure of user identifier / agent identifier and independent index file, ensures that different agents maintain independent memory spaces for the same user, avoids cross-agent memory leakage, and supports each role to form differentiated user cognition based on its own domain perspective.
[0064] The memory in this application is stored in a structured persistent manner, that is, the deduplicated memory is stored independently in a file format containing metadata prefixes, organized in a two-dimensional directory structure of user identifier and agent identifier, and each directory maintains an independent index file.
[0065] Given the lack of memory isolation design for multi-agent systems in related technologies, in scenarios where multiple agents coexist, different agents' memories of the same user are prone to confusion or leakage. To alleviate these problems, this application uses a two-dimensional directory isolation system based on user identifiers / agent identifiers and independent index files. This allows each agent in a multi-agent system to maintain independent and differentiated memories of the same user, ensuring user data security and more accurate agent responses.
[0066] Considering that in multi-session concurrent scenarios, such as a single user potentially conversing with multiple agents simultaneously, or conversing with the same agent on multiple devices, memory write operations may encounter race conditions. To mitigate this problem, this application allows processing the current dialogue memory data according to the target processing decision when the target processing decision is to update an existing entry or create a new entry. This includes: obtaining the current lock state corresponding to the target lock key, which is composed of the user identifier of the target user and the agent identifier of the target agent; and processing the current dialogue memory data according to the target processing decision when the current lock state is unlocked.
[0067] For example, the combination of the target user's user identifier and the target agent's agent identifier can be used as the lock key. The lock state is maintained through a Map data structure. When updating an existing entry or creating a new entry, the current lock state corresponding to the target lock key is obtained in real time. When the current lock state is unlocked, that is, when no other device performs a memory write operation, the current dialogue memory data is processed according to the target processing decision. When processing the current dialogue memory data, the lock state of the target lock key is updated to locked synchronously.
[0068] When the current lock state is locked, it can be polled at preset intervals to perform a memory write operation after the lock state changes.
[0069] For example, a per-user spinlock mechanism can be used, with {user ID} / {agent ID} as the lock key. The lock state is maintained through a Map data structure, and a 50ms polling interval is used to achieve waiting, thus serializing the memory write operation.
[0070] This application sets up a concurrent write security mechanism, which uses a combination of user identifier and agent identifier as the key and a spin lock to serialize the memory write operations of the same user and agent pair, ensuring the consistency of memory file and index writes in multi-session concurrent scenarios and preventing index file corruption caused by concurrent writes.
[0071] Optionally, the method further includes: when the number of stored memory files determined according to the target index file is greater than a preset capacity threshold, sending the target index file to the target large language model; using the target large language model based on multiple evaluation dimensions to determine a preset number of entries to be deleted from multiple target entries in the target index file; wherein the multiple evaluation dimensions include at least two of timeliness dimension, specificity dimension, and redundancy dimension; the timeliness dimension is used to evaluate the interval between the update time of the memory file and the current time; the specificity dimension is used to evaluate the information density of the memory content; the redundancy dimension is used to evaluate the degree of duplication of the memory content with other memory files; deleting the memory files corresponding to the preset number of entries to be deleted, and updating the target index file.
[0072] This application can also determine in real time whether the number of memory files in the user identifier / agent identifier directory exceeds a preset capacity threshold, and delete them when it does, to avoid the problem of storage space expanding indefinitely. The preset capacity threshold and preset number can be set according to actual needs.
[0073] During implementation, based on the target index file, it is determined whether the number of stored memory files exceeds a preset capacity threshold. If not, no deletion operation is required. If so, the target index file is sent to the target large language model. The target large language model uses at least two of several evaluation dimensions, such as timeliness, specificity, and redundancy, to determine a preset number of entries to be deleted from multiple target entries within the target index file. The timeliness dimension evaluates the interval between the update time of the memory file and the current time; for example, timeliness determines whether the memory is still in use based on the update time of the memory file and the current time. The specificity dimension evaluates the information density of the memory content; for example, specificity determines whether the description of the memory content is vague or lacks information. The redundancy dimension evaluates the degree of duplication between the memory content and other memory files; for example, redundancy determines whether any memory file duplicates other memory content based on the memory content of different memory files. The memory files corresponding to the selected preset number of entries to be deleted are then permanently deleted from the file system, and the target index file synchronously cleans up the corresponding entries, completing the real-time update of the target index file.
[0074] In this application, an editing standard elimination mechanism based on the evaluation of the target large language model is introduced. When the number of memory entries exceeds a preset capacity threshold, the target large language model selectively and permanently deletes the least important entries based on timeliness, specificity, and redundancy. This strictly controls the number of memory files within the capacity threshold, thereby fundamentally controlling storage space. Compared with the hierarchical movement strategy in related technologies (such as archiving but not deleting), this application fundamentally solves the problem of storage expansion under long-term operation.
[0075] Optionally, before extracting the transcribed text of the current dialogue in an asynchronous, non-blocking manner, this application further includes: determining the number of entries in the target index file corresponding to the target user under the target agent based on the user identifier of the target user and the agent identifier of the target agent; when the number of entries is greater than the target number, selecting a target number of target memory files from multiple memory files indicated by the target index file based on the dialogue topic of the current dialogue; and inputting the target memory files carrying preset behavior instructions into the system prompt of the target agent, wherein the preset behavior instructions are used to instruct the target agent to prohibit the memory acquisition behavior.
[0076] During the dialogue between the target user and the target agent, that is, after the target user establishes a new conversation with the target agent, this application can trigger a topic-related retrieval operation to retrieve and load a certain amount of historical memory, so that the target agent can better respond to the target user based on the loaded historical memory and conduct multiple rounds of dialogue with the target user, so that the content of the multiple rounds of dialogue can be extracted later to obtain the dialogue transcript and improve the user experience.
[0077] During implementation, the number of entries in the target index file corresponding to the target user under the target agent can be determined based on the user identifier of the target user and the agent identifier of the target agent. When the number of entries is less than or equal to the target number, all memory files in the target index file can be loaded. When the number of entries is greater than the target number, the target number of target memory files are selected from multiple memory files indicated by the target index file according to the dialogue topic of the current dialogue; that is, target memory files matching the dialogue topic are selected. If the number of target memory files matching the dialogue topic is less than the target number, some memory files can be randomly selected from memory files of other topics for loading.
[0078] The dialogue topic can be a specific topic input by the user, or it can be determined based on the user's input. Alternatively, when the total number of memory entries exceeds the target number N, keywords can be extracted from the current dialogue content, a keyword hit score can be calculated for the description text of each entry in the index file, and the top N memories with the highest scores can be loaded.
[0079] After identifying the target memory file, it can be input into the system prompts of the target agent, carrying preset behavioral instructions. This allows the target agent to respond more effectively to the target user. The preset behavioral instructions instruct the target agent to refrain from exhibiting memory acquisition behaviors. For example, the preset behavioral instructions could require the agent to integrate memory naturally into the conversation without explicitly mentioning words like "remember" or "memory." A possible preset behavioral instruction would be "Integrate naturally into the conversation, without explicitly mentioning 'remember' or 'memory,'" thus implicitly injecting historical memories.
[0080] The implicit memory injection mechanism of this application can retrieve historical memories related to the current topic when a new conversation is initialized, inject the retrieved historical memories into the agent's system prompt words as structured text, and attach behavioral constraint instructions (i.e., preset behavioral instructions). The behavioral constraint instructions require the agent to naturally integrate the memory into the conversation when using the memory without explicitly mentioning the memory behavior.
[0081] Research has shown that existing memory injection technologies lack a mechanism to conceal memory actions, potentially leading to agents outputting statements like "I remember you said before..." during conversations, disrupting the natural interaction experience. To mitigate this issue, this application employs implicit memory injection instructions (such as "integrate naturally into the conversation, do not explicitly mention memory actions"), enabling agents to utilize memories without exposing the underlying memory mechanisms. This provides a more natural user experience, allowing users to perceive that the agent truly understands them rather than simply retrieving data from a database. This mechanism significantly enhances the naturalness of the interaction and the user experience, making the interaction feel more natural and engaging.
[0082] The following detailed description of the cross-dialogue memory management method proposed in this application, with reference to specific embodiments, illustrates this method. This method is applied to multi-agent dialogue platforms, where the platform includes multiple AI roles with different professional backgrounds (such as physicists, biologists, mathematicians, etc.). The backend uses Node.js runtime, memory storage uses a file system (one Markdown file per memory entry), and the target large language model can utilize existing low-cost large models.
[0083] For example, suppose user "user-123" has a conversation with the digital human character "richard-feynman". At the beginning of the new conversation, a memory retrieval and injection process can be performed. For instance, the system calls the `recall("user-123", "richard-feynman", "", "zh")` method to read the index file `memories / user-123 / richard-feynman / MEMORY.md`. If 8 memory entries are parsed, since the number of entries does not exceed 10 (the target number), the text content of all 8 memory files is read directly. If more than 10 memory entries are parsed, LLM can be called to select 10 memory files from multiple memory files for memory retrieval. The system generates injection text based on the selected memory files, carrying behavioral constraint instructions (i.e., preset behavioral instructions), and appends it to the end of the digital human character's system prompt. For example, the generated injection text carrying behavioral constraint instructions is shown below: Here is what you know about this user (integrate naturally into the conversation, without explicitly mentioning "remember" or "memory"): - The user is a third-year physics student at Tsinghua University, whose research focuses on quantum error correction; - The user mentioned last time that they were preparing a paper on surface codes; - Users prefer to understand problems using Feynman diagrams.
[0084] The user continues the dialogue with the digital avatar. During this dialogue, the digital avatar can respond to user messages by incorporating recalled historical memories. For example, it can naturally utilize information from its memories in its responses. The digital avatar might know that the user is writing a paper on surface codes, thus naturally leading the discussion of the threshold theorem to the specific application of surface codes, rather than a general discussion.
[0085] During the third conversation between the user and the digital human avatar, memory retrieval is triggered. For example, when the number of conversation messages reaches four (the user sends two messages and the avatar replies with two), the system asynchronously triggers `extractAndSave` using a fire-and-forget method. The conversation transcript is truncated to the first 6000 characters and then sent to the LLM.
[0086] LLM extracts content from the transcribed text of a dialogue and outputs the extracted results, i.e., structured memory data. For example, LLM returns the following extraction results (i.e., the current dialogue memory data): --- name: Paper Progress Update type: project Description: The user's surface code paper has completed its first draft and is currently undergoing simulation experiments.
[0087] --- The user mentioned that the first draft of the surface coding paper has been completed and is currently being used for numerical simulation using the Stim simulator. It is expected to be submitted in two weeks.
[0088] --- name: Understanding the Threshold Theorem type: user Description: The user is confused about the details of the proof of the threshold theorem. --- Users don't quite understand Knill's proof of the threshold theorem and hope to understand it from a physical intuition perspective.
[0089] --- After retrieving the dialogue memory data, a deduplication decision is made for the current dialogue memory data. For example, for the memory "paper progress update", the system extracts keywords ["surface", "surface code", "paper", "completed", "draft", "simulation", "experiment"] and matches them with the existing entry in the index "the user last mentioned that they were preparing a paper about surface codes". If the keywords "surface", "surface code", and "paper" match, with a match count of 3 (≥2), the LLM three-way selection is triggered, that is, the LLM determines the target processing decision for the current dialogue memory data. The LLM response outputs "A" (only 1 token), that is, the target processing decision is to update the existing entry, and the system overwrites and updates the content and index description of the existing memory file.
[0090] For the memory entry "understanding the threshold theorem", the number of matches between the keyword and existing entries is less than 2. Therefore, a new file is created directly, namely the file "understanding the threshold theorem.md", and index entries are appended to the index file.
[0091] The system can also perform capacity checks. Specifically, it checks the number of .md files (excluding MEMORY.md) in the storage directories corresponding to the user and digital human role. Assuming there are currently 9, which is below the preset capacity threshold, the system skips the eviction process. If the number of memory files exceeds the preset capacity threshold, the system calls `evictIfNeeded` to send the complete index file to the LLM. The LLM then uses three dimensions—timeliness (e.g., "old information from January 2025"), specificity (e.g., "the user asked a question," a vague memory), and redundancy (e.g., "the user likes Python" and "the user prefers Python programming")—to output the 5 least important memory file names (i.e., outputting a preset number of entries to be deleted). The system then deletes these 5 memory files and their index entries sequentially, keeping the number of memory files within the preset capacity threshold.
[0092] In summary, this application specifically relates to a cross-conversation memory management method for digital humans (AI roles / intelligent agents). This method utilizes a Large Language Model (LLM) to automatically extract, deduplicate, retrieve, and discard user-related memories during dialogue, enabling the digital human to maintain continuous cognition of the user across multiple conversations. Simultaneously, an implicit memory injection mechanism allows the use of memories to be naturally integrated into the dialogue without exposing the underlying mechanisms. This application is particularly applicable to scenarios in multi-role digital human systems where each role independently maintains differentiated memories of the same user.
[0093] Corresponding to the aforementioned embodiments of the cross-dialogue memory management method, this application also provides embodiments of the cross-dialogue memory management device. Figure 3 A schematic diagram of the cross-dialogue memory management device provided in this application specifically includes: The extraction module 301 is used to extract the dialogue transcript of the current dialogue in an asynchronous and non-blocking manner when the current dialogue is detected to meet the memory storage triggering condition during the dialogue between the target user and the target intelligent agent. The generation module 302 is used to extract content from the transcribed dialogue text, generate at least one current dialogue memory data including the current dialogue, and construct a keyword set based on the memory description in the current dialogue memory data; The matching module 303 is used to perform keyword matching on multiple keywords included in the keyword set and target entries in the target index file corresponding to the target user under the target agent, and determine the number of keyword matches. Each user who has a dialogue with the target agent corresponds to an index file, and each entry in the index file corresponds to a memory file. The memory file is used to store dialogue memory data between the user and the target agent. The processing module 304 is used to determine a target processing decision for the current dialogue memory data from three preset decisions based on the set target large language model and the memory file indicated by the target index file when the number of keyword matches is greater than or equal to a preset number threshold, and process the current dialogue memory data according to the target processing decision, wherein the three preset decisions include: updating existing entries, creating new entries, and ignoring.
[0094] In an optional implementation, the processing module 304 is further configured to: when the number of keyword matches is less than the preset quantity threshold, determine the target processing decision for the current dialogue memory data as creating a new entry.
[0095] In an optional implementation, the generation module 302, when extracting content from the transcribed dialogue text to generate at least one current dialogue memory data item included in the current dialogue, is used to: Determine structured extraction rule information, which includes extraction criteria and exclusion rules; Using the target large language model, content extraction is performed on the transcribed dialogue text based on the extraction rule information to generate at least one current dialogue memory data, wherein the current dialogue memory data includes metadata and memory text, and the metadata includes name, type label and memory description.
[0096] In an optional implementation, when the extraction module 301 detects that the current conversation meets the memory storage triggering condition, it is configured to: determine that the current conversation meets the memory storage triggering condition when it detects that the number of messages in the current session is greater than a preset number threshold, the target user has a valid user identifier, and the user identifier is not an anonymous temporary identifier.
[0097] In an optional implementation, when the target processing decision is to update an existing entry or create a new entry, the processing module 304, when processing the current dialogue memory data according to the target processing decision, is configured to: Obtain the current lock state corresponding to the target lock key, which is composed of the user identifier of the target user and the agent identifier of the target agent; When the current lock state is unlocked, the current dialogue memory data is processed according to the target processing decision.
[0098] In an optional embodiment, the apparatus further includes: a deletion module 305, configured to: When the number of stored memory files is determined to be greater than a preset capacity threshold based on the target index file, the target index file is sent to the target large language model; Using the target large language model based on multiple evaluation dimensions, a preset number of entries to be deleted are determined from multiple target entries in the target index file; wherein the multiple evaluation dimensions include at least two of the following: timeliness dimension, specificity dimension, and redundancy dimension; the timeliness dimension is used to evaluate the interval between the update time of the memory file and the current time; the specificity dimension is used to evaluate the information density of the memory content; the redundancy dimension is used to evaluate the degree of duplication of the memory content with other memory files; Delete the memory files corresponding to the preset number of entries to be deleted, and update the target index file.
[0099] In an optional implementation, before retrieving the dialogue transcription text of the current dialogue in an asynchronous, non-blocking manner, the apparatus further includes: a memory retrieval module 306, configured to: Based on the user identifier of the target user and the agent identifier of the target agent, determine the number of entries in the target index file corresponding to the target user under the target agent; When the number of entries exceeds the target number, a target number of target memory files are selected from multiple memory files indicated by the target index file, based on the dialogue topic of the current dialogue. The target memory file carrying preset behavior instructions is input into the system prompt of the target agent, wherein the preset behavior instructions are used to instruct the target agent to prohibit the memory acquisition behavior.
[0100] In one optional implementation, when there are multiple agents, a storage directory is constructed using a two-dimensional structure consisting of user identifiers and agent identifiers. Different storage directories correspond to different user identifiers and / or agent identifiers. Each storage directory includes an index file and a memory file corresponding to each entry in the index file.
[0101] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0102] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0103] This application also provides a computer-readable storage medium storing a computer program that can be used to execute the cross-dialogue memory management method described in the above embodiments.
[0104] This application also provides a computer device, see [link to relevant documentation] Figure 4 The diagram shown illustrates the structure of the computer device provided in this application. At the hardware level, the computer device includes a processor, an internal bus, a network interface, memory, and non-volatile memory, and may also include other hardware required for various business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to implement the cross-dialogue memory management method described in the above embodiments. Of course, besides software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution entity of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.
[0105] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs) containing computer-usable program code. The form of a computer program product implemented on ROM, optical memory, etc.
[0106] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0107] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0108] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the functions specified in one or more boxes. In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0109] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0110] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, and optical disc read-only memory (CD). ROM, digital multifunction optical disc (DVD) or other optical storage, magnetic cassette tape, magnetic magnetic disk storage or other magnetic storage devices or any other non-transferable medium, may be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0111] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0112] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0113] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0114] The embodiments of the subject matter and functional operation described in this specification can be implemented in the following ways: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or combinations thereof. Embodiments of the subject matter described in this specification can be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier for execution by a data processing apparatus or for controlling the operation of a data processing apparatus. Alternatively or additionally, the program instructions may be encoded on artificially generated propagation signals, such as machine-generated electrical, optical, or electromagnetic signals, which are generated to encode information and transmit it to a suitable receiving device for execution by the data processing apparatus. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or combinations thereof.
[0115] The processing and logic flow described in this specification can be executed by one or more programmable computers that execute one or more computer programs to perform corresponding functions by operating on input data and generating output. The processing and logic flow can also be executed by dedicated logic circuitry—such as FPGAs (Field-Programmable Gate Arrays) or ASICs (Application-Specific Integrated Circuits), and the device can also be implemented as dedicated logic circuitry.
[0116] Suitable computers for executing computer programs include, for example, general-purpose and / or special-purpose microprocessors, or any other type of central processing unit. Typically, the central processing unit receives instructions and data from read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, a computer will also include one or more mass storage devices for storing data, such as disks, magneto-optical disks, or optical disks, or the computer will be operatively coupled to such mass storage devices to receive data from or transfer data to them, or both. However, a computer is not required to have such devices. Furthermore, a computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.
[0117] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CDs. ROM and DVD ROM disk. The processor and memory can be supplemented by or integrated into dedicated logic circuitry.
[0118] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.
[0119] Similarly, although the operations are depicted in a specific order in the accompanying drawings, this should not be construed as requiring these operations to be performed in the specific order shown or sequentially, or requiring all illustrated operations to be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.
[0120] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims may be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the drawings are not necessarily shown in a specific order or sequence to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.
[0121] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A cross-dialogue memory management method, characterized in that, The method includes: During the dialogue between the target user and the target agent, when the current dialogue meets the memory storage trigger condition, the dialogue transcription text of the current dialogue is extracted in an asynchronous and non-blocking manner. Content extraction is performed on the transcribed text of the dialogue to generate at least one current dialogue memory data, and a keyword set is constructed based on the memory description in the current dialogue memory data; The keyword set includes multiple keywords and target entries in the target index file corresponding to the target user under the target agent are matched to determine the number of keyword matches. Each user who has a dialogue with the target agent corresponds to an index file, and each entry in the index file corresponds to a memory file. The memory file is used to store the dialogue memory data between the user and the target agent. When the number of keyword matches is greater than or equal to a preset threshold, based on the set target large language model and the memory file indicated by the target index file, a target processing decision for the current dialogue memory data is determined from three preset decisions, and the current dialogue memory data is processed according to the target processing decision, wherein the three preset decisions include: updating existing entries, creating new entries, and ignoring.
2. The method according to claim 1, characterized in that, The method further includes: When the number of keyword matches is less than the preset threshold, the target processing decision for the current dialogue memory data is determined to be to create a new entry.
3. The method according to claim 1, characterized in that, Content extraction is performed on the transcribed text of the dialogue to generate at least one current dialogue memory data, including: Determine structured extraction rule information, which includes extraction criteria and exclusion rules; Using the target large language model, content extraction is performed on the transcribed dialogue text based on the extraction rule information to generate at least one current dialogue memory data, wherein the current dialogue memory data includes metadata and memory text, and the metadata includes name, type label and memory description.
4. The method according to claim 1, characterized in that, The detection that the current dialogue meets the memory storage trigger conditions includes: When the number of messages in the current session is detected to be greater than a preset threshold, the target user has a valid user identifier, and the user identifier is not an anonymous temporary identifier, it is determined that the current conversation meets the memory storage trigger condition.
5. The method according to claim 1, characterized in that, When the target processing decision is to update an existing entry or create a new entry, processing the current dialogue memory data according to the target processing decision includes: Obtain the current lock state corresponding to the target lock key, which is composed of the user identifier of the target user and the agent identifier of the target agent; When the current lock state is unlocked, the current dialogue memory data is processed according to the target processing decision.
6. The method according to claim 1, characterized in that, The method further includes: When the number of stored memory files is determined to be greater than a preset capacity threshold based on the target index file, the target index file is sent to the target large language model; Using the target large language model based on multiple evaluation dimensions, a preset number of entries to be deleted are determined from multiple target entries in the target index file; wherein the multiple evaluation dimensions include at least two of the following: timeliness dimension, specificity dimension, and redundancy dimension; the timeliness dimension is used to evaluate the interval between the update time of the memory file and the current time; the specificity dimension is used to evaluate the information density of the memory content; the redundancy dimension is used to evaluate the degree of duplication of the memory content with other memory files; Delete the memory files corresponding to the preset number of entries to be deleted, and update the target index file.
7. The method according to claim 1, characterized in that, Before extracting the dialogue transcript of the current dialogue in an asynchronous, non-blocking manner, the method further includes: Based on the user identifier of the target user and the agent identifier of the target agent, determine the number of entries in the target index file corresponding to the target user under the target agent; When the number of entries exceeds the target number, a target number of target memory files are selected from multiple memory files indicated by the target index file, based on the dialogue topic of the current dialogue. The target memory file carrying preset behavior instructions is input into the system prompt of the target agent, wherein the preset behavior instructions are used to instruct the target agent to prohibit the memory acquisition behavior.
8. The method according to any one of claims 1-7, characterized in that, When there are multiple agents, a storage directory is constructed using a two-dimensional structure consisting of user identifiers and agent identifiers. Different storage directories correspond to different user identifiers and / or agent identifiers. Each storage directory includes an index file and a memory file corresponding to each entry in the index file.
9. A cross-dialogue memory management device, characterized in that, The device includes: The extraction module is used to extract the transcribed text of the current dialogue in an asynchronous and non-blocking manner when the current dialogue meets the memory storage triggering conditions during the dialogue between the target user and the target agent. The generation module is used to extract content from the transcribed dialogue text, generate at least one current dialogue memory data including the current dialogue, and construct a keyword set based on the memory description in the current dialogue memory data; The matching module is used to perform keyword matching between multiple keywords included in the keyword set and target entries in the target index file corresponding to the target user under the target agent, and to determine the number of keyword matches. Each user who has a dialogue with the target agent corresponds to an index file, and each entry in the index file corresponds to a memory file. The memory file is used to store the dialogue memory data between the user and the target agent. The processing module is used to determine a target processing decision for the current dialogue memory data from three preset decisions based on the set target large language model and the memory file indicated by the target index file when the number of keyword matches is greater than or equal to a preset threshold, and process the current dialogue memory data according to the target processing decision, wherein the three preset decisions include: updating existing entries, creating new entries, and ignoring.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it implements the steps of the method according to any one of claims 1-8.
11. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor performs the steps of the method according to any one of claims 1-8.