Virtual character memory management method and system, electronic equipment and storage medium

By using the three-level memory management method and the character setting of virtual characters in the AI ​​virtual role-playing system, the problem of improper memory management of virtual characters in the existing technology in multiple rounds of dialogue is solved, and a more natural and consistent dialogue performance is achieved.

CN120045699AActive Publication Date: 2025-05-27GUANGZHOU HUYA INFORMATION TECH CO LTD

Patent Information

Application Number
CN202510510885.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2025-05-27
Estimated Expiration
2045-04-23

AI Technical Summary

Technical Problem

The existing AI virtual role-playing system has reduced dialogue coherence and naturalness due to improper memory management in multiple rounds of conversations, and lacks modeling of the behavior consistency of virtual characters themselves.

Method used

A three-level memory management method is adopted, including instantaneous memory, short-term memory and long-term memory, and memory fusion is carried out in combination with the character settings of virtual characters to ensure the organized storage and use of memory data.

Benefits of technology

It improves the consistency and naturalness of virtual characters' dialogues, enhances the consistency and authenticity of virtual characters, and enhances the emotional experience of users' dialogues.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045699A_ABST
    Figure CN120045699A_ABST
Patent Text Reader

Abstract

The invention relates to the field of artificial intelligence, in particular to a virtual role memory management method and system. The method comprises the following steps: acquiring instantaneous memory at the current moment and instantaneous memory at the previous moment according to dialogue content of a user and the virtual character; according to the short-term memory, the instantaneous memory, the long-term memory and the current dialogue content of the previous moment, obtaining the short-term memory of the current moment; according to the character setting of the virtual character, the long-time memory and the short-time memory of the previous moment, and the current dialogue content, obtaining the long-time memory of the current moment; and fusing the instantaneous memory, the short-term memory and the long-term memory of the current moment with the current dialogue content and the character setting of the virtual character to obtain the fused memory of the current moment. According to the method, multi-level processing and management can be carried out on the memory data in the virtual character, so that the memory data is stored and used more orderly, and the virtual character is more simulated according to the answer of the memory data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and more specifically, to a method, system, electronic device, and storage medium for managing virtual character memories. Background Art

[0002] In the prior art, AI virtual role-playing systems usually rely on simple dialogue contexts as memories. This results in the inability to correctly and effectively recall relevant memories when the number of dialogue turns exceeds the window threshold, thus affecting the coherence and naturalness of the dialogue. In addition, some AI virtual role-playing systems generate "memories" of AI virtual characters for users by extracting user attribute features from the dialogue, such as name, gender, age, hobbies, etc. However, these methods usually only focus on the portrait information on the user side and still lack the modeling of the AI virtual character's own OOC (Out-of-Character, i.e., behaviors or remarks beyond the character setting) responses, resulting in the AI virtual character appearing unrealistic and inconsistent in long multi-turn dialogues. Therefore, it is necessary to make necessary improvements to the memory management method of AI virtual characters. Summary of the Invention

[0003] The present invention aims to overcome at least one defect (shortcoming) of the above prior art, and provides a method, system, electronic device, and storage medium for managing virtual character memories, which are used to make the memory data in the virtual character stored and used more orderly, so that the responses of the virtual character based on the memory data are more realistic.

[0004] According to the first aspect of the present application, a method for managing virtual character memories is provided. The method includes: Pre-set a short-term memory library, a long-term memory library, and a character setting library for the virtual character; Obtain the dialogue content between the user and the virtual character, and obtain the current dialogue content at the current moment between the user and the virtual character, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment according to the dialogue content; Obtain the short-term memory of the virtual character at the current moment according to the instantaneous memory, short-term memory, long-term memory, and the current dialogue content at the previous moment, and add the short-term memory at the current moment to the short-term memory library; Obtain the long-term memory of the virtual character at the current moment according to the current dialogue content, the character setting of the virtual character, and the short-term memory and long-term memory at the previous moment; and add the long-term memory at the current moment to the long-term memory library; Fuse the current conversation content, the character settings of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment; among them, the short-term memory of the previous moment is obtained from the short-term memory library, and the long-term memory of the previous moment is obtained from the long-term memory library; the character settings of the virtual character are extracted from the character setting library.

[0005] It can be understood that this application can realize more comprehensive and accurate memory management of virtual characters through three levels of memory capabilities, including the instantaneous memory, short-term memory, and long-term memory of virtual characters, complete the generation and recall of the short-term memory of virtual characters, the generation and update of long-term memory, and the memory fusion of instantaneous memory, short-term memory, and long-term memory combined with the character settings of virtual characters, perform multi-level processing and management of the memory data in virtual characters, and can solve the memory pressure problem of traditional memory management based on multi-turn dialogue context splicing, the important information loss problem of traditional memory management based on dialogue summary, and the dialogue content inconsistency problem of memory management based on user-side feature modeling, realize more organized storage and use of the memory data in virtual characters, so that the virtual character's cognition of the entire conversation is more perfect, flexibly adapt to different dialogue needs of users, improve the generality and scalability of the virtual character memory management method, and improve the emotional experience of user conversations.

[0006] Optionally, the character settings of the virtual character are extracted from the character setting library, specifically including: The character settings of the virtual character are generated based on the speech content of the virtual character at multiple historical moments and stored in the character setting library.

[0007] It can be understood that the pre-set character setting library can record the character settings of virtual characters, so that when communicating with users, the answers are based on the character settings of virtual characters, which can make the performance of virtual characters more realistic and improve the authenticity of the conversation between users and virtual characters.

[0008] Optionally, obtaining the instantaneous memory at the current moment according to the conversation content includes: Preset the maximum capacity of the instantaneous memory; Starting from the current conversation content at the current moment, intercept a fragment of the conversation content by pushing the time forward according to the maximum capacity to obtain the first conversation content fragment, and splice the first conversation content fragment up and down to generate the instantaneous memory of the virtual character at the current moment; and / or, Obtaining the instantaneous memory of the previous moment according to the conversation content includes: Preset the maximum capacity of the instantaneous memory; Starting from the conversation content at the previous moment, a second conversation content segment is intercepted by shifting the time forward according to the maximum capacity, and the second conversation content segment is spliced up and down to generate the instantaneous memory of the virtual character at the previous moment. It can be understood that generating the instantaneous memory at the current moment and the instantaneous memory at the previous moment according to the conversation content and in combination with the preset maximum capacity of the instantaneous memory can ensure accurate and complete recording of the original conversation content between the virtual character and the user, ensure that the virtual character has a strong memory in the recently occurred conversation, enable the virtual character to better simulate the characteristics of human instantaneous memory, and improve the credibility of the entire conversation.

[0009] Optionally, obtaining the short-term memory of the virtual character at the current moment according to the instantaneous memory, short-term memory, long-term memory at the previous moment, and the current conversation content includes: Extracting the speech content of the user at the current moment from the current conversation content; Obtaining first association information according to the short-term memory at the previous moment and the speech content of the user at the current moment, and obtaining the recalled short-term memory according to the first association information; Obtaining second association information according to the instantaneous memory at the previous moment, the recalled short-term memory, the long-term memory at the previous moment, and the current conversation content, and obtaining the short-term memory at the current moment according to the second association information; and / or, Obtaining the long-term memory of the virtual character at the current moment according to the current conversation content, the character setting of the virtual character, and the short-term memory and long-term memory at the previous moment includes: Extracting the speech content of the user at the current moment from the current conversation content; Obtaining first association information according to the short-term memory at the previous moment and the speech content of the user at the current moment, and obtaining the recalled short-term memory according to the first association information; Obtaining third association information according to the recalled short-term memory, the long-term memory at the previous moment, the current conversation content, and the character setting of the virtual character, and obtaining the long-term memory at the current moment according to the third association information.

[0010] It is understandable that generating the short-term memory at the current moment based on the short-term memory, instantaneous memory, long-term memory at the previous moment, and the current conversation content at the current moment can enable the short-term memory to be recalled and generated through memory contents at multiple levels, enabling more accurate acquisition of memories related to the conversation content at the current moment and more accurately and realistically simulating the short-term memory ability of the virtual character; generating the long-term memory according to the short-term memory, long-term memory, and current conversation content at the previous moment, and combining the character settings of the virtual character, can accurately reflect the subjective characteristics of the virtual character affected by the long-term memory, making the content recorded in the long-term memory conform to the unique character settings of the virtual character, and being able to continuously affect the long-term memory according to the conversation content at different moments, making the generated long-term memory more credible and realistic.

[0011] Optionally, the method further includes: The first association information is obtained through a similarity recall algorithm function; and / or, The second association information is obtained through an abstract algorithm function of a large language model; and / or, The third association information is obtained through a portrait generation algorithm function of a large language model.

[0012] It is understandable that different association information is obtained based on different algorithm functions, which can more correspondingly capture the information characteristics of different memory information, making the found association information more accurate.

[0013] Optionally, the method further includes: Using the least recently used (LRU) eviction algorithm function to streamline the short-term memory of the virtual character at the current moment, obtaining the streamlined short-term memory at the current moment; Fusing the current conversation content, the character settings of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment, specifically: fusing the current conversation content, the character settings of the virtual character, the streamlined short-term memory at the current moment, and the instantaneous memory and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment.

[0014] It is understandable that the capacity of the short-term memory is limited. Streamlining the short-term memory can save a large amount of storage resources, and using the least recently used (LRU) eviction algorithm function for streamlining preferably retains frequently used memory contents, ensuring that these frequently used memory contents can be quickly retrieved and accessed, improving the response to the user's answer, and thus improving the reaction speed of the virtual character to the user's question.

[0015] Optionally, fusing the current conversation content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment includes: Processing the instantaneous memory, short-term memory, long-term memory, the current conversation content, and the character setting of the virtual character at the current moment by an information fusion algorithm function based on prompt engineering to obtain the fused memory of the virtual character at the current moment.

[0016] It can be understood that generating the fused memory of the virtual character at the current moment based on the instantaneous memory, short-term memory, long-term memory, current conversation content, and character setting of the virtual character at the current moment enables the fused memory to not only consider the conversation content at that moment but also combine the character's historical memory and character traits, so that the virtual character can show richer emotional colors and personality characteristics in the conversation.

[0017] According to the second aspect of the present application, a virtual character memory management system is provided, specifically including: A pre-preparation module for pre-setting a short-term memory library, a long-term memory library, and a character setting library of the virtual character; An acquisition module for acquiring the conversation content between the user and the virtual character, and obtaining the current conversation content at the current moment between the user and the virtual character, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment according to the conversation content; A short-term memory generation module for obtaining the short-term memory of the virtual character at the current moment according to the instantaneous memory, short-term memory, long-term memory, and the current conversation content at the previous moment, and adding the short-term memory at the current moment to the short-term memory library; A long-term memory generation module for obtaining the long-term memory of the virtual character at the current moment according to the current conversation content, the character setting of the virtual character, and the short-term memory and long-term memory at the previous moment; and adding the long-term memory at the current moment to the long-term memory library; A fusion module for fusing the current conversation content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment; Wherein, the short-term memory at the previous moment is obtained from the short-term memory library, and the long-term memory at the previous moment is obtained from the long-term memory library; the character setting of the virtual character is extracted from the character setting library.

[0018] According to a third aspect of the present application, there is provided an electronic device, including a memory and a processor. The memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement a virtual character memory management method described in the first aspect above.

[0019] According to a fourth aspect of the present application, there is provided a computer storage medium, on which a computer program is stored. When the computer program is executed, it implements a virtual character memory management method described in the first aspect above.

[0020] Based on any of the above aspects, a virtual character memory management method, system, electronic device, and storage medium provided by the embodiments of the present application can generate a fused memory of the virtual character at the current moment by pre-setting a short-term memory library, a long-term memory library, and a character setting library of the virtual character, and by obtaining the current conversation content between the user and the virtual character at the current moment, the instantaneous memory, short-term memory, long-term memory, and character setting of the virtual character at the previous moment. Thus, a comprehensive and accurate virtual character memory management method is proposed, which can perform multi-level processing and management of the memory data in the virtual character, making the memory data stored and used more orderly. Moreover, this memory management method has high generality and scalability, making the performance of the virtual character more realistic and enhancing the user's emotional experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts. Figure 1 It is a flowchart of a virtual character memory management method provided in this embodiment.

[0022] Figure 2 It is a flowchart of a method for generating instantaneous memory provided in this embodiment.

[0023] Figure 3 It is a flowchart of a method for generating short-term memory provided in this embodiment.

[0024] Figure 4 It is a flowchart of a method for generating long-term memory provided in this embodiment.

[0025] Figure 5 It is a module diagram of a virtual character memory management system provided in this embodiment.

[0026] Figure 6 It is a device structure diagram of the electronic device provided in this embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0027] The accompanying drawings of this application are only for illustrative purposes and should not be construed as a limitation on this application. To better illustrate the following embodiments, some components in the drawings are omitted, enlarged or reduced, which do not represent the dimensions of the actual product; for those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted.

[0028] In order to enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.

[0029] It should be noted that the terms "first", "second", etc. in the description and claims of this application and the above-mentioned accompanying drawings are used to distinguish similar objects and do not necessarily have to be used to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0030] At present, the field of artificial intelligence is developing rapidly, and the technologies and forms of virtual characters interacting with users based on language models penetrate into other fields and are widely used. How to make virtual characters more realistic in the process of communicating with users and respond more truthfully to users' answers is one of the key points in the research of this problem. The content of the virtual character's response to the user is generally related to the memory owned by the virtual character and the management of the memory. In the prior art, virtual characters usually rely on simple dialogue context as memory and record all the context content of the dialogue primitively. This leads to the situation that when the number of dialogue turns exceeds the window threshold of the dialogue, the earlier relevant memories will be overwritten due to limited storage and cannot be correctly and effectively recalled, thus affecting the coherence and naturalness of the dialogue. In addition, some virtual character backends generate the "memory" of the virtual character for the user by extracting the user's attribute features from the dialogue, such as the user's name, gender, age, hobbies, etc., to form the user's character setting, so as to better answer the user's questions based on the user's character setting. However, this method usually only focuses on the portrait information on the user side and lacks the virtual character's modeling of its own character setting, resulting in the virtual character showing unreality and inconsistency in long-term multi-turn conversations. Therefore, it is necessary to make necessary improvements to the memory management in virtual characters.

[0031] This embodiment provides a technical solution that can solve the above problems. The following will combine the accompanying drawings to elaborate on the specific implementation manners of the present application in detail.

[0032] Exemplarily, as Figure 1 shown, a flowchart of a virtual character memory management method provided by an embodiment of the present application, the method includes the following steps: S110. Preset a short-term memory library, a long-term memory library, and a character setting library for the virtual character; In this embodiment, a short-term memory library of a virtual character is pre-set to store short-term memories of multiple historical moments. It is understandable that the short-term memories of multiple historical moments are necessary data for generating partial memories of the current moment, and the short-term memories of historical moments can have a necessary impact on the partial memories of the current moment, so as to enable the virtual character to simulate the generation process of human short-term memory. Similarly, a long-term memory library of a virtual character is pre-set to store long-term memories of multiple historical moments. It is understandable that the long-term memories of multiple historical moments are necessary data for generating partial memories of the current moment, and the long-term memories of historical moments can have a necessary impact on the partial memories of the current moment. Influence, used for the generation process of virtual characters simulating human long-term memory; the generation method of short-term memory or long-term memory of historical moments is the same as that of short-term memory or long-term memory of the current moment, and the short-term memory or long-term memory of the current moment will also be added to the short-term memory library or long-term memory library after the generation is completed, and used as the necessary material for generating memory at the next moment; the short-term memory library can store the short-term memories of the multiple historical moments through a unique algorithm and database, and the long-term memory library can store the long-term memories of the multiple historical moments through a unique algorithm and database, so as not to affect the background running memory of the virtual character dialogue, and improve the response efficiency of the background operation; In this embodiment, the preset character setting library is used to continuously shape the character settings of the virtual characters, which can solve the problem that the virtual characters nowadays generally have only a deep memory of the user's side portrait and are unclear about their own character settings, which leads to the OOC (Out-of-Character) response to the user's answer that exceeds the character setting, resulting in a decrease in the user's dialogue experience. The OOC response of behavior or speech that exceeds the character setting means that when the virtual character faces questions that exceed the character setting preset before its training, it may generate inconsistent or untrue answers. For example, when the user asks the virtual character whether it has played a certain game, the virtual character may generate a random answer. If the user repeatedly asks the same question at different time points, the virtual character may give different answers, thereby destroying the consistency and credibility of the dialogue.

[0033] Specifically, the character settings of the virtual character are extracted from the character setting library, specifically including: The character setting of the virtual character is generated according to the speech content of the virtual character at multiple historical moments and stored in the character setting library.

[0034] In this embodiment, the virtual character settings included in the character setting library are not fixed. It is based on the virtual character settings set before training and generated through the speech content of the virtual character at multiple historical moments. The generation can be achieved by relying on specific algorithms. Different from the traditional virtual character construction model, which always follows the pre-training character settings, during user use, the speech of the virtual character does not affect its character settings, resulting in random answers from the virtual character to some repetitive questions. However, in this application, the character settings of the virtual character will be continuously enriched according to the historical speech of the virtual character, enabling the virtual character to remember the attributes carried by its own speech, so that it can be consistent with the historical speech when answering the same question next time, increasing the authenticity and reliability of the answer and allowing users to experience real simulated dialogue interactions.

[0035] S120. Obtain the dialogue content between the user and the virtual character, and obtain the current dialogue content at the current moment between the user and the virtual character, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment according to the dialogue content; In this embodiment, the instantaneous memory simulates the precise and transient short-term memory in human daily life, which is characterized by low information density and faithfulness to the original content. In this embodiment, the method of splicing multi-round dialogue contexts is used to implement it, and the maximum capacity of the instantaneous memory is set to simulate the forgetting behavior of the instantaneous memory.

[0036] Specifically, as Figure 2 shown, obtaining the instantaneous memory at the current moment according to the dialogue content includes: Preset the maximum capacity of the instantaneous memory; Starting from the current dialogue content at the current moment, intercept a dialogue content segment by shifting the time forward according to the maximum capacity to obtain a first dialogue content segment, and splice the first dialogue content segment up and down to generate the instantaneous memory of the virtual character at the current moment; Similarly, obtaining the instantaneous memory at the previous moment according to the dialogue content includes: Preset the maximum capacity of the instantaneous memory; Starting from the dialogue content at the previous moment, intercept a dialogue content segment by shifting the time forward according to the maximum capacity to obtain a second dialogue content segment, and splice the second dialogue content segment up and down to generate the instantaneous memory of the virtual character at the previous moment.

[0037] Exemplarily, the instantaneous memory of the virtual character at the current moment is specifically obtained through the following formula: where represents the current moment The speech content of the user represents the current moment The speech content of the virtual character represents the maximum capacity of the preset instantaneous memory respectively represent the speech content of the user at different historical moments respectively represent the speech content of the virtual character at different historical moments. Similarly, the instantaneous memory of the previous moment is also obtained according to the above formula.

[0038] In this embodiment, it can be understood that the conversation content of the user and the virtual character at different times forms the context of the conversation. By splicing the conversation context, the instantaneous memory of the virtual character can be formed. It can be understood that usually the background running memory of the virtual character is limited, and the information of the instantaneous memory is usually numerous, messy and of low density. If it is stored infinitely, it will occupy a large amount of memory, and the search time will also increase due to a large amount of unordered information. Therefore, the infinite storage of instantaneous memory has low availability in memory. The introduced maximum capacity of instantaneous memory can ensure that the latest conversation content is recorded as instantaneous memory, and the instantaneous memory exceeding the truncation threshold will be cleared or overwritten, which can control the memory used by the instantaneous memory and also well simulate the forgetting behavior of humans for earlier information that has little connection with deep memory.

[0039] S130. Obtain the short-term memory of the virtual character at the current moment according to the instantaneous memory, short-term memory, long-term memory of the previous moment and the current conversation content, and add the short-term memory of the current moment to the short-term memory library; In this embodiment, it is not enough to rely solely on instantaneous memory to interact with the user, nor does it conform to the normal human memory process. This application also introduces a method for generating short-term memory, which can generate short-term memory under the action of multi-level memory, making the short-term memory more feasible.

[0040] S140. Obtain the long-term memory of the virtual character at the current moment according to the current conversation content, the character setting of the virtual character, and the short-term memory and long-term memory of the previous moment; and add the long-term memory of the current moment to the long-term memory library; In this embodiment, long-term memory simulates the "impression" in human memory, which is characterized by high abstraction and little change. At the same time, the impression has a very strong subjective characteristic. This application uses a user portrait based on the personalized perspective of the virtual character to realize long-term memory modeling. This modeling process has two characteristics: ① integrating the task setting information of the virtual character itself; ② the modeling result changes slowly.

[0041] Specifically, such as Figure 3As shown, obtaining the short-term memory of the virtual character at the current moment according to the instantaneous memory, short-term memory, long-term memory at the previous moment, and the current conversation content includes: S131. Extract the speech content of the user at the current moment from the current conversation content; S132. Obtain the first associated information according to the short-term memory at the previous moment and the speech content of the user at the current moment, and obtain the recalled short-term memory according to the first associated information; S133. Obtain the second associated information according to the instantaneous memory at the previous moment, the recalled short-term memory, the long-term memory at the previous moment, and the current conversation content, and obtain the short-term memory at the current moment according to the second associated information; Specifically, as Figure 4 shown, obtaining the long-term memory of the virtual character at the current moment according to the current conversation content, the character setting of the virtual character, and the short-term memory and long-term memory at the previous moment includes: S141. Extract the speech content of the user at the current moment from the current conversation content; S142. Obtain the first associated information according to the short-term memory at the previous moment and the speech content of the user at the current moment, and obtain the recalled short-term memory according to the first associated information; S143. Obtain the third associated information according to the recalled short-term memory, the long-term memory at the previous moment, the current conversation content, and the character setting of the virtual character, and obtain the long-term memory at the current moment according to the third associated information.

[0042] Specifically, the method further includes: The first associated information is obtained through a recall algorithm function of similarity; The second associated information is obtained through an abstract algorithm function of a large language model; The third associated information is obtained through a portrait generation algorithm function of a large language model.

[0043] Exemplarily, the short-term memory of the virtual character at the current moment is specifically obtained through the following formula: where is the instantaneous memory of the virtual character at the previous moment ( ), is the short-term memory of the virtual character at the previous moment ( ), is a recall algorithm function based on similarity, represents according to the current moment The speech content of the user is for recall the relevant information in the short-term memory of the virtual character at the previous moment; It is an abstractive algorithm function based on a large language model.

[0044] In this embodiment, the short-term memory simulates general memory, which is characterized by a relatively high information density and is an abstract expression of the original memory content. In order to more accurately and realistically model the short-term memory ability of the virtual character, the short-term memory modeling of the virtual character in this application is set as a time-sequence process. The formation of the short-term memory of the virtual character at the current moment is jointly affected by the instantaneous memory, short-term memory, and long-term memory of the virtual character at the previous moment, and is driven by the dialogue behavior between the user and the virtual character.

[0045] In this embodiment, the similarity recall algorithm function can, according to the speech content of the user at the current moment , compare with the short-term memory at the previous moment , recall the short-term memory related to the speech content of the user at the current moment , and can avoid the problem of wasting time by searching each piece of information in the short-term memory; perform abstract extraction based on the large language model on the instantaneous memory at the previous moment, the recalled short-term memory, the long-term memory at the previous moment, and the dialogue content at the current moment, which can extract important memory information, remove functional statements that have no obvious association, no memory points, and no importance, so that the generated short-term memory has a high information density and strong usability. Preferably, this application generates the short-term memory at the current moment by using Prompt instructions or information driving.

[0046] Exemplarily, the long-term memory of the virtual character at the current moment is specifically obtained through the following formula: where represents the long-term memory of the virtual character at the previous moment, represents the character setting of the virtual character. It is a portrait generation algorithm function based on a large language model.

[0047] In this embodiment, also represents according to the speech content of the user at the current moment for recall the relevant information in the short-term memory of the virtual character at the previous moment; the character setting of the virtual character Through the extraction of the character setting library, the character setting of the virtual character is generated by the speech of the virtual character at historical moments and can correspond to the historical speech content of the virtual character. Based on the portrait generation algorithm function of the large language model, long-term memory is generated, which can better find the relevance in memories at all levels, thereby generating relatively fixed long-term memory, so as to improve the quality of interaction with users and enhance the emotion of interaction with users. Preferably, the specific dimension of the long-term memory of the present application can be adaptively expanded according to the task process of actual application.

[0048] Specifically, the method further includes: Using the least recently used (LRU) eviction algorithm function to streamline the short-term memory of the virtual character at the current moment, obtaining the streamlined short-term memory at the current moment; Fusing the current conversation content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment. Specifically: fusing the current conversation content, the character setting of the virtual character, the streamlined short-term memory at the current moment, and the instantaneous memory and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment.

[0049] Exemplarily, the short-term memory of the virtual character at the current moment Is streamlined, and the streamlined short-term memory at the current moment Is specifically obtained through the following formula: Wherein, Is the least recently used (LRU) eviction algorithm function.

[0050] In this embodiment, the capacity of the short-term memory is usually limited. The present application adopts the least recently used (LRU) eviction algorithm to streamline the content of the finally saved short-term memory, which can improve the access efficiency of the short-term memory, ensure that some commonly used information in the short-term memory can be quickly accessed when needed, help reduce the delay of accessing the short-term memory, improve the overall performance of the query, and at the same time optimize the memory usage and avoid waste of memory resources.

[0051] S150. Fusing the current conversation content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment; wherein, the short-term memory at the previous moment is obtained from the short-term memory library, and the long-term memory at the previous moment is obtained from the long-term memory library; the character setting of the virtual character is extracted from the character setting library.

[0052] In this embodiment, the integration of multi-level memories aims to integrate the different characteristics of instantaneous memory, short-term memory, and long-term memory to achieve a more natural, coherent, and personalized interaction experience. By comprehensively analyzing memory information at different levels, it is ensured that the virtual character can make appropriate responses according to the current conversation context while maintaining the consistency and coherence of the character.

[0053] Specifically, the integration of the current conversation content, the character settings of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the integrated memory of the virtual character at the current moment includes: The prompt engineering in the field of artificial intelligence is to guide the artificial intelligence model to generate higher-quality outputs that better meet expectations by designing and optimizing input prompts (Prompts). In specific implementation, the conversation content between the user and the virtual character is obtained through the design and optimization of the input prompts of the prompt engineering, and an information fusion algorithm function based on prompt engineering (Prompt Engineering) is constructed based on the instantaneous memory, short-term memory, long-term memory, the current conversation content, and the character settings of the virtual character to process the instantaneous memory, short-term memory, long-term memory, the current conversation content, and the character settings of the virtual character at the current moment to obtain the integrated memory of the virtual character at the current moment.

[0054] Exemplarily, the integrated memory of the virtual character at the current moment is specifically obtained through the following formula: where is the information fusion algorithm function based on prompt engineering.

[0055] In this embodiment, The function is an information fusion algorithm based on prompt engineering, which combines memory information at three different levels, the current conversation content, and various aspects such as the task settings of the virtual character. The purpose of this algorithm design is to not only consider the immediate conversation content but also combine the character's historical memory and personal traits, enabling the virtual character to show more rich emotional colors and personality characteristics in the conversation.

[0056] A virtual character memory management method proposed in this application can flexibly adapt to the virtual character dialogue requirements in different fields, with high generality and scalability. It proposes short-term memory and models the dialogue between the user and the virtual character round by round, improving the quality and fidelity of virtual character dialogue generation through a retrieval-enhancement method. Introducing the shaped virtual character setting can ensure high consistency and high freedom in the OOC scenarios of the virtual character in multi-round conversations. The proposed long-term memory actively models the user portrait features and uses the long-term memory to drive the virtual character to generate appropriate emotional responses according to the impression. This method can perform multi-level processing and management on the memory data in the virtual character, making the memory data stored and used more orderly, enabling the virtual character to better simulate human social behaviors, enhancing the user's emotional experience, and making the performance of the virtual character more lifelike.

[0057] As Figure 5 shown, the embodiment of this application also provides a virtual character memory management system. Optionally, the system may include: A pre-preparation module 211, an acquisition module 212, a short-term memory generation module 213, a long-term memory generation module 214, and a fusion module 215, where: The pre-preparation module 211 is used to pre-set the short-term memory library, long-term memory library, and character setting library of the virtual character; In this embodiment, the pre-preparation module 211 can be used to execute Figure 1 the steps S110 shown. The specific description of the pre-preparation module 211 can refer to the description of the steps S110.

[0058] The acquisition module 212 is used to acquire the dialogue content between the user and the virtual character, and obtain the current dialogue content at the current moment between the user and the virtual character, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment according to the dialogue content; In this embodiment, the acquisition module 212 can be used to execute Figure 1 the steps S120 shown. The specific description of the acquisition module 212 can refer to the description of the steps S120.

[0059] The short-term memory generation module 213 is used to obtain the short-term memory of the virtual character at the current moment according to the instantaneous memory, short-term memory, long-term memory, and the current dialogue content at the previous moment, and add the short-term memory at the current moment to the short-term memory library; In this embodiment, the short-term memory generation module 213 can be used to execute Figure 1 the steps S130 shown. The specific description of the short-term memory generation module 213 can refer to the description of the steps S130.

[0060] A long-term memory generation module 214, configured to obtain the long-term memory of the virtual character at the current moment according to the current conversation content, the character setting of the virtual character, and the short-term memory and long-term memory at the previous moment; and add the long-term memory at the current moment to the long-term memory library. In this embodiment, the long-term memory generation module 214 may be used to execute Figure 1 Step S140 shown. For the specific description of the long-term memory generation module 214, reference may be made to the description of step S140.

[0061] A fusion module 215, configured to fuse the current conversation content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment; wherein, the short-term memory at the previous moment is obtained from the short-term memory library, and the long-term memory at the previous moment is obtained from the long-term memory library; the character setting of the virtual character is extracted from the character setting library.

[0062] In this embodiment, the fusion module 215 may be used to execute Figure 1 Step S150 shown. For the specific description of the fusion module 215, reference may be made to the description of step S150.

[0063] This application embodiment also provides an electronic device, the structure of which is as Figure 6 shown. The electronic device includes a memory 311, a processor 312, a communication module 313, an input / output interface 314, etc. Optionally, the memory 311, the processor 312, the communication module 313, and the input / output interface 314 may be connected and communicate through a bus 315.

[0064] The memory 311 is used to store one or more computer programs and transmit the code of the computer programs to the processor 312; when the one or more computer programs are executed by the processor 312, a virtual character memory management method in this application embodiment is implemented.

[0065] Optionally, the electronic device may be connected to a network through the communication module 313 to communicate with other devices, such as terminals or servers, through the network to achieve data interaction. The electronic device may be various forms of digital computers, such as, by way of example, desktop computers, servers, workbenches, mainframe computers, or other types of computers. The electronic device may also be various forms of mobile terminals, such as, by way of example, smart phones, tablet computers, wearable devices (such as helmets, glasses, watches, etc.), and other similar mobile terminals.

[0066] Optionally, the electronic device may be connected to required input / output devices, such as a keyboard, a display device, etc., through the input / output interface 314. The electronic device itself may have a display device, and may also be externally connected to other display devices through the input / output interface 314. Optionally, a storage device, such as a hard disk, etc., may also be connected through the input / output interface 314, so that the data in the electronic device can be stored in the storage device, or the data in the storage device can be read, and the data in the storage device can also be stored in the memory 311. It can be understood that the input / output interface 314 may be a wired interface or a wireless interface. According to different actual application scenarios, the devices connected to the input / output interface 314 may be components of the electronic device or external devices connected to the electronic device when needed.

[0067] Optionally, the memory 311 may be a volatile memory and / or a non-volatile memory. The volatile memory may be a random access memory, etc., and the non-volatile memory may be a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, or a flash memory, etc.

[0068] Optionally, the computer program stored in the memory 311 may be divided into one or more modules. The one or more modules are stored in the memory 311 and executed by the processor 312 to complete the method provided by this embodiment itself. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the computer program instruction segments are used to describe the execution process of the computer program in the electronic device.

[0069] Optionally, the processor 312 may be various general and / or special processing components with processing and computing capabilities. Some examples of the processor 312 include but are not limited to a central processing unit, a graphics processing unit, a digital signal processor, various dedicated artificial intelligence computing chips, various processors running machine learning model algorithms, and may also be any suitable controller, microcontroller, processor, etc. The processor 312 executes the various methods and processes of this embodiment. Exemplarily, such as a virtual character memory management method of an embodiment of the present application.

[0070] Optionally, the bus 315 may include a path for transmitting information. The bus 315 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. According to different functions, the bus 315 may be divided into an address bus, a data bus, a control bus, etc.

[0071] In an alternative implementation, an embodiment of the present application further provides a computer storage medium, on which a computer program is stored. When the computer program is executed by a computer, the computer can execute the methods in the above method embodiments. Part or all of the computer program may be loaded and / or installed on the memory 311 of the electronic device. When the computer program is executed by the processor 312, one or more steps of a virtual character memory management method according to an embodiment of the present application can be executed.

[0072] Optionally, the computer-readable storage medium may be a random access memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, etc.

[0073] Obviously, the above embodiments of the present application are merely examples for clearly illustrating the technical solutions of the present application, rather than limitations on the specific implementation manners of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the claims of the present application shall be included in the protection scope of the claims of the present application.

Claims

1. A virtual character memory management method, characterized in that: The method comprises: Pre-setting the short-term memory library, long-term memory library and role setting library of the virtual character; Acquire the conversation content between the user and the virtual character, and acquire the current conversation content between the user and the virtual character at the current moment, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment according to the conversation content; According to the instantaneous memory, short-term memory, long-term memory of the previous moment and the current conversation content, the short-term memory of the virtual character at the current moment is acquired, and the short-term memory at the current moment is added to the short-term memory library; According to the current conversation content, the character setting of the virtual character, and the short-term memory and long-term memory of the previous moment, the long-term memory of the virtual character at the current moment is obtained, and the long-term memory at the current moment is added to the long-term memory library; The current dialogue content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment are integrated to obtain the integrated memory of the virtual character at the current moment; Among them, the short-term memory of the previous moment is obtained from the short-term memory library, and the long-term memory of the previous moment is obtained from the long-term memory library; the character setting of the virtual character is extracted from the character setting library.

2. A virtual character memory management method according to claim 1, characterized in that: The character settings of the virtual character are extracted from the character setting library, specifically including: The character setting of the virtual character is generated according to the speech content of the virtual character at multiple historical moments and stored in the character setting library.

3. A virtual character memory management method according to claim 1, characterized in that: Acquiring the instantaneous memory of the current moment according to the conversation content, including: Preset the maximum capacity of instantaneous memory; Taking the current dialogue content at the current moment as the starting point, according to the maximum capacity, the time is moved forward to intercept the dialogue content segment to obtain a first dialogue content segment, and the first dialogue content segment is spliced ​​up and down to generate the instantaneous memory of the virtual character at the current moment; and / or, Acquiring the instantaneous memory of the previous moment according to the content of the conversation, including: Preset the maximum capacity of instantaneous memory; Taking the conversation content at the previous moment as the starting point, the time is moved forward according to the maximum capacity to intercept a conversation content segment to obtain a second conversation content segment, and the second conversation content segment is spliced ​​up and down to generate the instantaneous memory of the virtual character at the previous moment.

4. A virtual character memory management method according to claim 1, characterized in that: The step of obtaining the short-term memory of the virtual character at the current moment according to the instantaneous memory, short-term memory, long-term memory at the previous moment and the current conversation content includes: Extracting the speech content of the user at the current moment from the current conversation content; Acquire first associated information according to the short-term memory at the previous moment and the speech content of the user at the current moment, and acquire the recalled short-term memory according to the first associated information; Acquire second associated information according to the instantaneous memory at the last moment, the recalled short-term memory, the long-term memory at the last moment, and the current conversation content, and acquire the short-term memory at the current moment according to the second associated information; and / or, According to the current dialogue content, the character setting of the virtual character, and the short-term memory and long-term memory of the previous moment, the long-term memory of the virtual character at the current moment is obtained, including: Extracting the speech content of the user at the current moment from the current conversation content; Acquire first associated information according to the short-term memory at the previous moment and the speech content of the user at the current moment, and acquire the recalled short-term memory according to the first associated information; The third associated information is obtained according to the recalled short-term memory, the long-term memory at the previous moment, the current dialogue content and the character setting of the virtual character, and the long-term memory at the current moment is obtained according to the third associated information.

5. A virtual character memory management method according to claim 4, characterized in that: Also includes: The first associated information is obtained by a similarity recall algorithm function; and / or, The second associated information is obtained by a summary algorithm function of a large language model; and / or, The third associated information is obtained through a portrait generation algorithm function of a large language model.

6. A virtual character memory management method according to any one of claims 1 to 5, characterized in that: Also includes: Using a least recently used elimination algorithm function to simplify the short-term memory of the virtual character at the current moment, to obtain a simplified short-term memory at the current moment; The current conversation content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment are integrated to obtain the integrated memory of the virtual character at the current moment. Specifically, the current conversation content, the character setting of the virtual character, the streamlined short-term memory at the current moment, and the instantaneous memory and long-term memory at the current moment are integrated to obtain the integrated memory of the virtual character at the current moment.

7. A virtual character memory management method according to any one of claims 1 to 5, characterized in that: The fusing of the current dialogue content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain the fused memory of the virtual character at the current moment includes: The information fusion algorithm function based on the prompt word engineering processes the instantaneous memory, short-term memory, long-term memory, the current dialogue content and the character setting of the virtual character at the current moment to obtain the fused memory of the virtual character at the current moment.

8. A virtual character memory management system, characterized in that: include: A pre-preparation module, used to pre-set the short-term memory library, long-term memory library and role setting library of the virtual character; An acquisition module, used to acquire the conversation content between the user and the virtual character, and acquire the current conversation content between the user and the virtual character at the current moment, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment according to the conversation content; A short-term memory generation module, used to obtain the short-term memory of the virtual character at the current moment according to the instantaneous memory, short-term memory, long-term memory of the previous moment and the current dialogue content, and add the short-term memory of the current moment to the short-term memory library; A long-term memory generation module, for obtaining the long-term memory of the virtual character at the current moment according to the current dialogue content, the character settings of the virtual character, and the short-term memory and long-term memory of the previous moment; and adding the long-term memory of the current moment to the long-term memory library; A fusion module, used to fuse the current dialogue content, the character settings of the virtual character, and the instantaneous memory, short-term memory, and long-term memory at the current moment to obtain a fused memory of the virtual character at the current moment; Among them, the short-term memory of the previous moment is obtained from the short-term memory library, and the long-term memory of the previous moment is obtained from the long-term memory library; the character setting of the virtual character is extracted from the character setting library.

9. An electronic device, comprising a memory and a processor, characterized in that: The memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement a virtual character memory management method as described in any one of claims 1-7.

10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, a virtual character memory management method as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Robot memory construction method and device

    CN108009624A

  • Data processing method for chat and related device

    CN114003702A

  • Interaction method and device, medium and electronic equipment

    CN117959715A

  • Session interaction method and device, electronic equipment and readable storage medium

    CN119185942A

  • Short video recommendation method and system based on real-time interest enhancement

    CN119226598A

Cited By

  • Virtual historical character dialogue method and system with role knowledge and context awareness

    CN121352040A