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

By memorizing and sorting chat statements in dialogue scenarios and building a smaller short-term memory bank, the problems of slow reply speed and high cost in the existing technology are solved, and the efficiency and logical reasoning capabilities of the dialogue model are improved.

CN119280838APending Publication Date: 2025-01-10BEIJING PERFECT WORLD SOFTWARE TECH DEV CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311735553.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-15
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

The short-term memory bank construction method of existing dialogue models leads to slow reply speed and high cost, mainly due to the need to input a large amount of text for reasoning.

Method used

By obtaining chat statement pairs in conversation scenarios, using the memory organization model to organize them into smaller short-term memories, and storing them in a preset memory bank, reducing the amount of text input to the conversation model.

Benefits of technology

It improves the reply speed of the dialogue model, reduces cost and overhead, and enhances the logical reasoning ability of the dialogue model, making the generated dialogue reply statements more accurate and realistic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119280838A_ABST
    Figure CN119280838A_ABST
Patent Text Reader

Abstract

The invention relates to a short-term memory library construction method and device for a dialogue model and electronic equipment, and the method comprises the steps: obtaining a chat statement pair between a player character and a non-player character in a dialogue scene, each statement pair in the chat statement pair comprises a dialogue statement of a player character and a dialogue reply statement of a dialogue model of a non-player character, the dialogue reply statement of the non-player character is obtained by reasoning structured dialogue information through the dialogue model, and the structured dialogue information comprises short-term memory information in a dialogue scene; sequentially inputting the chat statement pairs into a preset memory arrangement model for memory arrangement by taking the N statement pairs as a cycle to obtain short-term memories corresponding to the N statement pairs; and storing the short-term memory in a preset memory bank, and constructing a short-term memory bank. Therefore, the quantity of texts input to the dialogue model can be reduced, the reply speed of the dialogue model is improved, and the cost of the dialogue model is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of game development technology, and in particular to a method, device and electronic device for constructing a short-term memory bank of a dialogue model. Background Art

[0002] When using the dialogue model to simulate the dialogue content of non-player characters in the game dialogue scene, the dialogue model can record the dialogue content between the player character and the non-player character, form short-term memory and store it in the short-term memory bank, and introduce the short-term memory in subsequent dialogue interactions to better help the dialogue model infer the dialogue content of the non-player character, so that the dialogue model has stronger logical reasoning ability.

[0003] However, the existing short-term memory library construction method of the dialogue model is usually to directly store the dialogue content generated by the player character and the non-player character as short-term memory in the short-term memory library. This will result in too much text input to the dialogue model when using the short-term memory in the short-term memory library for reasoning, resulting in the problem of slow response speed of the dialogue model and high cost. Therefore, how to reasonably construct the short-term memory library of the dialogue model so that the dialogue model has strong logical reasoning ability while reducing the amount of text input to the dialogue model has become a technical problem that needs to be solved urgently. Summary of the invention

[0004] The present application provides a method, device and electronic device for constructing a short-term memory bank of a dialogue model to solve the problem that the dialogue content generated by a player character and a non-player character is directly stored in the short-term memory bank as short-term memory in the prior art, resulting in a slow response speed of the dialogue model and a high cost.

[0005] In a first aspect, an embodiment of the present application provides a method for constructing a short-term memory bank of a dialogue model, the method comprising:

[0006] Acquire chat sentence pairs between a player character and a non-player character in a dialogue scene, wherein each sentence pair in the chat sentence pairs includes a dialogue sentence of the player character and a dialogue reply sentence of the non-player character dialogue model, and the dialogue reply sentence of the non-player character is obtained by reasoning structured dialogue information through the dialogue model, and the structured dialogue information includes short-term memory information in the dialogue scene;

[0007] Inputting the chat sentence pairs into a preset memory arrangement model in sequence with N sentence pairs as a cycle to carry out memory arrangement, and obtaining short-term memory corresponding to each of the N sentence pairs, wherein N is a positive integer greater than or equal to 1, and the short-term memory is text information obtained by arranging the role information and dialogue content in the N sentence pairs, and the text volume of the short-term memory is less than the text volume of the N sentence pairs;

[0008] The short-term memory is stored in a preset memory bank to construct a short-term memory bank, wherein the preset memory bank is a pre-set memory bank for storing short-term memory, and the preset memory bank stores historical short-term memory generated by the memory organization model, and the historical short-term memory is used to generate short-term memory information in the structured dialogue information.

[0009] Optionally, obtaining chat sentence pairs between a player character and a non-player character in a dialogue scene includes:

[0010] Acquire a historical sentence pair in the dialogue scene and a target dialogue sentence input by the player character, wherein the historical sentence pair is a sentence pair generated before the target dialogue sentence and has not yet been sorted by the memory sorting model;

[0011] Matching short-term memory information matching the target dialogue sentence from the preset memory library, wherein the short-term memory information includes at least one short-term memory;

[0012] splicing the short-term memory information, the historical sentence pairs and the target dialogue sentence according to a first preset format to obtain the structured dialogue information;

[0013] Inputting the structured dialogue information and the preset prompt text into the dialogue model for inference to obtain a dialogue reply sentence corresponding to the target dialogue sentence, wherein the preset prompt text is a natural language and is used to prompt the dialogue model to infer the structured dialogue information according to the inference logic described in the natural language;

[0014] The target dialogue sentence and the dialogue reply sentence corresponding to the target dialogue sentence are spliced ​​according to a second preset format, and the spliced ​​text is used as the chat sentence pair.

[0015] Optionally, matching the short-term memory information matching the target dialogue sentence from the preset memory library includes:

[0016] Obtaining a first word vector corresponding to the target dialogue sentence and a second word vector corresponding to each historical short-term memory in the preset memory bank;

[0017] Calculate the similarity between the first word vector and each of the second word vectors respectively;

[0018] At least one historical short-term memory whose similarity is greater than a preset threshold is matched from the preset memory library, and the short-term memory information is generated based on the at least one historical short-term memory.

[0019] Optionally, the step of inputting the structured dialogue information and the preset prompt text into the dialogue model for inference to obtain a dialogue reply sentence corresponding to the target dialogue sentence includes:

[0020] Inputting the structured dialogue information and the preset prompt text into the dialogue model, wherein the preset prompt text includes a first text for inferring the semantics of the dialogue sentence and a second text for analyzing the memory related to the semantics of the dialogue sentence;

[0021] The first text is used to prompt the dialogue model to infer the semantics of the target dialogue sentence based on the historical sentences, and the second text is used to prompt the dialogue model to analyze the relevant memory of the target dialogue sentence based on the short-term memory information to obtain a dialogue response sentence corresponding to the target dialogue sentence.

[0022] Optionally, after inputting the chat sentence pairs into a preset memory arrangement model in a cycle of N sentence pairs to perform memory arrangement and obtaining the short-term memory corresponding to each of the N sentence pairs, the method further includes:

[0023] The sentence pairs input into the memory organization model are deleted, and when a new dialogue sentence input from the player character is received, the historical sentence pairs input into the dialogue model are updated.

[0024] Optionally, after updating the historical sentence pairs input into the dialogue model, the method further comprises:

[0025] Matching new short-term memory information matching the new dialogue sentence from the short-term memory library, wherein the new short-term memory information includes at least one short-term memory;

[0026] splicing the new short-term memory information, the updated historical sentence pair and the new dialogue sentence according to the first preset format to obtain new structured dialogue information;

[0027] The new structured dialogue information and the preset prompt text are input into the dialogue model for reasoning to obtain a new dialogue response sentence.

[0028] Optionally, storing the short-term memory in a preset memory bank to construct a short-term memory bank includes:

[0029] Obtaining a timestamp and a sequence stamp corresponding to each of the short-term memories, wherein the timestamp is determined based on the generation time of the short-term memories, and the sequence stamp is determined based on the generation order of the short-term memories;

[0030] Each of the short-term memories and the timestamp and sequence stamp corresponding to each of the short-term memories are stored in the preset memory library according to a third preset format to construct the short-term memory library.

[0031] In a second aspect, an embodiment of the present application further provides a device for constructing a short-term memory library of a dialogue model, the device comprising:

[0032] An acquisition module, used for acquiring chat sentence pairs between a player character and a non-player character in a dialogue scene, wherein each sentence pair in the chat sentence pairs includes a dialogue sentence of the player character and a dialogue reply sentence of the non-player character dialogue model, and the dialogue reply sentence of the non-player character is obtained by reasoning structured dialogue information through the dialogue model, and the structured dialogue information includes short-term memory information in the dialogue scene;

[0033] A memory arrangement module, used for sequentially inputting the chat sentence pairs into a preset memory arrangement model for memory arrangement with N sentence pairs as a cycle, to obtain short-term memory corresponding to each of the N sentence pairs, wherein N is a positive integer greater than or equal to 1, and the short-term memory is text information obtained by arranging the role information and dialogue content in the N sentence pairs, and the text volume of the short-term memory is less than the text volume of the N sentence pairs;

[0034] A construction module is used to store the short-term memory into a preset memory bank to construct a short-term memory bank, wherein the preset memory bank is a pre-set memory bank for storing short-term memory, and the preset memory bank stores historical short-term memory generated by the memory organization model, and the historical short-term memory is used to generate short-term memory information in the structured dialogue information.

[0035] In a third aspect, an embodiment of the present application further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0036] Memory, used to store computer programs;

[0037] The processor is used to implement the steps of the method for constructing a short-term memory bank of a dialogue model as described in any one of the first aspects when executing the program stored in the memory.

[0038] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for constructing a short-term memory bank of a dialogue model as described in any one of the first aspects.

[0039] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application obtains chat sentence pairs between a player character and a non-player character in a dialogue scene, wherein each sentence pair in the chat sentence pairs includes a dialogue sentence of the player character and a dialogue reply sentence of the dialogue model of the non-player character, and the dialogue reply sentence of the non-player character is obtained by inferring structured dialogue information through the dialogue model, and the structured dialogue information includes short-term memory information in the dialogue scene; the chat sentence pairs are input into a preset memory sorting model in sequence with N sentence pairs as a cycle. Memory is organized to obtain short-term memory corresponding to each of the N sentence pairs, wherein N is a positive integer greater than or equal to 1, and the short-term memory is text information obtained by organizing the role information and dialogue content in the N sentence pairs, and the text volume of the short-term memory is less than the text volume of the N sentence pairs; the short-term memory is stored in a preset memory bank to construct a short-term memory bank, wherein the preset memory bank is a pre-set memory bank for storing short-term memory, and the preset memory bank stores historical short-term memory generated by the memory organization model, and the historical short-term memory is used to generate short-term memory information in the structured dialogue information. Through the above method, the memory organization model can be used to organize the chat sentence pairs, and a short-term memory with a smaller text volume than the original N sentence pairs can be obtained. In this way, when using the dialogue model to generate dialogue response sentences of non-player characters, the short-term memory with a smaller text volume can be input into the dialogue model, avoiding the problem in the prior art that the original sentence pairs corresponding to the short-term memory need to be input into the dialogue model, resulting in a slower response speed and higher cost of the dialogue model, thereby reducing the amount of text input into the dialogue model, improving the response speed of the dialogue model, and reducing the cost of the dialogue model. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0042] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0043] Figure 1 A flowchart of a method for constructing a short-term memory bank of a dialogue model provided in an embodiment of the present application;

[0044] Figure 2 A schematic diagram of a chat interface within a game provided in an embodiment of the present application;

[0045] Figure 3 A schematic diagram of a flow chart of a method for constructing a short-term memory bank of another dialogue model provided in an embodiment of the present application;

[0046] Figure 4 A schematic diagram of the structure of a short-term memory library construction device for a dialogue model provided in an embodiment of the present application;

[0047] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0049] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0050] In order to solve the problem in the prior art that the memory data screened out from the memory bank for the dialogue mode of non-player characters is not accurate enough, resulting in the dialogue response sentences of the non-player characters not being consistent with actual expectations, the present application provides a dialogue control method, device, electronic device and storage medium for non-player characters, which can improve the accuracy of memory matching.

[0051] See also Figure 1 , Figure 1 The following is a flow chart of a method for constructing a short-term memory bank of a dialogue model provided in an embodiment of the present application. Figure 1 As shown, the method for constructing a short-term memory bank of the dialogue model may include the following steps:

[0052] Step 101: Obtain chat sentence pairs between a player character and a non-player character in a dialogue scene, wherein each sentence pair in the chat sentence pairs includes a dialogue sentence of the player character and a dialogue response sentence of a dialogue model of the non-player character, and the dialogue response sentence of the non-player character is obtained by inferring structured dialogue information through the dialogue model, and the structured dialogue information includes short-term memory information in the dialogue scene.

[0053] Specifically, the non-player character (NPC) is a virtual character in the game that is not controlled by real players, and the player character is any virtual character in the game that interacts with the non-player character. The chat sentence pair is a sentence pair generated by the player character and the non-player character during the dialogue interaction, and each sentence pair consists of the player character's dialogue sentence and the non-player character's dialogue model's dialogue reply sentence.

[0054] In this step, a dialogue model (such as a ChatGPT model or other generative speech models, etc.) can be used to generate dialogue response statements corresponding to each dialogue statement, thereby forming a pair of statements, and these pairs of statements are spliced ​​and saved according to a preset format. The preset format here can be the format of "Role A: XXXX; Role B: YYYY", or the format of "Role AXXXX, Role BYYYYY", or adding a timestamp or other preset fields on the basis of the aforementioned format. Among them, role A represents the name of the player character, role B represents the name of the non-player character, XXXX represents the dialogue statement, and YYYY represents the dialogue response statement.

[0055] It should be noted that when using the dialogue model to generate the dialogue reply statement corresponding to each dialogue sentence, it is necessary to splice the dialogue sentence and the short-term memory information generated in the current dialogue scene to form structured dialogue information and input it into the dialogue model. In this way, the dialogue model can combine the short-term memory related to the dialogue sentence to reason about the dialogue sentence and generate accurate dialogue reply sentences. Among them, the structured dialogue information here includes not only the dialogue sentences of the player character and the short-term memory information generated in the current dialogue scene, but also other information such as historical sentence pairs that have not yet been organized into short-term memory or other information, etc., which is not specifically limited in the embodiments of the present application. The short-term memory information here is obtained by memorizing and organizing the chat sentence pairs obtained above using the memory organization model, which will be described in detail in the subsequent steps and will not be repeated here.

[0056] Step 102: Input the chat sentence pairs into a preset memory organization model in sequence with N sentence pairs as a cycle to obtain short-term memory corresponding to each of the N sentence pairs, wherein N is a positive integer greater than or equal to 1, and the short-term memory is the text information obtained after organizing the role information and dialogue content in the N sentence pairs, and the amount of text in the short-term memory is less than the amount of text in the N sentence pairs.

[0057] Specifically, the value of N can be any positive integer such as 1, 2, 3, 4, etc. For example, when N is 2, 2 sentence pairs (4 sentences in total) are input into the memory arrangement model for memory arrangement; when N is 3, 3 sentence pairs (6 sentences in total) are input into the memory arrangement model for memory arrangement, etc.

[0058] The above short-term memory is the text information obtained after sorting out the character information and dialogue content in the original N sentence pairs, and its text volume is smaller than the text volume of the original N sentence pairs. For example, suppose the content of the original N sentence pairs is: "&2023.9.28 #{Role A expressed dissatisfaction with the taste of school food, and character B expressed understanding and offered to cook for her.};&2023.9.28 #{Role A expressed his love for hot pot and Japanese food, and asked about the food restaurants near the school. Character B recommended nearby hot pot restaurants and Japanese food restaurants, and suggested that they could try them together.};&2023.9.28 #{Role A invited character B to dinner as a thank you, and asked character B to choose between hot pot and Japanese food. Character B chose hot pot and expressed his expectation for it.};&2023.9.28 #{Role A asks character B why he chooses hot pot instead of Japanese food. Character B explains that hot pot is more suitable for sharing between two people and he is more interested in the taste of hot pot.}", after being sorted out using the memory sorting model, the short-term memory is: On September 28, 2023, character A invites character B to dinner as a thank you, and lets character B choose between hot pot and Japanese food. Character B chooses hot pot and expresses his expectation for it.

[0059] In this step, the chat sentence pairs can be input into the preset memory arrangement model in a cycle of N sentence pairs, and the short-term memory corresponding to each of the N sentence pairs can be obtained. For example, assuming that there are 10 chat sentence pairs obtained, and the value of N is 2, then every 2 sentence pairs will generate a short-term memory, and 10 sentence pairs will generate a total of 5 short-term memories.

[0060] Step 103: Store the short-term memory in a preset memory bank to construct a short-term memory bank, wherein the preset memory bank is a pre-set memory bank for storing short-term memory, and the preset memory bank stores historical short-term memory generated by the memory organization model, and the historical short-term memory is used to generate short-term memory information in structured dialogue information.

[0061] Specifically, the above-mentioned preset memory library is a pre-set memory library for storing short-term memory, which stores the historical short-term memory generated by the memory organization model (i.e., the short-term memory generated before receiving the current dialogue sentence of the player character). In this way, when the dialogue model infers the current dialogue sentence of the player character, the short-term memory information in the structured dialogue information can be generated according to the historical short-term memory, which is convenient for the dialogue model to understand the dialogue sentence and perform logical reasoning. The above-mentioned short-term memory library can be understood as an updated preset memory library, which can provide short-term memory for the dialogue model in real time. The short-term memory library is an embedding library constructed for short-term memory, which is specially used for word vector matching for short-term memory. The matching method of the short-term memory library is the same as the matching method of other memory libraries, that is, word vector matching is performed to obtain word vectors whose word vector similarity reaches a preset threshold as short-term memory information.

[0062] In this embodiment, the memory organization model can be used to organize the chat sentence pairs, and obtain short-term memory with a smaller text volume than the original N sentence pairs. In this way, when using the dialogue model to generate dialogue response sentences of non-player characters, the short-term memory with a smaller text volume can be input into the dialogue model, avoiding the problem in the prior art that the original sentence pairs corresponding to the short-term memory need to be input into the dialogue model, resulting in a slower response speed and higher cost of the dialogue model, thereby reducing the amount of text input into the dialogue model, improving the response speed of the dialogue model, and reducing the cost of the dialogue model.

[0063] Furthermore, the above step 102, obtaining chat sentence pairs between the player character and the non-player character in the dialogue scene, includes:

[0064] Obtaining historical sentence pairs in a dialogue scene and target dialogue sentences input by a player character, wherein the historical sentence pairs are sentence pairs generated before the target dialogue sentences and not yet organized by the memory organization model;

[0065] Matching short-term memory information matching the target dialogue sentence from a preset memory library, wherein the short-term memory information includes at least one short-term memory;

[0066] splicing the short-term memory information, the historical sentence pairs and the target dialogue sentences according to a first preset format to obtain structured dialogue information;

[0067] Input the structured dialogue information and the preset prompt text into the dialogue model for reasoning, and obtain the dialogue reply sentence corresponding to the target dialogue sentence, wherein the preset prompt text is a natural language, which is used to prompt the dialogue model to reason about the structured dialogue information according to the reasoning logic described by the natural language;

[0068] The target dialogue sentence and the dialogue reply sentence corresponding to the target dialogue sentence are spliced ​​according to a second preset format, and the spliced ​​text is used as a chat sentence pair.

[0069] In one embodiment, the structured dialogue information includes the dialogue sentences of the player character, short-term memory information, and historical sentence pairs that have not yet been organized into short-term memory. Therefore, when using the dialogue model to generate dialogue response sentences, it is necessary to first obtain the historical sentence pairs and the target dialogue sentences input by the player character, and then match the short-term memory information that matches the target dialogue sentences from the preset memory library, and then splice the short-term memory information, historical sentence pairs, and target dialogue sentences according to the first preset format to obtain structured dialogue information, and finally input the structured dialogue information and the preset prompt text into the dialogue model for reasoning to obtain the dialogue response sentence corresponding to the target dialogue sentence. Among them, the first preset format here can be similar to

[0070] The format is [Memory]xx[History]xx[Dialog]xx, where the content after [Memory] is the short-term memory information, the content after [History] is the historical sentence pair, and the content after [Dialog] is the target dialogue sentence.

[0071] The splicing order of [Memory], [History] and [Dialog] can be combined at will, and the embodiments of the present application do not make specific limitations. The preset prompt text here can be understood as a prompt input into the dialogue model, and its function is to prompt the dialogue model to infer the input structured dialogue information according to the reasoning logic described therein to generate a dialogue reply statement. After generating the dialogue reply statement, the target dialogue statement and the dialogue reply statement corresponding to the target dialogue statement can be spliced ​​according to the second preset format to obtain a sentence pair in the chat sentence pair. Among them, the second preset format here can be the format of "Role A: XXXX; Role B: YYYY", or the format of "Role AXXXX, Role BYYYYY", or add a timestamp or other preset fields on the basis of the aforementioned format.

[0072] For example, suppose the currently input structured dialogue information is: "[Memory] Your mother likes to command and preach to others, requiring them to complete certain things, and she must do what she thinks of. You like to cook, and you think cooking is a very healing thing. You also like to cook for people you like. You know how to get along with others, you are emotionally stable, you will never quarrel with others, and you can perceive the other person's feelings. If the other person is emotional and wants to quarrel, you will first think about what you did wrong, and then find a solution to the problem for the other person to choose. Your cat is very proud of you, and you feed it every day. There must be more than three types of food, otherwise it will Just knock over the food bowl and don't eat. Although your cat may dislike you sometimes, it always stays by your side. Because you have experienced a lot, you will not look down on others because you are good enough. No matter what questions the other party asks, you will answer them seriously and patiently. You like to solve problems. When you encounter a problem, you will first analyze the cause and then find a solution, especially when you encounter a code problem. On September 28, 2023, you and your junior sister were walking in the school. You felt that the silent atmosphere was a bit awkward, so you asked her if she had adapted to school life. {7} On September 28, 2023, the junior sister politely refused your help. At your insistence, you explained the question to her clearly.

[0073] {3}On September 28, 2023, you reviewed the advanced mathematics you had learned for your junior sister. Your junior sister was asked to write a meeting notice, so you asked her to finish writing it and then you could take a look. {4}On September 28, 2023, you knew that your junior sister was on duty alone at the Network Technology Center, so you went to see her under the pretext of checking her work. {1}On September 28, 2023, your junior sister expressed her learning difficulties to Role A and was worried that the teaching process would be time-consuming and energy-consuming. {301}On September 28, 2023, Role A said that he would not be disgusted, and believed that everyone's learning progress was different. As long as the junior sister was willing, he would be willing to teach. {304}On September 1, 2023, Role A explained that he asked this because the junior sister looked a bit like his childhood neighbor. {102}On September 1, 2023, the junior sister expressed that she was surprised by this and asked Role A's name and place of origin.

[0074] {103}On September 28, 2023, Character A explains that he came to check on the work situation and asks the school girl if she is busy.

[0075] {202}[History]P: It's OK, but the food here is too bland, there's nothing I like. G: I also think the food here is a bit bland, I usually like to cook by myself, do you have anything you want to eat, I can try to cook it for you. [Dialog]Haha, senior, you are too polite, I prefer hot pot and Japanese food, are there any good restaurants near the school? In this way, after receiving the structured dialogue information, the dialogue model can parse through the prompt to get [History] = The junior girl said that the taste here is too bland, there is nothing she likes, I suggested that I can make some food for her. The junior girl responded that I was too polite, and said that she likes hot pot and Japanese food, and asked if there are any good restaurants near the school. And according to the content after [Memory], recall one by one, and infer the dialogue reply sentence of character A.

[0076] In the prior art, the solution for implementing memory in the dialogue model is to directly send the dialogue sentence pairs generated in the past as memory text together with the current dialogue sentence to the dialogue model for reasoning. This will cause the amount of text input to the dialogue model to increase, which will easily lead to the following problems: 1) Increased cost of the dialogue model: The charging method of the dialogue model is usually proportional to the text volume of the dialogue sentence and the dialogue reply sentence. According to the memory principle of sending the historical dialogue sentence back to the dialogue model as the chat content, these records will occupy a large amount of text through accumulation, resulting in increased expenses. 2) Risk of text overflow: There is an upper limit on the amount of text that can be input into the dialogue model at a time. If the accumulated historical dialogue records are too large, the risk of text overflow will increase. 3) The reply speed slows down as the memory text accumulates: The reply speed of the dialogue model increases based on the amount of information text input by the user. If the accumulated memory text is too large, the reply speed of the dialogue model will become slower and slower.

[0077] Compared with the prior art, the method in the embodiments of the present application can generate dialogue response sentences by using structured dialogue information consisting of dialogue sentences of player characters, short-term memory information and historical sentence pairs that have not yet been organized into short-term memory, thereby reducing the amount of text input into the dialogue model, thereby improving the response speed of the dialogue model and reducing the cost overhead; and, because the input information contains short-term memory information, the logical reasoning ability of the dialogue model can be improved, making the generated dialogue response sentences more accurate and realistic.

[0078] Furthermore, the above step of matching short-term memory information matching the target dialogue sentence from the preset memory bank includes:

[0079] Obtaining a first word vector corresponding to the target dialogue sentence and a second word vector corresponding to each historical short-term memory in a preset memory bank;

[0080] Calculate the similarity between the first word vector and each second word vector respectively;

[0081] At least one historical short-term memory with a similarity greater than a preset threshold is matched from a preset memory library, and short-term memory information is generated based on the at least one historical short-term memory.

[0082] In one embodiment, when matching short-term memory information that matches the target dialogue sentence from the preset memory library, the first word vector corresponding to the target dialogue sentence and the second word vector corresponding to each historical short-term memory in the preset memory library can be obtained respectively, and then the similarity between the first word vector and each second word vector is calculated respectively, and then according to the calculated similarity, one or more historical short-term memories with a similarity greater than a preset threshold are matched from the preset memory library, and short-term memory information is generated based on the one or more historical short-term memories, that is, the information after [Memory] in the above text. It should be noted that the preset threshold can be a value such as 0.7, 0.8, etc.

[0083] In this way, short-term memories related to the current conversation topic can be accurately matched from the short-term memory bank, avoiding the input of information irrelevant to the current conversation topic into the conversation model, thereby further reducing the amount of text input into the conversation model.

[0084] Furthermore, the above step of inputting the structured dialogue information and the preset prompt text into the dialogue model for inference to obtain a dialogue response sentence corresponding to the target dialogue sentence includes:

[0085] Inputting structured dialogue information and preset prompt text into the dialogue model, wherein the preset prompt text includes a first text for inferring the semantics of the dialogue sentence and a second text for analyzing the memory related to the semantics of the dialogue sentence;

[0086] The first text prompt dialogue model is used to infer the semantics of the target dialogue sentence based on historical sentences, and the second text prompt dialogue model is used to analyze the relevant memory of the target dialogue sentence based on short-term memory information to obtain the dialogue response sentence corresponding to the target dialogue sentence.

[0087] In one embodiment, the preset prompt text includes a first text for inferring the semantics of the dialogue sentence and a second text for analyzing the memory related to the semantics of the dialogue sentence. Therefore, when the dialogue model is used for reasoning, the first text can be used to prompt the dialogue model to infer the semantics of the target dialogue sentence based on the historical sentence, and the second text can be used to prompt the dialogue model to analyze the memory related to the target dialogue sentence based on the short-term memory information, so as to obtain the dialogue reply sentence corresponding to the target dialogue sentence. In an optional implementation, when the structured dialogue information input to the dialogue model is in the format of [Memory]xx[History]xx[Dialog]xx, the first text can be "[History] = your complete understanding of the dialogue record between [History] and [Dialog], and clarify the logical relationship", and the second text can be "[Recall Analysis] = analyze each memory after [Memory], the larger the number in {}, the later the memory occurred, and output your understanding".

[0088] In the above manner, the first text and the second text in the preset prompt text may be used to prompt the dialogue model, so that the dialogue model can better use the information in the structured dialogue information for logical reasoning.

[0089] Furthermore, in the above step 102, the chat sentence pairs are sequentially input into a preset memory arrangement model for memory arrangement in a cycle of N sentence pairs, and after obtaining the short-term memory corresponding to each of the N sentence pairs, the method further includes:

[0090] The sentence pairs input to the memory organization model are deleted, and when new dialogue sentences input by the player character are received, the historical sentence pairs input to the dialogue model are updated.

[0091] In one embodiment, since the sentence pairs that have been sorted by the memory sorting model have been converted into short-term memory for the dialogue model to call, there is no need to retain the historical sentence pairs in the structured dialogue information. Therefore, after the memory sorting model completes each memory sorting, the sentence pairs input to the memory sorting model can be deleted, and when a new dialogue sentence input by the player character is received, the historical sentence pairs input to the dialogue model (i.e., the content after [History]) are updated. In other words,

[0092] The content after [History] is the dialogue sentences that have already occurred between the player character and the non-player character and have not yet been processed by the memory organization model. The number of dialogue sentences is related to the processing speed of the memory organization model. If the processing speed of the memory organization model is fast, the content after [History] may be empty.

[0093] Through the above method, the historical sentence pairs in the structured dialogue information can be updated in time to ensure that the sentence pairs retained in the historical sentence pairs are sentence pairs that have not yet been sorted by the memory sorting model, thereby ensuring the integrity of the input information while reducing the text volume of the input information.

[0094] Furthermore, after the above step of updating the historical sentence pairs input into the dialogue model, the method further includes:

[0095] Matching new short-term memory information matching the new dialogue sentence from the short-term memory bank, wherein the new short-term memory information includes at least one short-term memory;

[0096] splicing the new short-term memory information, the updated historical sentence pairs and the new dialogue sentences according to a first preset format to obtain new structured dialogue information;

[0097] The new structured dialogue information and preset prompt text are input into the dialogue model for reasoning to obtain new dialogue response sentences.

[0098] In one embodiment, when a new dialogue sentence input by a player character is received, in addition to updating the historical sentence pairs input to the dialogue model according to the sorting progress of the memory sorting model, new short-term memory information matching the new dialogue sentence can be matched from the short-term memory library, and then the new short-term memory information, the updated historical sentence pairs and the new dialogue sentence are spliced ​​according to the first preset format to obtain new structured dialogue information, and the new structured dialogue information and the preset prompt text are input into the dialogue model for reasoning to obtain a new dialogue reply sentence. For example, Figure 2 As shown, after the player character and the non-player character have been talking for a period of time (the topics include animal preferences and character relationships), a new dialogue reply sentence can be obtained based on the player character's new dialogue sentence (the topic content is animal preferences). Even if the topic of the new dialogue sentence input by the player character changes at this time, the dialogue model can accurately match the dialogue reply sentence corresponding to the current dialogue topic based on the previous short-term memory.

[0099] Through the above method, the memory organization model can be used to organize the chat sentence pairs generated by the dialogue model to obtain short-term memory information, and then the dialogue model can be used to infer the dialogue reply sentences based on the short-term memory information to obtain dialogue reply sentences. Then, the memory organization model is used to generate new chat sentence pairs based on the new dialogue reply sentences to generate new short-term memory information. This can be repeated so that the memory organization model and the dialogue model can be used perfectly together.

[0100] Furthermore, the above step 103, storing the short-term memory in a preset memory bank, constructing a short-term memory bank, includes:

[0101] Obtain the timestamp and sequence stamp corresponding to each short-term memory, where the timestamp is determined based on the generation time of the short-term memory, and the sequence stamp is determined based on the generation order of the short-term memory;

[0102] Each short-term memory and the timestamp and sequence stamp corresponding to each short-term memory are stored in a preset memory library according to a third preset format to construct a short-term memory library.

[0103] In one embodiment, when constructing a short-term memory library, a timestamp corresponding to the short-term memory can be determined based on the generation time of the short-term memory, and a sequence stamp corresponding to the short-term memory can be determined based on the generation order of the short-term memory. Then, the short-term memory and the timestamp and sequence stamp corresponding to the short-term memory are stored in a preset memory library according to a third preset format to construct the short-term memory library. For example, based on the content of the original N sentence pairs: "&2023.9.28 #{Role A expressed dissatisfaction with the taste of school food, and Character B expressed understanding and offered to cook for her.};&2023.9.28 #{Role A expressed his love for hot pot and Japanese food, and asked about the food stores near the school. Character B recommended nearby hot pot and Japanese food stores, and suggested that they could try them together.};&2023.9.28 #{Role A invited Character B to dinner as a thank you, and asked Character B to choose between hot pot and Japanese food. Character B chose hot pot and expressed his expectation for it.};&2023.9.28 #{Role A asked Character B why he chose hot pot instead of Japanese food. Character B explained that hot pot was more suitable for sharing between two people, and he was more interested in the taste of hot pot.}", the short-term memory can be obtained as follows: {204} On September 28, 2023, Character A invited Character B to dinner as a thank you, and asked Character B to choose between hot pot and Japanese food. Character B chose hot pot and expressed his expectation for it. The "{204}" is the sequence stamp, and "September 28, 2023" is the timestamp.

[0104] Through the above method, the dialogue model can better understand the generation time of the short-term memory according to the timestamp and sequence stamp in the short-term memory. When there are memories with opposite contents on the same topic, the most recent memory can be found according to the timestamp and sequence stamp, thereby ensuring the accuracy of the dialogue model reasoning.

[0105] In one embodiment, the short-term memory library construction process of the dialogue model provided in the embodiment of the present application is as follows: Figure 3 As shown, the following steps may be specifically included:

[0106] Step 301, record the chat sentence pairs between the player character and the non-player character, and summarize them according to the format of "player character: dialogue sentence content; non-player character: dialogue reply sentence content".

[0107] Step 302: After the cumulative output of chat sentence pairs reaches N, the N sentence pairs are sent to the memory organization model.

[0108] Step 303: The memory organization model organizes the N sentence pairs, adds time stamps and sequence stamps, and forms short-term memories which are stored in the short-term memory library.

[0109] Step 304: After the memory organization model is organized, the sentence pairs in the chat that have been sent to the memory organization model are deleted.

[0110] Step 305: When the dialogue model receives the dialogue sentences input by the player character, it matches the short-term memory information from the short-term memory library, obtains the historical dialogue sentence pairs from the deleted chat sentence pairs, and concatenates the short-term memory information, the historical dialogue sentence pairs and the dialogue sentences input by the player character and sends them to the dialogue model.

[0111] Step 306: The dialogue model performs a comprehensive analysis based on the recent chat records and the formed short-term memory and outputs a dialogue reply statement.

[0112] In the embodiment of the present application, because the memory process is controlled by the program, stability is guaranteed, and the operations of memory summary, storage, deletion, etc. can effectively avoid a series of text overflow, long response time, and high cost caused by the continuous accumulation of text received by the dialogue model. In addition, for game developers, it greatly saves the cost of paying for the dialogue model according to the amount of text; for players, if this dialogue model is used to play the intelligent NPC, the NPC's response speed is faster and the quality is more stable. For example, in a game type of massively multiplayer online role-playing game (Massive Multiplayer Online Role-Playing Game, referred to as MMORPG), there are usually multiple intelligent NPCs in the area provided. In the process of dialogue with other NPCs or virtual characters controlled by players, the intelligent NPC can identify the identity of the interlocutor, the content of the dialogue, the style of dialogue and the strategy, and form short-term memory stored in the short-term memory bank, and then gradually form the NPC's own views and habits based on these memories and the preset persona or personality corresponding to the NPC. Past interaction and dialogue history data may affect the NPC's future dialogue style, behavior pattern, etc. As the game continues to operate, many NPCs may also develop their own social attributes such as interests, hobbies, and occupations. In the game, virtual forces such as gangs, societies, or sects will be formed between NPCs or between NPCs and virtual characters controlled by players, and then perform relevant behaviors that are in line with the characteristics of the organization, such as collection teams, transportation teams, mercenary teams, intelligence organization teams, bands, dance troupes, etc., becoming an ecological community composed of AI that can self-evolve in the entire game environment.

[0113] See also Figure 4 , Figure 4 This is a schematic diagram of the structure of a short-term memory library construction device for a dialogue model provided in an embodiment of the present application. Figure 4 As shown, the device 400 includes:

[0114] An acquisition module 401 is used to acquire chat sentence pairs between a player character and a non-player character in a dialogue scene, wherein each sentence pair in the chat sentence pairs includes a dialogue sentence of the player character and a dialogue reply sentence of a dialogue model of the non-player character, and the dialogue reply sentence of the non-player character is obtained by reasoning structured dialogue information through the dialogue model, and the structured dialogue information includes short-term memory information in the dialogue scene;

[0115] The memory arrangement module 402 is used to sequentially input chat sentence pairs into a preset memory arrangement model for memory arrangement in a cycle of N sentence pairs, and obtain short-term memory corresponding to each of the N sentence pairs, wherein N is a positive integer greater than or equal to 1, and the short-term memory is the text information obtained by arranging the role information and the dialogue content in the N sentence pairs, and the text volume of the short-term memory is less than the text volume of the N sentence pairs;

[0116] The construction module 403 is used to store the short-term memory into a preset memory bank, and construct a short-term memory bank, wherein the preset memory bank is a pre-set memory bank for storing short-term memory, and the preset memory bank stores historical short-term memory generated by the memory organization model, and the historical short-term memory is used to generate short-term memory information in structured dialogue information.

[0117] Furthermore, the acquisition module 401 includes:

[0118] The first acquisition submodule is used to acquire historical sentence pairs in the dialogue scene and target dialogue sentences input by the player character, wherein the historical sentence pairs are sentence pairs generated before the target dialogue sentences and have not yet been sorted by the memory sorting model;

[0119] A matching submodule, used to match short-term memory information matching the target dialogue sentence from a preset memory library, wherein the short-term memory information includes at least one short-term memory;

[0120] A first concatenation submodule, configured to concatenate the short-term memory information, the historical sentence pairs, and the target dialogue sentence according to a first preset format to obtain structured dialogue information;

[0121] An input submodule is used to input structured dialogue information and preset prompt text into the dialogue model for reasoning, and obtain a dialogue reply sentence corresponding to the target dialogue sentence, wherein the preset prompt text is a natural language, which is used to prompt the dialogue model to reason about the structured dialogue information according to the reasoning logic described by the natural language;

[0122] The second splicing submodule is used to splice the target dialogue sentence and the dialogue reply sentence corresponding to the target dialogue sentence according to a second preset format, and use the spliced ​​text as a chat sentence pair.

[0123] Furthermore, the matching submodule includes:

[0124] An acquisition unit, used to acquire a first word vector corresponding to the target dialogue sentence and a second word vector corresponding to each historical short-term memory in a preset memory bank;

[0125] A calculation unit, used to calculate the similarity between the first word vector and each second word vector respectively;

[0126] The matching unit is used to match at least one historical short-term memory with a similarity greater than a preset threshold from a preset memory library, and generate short-term memory information based on the at least one historical short-term memory.

[0127] Furthermore, the input submodule includes:

[0128] An input unit, used to input structured dialogue information and preset prompt text into the dialogue model, wherein the preset prompt text includes a first text for inferring the semantics of the dialogue sentence and a second text for analyzing the memory related to the semantics of the dialogue sentence;

[0129] The reasoning unit is used to use the first text prompt dialogue model to infer the semantics of the target dialogue sentence based on the historical sentences, and use the second text prompt dialogue model to analyze the relevant memory of the target dialogue sentence based on the short-term memory information to obtain the dialogue response sentence corresponding to the target dialogue sentence.

[0130] Furthermore, the device 400 further includes:

[0131] The deletion module is used to delete the sentence pairs input into the memory arrangement model, and update the historical sentence pairs input into the dialogue model when receiving new dialogue sentences input by the player character.

[0132] Furthermore, the device 400 further includes:

[0133] A matching module, used to match new short-term memory information matching the new dialogue sentence from the short-term memory library, wherein the new short-term memory information includes at least one short-term memory;

[0134] A splicing module, used for splicing the new short-term memory information, the updated historical sentence pairs and the new dialogue sentences according to a first preset format to obtain new structured dialogue information;

[0135] The input module is used to input new structured dialogue information and preset prompt text into the dialogue model for reasoning to obtain new dialogue response sentences.

[0136] Furthermore, the construction module 403 includes:

[0137] The second acquisition submodule is used to obtain the timestamp and sequence stamp corresponding to each short-term memory, wherein the timestamp is determined based on the generation time of the short-term memory, and the sequence stamp is determined based on the generation order of the short-term memory;

[0138] The construction submodule is used to store each short-term memory and the timestamp and sequence stamp corresponding to each short-term memory into a preset memory library according to a third preset format, so as to construct a short-term memory library.

[0139] It should be noted that the device 400 can implement the steps of the method for constructing a short-term memory bank of a dialogue model provided by any of the aforementioned method embodiments, and can achieve the same technical effects, which will not be described one by one here.

[0140] like Figure 5 As shown, the embodiment of the present application further provides an electronic device, including a processor 511, a communication interface 512, a memory 513 and a communication bus 514, wherein the processor 511, the communication interface 512, and the memory 513 communicate with each other through the communication bus 514.

[0141] Memory 513, used for storing computer programs;

[0142] In one embodiment of the present application, the processor 511 is used to execute the program stored in the memory 513 to implement the method for constructing a short-term memory bank of the dialogue model provided by any of the aforementioned method embodiments, including:

[0143] Obtaining chat sentence pairs between a player character and a non-player character in a dialogue scene, wherein each sentence pair in the chat sentence pairs includes a dialogue sentence of the player character and a dialogue reply sentence of a dialogue model of the non-player character, and the dialogue reply sentence of the non-player character is obtained by reasoning structured dialogue information through the dialogue model, and the structured dialogue information includes short-term memory information in the dialogue scene;

[0144] The chat sentence pairs are input into the preset memory arrangement model in sequence with N sentence pairs as a cycle to obtain the short-term memory corresponding to each N sentence pair, wherein N is a positive integer greater than or equal to 1, and the short-term memory is the text information obtained after arranging the role information and dialogue content in the N sentence pairs, and the text amount of the short-term memory is less than the text amount of the N sentence pairs;

[0145] The short-term memory is stored in a preset memory bank to construct a short-term memory bank, wherein the preset memory bank is a pre-set memory bank for storing short-term memory, and the preset memory bank stores historical short-term memory generated by a memory organization model, and the historical short-term memory is used to generate short-term memory information in structured dialogue information.

[0146] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for constructing a short-term memory bank of a dialogue model provided in any of the aforementioned method embodiments are implemented.

[0147] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0148] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0149] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0150] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for constructing a short-term memory bank of a dialogue model, characterized in that: The method comprises: Acquire chat sentence pairs between a player character and a non-player character in a dialogue scene, wherein each sentence pair in the chat sentence pairs includes a dialogue sentence of the player character and a dialogue reply sentence of the non-player character dialogue model, and the dialogue reply sentence of the non-player character is obtained by reasoning structured dialogue information through the dialogue model, and the structured dialogue information includes short-term memory information in the dialogue scene; Inputting the chat sentence pairs into a preset memory arrangement model in sequence with N sentence pairs as a cycle to carry out memory arrangement, and obtaining short-term memory corresponding to each of the N sentence pairs, wherein N is a positive integer greater than or equal to 1, and the short-term memory is text information obtained by arranging the role information and dialogue content in the N sentence pairs, and the text volume of the short-term memory is less than the text volume of the N sentence pairs; The short-term memory is stored in a preset memory bank to construct a short-term memory bank, wherein the preset memory bank is a pre-set memory bank for storing short-term memory, and the preset memory bank stores historical short-term memory generated by the memory organization model, and the historical short-term memory is used to generate short-term memory information in the structured dialogue information.

2. The method according to claim 1, characterized in that The acquiring of chat sentence pairs between a player character and a non-player character in a dialogue scene includes: Acquire a historical sentence pair in the dialogue scene and a target dialogue sentence input by the player character, wherein the historical sentence pair is a sentence pair generated before the target dialogue sentence and has not yet been sorted by the memory sorting model; Matching short-term memory information matching the target dialogue sentence from the preset memory library, wherein the short-term memory information includes at least one short-term memory; splicing the short-term memory information, the historical sentence pairs and the target dialogue sentence according to a first preset format to obtain the structured dialogue information; Inputting the structured dialogue information and the preset prompt text into the dialogue model for inference to obtain a dialogue reply sentence corresponding to the target dialogue sentence, wherein the preset prompt text is a natural language and is used to prompt the dialogue model to infer the structured dialogue information according to the inference logic described in the natural language; The target dialogue sentence and the dialogue reply sentence corresponding to the target dialogue sentence are spliced ​​according to a second preset format, and the spliced ​​text is used as the chat sentence pair.

3. The method according to claim 2, characterized in that The matching of the short-term memory information matching the target dialogue sentence from the preset memory library includes: Obtaining a first word vector corresponding to the target dialogue sentence and a second word vector corresponding to each historical short-term memory in the preset memory bank; Calculate the similarity between the first word vector and each of the second word vectors respectively; At least one historical short-term memory whose similarity is greater than a preset threshold is matched from the preset memory library, and the short-term memory information is generated based on the at least one historical short-term memory.

4. The method according to claim 2, characterized in that: The step of inputting the structured dialogue information and the preset prompt text into the dialogue model for inference to obtain a dialogue reply sentence corresponding to the target dialogue sentence includes: Inputting the structured dialogue information and the preset prompt text into the dialogue model, wherein the preset prompt text includes a first text for inferring the semantics of the dialogue sentence and a second text for analyzing the memory related to the semantics of the dialogue sentence; The first text is used to prompt the dialogue model to infer the semantics of the target dialogue sentence based on the historical sentences, and the second text is used to prompt the dialogue model to analyze the relevant memory of the target dialogue sentence based on the short-term memory information to obtain a dialogue response sentence corresponding to the target dialogue sentence.

5. The method according to claim 2, characterized in that: After inputting the chat sentence pairs into a preset memory arrangement model in a cycle of N sentence pairs to perform memory arrangement and obtaining the short-term memory corresponding to each of the N sentence pairs, the method further includes: The sentence pairs input into the memory organization model are deleted, and when a new dialogue sentence input from the player character is received, the historical sentence pairs input into the dialogue model are updated.

6. The method according to claim 5, characterized in that After the updating of the historical sentence pairs input into the dialogue model, the method further comprises: Matching new short-term memory information matching the new dialogue sentence from the short-term memory library, wherein the new short-term memory information includes at least one short-term memory; splicing the new short-term memory information, the updated historical sentence pair and the new dialogue sentence according to the first preset format to obtain new structured dialogue information; The new structured dialogue information and the preset prompt text are input into the dialogue model for reasoning to obtain a new dialogue response sentence.

7. The method according to claim 1, characterized in that The storing of the short-term memory into a preset memory bank to construct a short-term memory bank comprises: Obtaining a timestamp and a sequence stamp corresponding to each of the short-term memories, wherein the timestamp is determined based on the generation time of the short-term memories, and the sequence stamp is determined based on the generation order of the short-term memories; Each of the short-term memories and the timestamp and sequence stamp corresponding to each of the short-term memories are stored in the preset memory library according to a third preset format to construct the short-term memory library.

8. A short-term memory library construction device for a dialogue model, characterized in that: The device comprises: An acquisition module, used for acquiring chat sentence pairs between a player character and a non-player character in a dialogue scene, wherein each sentence pair in the chat sentence pairs includes a dialogue sentence of the player character and a dialogue reply sentence of the non-player character dialogue model, and the dialogue reply sentence of the non-player character is obtained by reasoning structured dialogue information through the dialogue model, and the structured dialogue information includes short-term memory information in the dialogue scene; A memory arrangement module, used for sequentially inputting the chat sentence pairs into a preset memory arrangement model for memory arrangement with N sentence pairs as a cycle, to obtain short-term memory corresponding to each of the N sentence pairs, wherein N is a positive integer greater than or equal to 1, the short-term memory is text information obtained after arranging the role information and dialogue content in the N sentence pairs, and the text volume of the short-term memory is less than the text volume of the N sentence pairs, and N is a positive integer greater than or equal to 1; A construction module is used to store the short-term memory into a preset memory bank to construct a short-term memory bank, wherein the preset memory bank is a pre-set memory bank for storing short-term memory, and the preset memory bank stores historical short-term memory generated by the memory organization model, and the historical short-term memory is used to generate short-term memory information in the structured dialogue information.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the steps of the method for constructing a short-term memory bank of a dialogue model as described in any one of claims 1 to 7 when executing a program stored in a memory.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for constructing a short-term memory bank of a dialogue model described in any one of claims 1 to 7 are implemented.

Citation Information

Cited By

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

    CN120045699A

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

    CN120045699B