CN112231457A - Multi-turn dialogue generation method and device for chatting robot and chatting robot - Google Patents

Multi-turn dialogue generation method and device for chatting robot and chatting robot Download PDF

Info

Publication number
CN112231457A
CN112231457A CN202011117440.7A CN202011117440A CN112231457A CN 112231457 A CN112231457 A CN 112231457A CN 202011117440 A CN202011117440 A CN 202011117440A CN 112231457 A CN112231457 A CN 112231457A
Authority
CN
China
Prior art keywords
sentence
rewriting
conversation
candidate
rewritten
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011117440.7A
Other languages
Chinese (zh)
Inventor
陈倩倩
景艳山
蔡怡蕾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Minglue Zhaohui Technology Co Ltd
Original Assignee
Beijing Minglue Zhaohui Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Minglue Zhaohui Technology Co Ltd filed Critical Beijing Minglue Zhaohui Technology Co Ltd
Priority to CN202011117440.7A priority Critical patent/CN112231457A/en
Publication of CN112231457A publication Critical patent/CN112231457A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/335Filtering based on additional data, e.g. user or group profiles
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Machine Translation (AREA)

Abstract

The application relates to a chatting robot multi-turn dialog generation method and device and a chatting robot, wherein the chatting robot multi-turn dialog generation method comprises the following steps: a conversation content acquisition step, which is used for acquiring a conversation text and filtering sensitive words in the conversation text; a keyword extraction step, which is used for extracting the conversation keywords in the conversation text based on mutual information; a rewriting candidate sentence generating step, configured to extract adjacent words of the dialog keywords, where the adjacent words and the keywords constitute a key phrase, and the key phrase and a dialog tail sentence in the dialog text constitute a rewriting candidate sentence; a rewritten sentence generating step of converting the rewritten candidate sentence into a rewritten sentence through encoding and decoding by a context rewriting network and outputting the rewritten sentence; and a dialogue generating step of inputting the rewritten sentence into a dialogue model to obtain a dialogue answer. Through the application, the single-wheel frame is used in a multi-wheel scene, and higher response precision is realized.

Description

Multi-turn dialogue generation method and device for chatting robot and chatting robot
Technical Field
The present application relates to the field of session robots, and in particular, to a method and an apparatus for generating a multi-turn session of a chat robot, and a computer-readable storage medium.
Background
Chat robots (chatterbots) are computer programs that talk over conversations or text, and can simulate human conversations and pass turing tests. In the chat robot, the problems of front-back cross reference and information omission often occur in multiple rounds of conversations, and the understanding of the multiple rounds of conversations is always a very difficult problem.
At present, the modeling of a single round of conversation is relatively mature, the model can often generate better replies, however, if the input is a plurality of rounds of conversation, the challenge is still greater, and the replies given by the chat robot are often unsatisfactory due to the common reference relationship and the missing information phenomenon in the plurality of rounds of conversation. Existing multi-turn conversation chat robots are mainly based on a retrieval chat robot and a generated chat robot, wherein the retrieval-based chat robot only considers the last sentence and ignores the previous words for the multi-turn conversation processing in the early period, which is also called Short Text Conversation (STC); the chat robot based on retrieval recently uses a heuristic text rewriting method to retrieve from a large text index, adds keywords in the last question sentence of a plurality of rounds of conversations and redefines the context; the generated chat robot encodes historical information for multiple rounds of conversations to represent context, plus different levels of attention mechanisms.
However, in the above prior art, the chat robot based on search uses a heuristic text rewriting method, which has the defect of inexplicability and is not favorable for finding errors; in the text rewriting method, data needs to be manually marked in the rewriting process, so that the labor cost is increased. Chat robots often generate problems of meaningless replies based on the generated rounds of conversations. For example, "i don't know", "i is also" and so on. The meaningless response is generated mainly because the proportion of the response in the corpus is high, so that the trained model tends to generate the more general meaningless response. Above, the existing model cannot meet the requirements.
Disclosure of Invention
The embodiment of the application provides a chatting robot multi-turn dialogue generation method and device, a chatting robot and a computer readable storage medium, a multi-turn dialogue model is rewritten into a single-turn dialogue model, a single-turn frame is used in a multi-turn scene, and higher response accuracy is achieved.
In a first aspect, an embodiment of the present application provides a method for generating a multi-turn dialogue of a chat robot, including:
a dialogue content acquisition step, which is used for acquiring dialogue texts and filtering sensitive words in the dialogue texts, and filtering the sensitive words possibly contained in the dialogue texts, such as politics, evil and faith, yellow gambling poison, gun ammunition, sarcastism and the like, so as to avoid adverse effects of the sensitive words in the dialogue contents;
a keyword extraction step, which is used for extracting the conversation keywords in the conversation text based on mutual information;
a rewriting candidate sentence generating step, configured to extract adjacent words of the dialog keywords, where the adjacent words and the keywords constitute a key phrase, and the key phrase and a dialog tail sentence in the dialog text constitute a rewriting candidate sentence;
a rewritten sentence generating step of converting the rewritten candidate sentence into a rewritten sentence through encoding and decoding by a context rewriting network and outputting the rewritten sentence;
and a dialogue generating step of inputting the rewritten sentence into a dialogue model to obtain a dialogue answer.
Through the steps, the multi-turn conversation is rewritten into the single-turn conversation model by using the context, only one reply is generated according to the rewritten sentence, the length of the conversation context is simplified and shortened, higher response precision is realized, meanwhile, manual marking is not needed, and the working cost is reduced.
In some embodiments, the candidate sentence rewriting generation step further includes:
a key phrase extraction step, which is used for extracting adjacent words of the conversation keywords and combining the conversation keywords and the adjacent words thereof to form a key phrase with complete semantics;
and a rewriting candidate sentence acquisition step, which is used for inserting the key phrase into the dialog tail sentence in the dialog text by using an LSTM language model to obtain a plurality of candidate rewriting candidate sentences, and selecting the candidate rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.
In some of these embodiments, the rewritten sentence generating step further comprises:
a rewriting encoding step, which is used for encoding the context information and the tail sentence information in the rewriting candidate sentence by adopting two encoders consisting of bidirectional GRU networks, wherein the two encoders are respectively used for learning the representation of the context information and the representation of the tail sentence information;
a rewrite decoding step for generating a rewrite sentence by using a decoder composed of a GRU network, the decoder being based on an Attention Mechanism (Attention Mechanism) for acquiring information from the context information and the tail sentence information and a Copy Mechanism (Copy Mechanism); the replication mechanism is used to replicate important words in the context information.
Based on the above steps, a text rewrite method using rules is implemented so that the rewrite process is interpretable.
In some embodiments, the chat-robot multi-turn dialog generation method further includes:
a context rewriting network optimization step, configured to adjust network parameters of the context rewriting network by using a Reinforcement Learning method (RL).
In some embodiments, the reinforcement learning method further comprises:
generating and rewriting a plurality of candidate sentences by using a pre-trained model;
the maximized reward value is calculated, and the context rewrite network is optimized by using the reward value reward.
Through the steps, the embodiment of the application establishes direct connection between the context rewriting model and different tasks based on the reinforcement learning method, so that the problem that the performance of the pre-trained model is limited due to inclusion errors and noise of the generated rewriting sentences is solved, the parameters of the context rewriting model are optimized, and the rewriting accuracy is improved.
In some embodiments, the dialog model is a Seq2Seq model based on an attention model, the Seq2Seq is a variation of a recurrent neural network, and includes an Encoder (Encoder) and a Decoder (Decoder), wherein the Encoder is used for encoding an input sentence into a context variable C, each output is decoded by using the context variable C without distinction, the attention model is used for encoding the Encoder into a different context variable C according to each time step of a sequence, and the Decoder is used for decoding the output by combining each different C, so that the accuracy of a dialog generation result is effectively improved.
In a second aspect, an embodiment of the present application provides a multi-turn dialog generation apparatus, including:
the conversation content acquisition module is used for acquiring a conversation text and filtering sensitive words in the conversation text;
the keyword extraction module is used for extracting the conversation keywords in the conversation text based on mutual information;
the rewriting candidate sentence generating module is used for extracting adjacent words of the conversation keywords, forming key phrases with the adjacent words and the keywords, and forming the key phrases and the conversation tail sentences in the conversation texts into rewriting candidate sentences;
a rewritten sentence generating module for converting the rewritten candidate sentence into a rewritten sentence through encoding and decoding by a context rewriting network and outputting the rewritten sentence;
and the dialogue generating module is used for inputting the rewritten sentence into a dialogue model to obtain a dialogue answer.
By the device, multiple rounds of conversations are rewritten into a single round of conversation model by context, only one reply is generated according to the rewritten sentence, the length of the conversation context is simplified and shortened, higher response precision is realized, manual marking is not needed, and the working cost is reduced.
In some embodiments, the rewrite candidate sentence generation module further includes:
the key phrase extraction module is used for extracting adjacent words of the conversation keywords and combining the conversation keywords and the adjacent words to form a key phrase with complete semantics;
and the rewriting candidate sentence acquisition module is used for inserting the key phrases into the conversation tail sentences in the conversation text by utilizing an LSTM language model to obtain a plurality of candidate rewriting candidate sentences, and selecting the candidate rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.
In some embodiments, the rewritten sentence generating module further comprises:
the rewrite coding module is used for coding the context information and the tail sentence information in the rewrite candidate sentences by adopting two coders consisting of bidirectional GRU networks, wherein the two coders are respectively used for learning the representation of the context information and the representation of the tail sentence information;
and the rewriting decoding module is used for generating a rewriting sentence by adopting a decoder consisting of a GRU network, and the decoder is based on an attention mechanism and a replication mechanism. The attention mechanism is used for acquiring information from the context information and the tail sentence information; the replication mechanism is used to replicate important words in the context information.
Based on the above structure, a text rewriting method using rules is realized so that the rewriting process can be interpreted.
In some embodiments, the multi-turn dialog generating device further comprises:
and the context rewriting network optimization module is used for adjusting the network parameters of the context rewriting network by using a reinforcement learning method.
In some embodiments, the reinforcement learning method further comprises:
generating and rewriting a plurality of candidate sentences by using a pre-trained model;
the maximized reward value is calculated, and the context rewrite network is optimized by using the reward value reward.
Through the steps, the embodiment of the application establishes direct connection between the context rewriting model and different tasks based on the reinforcement learning method, so that the problem that the performance of the pre-trained model is limited due to inclusion errors and noise of the generated rewriting sentences is solved, the parameters of the context rewriting model are optimized, and the rewriting accuracy is improved.
In some embodiments, the dialogue model is a Seq2Seq model based on an attention model, which effectively improves the accuracy of the dialogue generation result.
In a third aspect, an embodiment of the present application provides a chat robot, where the dialogue chat robot responds based on the chat robot multi-turn dialogue generating method according to the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the method for generating a chat-robot multi-turn dialog according to the first aspect.
Compared with the related art, the chatting robot multi-turn dialog generation method and device, the chatting robot and the computer-readable storage medium provided by the embodiment of the application rewrite the multi-turn dialog into the single-turn dialog, and the dialog generation can be realized by using the frame of the single-turn dialog, so that the response precision is improved; conversation keyword extraction is realized based on mutual information, so that manual labeling of data is not needed in the rewriting process; a text rewriting mode based on the LSTM language model, the reordering model and the context rewriting network construction rule, so that a rewriting process can be explained; the embodiment of the application also uses reinforcement learning to continuously adjust the parameters of the rewriting network, thereby improving the rewriting precision.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a flowchart illustrating a method for generating a multi-turn dialogue of a chat robot according to an embodiment of the present disclosure;
fig. 2 is another flowchart illustration of a chat-robot multi-turn dialog generation method according to an embodiment of the application;
fig. 3 is a block diagram schematically illustrating the structure of a multi-turn dialog generating apparatus according to an embodiment of the present application;
fig. 4 is another structural schematic block diagram of a multi-turn dialog generating device according to an embodiment of the present application;
fig. 5 is a schematic diagram illustrating a rewritten sentence generating step in a multi-turn dialog generating method of a chat robot according to an embodiment of the application;
fig. 6 is a schematic diagram of a dialog generation step in a chat robot multi-turn dialog generation method according to an embodiment of the application.
Description of the drawings:
1. a multi-turn dialog generating device; 11. a conversation content acquisition module; 12. a keyword extraction module; 13. a rewrite candidate sentence generation module; 14. a rewritten sentence generating module; 15. a dialog generation module; 16. a context rewrite network optimization module; 131. a key phrase extraction module; 132. a rewrite candidate sentence acquisition module; 141. a rewrite encoding module; 142. and rewriting the decoding module.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application.
It is obvious that the drawings in the following description are only examples or embodiments of the present application, and that it is also possible for a person skilled in the art to apply the present application to other similar contexts on the basis of these drawings without inventive effort. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of ordinary skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms referred to herein shall have the ordinary meaning as understood by those of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar words throughout this application are not to be construed as limiting in number, and may refer to the singular or the plural. The present application is directed to the use of the terms "including," "comprising," "having," and any variations thereof, which are intended to cover non-exclusive inclusions; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to the listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as referred to herein means two or more. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
Fig. 1 is a schematic flow diagram of a method for generating a multi-turn dialogue of a chat robot according to an embodiment of the present application, and with reference to fig. 1, the flow includes the following steps:
a dialogue content obtaining step S1, configured to obtain a dialogue text and filter sensitive words in the dialogue text, and filter sensitive words that may be included in the dialogue text, such as politics, evil and faith, yellow gambling poison, gun ammunition, sartorium, etc., so as to avoid adverse effects of the sensitive words on the dialogue content;
a keyword extraction step S2, configured to extract a dialog keyword in the dialog text based on the mutual information after performing preprocessing operations such as word segmentation, word frequency statistics, common word punishment, and low-frequency word punishment on the dialog text;
a rewriting candidate sentence generating step S3, configured to extract adjacent words of the dialog keywords, where the adjacent words and the keywords constitute a key phrase, and the key phrase and a dialog tail sentence in the dialog text constitute a rewriting candidate sentence;
a rewritten sentence generating step S4 of converting the rewritten candidate sentence into a rewritten sentence through encoding and decoding by a context rewriting network and outputting the rewritten sentence;
a dialog generation step S5, inputting the rewritten sentence into a dialog model to obtain a dialog answer, specifically, inputting the rewritten sentence into a Seq2Seq dialog model in a question-and-answer manner, encoding the input sentence into a context variable C by an Encoder of the Seq2Seq dialog model, decoding each output using the context variable C without distinction during decoding, encoding the Encoder into a different context variable C according to each time step of the sequence based on the attention model, and decoding and outputting by a Decoder of the Seq2Seq dialog model in combination with each different C to complete the dialog.
Wherein the rewrite candidate sentence generation step S3 further includes:
a key phrase extracting step S301, for extracting adjacent words of the dialogue keywords, and combining the dialogue keywords and the adjacent words to form a key phrase with complete semantics;
a rewriting candidate sentence obtaining step S302, configured to insert a key phrase into a dialog tail sentence in a dialog text by using an LSTM language model to obtain a plurality of candidate rewriting candidate sentences, and select the plurality of candidate rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.
The rewritten sentence generating step S4 further includes:
a rewriting encoding step S401, configured to encode context information and tail sentence information in a rewriting candidate sentence respectively by using two encoders composed of two bidirectional GRU networks, where the two encoders are respectively used for learning context information representation and tail sentence information representation, and the specific principle of the step S401 is to connect the invisible states of the left and right GRU networks in the sentence according to a positive time direction and a negative time direction by using the bidirectional GRU networks, so as to merge the left and right words of the rewriting candidate sentence;
a rewrite decoding step S402, configured to generate a rewrite sentence by using a decoder composed of a GRU network, where the decoder is based on an attention mechanism and a replication mechanism, and the attention mechanism is used to obtain information from context information and tail sentence information; the copying mechanism is used for copying important words in the context information, specifically, directly copying the important words from the context by using Copy mode, and predicting the distribution of the vocabulary by using Predict mode.
Through the steps, the multi-turn conversation is rewritten into the single-turn conversation model by using the context, and only one reply is generated according to the rewritten sentence, so that the length of the conversation context is simplified and shortened, and higher response precision is realized; meanwhile, manual marking is not needed, and the working cost is reduced; a text rewriting method using rules is realized, so that the rewriting process can be explained; and the accuracy of the dialog generation result is further effectively improved by utilizing the dialog model with the attention mechanism.
Fig. 2 is another schematic flow diagram of the method for generating the multi-round chat robot dialog according to an embodiment of the present application, and reference is made to fig. 2, where the same steps as those in the method for generating the multi-round chat robot dialog are not repeated, and the difference is that the method further includes the following steps:
a context rewriting network optimizing step S6, configured to adjust network parameters of the context rewriting network by using a reinforcement learning method, where the reinforcement learning method further includes: generating and rewriting a plurality of candidate sentences by using a pre-trained model; the maximized reward value is calculated and the network is rewritten with the reward value rewarded optimized context.
Through the steps, the direct connection between the context rewriting model and different tasks is established based on the reinforcement learning method, so that the problem that the performance of the pre-training model is limited due to the inclusion error and noise of the generated rewriting sentences is solved, the parameters of the context rewriting model are optimized, and the rewriting accuracy is improved.
The rewriting process and the dialogue process of the embodiment of the present application are described and explained below by preferred embodiments. Fig. 5 is a schematic diagram of a generation step of a rewritten sentence in the multi-turn dialogue generation method for the chatting robot according to the embodiment of the present application, fig. 6 is a schematic diagram of a generation step of a dialogue in the multi-turn dialogue generation method for the chatting robot according to the embodiment of the present application, and as shown with reference to fig. 5 and 6,
step S302, an LSTM language model is used for inserting key phrases into dialogue tail sentences in the dialogue text, 3 sentences with high model scores are selected from the LSTM language model to be used as alternative rewriting candidate sentences, and answers in the dialogue text are used for selecting a plurality of alternative rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.
The rewritten sentence generation is performed by step S4, first learning by the two encoders that the context in the rewritten candidate sentence indicates "i hate cake" and the tail sentence indicates "why? Good taste ", then" unpleasant cake "is copied and inserted into the tail sentence in step S402 according to the attention mechanism and the copying mechanism, and the output rewritten sentence is" why unpleasant cake? Is delicious. ".
Step S5 inputs the rewritten sentence into the dialogue model Seq2Seq, and outputs the dialogue result "tired". "
It should be noted that the steps illustrated in the above-described flow diagrams or in the flow diagrams of the figures may be performed in a computer system, such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flow diagrams, in some cases, the steps illustrated or described may be performed in an order different than here.
The embodiment also provides a multi-turn dialog generating device, and fig. 3 is a block diagram schematically illustrating the structure of the multi-turn dialog generating device according to the embodiment of the present application. Referring to fig. 3, the multi-turn dialog generating device 1 includes: a dialogue content acquisition module 11, a keyword extraction module 12, a rewrite candidate sentence generation module 13, a rewrite sentence generation module 14, a dialogue generation module 15, and the like. Those skilled in the art will appreciate that the multi-turn dialog generating device illustrated in fig. 3 does not constitute a limitation of multi-turn dialog generating devices and may include more or less structures than those illustrated, or some of the structures may be combined, or a different arrangement of structures.
The following describes the structure of the ue in detail with reference to fig. 3:
the conversation content acquisition module 11 is used for acquiring a conversation text and filtering sensitive words in the conversation text;
a keyword extraction module 12, configured to extract a dialog keyword in the dialog text based on the mutual information;
a rewriting candidate sentence generating module 13, configured to extract adjacent words of the dialog keywords, where the adjacent words and the keywords constitute a key phrase, and the key phrase and a dialog tail sentence in the dialog text constitute a rewriting candidate sentence;
a rewritten sentence generating module 14 for converting the rewritten candidate sentence into a rewritten sentence through encoding and decoding by a context rewriting network and outputting the rewritten sentence;
and the dialogue generating module 15 inputs the rewritten sentence into a dialogue model to obtain a dialogue answer, and specifically, the dialogue model adopts a Seq2Seq model based on an attention model so as to effectively improve the accuracy of a dialogue generating result.
Wherein, the rewriting candidate sentence generation module 13 further includes:
a key phrase extracting module 131, configured to extract neighboring words of the dialog key words, and combine the dialog key words and the neighboring words to form a key phrase with complete semantics;
the candidate rewriting sentence acquisition module 132 is configured to insert a key phrase into a dialog tail sentence in a dialog text by using an LSTM language model to obtain a plurality of candidate rewriting candidate sentences, and select the candidate rewriting sentences through a reordering model to obtain a candidate rewriting sentence.
The rewritten sentence generating module 14 further includes:
a rewrite coding module 141, configured to code context information and tail sentence information in the rewrite candidate sentence by using two encoders composed of bidirectional GRU networks, where the two encoders are respectively used for learning context information representation and tail sentence information representation;
and a rewrite decoding module 142 for generating a rewrite sentence by using a decoder composed of a GRU network, the decoder being based on an attention mechanism and a replication mechanism. The attention mechanism is used for acquiring information from the context information and the tail sentence information; a replication mechanism is used to replicate important words in the context information.
By the device, multiple rounds of conversations are rewritten and converted into a single round of conversation model by context, only one reply is generated according to the rewritten sentence, the length of the conversation context is simplified and shortened, higher response precision is realized, manual marking is not needed, and the working cost is reduced; a text rewrite method using rules is implemented so that the rewrite process is interpretable.
The embodiment also provides a multi-turn dialog generating device, and fig. 4 is another structural schematic block diagram of the multi-turn dialog generating device according to the embodiment of the present application; referring to fig. 4, the same parts of the apparatus as those of the multi-turn dialog generating apparatus are not described again, except that the apparatus further includes:
and the context rewriting network optimization module 16 is used for adjusting the network parameters of the context rewriting network by using a reinforcement learning method.
In some embodiments, the reinforcement learning method further comprises:
generating and rewriting a plurality of candidate sentences by using a pre-trained model;
the maximized reward value is calculated and the network is rewritten with the reward value rewarded optimized context.
Through the steps, the direct connection between the context rewriting model and different tasks is established based on the reinforcement learning method, so that the problem that the performance of the pre-training model is limited due to the inclusion error and noise of the generated rewriting sentences is solved, the parameters of the context rewriting model are optimized, and the rewriting accuracy is improved.
The above modules may be functional modules or program modules, and may be implemented by software or hardware. For a module implemented by hardware, the modules may be located in the same processor; or the modules can be respectively positioned in different processors in any combination.
The embodiment of the application further provides a chat robot, and the dialogue chat robot responds based on any one of the chat robot multi-turn dialogue generating methods in the embodiments.
In addition, in combination with the multi-turn dialogue generation method for the chat robot in the foregoing embodiments, embodiments of the present application may provide a computer-readable storage medium to implement. The computer readable storage medium having stored thereon computer program instructions; the computer program instructions, when executed by a processor, implement any one of the chat robot multi-turn dialog generation methods in the above embodiments.
To sum up, according to the method and the device for generating the multi-turn dialogue of the chat robot, the chat robot and the computer-readable storage medium provided by the embodiment of the application, the multi-turn dialogue is rewritten into a single-turn dialogue, and the dialogue generation can be realized by using a frame of the single-turn dialogue, so that the response precision is improved; conversation keyword extraction is realized based on mutual information, so that manual labeling of data is not needed in the rewriting process; a text rewriting mode based on the LSTM language model, the reordering model and the context rewriting network construction rule, so that the rewriting process can be explained; the embodiment of the application also uses reinforcement learning to continuously adjust the parameters of the context rewriting network, so that the rewriting precision is improved.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A multi-turn dialogue generation method for a chat robot is characterized by comprising the following steps:
a conversation content acquisition step, which is used for acquiring a conversation text and filtering sensitive words in the conversation text;
a keyword extraction step, which is used for extracting the conversation keywords in the conversation text based on mutual information;
a rewriting candidate sentence generating step, configured to extract adjacent words of the dialog keywords, where the adjacent words and the keywords constitute a key phrase, and the key phrase and a dialog tail sentence in the dialog text constitute a rewriting candidate sentence;
a rewritten sentence generating step of converting the rewritten candidate sentence into a rewritten sentence through encoding and decoding by a context rewriting network and outputting the rewritten sentence;
and a dialogue generating step of inputting the rewritten sentence into a dialogue model to obtain a dialogue answer.
2. A chat-robot multi-turn dialog generation method according to claim 1, wherein the rewrite candidate sentence generation step further comprises:
a key phrase extraction step, which is used for extracting adjacent words of the conversation keywords and combining the conversation keywords and the adjacent words thereof to form a key phrase with complete semantics;
and a rewriting candidate sentence acquisition step, which is used for inserting the key phrase into the dialog tail sentence in the dialog text by using an LSTM language model to obtain a plurality of candidate rewriting candidate sentences, and selecting the candidate rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.
3. A chat-robot multi-turn dialog generation method according to claim 2, wherein the rewritten sentence generation step further comprises:
a rewriting encoding step, which is used for encoding the context information and the tail sentence information in the rewriting candidate sentence by adopting two encoders consisting of two bidirectional GRU networks;
and a rewriting decoding step for generating a rewritten sentence by using a decoder composed of a GRU network, wherein the decoder is based on an attention mechanism and a replication mechanism.
4. A chat-robot multi-turn dialog generation method in accordance with claim 1, further comprising:
and a context rewriting network optimization step, which is used for adjusting the network parameters of the context rewriting network by using a reinforcement learning method.
5. A chat-robot multi-turn dialog generation method in accordance with claim 1, where the dialog model is a Seq2Seq model based on an attention model.
6. A multi-turn dialog generation device, comprising:
the conversation content acquisition module is used for acquiring a conversation text and filtering sensitive words in the conversation text;
the keyword extraction module is used for extracting the conversation keywords in the conversation text based on mutual information;
the rewriting candidate sentence generating module is used for extracting adjacent words of the conversation keywords, forming key phrases with the adjacent words and the keywords, and forming the key phrases and the conversation tail sentences in the conversation texts into rewriting candidate sentences;
a rewritten sentence generating module for converting the rewritten candidate sentence into a rewritten sentence through encoding and decoding by a context rewriting network and outputting the rewritten sentence;
and the dialogue generating module is used for inputting the rewritten sentence into a dialogue model to obtain a dialogue answer.
7. A multi-turn dialog generation device according to claim 6, wherein the rewrite candidate sentence generation module further comprises:
the key phrase extraction module is used for extracting adjacent words of the conversation keywords and combining the conversation keywords and the adjacent words to form a key phrase with complete semantics;
and the rewriting candidate sentence acquisition module is used for inserting the key phrases into the conversation tail sentences in the conversation text by utilizing an LSTM language model to obtain a plurality of candidate rewriting candidate sentences, and selecting the candidate rewriting candidate sentences through a reordering model to obtain a rewriting candidate sentence.
8. A multi-turn dialog generation device according to claim 7, characterised in that the rewritten sentence generation module further comprises:
the rewriting coding module is used for respectively coding the context information and the tail sentence information in the rewriting candidate sentences by adopting two coders consisting of two bidirectional GRU networks;
and the rewriting decoding module is used for generating a rewriting sentence by adopting a decoder consisting of a GRU network, and the decoder is based on an attention mechanism and a replication mechanism.
9. A multi-turn dialog generation device as claimed in claim 6, further comprising:
and the context rewriting network optimization module is used for adjusting the network parameters of the context rewriting network by using a reinforcement learning method.
10. A chat robot characterized in that it responds based on a chat robot multi-turn dialog generation method as claimed in any of claims 1-5.
CN202011117440.7A 2020-10-19 2020-10-19 Multi-turn dialogue generation method and device for chatting robot and chatting robot Pending CN112231457A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011117440.7A CN112231457A (en) 2020-10-19 2020-10-19 Multi-turn dialogue generation method and device for chatting robot and chatting robot

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011117440.7A CN112231457A (en) 2020-10-19 2020-10-19 Multi-turn dialogue generation method and device for chatting robot and chatting robot

Publications (1)

Publication Number Publication Date
CN112231457A true CN112231457A (en) 2021-01-15

Family

ID=74118989

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011117440.7A Pending CN112231457A (en) 2020-10-19 2020-10-19 Multi-turn dialogue generation method and device for chatting robot and chatting robot

Country Status (1)

Country Link
CN (1) CN112231457A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113868386A (en) * 2021-09-18 2021-12-31 天津大学 Controllable emotion conversation generation method
CN113868395A (en) * 2021-10-11 2021-12-31 北京明略软件系统有限公司 Multi-round dialogue generation type model establishing method and system, electronic equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113868386A (en) * 2021-09-18 2021-12-31 天津大学 Controllable emotion conversation generation method
CN113868395A (en) * 2021-10-11 2021-12-31 北京明略软件系统有限公司 Multi-round dialogue generation type model establishing method and system, electronic equipment and medium

Similar Documents

Publication Publication Date Title
Evans et al. Can neural networks understand logical entailment?
CN109844743B (en) Generating responses in automated chat
CN110309287B (en) Retrieval type chatting dialogue scoring method for modeling dialogue turn information
CN108549658B (en) Deep learning video question-answering method and system based on attention mechanism on syntax analysis tree
CN106875940B (en) Machine self-learning construction knowledge graph training method based on neural network
CN111310439B (en) Intelligent semantic matching method and device based on depth feature dimension changing mechanism
Udagawa et al. A natural language corpus of common grounding under continuous and partially-observable context
CN108845994B (en) Neural machine translation system using external information and training method of translation system
CN112328756B (en) Context-based dialog generation method and system
CN112231457A (en) Multi-turn dialogue generation method and device for chatting robot and chatting robot
CN112948558B (en) Method and device for generating context-enhanced problems facing open domain dialog system
CN110851575B (en) Dialogue generating system and dialogue realizing method
CN112069295A (en) Similar question recommendation method and device, electronic equipment and storage medium
CN111027292B (en) Method and system for generating limited sampling text sequence
CN112417127A (en) Method, device, equipment and medium for training conversation model and generating conversation
CN116862000B (en) Causal thinking chain generation method, device and equipment for generating artificial intelligence
CN110942774A (en) Man-machine interaction system, and dialogue method, medium and equipment thereof
CN111897960B (en) Method, device, equipment and storage medium for reasoning between dynamic legal events
CN108364066B (en) Artificial neural network chip and its application method based on N-GRAM and WFST model
CN113392640A (en) Title determining method, device, equipment and storage medium
CN108363685B (en) Self-media data text representation method based on recursive variation self-coding model
CN115905487A (en) Document question and answer method, system, electronic equipment and storage medium
CN114239536A (en) Event extraction method, system and computer readable storage medium
CN114912020A (en) Multi-sub-target dialogue recommendation method based on user preference graph
CN116822633B (en) Model reasoning method and device based on self-cognition and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination