Method and device for generating multi-round dialogue of chat robot and chat robot

By rewriting the multi-round dialogue model into a single-round dialogue model and rewriting the network transformation dialogue using context, the problem of multi-round dialogue chatbots generating meaningless replies is solved, and a higher response accuracy and interpretable rewriting process is achieved.

CN112231457BActive Publication Date: 2025-02-25BEIJING XUEZHITU NETWORK TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011117440.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-19
Publication Date
2025-02-25
Estimated Expiration
2040-10-19

AI Technical Summary

Technical Problem

Existing multi-round dialogue chatbots have unexplainable flaws when handling multi-round dialogue, resulting in the generation of meaningless responses, and the training model tends to generate universal meaningless responses, which cannot meet the needs.

Method used

Rewrite the multi-round dialogue model into a single-round dialogue model, use the context rewriting network to convert multiple-round dialogue into a single-round dialogue, and generate replies with higher response accuracy through keyword extraction and rewriting candidate sentences.

Benefits of technology

This enables the generation of higher responsiveness responses using a single-wheel framework in multiple round scenarios, simplifies the length of the conversation context, reduces work costs, and makes the rewrite process interpretable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112231457B_ABST
    Figure CN112231457B_ABST
Patent Text Reader

Abstract

The present application relates to a method, device and chat robot for generating multi-round conversations of a chat robot, wherein the method comprises: a conversation content acquisition step for acquiring a conversation text and filtering sensitive words in the conversation text; a keyword extraction step for extracting conversation keywords in the conversation text based on mutual information; a rewriting candidate sentence generation step for extracting adjacent words of the conversation keywords, wherein the adjacent words and the keywords form a key phrase, and the key phrase and the conversation tail sentence in the conversation text form a rewriting candidate sentence; a rewriting sentence generation step, wherein the rewriting candidate sentence is converted into a rewriting sentence through encoding and decoding through a context rewriting network and output; and a conversation generation step, wherein the rewriting sentence is input into a conversation model to obtain a conversation answer. Through the present application, a single-round framework is used in a multi-round scenario to achieve higher response accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of conversational robots, and in particular to a method and device for generating multi-round conversations of a chat robot, a chat robot, and a computer-readable storage medium. Background Art

[0002] Chatbots are computer programs that communicate through dialogue or text, and can simulate human dialogue and pass the Turing test. In chatbots, multi-round dialogues often have problems with cross-references and information omissions, and multi-round dialogue understanding has always been a very difficult problem.

[0003] At present, the modeling of single-round dialogue is relatively mature, and the model can often generate good responses. However, if the input is a multi-round dialogue, there are still relatively large challenges. Since there are often co-reference relationships and information missing in multi-round dialogues, the responses given by chatbots are often unsatisfactory. The existing multi-round dialogue chatbots mainly include retrieval-based chatbots and generation-based chatbots. Among them, the retrieval-based chatbots only consider the last sentence of multi-round dialogues in the early stage, ignoring the previous words, which is also called short text conversation (STC); while the recent retrieval-based chatbots use heuristic text rewriting methods to retrieve from large text indexes, add keywords to the last round of questions in multi-round dialogues, and redefine the context; the generation-based chatbots use historical information to encode the context of multi-round dialogues, and add different levels of attention mechanisms.

[0004] However, in the above-mentioned prior art, the retrieval-based chatbot uses a heuristic text rewriting method, which has the defect of being unexplainable and is not conducive to finding errors; among them, the text rewriting method requires manual annotation of data during the rewriting process, which increases labor costs. The problem of meaningless replies is often generated by the generated multi-round dialogue chatbot. For example, meaningless replies such as "I don't know" and "Me too". The generation of such meaningless replies is mainly because the proportion of such replies in the corpus is relatively high, which makes the trained model tend to generate more common meaningless replies. The above makes the existing model unable to meet the needs. Summary of the invention

[0005] The embodiments of the present application provide a method and device for generating multi-round conversations of a chat robot, a chat robot and a computer-readable storage medium, which rewrite the multi-round conversation model into a single-round conversation model, implement the use of a single-round framework in a multi-round scenario, and achieve higher response accuracy.

[0006] In a first aspect, an embodiment of the present application provides a method for generating a multi-round dialogue of a chat robot, comprising:

[0007] The conversation content acquisition step is used to acquire the conversation text and filter out sensitive words in the conversation text, filtering out sensitive words related to politics, superstition and cults, pornography, gambling, drugs, firearms and ammunition, satire and slander, etc. that may be contained in the conversation text, so as to avoid these sensitive words from causing adverse effects in the conversation content;

[0008] A keyword extraction step, for extracting conversation keywords in the conversation text based on mutual information;

[0009] A rewriting candidate sentence generating step is used to extract adjacent words of the dialogue keyword, wherein the adjacent words and the keyword form a key phrase, and the key phrase and the dialogue end sentence in the dialogue text form a rewriting candidate sentence;

[0010] A rewritten sentence generation step, in which the rewritten candidate sentence is converted into a rewritten sentence by encoding and decoding through a contextual rewriting network and outputted;

[0011] The dialogue generation step is to input the rewritten sentence into a dialogue model to obtain a dialogue answer.

[0012] Through the above steps, the multi-round dialogue is converted into a single-round dialogue model by using context rewriting. Only one reply needs to be generated according to the rewritten sentence. This simplifies and shortens the length of the dialogue context and achieves higher response accuracy. At the same time, no manual labeling is required, which reduces work costs.

[0013] In some embodiments, the rewriting candidate sentence generating step further comprises:

[0014] A key phrase extraction step, for extracting adjacent words of the conversation keyword, and combining the conversation keyword and its adjacent words to form a semantically complete key phrase;

[0015] The rewriting candidate sentence acquisition step is used to use an LSTM language model to insert the key phrase into the last sentence of the dialogue in the dialogue text to obtain multiple alternative rewriting candidate sentences, and select the multiple alternative rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.

[0016] In some embodiments, the rewritten sentence generation step further comprises:

[0017] A rewriting encoding step is used to encode the context information and the last sentence information in the rewriting candidate sentence using two encoders composed of a bidirectional GRU network, wherein the two encoders are used to learn the context information representation and the last sentence information representation respectively;

[0018] The rewriting decoding step is used to generate a rewritten sentence using a decoder composed of a GRU network, wherein the decoder is based on an attention mechanism and a copy mechanism, wherein the attention mechanism is used to obtain information from the context information and the end sentence information; and the copy mechanism is used to copy important words in the context information.

[0019] Based on the above steps, a text rewriting method using rules is implemented, making the rewriting process explainable.

[0020] In some embodiments, the method for generating multiple rounds of dialogues by the chat robot further includes:

[0021] A context rewriting network optimization step is used to adjust the network parameters of the context rewriting network using a reinforcement learning (RL) method.

[0022] In some embodiments, the reinforcement learning method further comprises:

[0023] Generate and rewrite multiple candidate sentences using a pre-trained model;

[0024] The maximized reward value is calculated, and the context rewriting network is optimized using the reward value reward.

[0025] Through the above steps, the embodiment of the present application establishes a direct connection between the context rewriting model and different tasks based on the reinforcement learning method, thereby solving the problem that the performance of the pre-trained model is limited by the errors and noise contained in the generated rewritten sentences, optimizing the parameters of the context rewriting model, and improving the accuracy of rewriting.

[0026] In some of the embodiments, the dialogue model is a Seq2Seq model based on an attention model. Seq2Seq is a variant of a recurrent neural network, including an encoder and a decoder. The encoder is used to encode an input sentence into a context variable C. During decoding, each output is decoded indiscriminately using the context variable C. The attention model is used to encode the encoder into different context variables C according to each time step of the sequence. The decoder is used to combine each different C for decoding output, thereby effectively improving the accuracy of the dialogue generation result.

[0027] In a second aspect, an embodiment of the present application provides a multi-round dialogue generation device, including:

[0028] A conversation content acquisition module, used to acquire the conversation text and filter sensitive words in the conversation text;

[0029] A keyword extraction module, used for extracting conversation keywords in the conversation text based on mutual information;

[0030] A rewriting candidate sentence generating module is used to extract adjacent words of the dialogue keyword, wherein the adjacent words and the keyword form a key phrase, and the key phrase and the dialogue ending sentence in the dialogue text form a rewriting candidate sentence;

[0031] A rewriting sentence generation module converts the rewriting candidate sentence into a rewriting sentence through encoding and decoding via a context rewriting network and outputs the rewriting sentence;

[0032] The dialogue generation module inputs the rewritten sentence into a dialogue model to obtain a dialogue answer.

[0033] Through the above device, multi-round conversations are converted into a single-round conversation model using context rewriting. Only one reply needs to be generated based on the rewritten sentence, which simplifies and shortens the length of the conversation context and achieves higher response accuracy. At the same time, no manual labeling is required, reducing work costs.

[0034] In some embodiments, the rewriting candidate sentence generation module further includes:

[0035] A key phrase extraction module, used to extract adjacent words of the conversation keyword, and combine the conversation keyword and its adjacent words to form a semantically complete key phrase;

[0036] The rewriting candidate sentence acquisition module is used to use an LSTM language model to insert the key phrase into the last sentence of the dialogue in the dialogue text to obtain multiple alternative rewriting candidate sentences, and select the multiple alternative rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.

[0037] In some embodiments, the rewriting sentence generation module further comprises:

[0038] A rewriting encoding module, used to encode the context information and the last sentence information in the rewriting candidate sentence using two encoders composed of a bidirectional GRU network, wherein the two encoders are used to learn the context information representation and the last sentence information representation respectively;

[0039] The rewriting decoding module is used to generate a rewritten sentence using a decoder composed of a GRU network, and the decoder is based on an attention mechanism and a copy mechanism. The attention mechanism is used to obtain information from the context information and the end sentence information; the copy mechanism is used to copy important words in the context information.

[0040] Based on the above structure, a text rewriting method using rules is implemented, making the rewriting process explainable.

[0041] In some embodiments, the multi-round dialogue generating device further includes:

[0042] A context rewriting network optimization module is used to adjust the network parameters of the context rewriting network using a reinforcement learning method.

[0043] In some embodiments, the reinforcement learning method further comprises:

[0044] Generate and rewrite multiple candidate sentences using a pre-trained model;

[0045] The maximized reward value is calculated, and the context rewriting network is optimized using the reward value reward.

[0046] Through the above steps, the embodiment of the present application establishes a direct connection between the context rewriting model and different tasks based on the reinforcement learning method, thereby solving the problem that the performance of the pre-trained model is limited by the errors and noise contained in the generated rewritten sentences, optimizing the parameters of the context rewriting model, and improving the accuracy of rewriting.

[0047] In some of the embodiments, the dialogue model is a Seq2Seq model based on an attention model, which effectively improves the accuracy of dialogue generation results.

[0048] In a third aspect, an embodiment of the present application provides a small talk robot, which responds based on the small talk robot multi-round dialogue generation method as described in the first aspect above.

[0049] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for generating multiple rounds of conversations of a small talk robot as described in the first aspect above.

[0050] Compared with the related art, the method, device, chat robot and computer-readable storage medium for generating multi-round conversations of a chat robot provided in the embodiments of the present application rewrite multi-round conversations into single-round conversations, and use the framework of single-round conversations to achieve conversation generation, thereby improving response accuracy; conversation keyword extraction is achieved based on mutual information, so that the rewriting process does not require manual data annotation; a text rewriting method based on the LSTM language model, reordering model and context rewriting network construction rules makes the rewriting process explainable; the embodiments of the present application also use reinforcement learning to continuously adjust the parameters of the rewriting network to improve the accuracy of rewriting.

[0051] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0053] Figure 1 It is a flowchart of a method for generating a multi-round conversation of a small talk robot according to an embodiment of the present application;

[0054] Figure 2 is another flowchart of the method for generating a multi-round conversation of a small talk robot according to an embodiment of the present application;

[0055] Figure 3 is a schematic block diagram of the structure of a multi-round dialogue generation device according to an embodiment of the present application;

[0056] Figure 4 is another schematic block diagram of the structure of the multi-round dialogue generation device according to an embodiment of the present application;

[0057] Figure 5 This is a schematic diagram of a rewriting sentence generation step in a method for generating a multi-round conversation of a small talk robot according to an embodiment of the present application;

[0058] Figure 6 It is a schematic diagram of the dialogue generation steps in the method for generating multiple rounds of dialogues of a small talk robot according to an embodiment of the present application. Description of the drawings:

[0060] 1. Multi-round dialogue generation device; 11. Dialogue content acquisition module; 12. Keyword extraction module; 13. Rewrite candidate sentence generation module; 14. Rewrite sentence generation module; 15. Dialogue generation module; 16. Context rewriting network optimization module; 131. Key phrase extraction module; 132. Rewrite candidate sentence acquisition module; 141. Rewrite encoding module; 142. Rewrite decoding module. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0062] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.

[0063] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0064] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0065] This embodiment provides a method for generating multiple rounds of dialogues of a chat robot. Figure 1 is a flow chart of a method for generating a multi-round conversation of a small talk robot according to an embodiment of the present application, with reference to Figure 1As shown, the process includes the following steps:

[0066] The conversation content acquisition step S1 is used to acquire the conversation text and filter out sensitive words in the conversation text, filtering out sensitive words related to politics, superstition and cults, pornography, gambling and drugs, firearms and ammunition, satire and slander, etc. that may be contained in the conversation text, so as to avoid these sensitive words from causing adverse effects in the conversation content;

[0067] The keyword extraction step S2 is used to extract the conversation keywords in the conversation text based on mutual information after preprocessing the conversation text such as word segmentation, word frequency statistics, and penalty for common words and low-frequency words;

[0068] The rewriting candidate sentence generation step S3 is used to extract the adjacent words of the dialogue keyword, the adjacent words and the keyword form a key phrase, and the key phrase and the dialogue end sentence in the dialogue text form a rewriting candidate sentence;

[0069] Rewrite sentence generation step S4, converting the rewrite candidate sentence into a rewrite sentence by encoding and decoding through a context rewriting network and outputting the rewrite sentence;

[0070] In the dialogue generation step S5, the rewritten sentence is input into a dialogue model to obtain a dialogue answer. Specifically, the rewritten sentence is input into the Seq2Seq dialogue model in the form of a question and answer. The Encoder of the Seq2Seq dialogue model encodes the input sentence into a context variable C. During decoding, each output is decoded indiscriminately using the context variable C. At the same time, based on the attention model, the encoder is encoded into a different context variable C according to each time step of the sequence, and then the Decoder of the Seq2Seq dialogue model is used to combine each different C for decoding output to complete the dialogue.

[0071] The rewriting candidate sentence generation step S3 further includes:

[0072] The key phrase extraction step S301 is used to extract the adjacent words of the conversation keyword and combine the conversation keyword and its adjacent words to form a semantically complete key phrase;

[0073] The rewriting candidate sentence acquisition step S302 is used to use an LSTM language model to insert the key phrase into the last sentence of the dialogue in the dialogue text to obtain multiple candidate rewriting sentences, and select the multiple candidate rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.

[0074] The rewritten sentence generation step S4 further comprises:

[0075] The rewriting encoding step S401 is used to use two encoders composed of a bidirectional GRU network to encode the context information and the end sentence information in the rewriting candidate sentence respectively, wherein the two encoders are used to learn the context information representation and the end sentence information representation respectively. The specific principle of step S401 is to use the bidirectional GRU network to connect the invisible states of the left and right GRU networks in the sentence in the positive time direction and the negative time direction, thereby merging the left and right words of the rewriting candidate sentence;

[0076] The rewriting decoding step S402 is used to generate a rewritten sentence using a decoder composed of a GRU network. The decoder is based on an attention mechanism and a copy mechanism. The attention mechanism is used to obtain information from context information and end sentence information; the copy mechanism is used to copy important words in the context information. Specifically, the Copy mode is used to directly copy important words from the context, and the Predict mode is used to predict the distribution of vocabulary.

[0077] Through the above steps, multi-round dialogues are converted into single-round dialogue models using context rewriting. Only one reply needs to be generated based on the rewritten sentence, which simplifies and shortens the length of the dialogue context and achieves higher response accuracy. At the same time, no manual annotation is required, reducing work costs. A text rewriting method using rules is implemented to make the rewriting process explainable. A dialogue model with an attention mechanism is used to further effectively improve the accuracy of dialogue generation results.

[0078] This application also provides a method for generating multiple rounds of conversations with a chat robot. Figure 2 is another flow chart of the method for generating a multi-round conversation of a small talk robot according to an embodiment of the present application, with reference to Figure 2 As shown, the steps in this process are the same as those in the above-mentioned method for generating multiple rounds of conversations with a small talk robot, and are not described in detail. The difference is that the process also includes the following steps:

[0079] The context rewriting network optimization step S6 is used to adjust the network parameters of the context rewriting network using a reinforcement learning method, wherein the reinforcement learning method further includes: using a pre-trained model to generate and rewrite multiple candidate sentences; calculating a maximized reward value, and using the reward value reward to optimize the context rewriting network.

[0080] Through the above steps, the embodiment of the present application establishes a direct connection between the context rewriting model and different tasks based on the reinforcement learning method, thereby solving the problem that the performance of the pre-trained model is limited by the errors and noise contained in the generated rewritten sentences, optimizing the parameters of the context rewriting model, and improving the accuracy of rewriting.

[0081] The rewriting process and the dialogue process of the embodiment of the present application are described and illustrated below through a preferred embodiment. Figure 5Schematic diagram of the rewriting sentence generation step in the method for generating a multi-round conversation of a small talk robot according to an embodiment of the present application, Figure 6 This is a schematic diagram of the dialogue generation steps in the method for generating a multi-round dialogue of a small talk robot according to an embodiment of the present application, with reference to Figure 5 , 6 As shown,

[0082] Step S302 uses an LSTM language model to insert the key phrase into the last sentence of the conversation in the conversation text, selects three sentences with higher model scores in the LSTM language model as alternative rewriting candidate sentences, and uses the answers in the conversation text to select multiple alternative rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.

[0083] The rewritten sentence is generated in step S4. First, in step S401, two encoders learn to rewrite the context representation "I hate cake" and the tail sentence representation "Why? It's delicious" in the candidate sentence. Then, in step S402, "hate cake" is copied and inserted into the tail sentence according to the attention mechanism and the copy mechanism. The output rewritten sentence is "Why do you hate cake? It's delicious.".

[0084] Step S5 inputs the rewritten sentence into the dialogue model Seq2Seq and outputs the dialogue result "bored."

[0085] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0086] This embodiment also provides a multi-round dialogue generation device, Figure 3 is a schematic block diagram of the structure of a multi-round dialogue generation device according to an embodiment of the present application. Figure 3 As shown, the multi-round dialogue generation device 1 includes: a dialogue content acquisition module 11, a keyword extraction module 12, a rewriting candidate sentence generation module 13, a rewriting sentence generation module 14, a dialogue generation module 15 and other structures. Those skilled in the art can understand that Figure 3 The multi-round dialogue generation device shown in the figure does not constitute a limitation on the multi-round dialogue generation device, and may include more or less structures than shown in the figure, or combine certain structures, or have different structural arrangements.

[0087] Combine the following Figure 3 The following is a detailed introduction to the various components of the user terminal:

[0088] A conversation content acquisition module 11 is used to acquire the conversation text and filter sensitive words in the conversation text;

[0089] A keyword extraction module 12, used to extract conversation keywords in the conversation text based on mutual information;

[0090] A rewriting candidate sentence generating module 13 is used to extract adjacent words of the dialogue keyword, the adjacent words and the keyword form a key phrase, and the key phrase and the dialogue end sentence in the dialogue text form a rewriting candidate sentence;

[0091] A rewriting sentence generation module 14 converts the rewriting candidate sentence into a rewriting sentence by encoding and decoding through a context rewriting network and outputs the rewriting sentence;

[0092] The dialogue generation module 15 inputs the rewritten sentence into a dialogue model to obtain a dialogue answer. Specifically, the dialogue model adopts a Seq2Seq model based on an attention model to effectively improve the accuracy of the dialogue generation result.

[0093] The rewriting candidate sentence generating module 13 further includes:

[0094] A key phrase extraction module 131 is used to extract adjacent words of a conversation keyword and combine the conversation keyword and its adjacent words to form a semantically complete key phrase;

[0095] The rewriting candidate sentence acquisition module 132 is used to use an LSTM language model to insert key phrases into the last sentence of the dialogue text to obtain multiple candidate rewriting sentences, and select the multiple candidate rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.

[0096] The rewriting sentence generation module 14 further comprises:

[0097] A rewriting encoding module 141 is used to encode the context information and the end sentence information in the rewriting candidate sentence using two encoders composed of a bidirectional GRU network, wherein the two encoders are used to learn the context information representation and the end sentence information representation respectively;

[0098] The rewriting decoding module 142 is used to generate the rewriting sentence by using a decoder composed of a GRU network, and the decoder is based on an attention mechanism and a copy mechanism. The attention mechanism is used to obtain information from context information and end sentence information; the copy mechanism is used to copy important words in the context information.

[0099] Through the above device, multi-round dialogues are converted into single-round dialogue models using context rewriting. Only one reply needs to be generated based on the rewritten sentence, which simplifies and shortens the length of the dialogue context and achieves higher response accuracy. At the same time, no manual annotation is required, reducing work costs. A text rewriting method using rules is implemented, making the rewriting process explainable.

[0100] This embodiment also provides a multi-round dialogue generation device, Figure 4is another structural schematic block diagram of the multi-round dialogue generation device according to an embodiment of the present application; Figure 4 As shown, the similarities between the device and the above-mentioned multi-round dialogue generation device are not repeated here, except that the device further includes:

[0101] A context rewriting network optimization module 16 is used to adjust the network parameters of the context rewriting network using a reinforcement learning method.

[0102] In some embodiments, the reinforcement learning method further comprises:

[0103] Generate and rewrite multiple candidate sentences using a pre-trained model;

[0104] Calculate the maximized reward value and use the reward value reward to optimize the context and rewrite the network.

[0105] Through the above steps, the embodiment of the present application establishes a direct connection between the context rewriting model and different tasks based on the reinforcement learning method, thereby solving the problem that the performance of the pre-trained model is limited by the errors and noise contained in the generated rewritten sentences, optimizing the parameters of the context rewriting model, and improving the accuracy of rewriting.

[0106] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0107] The embodiment of the present application also provides a chat robot, which responds based on any one of the chat robot multi-round dialogue generation methods in the above embodiments.

[0108] In addition, in combination with the method for generating a multi-round conversation of a small talk robot in the above embodiment, the embodiment of the present application can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the methods for generating a multi-round conversation of a small talk robot in the above embodiment is implemented.

[0109] To sum up, the method, device, chat robot and computer-readable storage medium for generating multi-round conversations of a chat robot provided in the embodiments of the present application rewrite multi-round conversations into single-round conversations, and use the framework of single-round conversations to achieve conversation generation, thereby improving response accuracy; conversation keyword extraction is achieved based on mutual information, so that the rewriting process does not require manual data annotation; a text rewriting method based on LSTM language model, reordering model and context rewriting network construction rules makes the rewriting process explainable; the embodiments of the present application also use reinforcement learning to continuously adjust the parameters of the context rewriting network to improve the accuracy of rewriting.

[0110] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0111] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for generating multi-round dialogues of a chat robot, characterized in that: include: A conversation content acquisition step, for acquiring the conversation text and filtering sensitive words in the conversation text; A keyword extraction step, for extracting conversation keywords in the conversation text based on mutual information; A rewriting candidate sentence generating step is used to extract adjacent words of the dialogue keyword, wherein the adjacent words and the keyword form a key phrase, and the key phrase and the dialogue end sentence in the dialogue text form a rewriting candidate sentence; A rewritten sentence generation step, in which the rewritten candidate sentence is converted into a rewritten sentence by encoding and decoding through a contextual rewriting network and outputted; a dialogue generation step, inputting the rewritten sentence into a dialogue model to obtain a dialogue answer; The rewriting sentence generation step further comprises: The rewriting encoding step is used to respectively encode the context information and the end sentence information in the rewriting candidate sentence using two encoders composed of a bidirectional GRU network, and the bidirectional GRU network is used to connect the invisible states of the left and right GRU networks in the sentence in a positive time direction and a negative time direction, so as to merge the left and right words of the rewriting candidate sentence; The rewriting decoding step is used to generate a rewritten sentence using a decoder composed of a GRU network. The decoder is based on an attention mechanism and a copy mechanism. The attention mechanism is used to obtain information from context information and sentence end information. The copy mechanism is used to copy important words in the context information. Specifically, the Copy mode is used to directly copy important words from the context, and the Predict mode is used to predict the distribution of vocabulary.

2. The method for generating a multi-round conversation of a small talk robot according to claim 1, characterized in that: The rewriting candidate sentence generation step further comprises: A key phrase extraction step, for extracting adjacent words of the conversation keyword, and combining the conversation keyword and its adjacent words to form a semantically complete key phrase; The rewriting candidate sentence acquisition step is used to use an LSTM language model to insert the key phrase into the last sentence of the dialogue in the dialogue text to obtain multiple alternative rewriting candidate sentences, and select the multiple alternative rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.

3. The method for generating a multi-round conversation of a small talk robot according to claim 1, characterized in that: Also includes: A context rewriting network optimization step is used to adjust the network parameters of the context rewriting network using a reinforcement learning method.

4. The method for generating multi-round dialogues of a small talk robot according to claim 1, characterized in that: The dialogue model is a Seq2Seq model based on an attention model.

5. A multi-round dialogue generation device, characterized in that: include: A conversation content acquisition module, used to acquire the conversation text and filter sensitive words in the conversation text; A keyword extraction module, used for extracting conversation keywords in the conversation text based on mutual information; A rewriting candidate sentence generating module is used to extract adjacent words of the dialogue keyword, wherein the adjacent words and the keyword form a key phrase, and the key phrase and the dialogue ending sentence in the dialogue text form a rewriting candidate sentence; A rewriting sentence generation module converts the rewriting candidate sentence into a rewriting sentence through encoding and decoding via a context rewriting network and outputs the rewriting sentence; A dialogue generation module, inputting the rewritten sentence into a dialogue model to obtain a dialogue answer; The rewriting sentence generation module further comprises: A rewriting encoding module, which is used to respectively encode the context information and the end sentence information in the rewriting candidate sentence using two encoders composed of a bidirectional GRU network, and connect the invisible states of the left and right GRU networks in the sentence in a positive time direction and a negative time direction using the bidirectional GRU network, so as to merge the left and right words of the rewriting candidate sentence; The rewriting decoding module is used to generate rewritten sentences using a decoder composed of a GRU network. The decoder is based on an attention mechanism and a copy mechanism. The attention mechanism is used to obtain information from context information and sentence end information. The copy mechanism is used to copy important words in the context information. Specifically, the Copy mode is used to directly copy important words from the context, and the Predict mode is used to predict the distribution of vocabulary.

6. The multi-round dialogue generation device according to claim 5, characterized in that: The rewriting candidate sentence generation module further includes: A key phrase extraction module, used to extract adjacent words of the conversation keyword, and combine the conversation keyword and its adjacent words to form a semantically complete key phrase; The rewriting candidate sentence acquisition module is used to use an LSTM language model to insert the key phrase into the last sentence of the dialogue in the dialogue text to obtain multiple alternative rewriting candidate sentences, and select the multiple alternative rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.

7. The multi-round dialogue generation device according to claim 5, characterized in that: Also includes: A context rewriting network optimization module is used to adjust the network parameters of the context rewriting network using a reinforcement learning method.

8. A chat robot, characterized in that: The small talk robot responds based on the small talk robot multi-round dialogue generation method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Method and device for conducting multi-round conversation based on topic keyword guidance

    CN109086329A

  • Multi-round dialogue reply selection method and system based on QA knowledge base reasoning

    CN110096567A