A method, system, electronic device and storage medium for virtual character memory management

Through the multi-level memory management method, the problem of improper memory management of AI virtual characters during long-term conversations is solved, the coherence and realism of virtual character dialogues is achieved, and the user experience is improved.

CN120045699BActive Publication Date: 2025-08-05GUANGZHOU HUYA INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510510885.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2025-08-05
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 long and multiple rounds of dialogues, and lacks modeling of virtual roles' own settings, and its performance is unreal and inconsistent.

Method used

Multi-level memory management methods are adopted, including short-term memory database, long-term memory database and character setting library. By obtaining user conversation content and virtual character instant memory, instantaneous, short-term, and long-term memories are generated and integrated, and combined with the character settings of virtual characters, the comprehensive management of virtual character memory is achieved.

Benefits of technology

Improve the coherence and realism of virtual character conversations, enhance the user's interactive experience, and ensure that virtual characters maintain consistency and authenticity in multiple rounds of conversations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045699B_ABST
    Figure CN120045699B_ABST
Patent Text Reader

Abstract

The present application relates to the field of artificial intelligence, and more specifically, to a method and system for managing virtual character memories. The method includes: obtaining the instantaneous memory of the current moment and the instantaneous memory of the previous moment based on the content of the conversation between the user and the virtual character; obtaining the short-term memory of the current moment based on the short-term memory, instantaneous memory, long-term memory of the previous moment, and the current conversation content; obtaining the long-term memory of the current moment based on the character settings of the virtual character, the long-term memory of the previous moment, short-term memory, and the current conversation content; and fusing the instantaneous memory, short-term memory, long-term memory of the current moment with the current conversation content and the character settings of the virtual character to obtain the fused memory of the current moment. This method can perform multi-level processing and management of the memory data of the virtual character, so that the memory data can be stored and used in a more organized manner, thereby making the virtual character's responses based on the memory data more realistic.
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 virtual character memory management method, system, electronic device and storage medium. Background Art

[0002] In existing technologies, AI virtual role-playing systems typically rely on simple conversation context as memory. This results in the inability to correctly and effectively recall relevant memories when the number of conversation turns exceeds a window threshold, thus affecting the coherence and naturalness of the conversation. Furthermore, some AI virtual role-playing systems generate the AI virtual character's "memory" of the user by extracting user attributes from the conversation, such as name, gender, age, and hobbies. However, these methods typically only focus on user-side profile information and still lack modeling of the AI virtual character's own reactions to OOC (Out-of-Character) (behavior or speech that exceeds the character's set expectations). This causes the AI virtual character to behave unrealistically and inconsistently during long, multi-round conversations. Therefore, necessary improvements are needed to the memory management methods of AI virtual characters. Summary of the Invention

[0003] The present invention aims to overcome at least one defect (shortcoming) of the above-mentioned prior art and provide a virtual character memory management method, system, electronic device and storage medium for realizing a more organized storage and use of the memory data in the virtual character, thereby making the virtual character's answer performance based on the memory data more realistic.

[0004] According to a first aspect of the present application, a virtual character memory management method is provided, the method comprising:

[0005] Pre-setting the virtual character's short-term memory library, long-term memory library and character setting library;

[0006] Acquire the conversation content between the user and the virtual character, and acquire the current conversation content, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment between the user and the virtual character based on the conversation content;

[0007] Obtaining the short-term memory of the virtual character at the current moment based on the instantaneous memory, short-term memory, long-term memory of the previous moment and the current conversation content, and adding the short-term memory at the current moment to the short-term memory library;

[0008] Acquire 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;

[0009] 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; wherein, 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.

[0010] It is understandable that the present application can achieve more comprehensive and accurate virtual character memory management through three levels of memory capabilities, including the virtual character's instantaneous memory, short-term memory, and long-term memory, complete the generation and recall of the virtual character's short-term memory, the generation and update of long-term memory, and the memory fusion of instantaneous memory, short-term memory, and long-term memory in combination with the virtual character's character settings, and perform multi-level processing and management of the memory data in the virtual character. It can solve the memory pressure problem of traditional memory management based on multi-round 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, and realize the more organized storage and use of the memory data in the virtual character, so that the virtual character's cognition of the entire dialogue is more complete, and it can flexibly adapt to the different dialogue needs of users, improve the versatility and scalability of the virtual character memory management method, and improve the emotional experience of the user dialogue.

[0011] Optionally, the character settings of the virtual character are extracted from the character setting library, specifically including:

[0012] The character setting of the virtual character is generated based on the speech content of the virtual character at multiple historical moments and stored in the character setting library.

[0013] It is understandable that the pre-set character setting library can record the character settings of the virtual character, so that when communicating with the user, the answers are based on the character settings of the virtual character, which can make the performance of the virtual character more realistic and improve the authenticity of the dialogue between the user and the virtual character.

[0014] Optionally, obtaining the instantaneous memory at the current moment according to the conversation content includes:

[0015] Pre-set the maximum capacity of instantaneous memory;

[0016] Taking the current conversation content at the current moment as a starting point, moving forward in time according to the maximum capacity to intercept a conversation content segment to obtain a first conversation content segment, and splicing the first conversation content segment from top to bottom to generate the instantaneous memory of the virtual character at the current moment;

[0017] and / or,

[0018] Acquiring the instantaneous memory of the previous moment according to the conversation content, including:

[0019] Pre-set the maximum capacity of instantaneous memory;

[0020] Taking the conversation content at the previous moment as the starting point, the time is moved forward according to the maximum capacity to intercept the 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.

[0021] It is understandable that, based on the content of the conversation and in combination with the pre-set maximum capacity of the instantaneous memory, the instantaneous memory of the current moment and the instantaneous memory of the previous moment are generated, which can ensure that the original conversation content between the virtual character and the user is accurately and completely recorded, and ensure that the virtual character has a strong memory in the most recent conversation, so that the virtual character can better simulate the characteristics of human instantaneous memory and improve the credibility of the entire conversation.

[0022] Optionally, obtaining the short-term memory of the virtual character at the current moment based on the instantaneous memory, short-term memory, long-term memory of the previous moment and the current conversation content includes:

[0023] Extracting the user's speech content at the current moment from the current conversation content;

[0024] Acquire first associated information based on 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 based on the first associated information;

[0025] Acquire second associated information based on 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 acquire the short-term memory at the current moment based on the second associated information; and / or,

[0026] Acquiring 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, including:

[0027] Extracting the user's speech content at the current moment from the current conversation content;

[0028] Acquire first associated information based on 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 based on the first associated information;

[0029] The third associated information is obtained based on 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 the long-term memory at the current moment is obtained based on the third associated information.

[0030] It is understandable that generating the short-term memory of the current moment based on the short-term memory, instantaneous memory, long-term memory of the previous moment and the current conversation content of the current moment can enable the short-term memory to be recalled and generated through multiple levels of memory content, so that the memory related to the conversation content of the current moment can be obtained more accurately, and the short-term memory ability of the virtual character can be more accurately and realistically realized; the generation of long-term memory based on the short-term memory, long-term memory and current conversation content of the previous moment, combined with the character setting of the virtual character, can accurately affect the subjective characteristics of the virtual character that affect the long-term memory, so that the content recorded in the long-term memory is in accordance with the unique character setting of the virtual character, and can continuously affect the long-term memory according to the conversation content at different moments, so that the generated long-term memory is more credible and authentic.

[0031] Optionally, the method further includes:

[0032] The first associated information is obtained by a similarity recall algorithm function; and / or,

[0033] The second association information is obtained by a summary algorithm function of a large language model; and / or,

[0034] The third associated information is obtained through a portrait generation algorithm function of a large language model.

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

[0036] Optionally, the method further includes:

[0037] Streamlining the short-term memory of the virtual character at the current moment using a least recently used elimination algorithm function to obtain a streamlined short-term memory at the current moment;

[0038] 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.

[0039] It is understandable that the capacity of short-term memory is limited. Streamlining the short-term memory can save a lot of storage resources. Streamlining is performed using a least recently used elimination algorithm function, preferably retaining commonly used memory content to ensure that these commonly used memory contents can be quickly found and accessed, thereby improving responsiveness to user answers and thereby improving the speed at which the virtual character responds to user questions.

[0040] Optionally, the fusing of 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:

[0041] The information fusion algorithm function based on the prompt word project 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.

[0042] It is understandable that the fused memory of the virtual character at the current moment is generated based on the instantaneous memory, short-term memory, long-term memory, current dialogue content and virtual character settings of the current moment, so that the fused memory not only takes into account the dialogue content at that moment, but also combines the character's historical memory and character traits, so that the virtual character can show richer emotional colors and personality characteristics in the dialogue.

[0043] According to a second aspect of the present application, a virtual character memory management system is provided, specifically comprising:

[0044] A pre-preparation module for pre-setting the short-term memory library, long-term memory library and character setting library of the virtual character;

[0045] An acquisition module, configured to acquire the content of a conversation between the user and the virtual character, and acquire the current conversation content, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment between the user and the virtual character based on the conversation content;

[0046] a short-term memory generation module, configured to obtain the short-term memory of the virtual character at the current moment based on 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;

[0047] a long-term memory generation module, configured to obtain the long-term memory of the virtual character at the current moment based on the current conversation content, the character settings 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;

[0048] A fusion module, configured to 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 a fused memory of the virtual character at the current moment;

[0049] The short-term memory of the previous moment is obtained from the short-term memory library, the long-term memory of the previous moment is obtained from the long-term memory library; and the character setting of the virtual character is extracted from the character setting library.

[0050] According to a third aspect of the present application, an electronic device is provided, comprising a memory and a processor, wherein 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.

[0051] According to a fourth aspect of the present application, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed, the method for managing virtual character memory as described in the first aspect above is implemented.

[0052] Based on any one of the above aspects, the embodiments of the present application provide a virtual character memory management method, system, electronic device and storage medium, which can pre-set the short-term memory library, long-term memory library and character setting library of the virtual character, and generate the fused memory of the virtual character at the current moment 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, thereby proposing a comprehensive and accurate virtual character memory management method, which can perform multi-level processing and management of the memory data in the virtual character, so that the memory data can be stored and used more systematically, and the memory management method has high versatility and scalability, making the performance of the virtual character more realistic and enhancing the user's emotional experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work. Figure 1 This is a flow chart of a virtual character memory management method provided in this embodiment.

[0054] Figure 2 This is a flow chart of a method for generating transient memory provided by this embodiment.

[0055] Figure 3 This is a flow chart of a method for generating short-term memory provided in this embodiment.

[0056] Figure 4 This is a flow chart of a method for generating long-term memory provided in this embodiment.

[0057] Figure 5This is a module diagram of a virtual character memory management system provided by this embodiment.

[0058] Figure 6 This is a device structure diagram of the electronic device provided in this embodiment. DETAILED DESCRIPTION

[0059] The figures in this application are for illustrative purposes only and are not to be construed as limiting the present application. To better illustrate the following embodiments, some components in the figures may be omitted, enlarged, or reduced in size, and do not represent actual product dimensions. Those skilled in the art will appreciate that some well-known structures and their descriptions may be omitted from the figures.

[0060] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0061] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0062] The field of artificial intelligence is currently experiencing rapid development. Among these, the techniques and methods for interacting with users through language models have permeated other fields and are being widely adopted. One of the key research areas is how to make virtual characters more realistic and their responses more authentic during conversations. The content of a virtual character's responses to users is generally related to the character's memory and how it is managed. Existing technologies typically rely on simple conversation context as memory, recording all conversation contextual content in its original form. This results in older, relevant memories being overwritten due to limited storage when the number of conversation turns exceeds the conversation window threshold, preventing them from being accurately and effectively recalled, thus affecting the coherence and naturalness of the conversation. Furthermore, some virtual character backends extract user attributes from the conversation, such as name, gender, age, and hobbies, to generate a virtual character's "memory" of the user and form a user profile. This allows the character to better answer questions based on the user's profile. However, this approach typically focuses solely on user-side profile information and lacks the ability to model the character's own personality. This can lead to unrealistic and inconsistent performance during long, multi-turn conversations. Therefore, improvements to memory management within virtual characters are necessary.

[0063] This embodiment provides a technical solution that can solve the above-mentioned problem. The specific implementation methods of this application are described in detail below with reference to the accompanying drawings.

[0064] For example, Figure 1 As shown, a flowchart of a virtual character memory management method provided by an embodiment of the present application includes the following steps:

[0065] S110, pre-setting the short-term memory library, long-term memory library, and character setting library of the virtual character;

[0066] 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, which is used for 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. Impact, 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. After the short-term memory or long-term memory of the current moment is completed, it will also be added to the short-term memory library or long-term memory library to be 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, thereby improving the response efficiency of the background operation;

[0067] In this embodiment, a pre-set character setting library is used to continuously shape the character settings of virtual characters. This can solve the common problem that virtual characters only have a deep memory of the user's profile and are unclear about their own character settings. This leads to OOC (Out-of-Character) responses to the user's answers, which leads to a decrease in the user's conversation experience. The OOC response to the character's behavior or speech means that when the virtual character is faced with questions that exceed the character settings preset before training, it may generate inconsistent or unrealistic answers. For example, when a 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 undermining the consistency and credibility of the conversation.

[0068] Specifically, the character settings of the virtual character are extracted from the character setting library, specifically including:

[0069] The character setting of the virtual character is generated based on the speech content of the virtual character at multiple historical moments and stored in the character setting library.

[0070] In this embodiment, the virtual character settings contained in the character setting library are not static. They are based on the virtual character settings set before training and are generated through the speech content of the virtual character at multiple historical moments. The generation can be achieved by relying on a specific algorithm. Different from the traditional model of virtual character construction, the character settings of the virtual character itself always follow the character settings before training. During user use, the speech of the virtual character does not affect its character settings, which results in the virtual character's answers to certain repeated questions being random. However, this application will continuously enrich the character settings of the virtual character based on the historical speeches of the virtual character, so that the virtual character remembers the attributes of its own speech, so that the next time it answers the same question, it can be consistent with the historical speech, increasing the authenticity and reliability of the answer, so that the user can experience a real simulated dialogue interaction.

[0071] S120, obtaining the conversation content between the user and the virtual character, and obtaining the current conversation content, the current moment's instantaneous memory, and the previous moment's instantaneous memory between the user and the virtual character based on the conversation content;

[0072] In this embodiment, transient memory simulates the precise, transient nature of human memory in daily life. It is characterized by low information density and faithfulness to the original content. This embodiment implements this by splicing together the context of multiple conversations, and sets a maximum capacity for transient memory to simulate the forgetting behavior of transient memory.

[0073] Specifically, if Figure 2 As shown, obtaining the instantaneous memory of the current moment according to the conversation content includes:

[0074] Pre-set the maximum capacity of instantaneous memory;

[0075] Taking the current conversation content at the current moment as a starting point, moving forward in time according to the maximum capacity to intercept a conversation content segment to obtain a first conversation content segment, and splicing the first conversation content segment from top to bottom to generate the instantaneous memory of the virtual character at the current moment;

[0076] Similarly, obtaining the instantaneous memory of the previous moment based on the conversation content includes:

[0077] Pre-set the maximum capacity of instantaneous memory;

[0078] Taking the conversation content at the previous moment as the starting point, the time is moved forward according to the maximum capacity to intercept the 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.

[0079] For example, the instantaneous memory of the virtual character at the current moment It is obtained by the following formula:

[0080]

[0081] in, Indicates the current time The user's speech content, Indicates the current time The content of the virtual character's speech, Indicates the maximum capacity of the preset instantaneous memory. Respectively represent the user's speech content at different historical moments, They 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.

[0082] In this embodiment, it is understood that the conversations between the user and the virtual character at different times form the conversation context. This conversation context is then pieced together to form the virtual character's transient memory. It is also understood that the virtual character's background operating memory is typically limited, and the information in transient memory is often numerous, disorganized, and low-density. Storing this information infinitely would occupy a significant amount of memory and increase search time due to the large amount of disordered information. Therefore, infinitely storing transient memory would not be highly usable in terms of memory. The maximum capacity of the introduced transient memory ensures that the most recent conversation content is recorded as transient memory. Transient memory that exceeds a cutoff threshold is cleared or overwritten. This effectively controls the memory used by transient memory and effectively simulates the human tendency to forget older information that is not closely related to deep memory.

[0083] S130, obtaining the short-term memory of the virtual character at the current moment based on the instantaneous memory, short-term memory, long-term memory of the previous moment and the current conversation content, and adding the short-term memory at the current moment to the short-term memory library;

[0084] In this embodiment, it is not enough to rely solely on instantaneous memory to interact with the user, and it is not in line with 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 short-term memory more feasible.

[0085] S140, obtaining the long-term memory of the virtual character at the current moment based on 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 adding the long-term memory of the current moment to the long-term memory library;

[0086] In this embodiment, long-term memory simulates the "impressions" in human memory, which are characterized by high abstraction and little change. Impressions are also highly subjective. This application utilizes user profiling based on the personalized perspective of the virtual character to implement long-term memory modeling. This modeling process has two key characteristics: 1) it incorporates the virtual character's own task setting information; 2) the modeling results are slowly changing.

[0087] Specifically, if Figure 3 As shown, the acquisition of the short-term memory of the virtual character at the current moment based on the instantaneous memory, short-term memory, long-term memory of the previous moment and the current conversation content includes:

[0088] S131, extracting the user's speech content at the current moment from the current conversation content;

[0089] S132: obtaining first associated information based on 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 based on the first associated information;

[0090] S133, obtaining second association information based on 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 based on the second association information;

[0091] Specifically, if Figure 4 As shown, 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, including:

[0092] S141, extracting the user's speech content at the current moment from the current conversation content;

[0093] S142: obtaining first associated information based on 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 based on the first associated information;

[0094] S143. Obtain third association information based on 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 based on the third association information.

[0095] Specifically, the method further includes:

[0096] The first associated information is obtained through a similarity recall algorithm function;

[0097] The second associated information is obtained through a summary algorithm function of a large language model;

[0098] The third associated information is obtained through a portrait generation algorithm function of a large language model.

[0099] For example, the short-term memory of the virtual character at the current moment It is obtained by the following formula:

[0100]

[0101] in, The last moment of the virtual character ( ) of instantaneous memory, The last moment of the virtual character ( ) of short-term memory, It is a recall algorithm function based on similarity, Indicates based on Current moment The user's speech content is Recalling relevant information from the virtual character's short-term memory at the previous moment; It is a summary algorithm function based on a large language model.

[0102] In this embodiment, short-term memory simulates general memory, characterized by high information density and an abstract representation of the original memory content. To more accurately and realistically model the short-term memory capabilities of a virtual character, this application models the short-term memory of a virtual character as a sequential process. The formation of a virtual character's short-term memory at the current moment is influenced by the virtual character's instantaneous memory, short-term memory, and long-term memory at the previous moment, and is driven by the user's conversational behavior with the virtual character.

[0103] In this embodiment, the similarity recall algorithm function can be used to determine the content of the user's current speech. , and the short-term memory of the previous moment Compare and recall the user's current speech content Relevant short-term memory can avoid the problem of wasting time by searching for each piece of information in the short-term memory; the summary extraction of the instantaneous memory of the previous moment, the recalled short-term memory, the long-term memory of the previous moment and the current moment conversation content based on the large language model can extract important memory information and remove functional sentences that have no obvious relevance, no memorable points and no importance, so that the generated short-term memory has high information density and strong usability. Preferably, the present application generates the short-term memory of the current moment by using the Prompt instruction or information drive.

[0104] For example, the long-term memory of the virtual character at the current moment It is obtained by the following formula:

[0105]

[0106] in, represents the long-term memory of the virtual character at the last moment, Indicates the character settings of the virtual character. It is a portrait generation algorithm function based on a large language model.

[0107] In this embodiment, Likewise, according to The current moment of the user's speech content Recall the relevant information in the short-term memory of the virtual character at the last 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 through the speeches of the virtual character at historical moments, which can correspond to the historical speech content of the virtual character. The portrait generation algorithm function based on the large language model generates long-term memory, which can better find the correlation in each level of memory, thereby generating a relatively fixed long-term memory, thereby improving the quality of interaction with users and enhancing the emotional interaction with users. Preferably, the specific dimensions of the long-term memory of this application can be adaptively expanded according to the task process of actual application.

[0108] Specifically, the method further includes:

[0109] Streamlining the short-term memory of the virtual character at the current moment using a least recently used elimination algorithm function to obtain a streamlined short-term memory at the current moment;

[0110] 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.

[0111] For example, the short-term memory of the virtual character at the current moment Streamlined, streamlined current moment short-term memory It is obtained by the following formula:

[0112]

[0113] in, It is the least recently used elimination algorithm function.

[0114] In this embodiment, the capacity of short-term memory is usually limited. This application uses a least recently used (LRU) elimination algorithm to streamline the short-term memory content that is ultimately saved, which can improve the access efficiency of short-term memory, ensure that some commonly used information in short-term memory can be quickly accessed when needed, help reduce the delay in accessing short-term memory, improve the overall query performance, and also optimize memory usage and avoid wasting memory resources.

[0115] S150. 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; wherein 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; and the character settings of the virtual character are extracted from the character settings library.

[0116] In this embodiment, the fusion of multiple levels of memory is intended to integrate the different characteristics of instantaneous memory, short-term memory, and long-term memory to achieve a more natural, coherent, and personalized interactive experience. By comprehensively analyzing memory information at different levels, it ensures that the virtual character can respond appropriately according to the current dialogue situation while maintaining the consistency and coherence of the character.

[0117] Specifically, the fusing of 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:

[0118] Prompt Engineering is a field of artificial intelligence that uses the design and optimization of input prompts to guide AI models to generate more predictable, high-quality output. In specific implementations, the design and optimization of prompts in prompt engineering are used to obtain the content of the conversation between the user and the virtual character. Based on the current instantaneous memory, short-term memory, long-term memory, the current conversation content, and the virtual character's character settings, an information fusion algorithm function based on prompt engineering is constructed. This information is processed to obtain the virtual character's current fused memory.

[0119] For example, the fusion memory of the virtual character at the current moment It is obtained by the following formula:

[0120]

[0121] in, It is an information fusion algorithm function based on the prompt word engineering.

[0122] In this embodiment, The function is an information fusion algorithm based on the prompt word project. It combines three different levels of memory information, the current conversation content, and the virtual character's mission settings. The algorithm is designed to not only consider the immediate conversation content but also incorporate the character's historical memory and personal traits, allowing the virtual character to express richer emotions and personality traits in conversation.

[0123] This application proposes a virtual character memory management method that can flexibly adapt to the needs of virtual character dialogues in different fields and has high versatility and scalability. It proposes short-term memory and models the dialogues between users and virtual characters on a round-by-round basis, and improves the quality and fidelity of virtual character dialogue generation through a retrieval-enhancement approach. The introduction of shaped virtual character settings can ensure that virtual characters have high consistency and high freedom in OOC scenarios in multi-round dialogues. The proposed long-term memory realizes active modeling of user portrait features and uses long-term memory to drive virtual characters to produce appropriate emotional responses based on impressions. This method can perform multi-level processing and management of memory data in virtual characters, so that memory data can be stored and used in a more organized manner, so that virtual characters can better simulate human social behavior, enhance users' emotional experience, and make the performance of virtual characters more realistic.

[0124] like Figure 5 As shown, the embodiment of the present application also provides a virtual character memory management system. Optionally, the system may include:

[0125] Pre-preparation module 211, acquisition module 212, short-term memory generation module 213, long-term memory generation module 214, fusion module 215, wherein:

[0126] A 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;

[0127] In this embodiment, the pre-preparation module 211 can be used to perform Figure 1 As shown in step S110 , for a detailed description of the pre-preparation module 211 , reference may be made to the description of step S110 .

[0128] An acquisition module 212 is configured to acquire the content of a conversation between the user and the virtual character, and acquire the current conversation content, the current instantaneous memory, and the previous instantaneous memory of the user and the virtual character based on the conversation content;

[0129] In this embodiment, the acquisition module 212 can be used to perform Figure 1 As shown in step S120, for a detailed description of the acquisition module 212, reference may be made to the description of step S120.

[0130] A short-term memory generation module 213 is configured to obtain the short-term memory of the virtual character at the current moment based on 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;

[0131] In this embodiment, the short-term memory generation module 213 can be used to perform Figure 1 As shown in step S130 , for a detailed description of the short-term memory generation module 213 , reference may be made to the description of step S130 .

[0132] The long-term memory generation module 214 is configured to obtain the long-term memory of the virtual character at the current moment based on the current conversation content, the character settings 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;

[0133] In this embodiment, the long-term memory generation module 214 can be used to perform Figure 1 As shown in step S140 , for a detailed description of the long-term memory generation module 214 , reference may be made to the description of step S140 .

[0134] The fusion module 215 is used to fuse the current conversation content, the character setting of the virtual character, and the instantaneous memory, short-term memory, and long-term memory of the current moment to obtain the fused memory of the virtual character at the current moment; wherein, 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.

[0135] In this embodiment, the fusion module 215 can be used to perform Figure 1 As shown in step S150 , for a detailed description of the fusion module 215 , reference may be made to the description of step S150 .

[0136] The present application also provides an electronic device, the structure of which is as follows: Figure 6 As shown, the electronic device includes a memory 311, a processor 312, a communication module 313 and an input / output interface 314, etc. Optionally, the memory 311, the processor 312, the communication module 313 and the input / output interface 314 can be connected and communicated through a bus 315.

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

[0138] Optionally, the electronic device can be connected to a network via the communication module 313 to communicate with other devices, such as a terminal or a server, via the network to achieve data interaction. The electronic device can be various forms of digital computers, such as desktop computers, servers, workstations, mainframe computers, or other types of computers. The electronic device can also be various forms of mobile terminals, such as smartphones, tablet computers, wearable devices (such as helmets, glasses, watches, etc.), and other similar mobile terminals.

[0139] Optionally, the electronic device can be connected to the required input / output devices, such as a keyboard, a display device, etc., through the input / output interface 314. The electronic device itself can have a display device, and can also be connected to other display devices through the input / output interface 314. Optionally, a storage device, such as a hard disk, can also be connected through the input / output interface 314, so that data in the electronic device can be stored in the storage device, or data in the storage device can be read, and data in the storage device can also be stored in the memory 311. It can be understood that the input / output interface 314 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to the input / output interface 314 can be a component of the electronic device, or it can be an external device connected to the electronic device when needed.

[0140] Optionally, the memory 311 can be a volatile memory and / or a non-volatile memory, the volatile memory can be a random access memory, etc., and the non-volatile memory can 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.

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

[0142] Optionally, processor 312 may be any general-purpose and / or specialized processing component with processing and computing capabilities. Examples of processor 312 include, but are not limited to, a central processing unit, a graphics processing unit, a digital signal processor, various specialized artificial intelligence computing chips, various processors for running machine learning model algorithms, and any suitable controller, microcontroller, processor, etc. Processor 312 executes the various methods and processes of this embodiment, such as, for example, a virtual character memory management method according to an embodiment of the present application.

[0143] Optionally, the bus 315 may include a path for transmitting information. The bus 315 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. Depending on their functions, the bus 315 may be categorized as an address bus, a data bus, a control bus, or the like.

[0144] In an optional implementation, the present embodiment further provides a computer storage medium having a computer program stored thereon. When the computer program is executed by a computer, the computer is enabled to perform the method of the above-described method embodiment. Part or all of the computer program can be loaded and / or installed into 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 of the present embodiment can be performed.

[0145] 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, or the like.

[0146] Obviously, the above embodiments of the present application are merely examples for clearly illustrating the technical solution of the present application, and are not intended to limit the specific implementation methods of the present application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present application shall be included in the scope of protection of the claims of the present application.

Claims

1. A virtual character memory management method, characterized in that: The method comprises: Pre-setting the virtual character's short-term memory library, long-term memory library and character setting library; Acquire the conversation content between the user and the virtual character, and acquire the current conversation content, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment between the user and the virtual character based on the conversation content; Extracting the speech content of the user at the current moment from the current conversation content; obtaining first association information based on 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 based on the first association information; obtaining second association information based on 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, obtaining the short-term memory at the current moment based on the second association information, and adding the short-term memory at the current moment to the short-term memory library; Obtaining third association information based on the recalled short-term memory, the long-term memory of the previous moment, the current conversation content, and the character setting of the virtual character, obtaining the long-term memory of the current moment based on the third association information, and adding the long-term memory of the current moment to the long-term memory library; 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 a fused memory of the virtual character at the current moment; The short-term memory of the previous moment is obtained from the short-term memory library, the long-term memory of the previous moment is obtained from the long-term memory library; and 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 based on 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 instantaneous memory at the current moment according to the conversation content, including: Pre-set the maximum capacity of instantaneous memory; Taking the current conversation content at the current moment as a starting point, moving forward in time according to the maximum capacity to intercept a conversation content segment to obtain a first conversation content segment, and splicing the first conversation content segment from top to bottom 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 conversation content, including: Pre-set 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 the 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: Also includes: The first associated information is obtained by a similarity recall algorithm function; and / or, The second association 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.

5. A virtual character memory management method according to any one of claims 1 to 4, characterized in that: Also includes: Streamlining the short-term memory of the virtual character at the current moment using a least recently used elimination algorithm function to obtain a streamlined 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.

6. A virtual character memory management method according to any one of claims 1 to 4, characterized in that: The fusing of 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: The information fusion algorithm function based on the prompt word project 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.

7. A virtual character memory management system, characterized in that: include: A pre-preparation module for pre-setting the short-term memory library, long-term memory library and character setting library of the virtual character; An acquisition module, configured to acquire the content of a conversation between the user and the virtual character, and acquire the current conversation content, the instantaneous memory at the current moment, and the instantaneous memory at the previous moment between the user and the virtual character based on the conversation content; A short-term memory generation module is used to extract the user's speech content at the current moment from the current conversation content; Acquire first association information based on 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 based on the first association information; acquire second association information based on 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, acquire the short-term memory at the current moment based on the second association information, and add the short-term memory at the current moment to the short-term memory library; a long-term memory generation module, configured to obtain third association information based on the recalled short-term memory, the long-term memory of the previous moment, the current conversation content, and the character settings of the virtual character, obtain the long-term memory of the current moment based on the third association information, and add the long-term memory of the current moment to the long-term memory library; A fusion module, configured to 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 a fused memory of the virtual character at the current moment; The short-term memory of the previous moment is obtained from the short-term memory library, the long-term memory of the previous moment is obtained from the long-term memory library; and the character setting of the virtual character is extracted from the character setting library.

8. A virtual character memory management system according to claim 7, characterized in that: Acquiring instantaneous memory at the current moment according to the conversation content, including: Pre-set the maximum capacity of instantaneous memory; Taking the current conversation content at the current moment as a starting point, moving forward in time according to the maximum capacity to intercept a conversation content segment to obtain a first conversation content segment, and splicing the first conversation content segment from top to bottom 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 conversation content, including: Pre-set 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 the 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.

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 according to any one of claims 1 to 6.

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 according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Interaction method and device, medium and electronic equipment

    CN117959715A

  • Short-term memory bank construction method and device of dialogue model and electronic equipment

    CN119280838A