Conversation reply generation method and device, electronic equipment and storage medium
By using long-term memory modules and short-term memory modules in the natural language processing system, we generate dialogue reply information, which solves the problem of incoherence of dialogue and enhances the authenticity and user experience of dialogue.
Patent Information
- Application Number
- CN202411213069.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-06
AI Technical Summary
Natural language processing systems have problems with incoherence of dialogue in intelligent dialogue, such as inconsistent emotional expression or non-continuation of themes, which affects the naturalness and user experience of dialogue.
By introducing a long-term memory module and a short-term memory module into the dialogue system, user information is obtained and extracted from reflection information and dialogue segments, and dialogue reply information corresponding to the current dialogue input information is generated to continue the emotions and themes in the dialogue.
The realism and coherence of the conversation is achieved, the user experience is improved, and the dialogue system can maintain emotional and theme consistency in multiple rounds of conversations.
Smart Images

Figure CN119088938A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of natural language processing technology, and in particular, to a method, device, electronic device and storage medium for generating dialogue responses. Background Art
[0002] With the development of natural language processing technology, natural language processing systems are becoming more and more important in various application scenarios, such as online customer service, virtual assistants, game characters, etc. In intelligent dialogue, natural language processing systems may have problems with incoherent dialogue, such as inconsistent emotional expression or discontinuation of topics, which makes the dialogue seem intermittent and lacks fluency, affecting the naturalness of the dialogue and user experience. Summary of the invention
[0003] In view of this, in order to maintain the continuity of the conversation topic and emotion during the conversation process, make the conversation realistic and coherent, and effectively improve the user experience; the embodiments of the present invention provide a method, device, electronic device and storage medium for generating a conversation reply.
[0004] In a first aspect, an embodiment of the present invention provides a method for generating a dialogue reply, the method being applied to a dialogue system, the method comprising:
[0005] Responding to current dialogue input information of the target object during the dialogue process, acquiring user information of the target object;
[0006] Extracting self-reflective information from the long-term memory module of the dialogue system based on user information, and extracting a preset number of dialogue segments from the short-term memory module; wherein the self-reflective information includes a character portrait and expected dialogue information, the character portrait is the expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segments;
[0007] Based on the self-reflection information and a preset number of dialogue segments, dialogue reply information corresponding to the current dialogue input information is generated.
[0008] In one possible implementation, extracting self-reflection information from a long-term memory module of a dialogue system based on user information, and extracting a preset number of dialogue segments from a short-term memory module, includes:
[0009] Querying all self-reflection information matching the user information from the long-term memory module of the dialogue system; wherein the long-term memory module stores the correspondence between the self-reflection information and the user information, and the generation time of each self-reflection information;
[0010] Extracting the self-reflective information whose generation time is closest to the input time of the current input information from all the self-reflective information queried;
[0011] Querying all conversation segments matching the user information from the short-term memory module; wherein the short-term memory module stores the correspondence between the conversation segments and the user information, as well as the conversation time period of each conversation segment;
[0012] Arrange the conversation segments in order according to the distance between the conversation segments and the input time;
[0013] A preset number of dialogue segments are extracted from the plurality of dialogue segments in order.
[0014] In a possible implementation, before obtaining the user information of the target object in response to the current dialogue input information of the target object during the dialogue process, the method further includes:
[0015] Obtain the previous round of dialogue segments and character background information of the target object; wherein the character background information is used to characterize the personality characteristics of the target object;
[0016] Input the previous round of dialogue segments and character background information into the base model, and the base model outputs the corresponding self-reflection information;
[0017] Store the self-reflection information in the long-term memory module and store the previous round of dialogue segments in the short-term memory module.
[0018] In one possible implementation, storing the self-reflection information in a long-term memory module includes:
[0019] Extract the self-reflective information corresponding to the target object’s most recent conversation segment from the long-term memory module;
[0020] Compare the self-reflective information corresponding to the most recent conversation segment with the self-reflective information corresponding to the previous conversation segment;
[0021] When it is found that the self-reflection information corresponding to the most recent dialogue segment is inconsistent with the self-reflection information corresponding to the previous dialogue segment, the self-reflection information corresponding to the previous dialogue segment is stored in the long-term memory module.
[0022] In a possible implementation, generating dialogue reply information corresponding to current dialogue input information based on the self-reflection information and a preset number of dialogue segments includes:
[0023] The current dialogue input information, self-reflection information and a preset number of dialogue segments are input into the large language model in the dialogue system, and the dialogue response information corresponding to the current dialogue input information is output through the large language model.
[0024] In one possible implementation, the method further includes:
[0025] The current dialogue input information and dialogue response information are stored in the short-term memory module.
[0026] In one possible implementation, the method further includes:
[0027] Generate a dialogue reply text message or a dialogue reply voice message from the dialogue reply message;
[0028] The dialogue reply text information is sent to the text display module of the dialogue system for display, or the dialogue reply voice information is sent to the voice broadcast module of the dialogue system for broadcast.
[0029] In a second aspect, an embodiment of the present invention provides a device for generating a dialogue reply, the device being applied to a dialogue system, the device comprising:
[0030] An acquisition module, used for acquiring user information of the target object in response to current dialogue input information of the target object during the dialogue process;
[0031] An extraction module is used to extract self-reflective information from the long-term memory module of the dialogue system based on user information, and to extract a preset number of dialogue segments from the short-term memory module; wherein the self-reflective information includes a character portrait and expected dialogue information, the character portrait is the expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segments;
[0032] The generation module is used to generate dialogue response information corresponding to the current dialogue input information based on the current dialogue input information, the self-reflection information and a preset number of dialogue segments.
[0033] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a processor and a memory, wherein the processor is used to execute a program for generating conversation replies stored in the memory to implement the above-mentioned method for generating conversation replies.
[0034] In a fourth aspect, an embodiment of the present invention provides a storage medium, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above-mentioned method of generating dialogue replies.
[0035] The method, device, electronic device and storage medium for generating dialogue responses provided by the embodiments of the present invention include: obtaining user information of the target object in response to the current dialogue input information of the target object during the dialogue process; extracting self-reflection information from the long-term memory module of the dialogue system based on the user information, and extracting a preset number of dialogue segments from the short-term memory module; wherein the self-reflection information includes a character portrait and expected dialogue information, the character portrait is the expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue response information predicted based on the dialogue topic of the previous round of dialogue segments, and based on the self-reflection information and the preset number of dialogue segments, the dialogue response information corresponding to the current dialogue input information is generated. The above technical solution can enable the dialogue system to self-reflect according to the dialogue content after each dialogue ends, and continue the emotions and themes in the self-reflection information to the next round of dialogue, so that the dialogue has a sense of reality and coherence, and effectively improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A flowchart of an embodiment of a method for generating a dialogue reply provided by an embodiment of the present invention;
[0037] Figure 2 A flowchart of another method for generating a dialogue reply provided by an embodiment of the present invention;
[0038] Figure 3 A block diagram of an embodiment of a device for generating a dialogue reply provided by an embodiment of the present invention;
[0039] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] To facilitate understanding of the embodiments of the present invention, specific embodiments will be further explained below in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.
[0042] The embodiment of the present invention provides a method for generating dialogue responses, which is applied to a dialogue system, also known as a conversation agent, a computer system that simulates human conversation, that is, an intelligent agent, which is intended to form a coherent and smooth dialogue with humans. The communication methods mainly include voice / text / picture, and of course other methods such as gestures / tactile sensations can also be used. Figure 1 , Figure 1 A flowchart of an embodiment of a method for generating a dialogue reply provided in an embodiment of the present invention. Figure 1 The process shown may include the following steps:
[0043] Step 101, in response to the current dialogue input information of the target object during the dialogue process, obtaining the user information of the target object;
[0044] The target object may refer to any user who conducts an intelligent dialogue, and the user may be a real person or a virtual person such as a robot.
[0045] The above-mentioned current dialogue input information is not limited to information forms such as voice, text, and pictures. In actual application, the above-mentioned dialogue system provides a dialogue interface, which can be used for the target object to input the current dialogue input information, and to display the target object's current dialogue input information and dialogue reply information.
[0046] User information can be understood as the unique identification information of the target object. If the target object is a real person, the user information can be the user's ID number, user ID (Identity), the device ID or name of the device used, and other information. If the target object is a virtual person, the user information can be the device number or device name of the virtual person, and other information. User information is not limited here.
[0047] Step 102, extracting self-reflection information from the long-term memory module of the dialogue system based on the user information, and extracting a preset number of dialogue segments from the short-term memory module;
[0048] The above-mentioned self-reflection information includes character portraits and expected dialogue information, wherein the character portraits are expression information used to characterize the dialogue system's overall impression of the target object in the previous round of dialogue segments, and the expression information includes at least one of the following: emotional tendencies, personal qualities, personality, etc., that is, the dialogue system can specifically analyze and derive the emotional tendencies, personal qualities, personality and other aspects of the target object shown in the previous round of dialogue segments.
[0049] The dialogue segment includes the dialogue input information and dialogue reply information input by the target object. In this embodiment, the character portrait including emotional tendency and personality is used as an example for explanation. For example, the dialogue input information input by the target object in the previous round of dialogue segment is: xx, I am going to go out with my friends at 3 o'clock this afternoon. I feel very happy. You have to remind me. The dialogue reply information output by the dialogue system is: OK, I will remind you at that time. I wish you a happy time. Through the above dialogue system, the target object can be analyzed for character emotion, and the target object's emotional tendency is happy and the personality is cheerful.
[0050] If the target object inputs the dialogue input information in the previous round of dialogue segment: xx, I feel a little uncomfortable, remind me to take medicine at 3 pm. The dialogue reply information output by the dialogue system is: OK, I will remind you then, I wish you a speedy recovery. Through the above dialogue system, the target object can be analyzed for its emotional tendency, and the target object's emotional tendency is low and his personality is gloomy.
[0051] The expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segment; it can be understood as the predicted dialogue reply information that continues the dialogue topic of the previous round of dialogue segment. The dialogue input information input by the target object in the previous round of dialogue segment is: xx, I am going to go out with my friends at 3 o'clock this afternoon. I feel very happy. You have to remind me. The dialogue reply information output by the dialogue system is: OK, I will remind you then. I wish you a happy time. The expected dialogue information can be to remember to go out at 3 o'clock in the afternoon.
[0052] The dialogue input information input by the target object in the previous round of dialogue segment is: xx, I feel a little uncomfortable, remind me to take medicine at 3 pm. The dialogue response information output by the dialogue system is: OK, I will remind you then, I wish you a speedy recovery. The expected dialogue information can be: Remember to take medicine at 3 pm.
[0053] In this embodiment, the dialogue system draws on the behavior of humans when they are self-reflecting. After each dialogue, it performs self-reflection, analyzes the emotional expression of the target object during the dialogue, and draws a character portrait of the dialogue object. It anticipates the next dialogue and writes the self-reflection information into the long-term memory module of the dialogue system, so that this information becomes a reference and guide for future dialogue generation. With the assistance of the long-term memory module, it ensures that in multiple rounds of dialogue, the dialogue system can continue the emotions and topics of the previous dialogue, and improve the authenticity and coherence of the dialogue. The role of the above-mentioned long-term memory module is to be able to retain information for a long time, generally referring to an external knowledge base, and usually a vector database is used to store self-reflection information.
[0054] Extracting a preset number of dialogue segments from the short-term memory module can be understood as historical dialogue segments that are close to the input time of the current dialogue input information. The preset number of dialogue segments may continue the dialogue topic. Therefore, using the preset number of dialogue segments for generating dialogue reply information can maintain the consistency of the dialogue topic to a certain extent. The function of the short-term memory module is to temporarily store dialogue segments, and the stored dialogue segments can be cleared after a period of time.
[0055] The preset number can be one, two, three, etc., and can be set according to needs and is not limited here.
[0056] Step 103 : Generate dialogue reply information corresponding to the current dialogue input information based on the self-reflection information and a preset number of dialogue segments.
[0057] For ease of understanding, the dialogue input information input by the target object with a preset number of 1 dialogue segments is: xx, I am going to go out with my friends at 3 o'clock this afternoon. I feel very happy. You have to remind me. The dialogue reply information output by the dialogue system is: OK, I will remind you then. I wish you a happy time. For example, the emotional tendency of the character portrait in the self-reflection information is happy and the personality is cheerful. For example, if the expected dialogue information is to remember to go out at 3 o'clock in the afternoon, if the current dialogue input information input by the target object is: xx, what time is it now, the dialogue reply information output by the dialogue system is: I am here, I am here, the current time is 2:50 in the afternoon, you should go out and play with friends in 10 minutes, I wish you a happy time, I will wait for you to come back at home. This kind of light-hearted dialogue reply information can also bring joy to the target object, so that the dialogue can be consistent in both emotion and theme.
[0058] The dialogue input information input by the target object with a preset number of 1 dialogue segments is: xx, I feel a little uncomfortable, remind me to take medicine at 3 pm. The dialogue reply information output by the dialogue system is: OK, I will remind you then, I wish you a speedy recovery. The emotional tendency of the character portrait in the self-reflection information is low and the personality is gloomy. The expected dialogue information can be, for example, remember to take medicine at 3 pm. If the current dialogue input information input by the target object is: xx, what time is it now, the dialogue reply information output by the dialogue system is: The current time is 2:50 pm, you should take medicine in 10 minutes, I am so worried about you, I wish you a speedy recovery. This kind of dialogue reply information with a heavier tone can make the dialogue consistent in emotion and theme.
[0059] The method for generating a dialogue reply provided by an embodiment of the present invention includes: obtaining user information of the target object in response to the current dialogue input information of the target object during the dialogue process; extracting self-reflection information from the long-term memory module of the dialogue system based on the user information, and extracting a preset number of dialogue segments from the short-term memory module; wherein the self-reflection information includes a character portrait and expected dialogue information, the character portrait is the expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segments, and based on the self-reflection information and the preset number of dialogue segments, the dialogue reply information corresponding to the current dialogue input information is generated. The above technical solution can enable the dialogue system to self-reflect according to the dialogue content after each dialogue ends, and continue the emotions and themes in the self-reflection information to the next round of dialogue, so that the dialogue has a sense of reality and coherence, and effectively improves the user experience.
[0060] exist Figure 1 Based on Figure 2 , Figure 2 A flowchart of another embodiment of a method for generating a dialogue reply provided in an embodiment of the present invention. Figure 2 The process shown may include the following steps:
[0061] Step 201, obtaining the previous round of dialogue segments and character background information of the target object;
[0062] The character background information is used to characterize the personality characteristics of the target object. Specifically, the character background information matching the user information can be queried from the character background information database according to the user information of the target object. The character background information database stores the correspondence between the character background information and the user information.
[0063] The previous round of dialogue segments are also extracted from the short-term memory module, which is the same as the process of extracting a preset number of dialogue segments from the short-term memory module described below, which will be described in detail below and will not be repeated here.
[0064] Step 202, input the previous round of dialogue segments and character background information into the base model, and the base model outputs corresponding self-reflection information;
[0065] The base model can be understood as a large language model: Large Language Model, or LLM for short, is a computer model that can process and generate natural language. LLM can predict the next word or sentence by learning the statistical laws and semantic information of language data. As the input data set and parameter space continue to expand, the capabilities of LLM will also expand accordingly. It is used in a variety of application fields, such as machine learning, machine translation, speech recognition, image processing, etc., so it is called a multimodal large language model.
[0066] The previous round of dialogue segments and character background information are input into the base model, and the pre-trained base model can output the corresponding self-reflection information.
[0067] Step 203, storing the self-reflection information in the long-term memory module, and storing the previous round of dialogue segments in the short-term memory module;
[0068] The process from step 201 to step 203 is performed after the last round of dialogue is completed.
[0069] Step 204, in response to the current dialogue input information of the target object during the dialogue process, obtaining the user information of the target object;
[0070] Step 205, extracting self-reflection information from the long-term memory module of the dialogue system based on the user information, and extracting a preset number of dialogue segments from the short-term memory module;
[0071] Among them, the self-reflection information includes character portraits and expected dialogue information. The character portraits are expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the predicted response information for the next round of dialogue based on the dialogue topic of the previous round of dialogue segments.
[0072] The above step 205 can be specifically implemented through steps A1 to A5:
[0073] Step A1, querying all self-reflective information matching the user information from the long-term memory module of the dialogue system;
[0074] Among them, the long-term memory module stores the correspondence between self-reflection information and user information, as well as the generation time of each self-reflection information; the generation time is the time when the base large model outputs the self-reflection information, and the generation time is based on the system time.
[0075] According to the above description, the corresponding relationship between the self-reflection information and the user information can be obtained as shown in Table 1 below, wherein the user information is described by taking the user ID as an example, as shown in Table 1:
[0076] Table 1
[0077]
[0078] It should be noted that Table 1 only shows an example of the correspondence between the self-reflection information and the user information. The specific correspondence between the self-reflection information and the user information can be set according to actual needs and is not limited here.
[0079] If the user information is user ID1, it can be seen from Table 1 that there are two self-reflection information corresponding to user ID1, namely, the self-reflection information "The emotional tendency is happy, the personality is cheerful, remember to go out at 3 pm" generated at 2 pm on August 6, 2024, and the self-reflection information "The emotional tendency is depressed, the personality is gloomy, remember to take medicine and rest" generated at 10 am on August 6, 2024.
[0080] Step A2, extracting the self-reflective information whose generation time is closest to the input time of the current input information from all the self-reflective information queried;
[0081] It can be understood as extracting the most recently generated self-reflective information from multiple self-reflective information. Continuing with the previous example, the extracted self-reflective information corresponding to the target object is "emotional tendency is happy, personality is cheerful, remember to go out at 3 pm."
[0082] Step A3, querying all dialogue segments matching the user information from the short-term memory module;
[0083] The short-term memory module stores the corresponding relationship between the conversation segments and the user information, as well as the conversation time period of each conversation segment; similarly, the conversation time period is based on the system time.
[0084] According to the above description, the corresponding relationship between the conversation segments and the user information as shown in Table 2 below can be obtained, as shown in Table 2:
[0085] Table 2
[0086]
[0087] It should be noted that Table 2 only shows an example of the correspondence between the conversation segments and the user information. The specific correspondence between the conversation segments and the user information can be set according to actual needs and is not limited here.
[0088] If the user information is user ID1, it can be seen from Table 2 that there are two dialogue segments corresponding to user ID1, namely "xx, I am going out to play with friends at 3 o'clock this afternoon. I feel very happy. You have to remind me. OK, I will remind you then. I wish you have fun." and "xx, I feel a little uncomfortable. Remind me to take medicine at 11 o'clock in the morning. OK, I will remind you then. I wish you a speedy recovery.".
[0089] Step A4, arranging the conversation segments in order according to the distance between the conversation time segment and the input time;
[0090] Continuing with the previous example, if the input time of the current dialogue input information is 2:50 p.m. on August 6, 2024, the dialogue time period from 2:05:10 p.m. on August 6, 2024 to 2:05:12 p.m. on August 6, 2024 is closer to the input time than the dialogue time period from 10:00 a.m. on August 6, 2024 to 10:02 a.m. on August 6, 2024. The above two dialogue segments are sorted in chronological order.
[0091] Step A5: extracting a preset number of dialogue segments from the multiple dialogue segments in order.
[0092] If the preset number is 1, the conversation segment corresponding to the conversation time period from 2:05:10 pm on August 6, 2024 to 2:05:12 pm on August 6, 2024 is extracted; if the preset number is 2, both conversation segments queried above are extracted.
[0093] Step 206, input the current dialogue input information, the self-reflection information and a preset number of dialogue segments into a large language model in the dialogue system, and output dialogue response information corresponding to the current dialogue input information through the large language model.
[0094] The large language model here can be the same language model as the above-mentioned base large model, or it can be another language model, which is not limited here. In this embodiment, the large language model can be GPT (Generative Pre-trained Transformer)-3, GPT-4, PaLM (Scaling Language Modeling with Pathways), LLaMA (Large Language Model Meta AI), etc., which is not limited here.
[0095] The current dialogue input information, self-reflection information and a preset number of dialogue segments are input into the large language model in the dialogue system. The pre-trained large language model can output dialogue response information corresponding to the current dialogue input information.
[0096] In actual use, the dialogue reply information is converted into dialogue reply text information or dialogue reply voice information; the dialogue reply text information is sent to the text display module of the dialogue system for display, or the dialogue reply voice information is sent to the voice broadcast module of the dialogue system for broadcast. The text display module is the above-mentioned dialogue interface, and the dialogue reply information is specifically in text form or voice form according to the choice of the target object, which is not limited here.
[0097] In order to enable the next round of dialogue to continue the emotion and theme of the current round of dialogue, the current dialogue input information and dialogue response information can be stored in the short-term memory module, and the process from step 201 to step 202 is performed for the current round of dialogue segment to obtain the self-reflection information of the current round of dialogue segment, which is used for the next round of dialogue generation to ensure the coherence, emotional consistency and theme continuity of the dialogue.
[0098] The embodiment of the present invention provides a device for generating a dialogue reply, which is applied to a dialogue system. Figure 3 , is a block diagram of an embodiment of a device for generating a dialogue reply provided by an embodiment of the present invention. Figure 3 As shown, the device comprises:
[0099] An acquisition module 301 is used to acquire user information of a target object in response to current dialogue input information of the target object during a dialogue process;
[0100] Extraction module 302, used to extract self-reflection information from the long-term memory module of the dialogue system based on user information, and to extract a preset number of dialogue segments from the short-term memory module; wherein the self-reflection information includes character portrait and expected dialogue information, the character portrait is the expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segments;
[0101] The generation module 303 is used to generate dialogue reply information corresponding to the current dialogue input information based on the current dialogue input information, the self-reflection information and a preset number of dialogue segments.
[0102] The device for generating a dialogue reply provided by an embodiment of the present invention includes, in response to the current dialogue input information of the target object during the dialogue process, obtaining the user information of the target object; extracting self-reflection information from the long-term memory module of the dialogue system based on the user information, and extracting a preset number of dialogue segments from the short-term memory module; wherein the self-reflection information includes a character portrait and expected dialogue information, the character portrait is the expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segments, and based on the self-reflection information and the preset number of dialogue segments, the dialogue reply information corresponding to the current dialogue input information is generated. The above technical solution can enable the dialogue system to self-reflect according to the dialogue content after each dialogue ends, and continue the emotions and themes in the self-reflection information to the next round of dialogue, so that the dialogue has a sense of reality and coherence, and effectively improves the user experience.
[0103] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, Figure 4The electronic device 500 shown includes: at least one processor 501, a memory 502, at least one network interface 504 and other user interfaces 503. The various components in the electronic device 500 are coupled together via a bus system 505. It is understood that the bus system 505 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 505 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 505 is not shown in FIG. Figure 4 Various buses are labeled as bus system 505 .
[0104] The user interface 503 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).
[0105] It can be understood that the memory 502 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DRRAM). The memory 502 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0106] In some implementations, the memory 502 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 5021 and an application program 5022 .
[0107] The operating system 5021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 5022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present invention can be included in the application 5022.
[0108] In the embodiment of the present invention, by calling the program or instruction stored in the memory 502, specifically, the program or instruction stored in the application 5022, the processor 501 is used to execute the method steps provided by each method embodiment, for example, including:
[0109] Responding to current dialogue input information of the target object during the dialogue process, acquiring user information of the target object;
[0110] Extracting self-reflective information from the long-term memory module of the dialogue system based on user information, and extracting a preset number of dialogue segments from the short-term memory module; wherein the self-reflective information includes a character portrait and expected dialogue information, the character portrait is the expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segments;
[0111] Based on the self-reflection information and a preset number of dialogue segments, dialogue reply information corresponding to the current dialogue input information is generated.
[0112] In one possible implementation, extracting self-reflection information from a long-term memory module of a dialogue system based on user information, and extracting a preset number of dialogue segments from a short-term memory module, includes:
[0113] Querying all self-reflection information matching the user information from the long-term memory module of the dialogue system; wherein the long-term memory module stores the correspondence between the self-reflection information and the user information, and the generation time of each self-reflection information;
[0114] Extracting the self-reflective information whose generation time is closest to the input time of the current input information from all the self-reflective information queried;
[0115] Querying all conversation segments matching the user information from the short-term memory module; wherein the short-term memory module stores the correspondence between the conversation segments and the user information, as well as the conversation time period of each conversation segment;
[0116] Arrange the conversation segments in order according to the distance between the conversation segments and the input time;
[0117] A preset number of dialogue segments are extracted from the plurality of dialogue segments in order.
[0118] In a possible implementation, before obtaining the user information of the target object in response to the current dialogue input information of the target object during the dialogue process, the method further includes:
[0119] Obtain the previous round of dialogue segments and character background information of the target object; wherein the character background information is used to characterize the personality characteristics of the target object;
[0120] Input the previous round of dialogue segments and character background information into the base model, and the base model outputs the corresponding self-reflection information;
[0121] Store the self-reflection information in the long-term memory module and store the previous round of dialogue segments in the short-term memory module.
[0122] In one possible implementation, storing the self-reflection information in a long-term memory module includes:
[0123] Extract the self-reflective information corresponding to the target object’s most recent conversation segment from the long-term memory module;
[0124] Compare the self-reflective information corresponding to the most recent conversation segment with the self-reflective information corresponding to the previous conversation segment;
[0125] When it is found that the self-reflection information corresponding to the most recent dialogue segment is inconsistent with the self-reflection information corresponding to the previous dialogue segment, the self-reflection information corresponding to the previous dialogue segment is stored in the long-term memory module.
[0126] In a possible implementation, generating dialogue reply information corresponding to current dialogue input information based on the self-reflection information and a preset number of dialogue segments includes:
[0127] The current dialogue input information, self-reflection information and a preset number of dialogue segments are input into the large language model in the dialogue system, and the dialogue response information corresponding to the current dialogue input information is output through the large language model.
[0128] In one possible implementation, the method further includes:
[0129] The current dialogue input information and dialogue response information are stored in the short-term memory module.
[0130] In one possible implementation, the method further includes:
[0131] Generate a dialogue reply text message or a dialogue reply voice message from the dialogue reply message;
[0132] The dialogue reply text information is sent to the text display module of the dialogue system for display, or the dialogue reply voice information is sent to the voice broadcast module of the dialogue system for broadcast.
[0133] The method disclosed in the above embodiment of the present invention can be applied to the processor 501, or implemented by the processor 501. The processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 501 or the instruction in the form of software. The above processor 501 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 502, and the processor 501 reads the information in the memory 502 and completes the steps of the above method in combination with its hardware.
[0134] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0135] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0136] The electronic device provided in this embodiment may be Figure 4 The electronic device shown in FIG. 1 may perform the following steps: Figure 1-2 All steps of the method for generating dialogue responses in , thereby achieving Figure 1-2 For details, please refer to the technical effect of the method for generating dialogue replies shown in Figure 1-2 For the sake of brevity, the relevant description is not repeated here.
[0137] The embodiment of the present invention also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.
[0138] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned method of generating dialogue replies can be implemented.
[0139] The processor is used to execute the program for generating a dialogue reply stored in the memory to implement the steps of the following method for generating a dialogue reply:
[0140] Responding to current dialogue input information of the target object during the dialogue process, acquiring user information of the target object;
[0141] Extracting self-reflective information from the long-term memory module of the dialogue system based on user information, and extracting a preset number of dialogue segments from the short-term memory module; wherein the self-reflective information includes a character portrait and expected dialogue information, the character portrait is the expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segments;
[0142] Based on the self-reflection information and a preset number of dialogue segments, dialogue reply information corresponding to the current dialogue input information is generated.
[0143] In one possible implementation, extracting self-reflection information from a long-term memory module of a dialogue system based on user information, and extracting a preset number of dialogue segments from a short-term memory module, includes:
[0144] Querying all self-reflection information matching the user information from the long-term memory module of the dialogue system; wherein the long-term memory module stores the correspondence between the self-reflection information and the user information, and the generation time of each self-reflection information;
[0145] Extracting the self-reflective information whose generation time is closest to the input time of the current input information from all the self-reflective information queried;
[0146] Querying all conversation segments matching the user information from the short-term memory module; wherein the short-term memory module stores the correspondence between the conversation segments and the user information, as well as the conversation time period of each conversation segment;
[0147] Arrange the conversation segments in order according to the distance between the conversation segments and the input time;
[0148] A preset number of dialogue segments are extracted from the plurality of dialogue segments in order.
[0149] In a possible implementation, before obtaining the user information of the target object in response to the current dialogue input information of the target object during the dialogue process, the method further includes:
[0150] Obtain the previous round of dialogue segments and character background information of the target object; wherein the character background information is used to characterize the personality characteristics of the target object;
[0151] Input the previous round of dialogue segments and character background information into the base model, and the base model outputs the corresponding self-reflection information;
[0152] Store the self-reflection information in the long-term memory module and store the previous round of dialogue segments in the short-term memory module.
[0153] In one possible implementation, storing the self-reflection information in a long-term memory module includes:
[0154] Extract the self-reflective information corresponding to the target object’s most recent conversation segment from the long-term memory module;
[0155] Compare the self-reflective information corresponding to the most recent conversation segment with the self-reflective information corresponding to the previous conversation segment;
[0156] When it is found that the self-reflection information corresponding to the most recent dialogue segment is inconsistent with the self-reflection information corresponding to the previous dialogue segment, the self-reflection information corresponding to the previous dialogue segment is stored in the long-term memory module.
[0157] In a possible implementation, generating dialogue reply information corresponding to current dialogue input information based on the self-reflection information and a preset number of dialogue segments includes:
[0158] The current dialogue input information, self-reflection information and a preset number of dialogue segments are input into the large language model in the dialogue system, and the dialogue response information corresponding to the current dialogue input information is output through the large language model.
[0159] In one possible implementation, the method further includes:
[0160] The current dialogue input information and dialogue response information are stored in the short-term memory module.
[0161] In one possible implementation, the method further includes:
[0162] Generate a dialogue reply text message or a dialogue reply voice message from the dialogue reply message;
[0163] The dialogue reply text information is sent to the text display module of the dialogue system for display, or the dialogue reply voice information is sent to the voice broadcast module of the dialogue system for broadcast.
[0164] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0165] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0166] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for generating a dialogue reply, characterized in that: The method is applied to a dialogue system, and the method comprises: In response to current dialogue input information of the target object during the dialogue process, acquiring user information of the target object; Extracting self-reflection information from the long-term memory module of the dialogue system based on the user information, and extracting a preset number of dialogue segments from the short-term memory module; wherein the self-reflection information includes a character portrait and expected dialogue information, the character portrait is expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information is the next round of dialogue reply information predicted based on the dialogue topic of the previous round of dialogue segments; Based on the self-reflection information and a preset number of the dialogue segments, dialogue reply information corresponding to the current dialogue input information is generated.
2. The method according to claim 1, characterized in that The extracting of self-reflection information from the long-term memory module of the dialogue system based on the user information, and extracting a preset number of dialogue segments from the short-term memory module, comprises: Querying all self-reflection information matching the user information from the long-term memory module of the dialogue system; wherein the long-term memory module stores the correspondence between the self-reflection information and the user information, and the generation time of each of the self-reflection information; Extracting the self-reflective information whose generation time is closest to the input time of the current input information from all the self-reflective information queried; Querying all the conversation segments matching the user information from the short-term memory module; wherein the short-term memory module stores the correspondence between the conversation segments and the user information, as well as the conversation time period of each of the conversation segments; Arranging the conversation segments in order according to the distance between the conversation time segment and the input time; A preset number of dialogue segments are extracted from the plurality of dialogue segments in order.
3. The method according to claim 1, characterized in that Before acquiring the user information of the target object in response to the current dialogue input information of the target object during the dialogue process, the method further includes: Acquire the previous round of dialogue segments and character background information of the target object; wherein the character background information is used to characterize the personality characteristics of the target object; Inputting the previous round of dialogue segments and the character background information into the base large model, and the base large model outputs corresponding self-reflection information; The self-reflection information is stored in the long-term memory module, and the last round of dialogue segment is stored in the short-term memory module.
4. The method according to claim 3, characterized in that The storing the self-reflection information into the long-term memory module comprises: Extracting the self-reflection information corresponding to the most recent conversation segment of the target object from the long-term memory module; Compare the self-reflection information corresponding to the most recent conversation segment with the self-reflection information corresponding to the previous conversation segment; When it is found that the self-reflection information corresponding to the most recent conversation segment is inconsistent with the self-reflection information corresponding to the previous conversation segment, the self-reflection information corresponding to the previous conversation segment is stored in the long-term memory module.
5. The method according to claim 1, characterized in that The step of generating dialogue reply information corresponding to the current dialogue input information based on the self-reflection information and a preset number of the dialogue segments includes: The current dialogue input information, the self-reflection information and a preset number of the dialogue segments are input into a large language model in the dialogue system, and dialogue response information corresponding to the current dialogue input information is output through the large language model.
6. The method according to claim 1, characterized in that The method further comprises: The current dialogue input information and the dialogue reply information are stored in the short-term memory module.
7. The method according to claim 1, characterized in that The method further comprises: Generating a dialogue reply text message or a dialogue reply voice message from the dialogue reply information; The dialogue reply text information is sent to the text display module of the dialogue system for display, or the dialogue reply voice information is sent to the voice broadcast module of the dialogue system for broadcast.
8. A device for generating a dialogue reply, characterized in that: The device is applied to a dialogue system, and comprises: An acquisition module, configured to acquire user information of the target object in response to current dialogue input information of the target object during the dialogue process; an extraction module, configured to extract self-reflection information from the long-term memory module of the dialogue system based on the user information, and to extract a preset number of dialogue segments from the short-term memory module; wherein the self-reflection information includes a character portrait and expected dialogue information, the character portrait being expression information used to characterize the overall impression of the dialogue system on the target object in the previous round of dialogue segments, and the expected dialogue information being predicted reply information for the next round of dialogue based on the dialogue topic of the previous round of dialogue segments; A generation module is used to generate dialogue reply information corresponding to the current dialogue input information based on the current dialogue input information, the self-reflection information and a preset number of the dialogue segments.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a program for generating a dialogue reply stored in the memory to implement the method for generating a dialogue reply according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method for generating a dialogue reply according to any one of claims 1 to 7.
Citation Information
Patent Citations
Conversation generation method and device based on artificial intelligence, equipment and storage medium
CN114756667A
Chat robot and dialogue method based on chat robot
CN117390136A
A separator for a litium secondary battery and a lithium secondary battery comprising the same
KR102781359B1
