Task-based dialogue sentence response generation method and storage medium based on deep learning
By adopting a two-stage neural network model and a multi-head attention mechanism in a task-based dialogue system, the problem of slot errors is solved, and the generated reply sentences are accurate and smooth, close to human language.
Patent Information
- Application Number
- CN202111413858.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-25
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-11-25
AI Technical Summary
Existing task-based dialogue systems are prone to slot errors when generating reply sentences, leading to information loss or redundancy and affecting the user experience.
A two-stage neural network model based on deep learning, including a sentence planner and a segment generator, is used to generate the skeleton of the reply sentence through the conversation actions and reply sentences in the training set, and progressively generates text fragments within the skeleton, leveraging multi-head attention. Mechanism and retrieval mechanism ensure the accuracy and fluency of the generated reply sentences.
It effectively reduces slot errors, ensures that the generated reply sentences are highly controllable and close to human language habits, and improves the generation quality of task-based dialogue systems.
Smart Images

Figure CN114358021B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a method and storage medium for generating task-based dialogue sentence responses based on deep learning. Background Art
[0002] Natural language generation (NLG) is an interdisciplinary subject between artificial intelligence and computational linguistics. Its purpose is to enable machines to generate understandable human language texts. The progress of this technology helps to build strong artificial intelligence systems and improve the understanding of human language. In task-based dialogue systems, natural language generation (NLG) is the last and most important step. In this link, the goal of the natural language generation module is to convert dialogue actions into natural language replies. Traditional methods are usually rule-based, decomposing the NLG task into two parts: sentence planning and surface realization. Sentence planning is responsible for generating a tree structure that can reflect the reply sentence according to the dialogue action, and surface realization further converts this tree structure into a reply sentence. Although such methods have good robustness, they are heavily dependent on prior knowledge in the field and the manual setting of rules, that is, they do not have good generalization. In addition, the reply sentences generated by such methods are usually very boring due to the limitations of manual rules, and cannot well imitate the flexibility and diversity of human language.
[0003] In recent years, methods based on data-driven end-to-end neural networks have achieved better results in this task and attracted the attention of more researchers. For example, early solutions designed a neural network model with an encoder and a decoder, and processed the slot-value pairs in the dialogue actions through the attention mechanism. Later researchers designed a decoder based on LSTM (Long Short-Term Memory Network) to select and integrate the semantic elements generated by the attention mechanism. Later solutions designed a multi-task learning framework. While training the conditional language modeling task for reply generation based on dialogue actions, an unconditional language modeling task that shares the encoder of the above task was added. Compared with previous work, this framework significantly improved the fluency of dialogue sentences. Recently, some scholars designed an iterative rewriting method for the slot loss and slot redundancy of reply sentences in this task. This method uses a retrieval-based bootstrapping method to sample error cases in the training corpus to enrich the original training data. The author also introduced policy-based reinforcement learning, so that the training model has discrete rewards consistent with the evaluation indicators, which greatly improves the controllability of reply generation in task-based dialogue systems. In addition, there are studies exploring interpretable neural networks for this task. The proposed method includes a sentence renderer set consisting of multiple decoders and a pattern converter. When generating a reply sentence, the pattern converter selects the appropriate decoder to generate different parts of a reply. Compared with previous work, this method has better interpretability.
[0004] Although the above methods have enabled the machine to simulate human language habits well, slot errors are still inevitable in the generated dialogue sentences, that is, slots in the input are ignored or redundant slots are generated. In the common processes of task-based dialogue systems (state tracking, action determination, and response generation), slot errors will cause the dialogue actions decided by the previous module to not appear accurately in the response sentence, resulting in information loss or redundancy, that is, the generated response sentence cannot well carry out the user's speech or needs, resulting in a poor user experience.
[0005] The disclosure of the above background technology content is only used to assist in understanding the concept and technical solution of the present invention. It does not necessarily belong to the prior art of this patent application. In the absence of clear evidence that the above content has been disclosed on the filing date of this patent application, the above background technology should not be used to evaluate the novelty and creativity of the present application. Summary of the invention
[0006] In order to solve the existing problems, the present invention provides a task-based dialogue sentence response generation method and storage medium based on deep learning.
[0007] In order to solve the above problems, the technical solution adopted by the present invention is as follows:
[0008] A method for generating task-based dialogue sentence responses based on deep learning comprises the following steps: S1: constructing a neural network model, the neural network model comprising a sentence planner and a segment generator, the sentence planner being used to generate a skeleton of a response sentence, and the segment generator being used to generate a response sentence; S2: training the sentence planner and the segment generator of the neural network model through dialogue actions and corresponding response sentences in a training set to obtain a trained neural network model; S3: using the trained neural network model to automatically generate a response sentence with a given dialogue action as input.
[0009] Preferably, training the sentence planner and the segmentation generator of the neural network model includes the following steps: S21: using vocabulary masking technology to replace specific values in all text data with corresponding slot names in the dialogue action, and the dialogue action after vocabulary masking is passed through the sentence planner to obtain the skeleton of the reply sentence, which includes the dialogue action and a series of semantically sorted slots; S22: the segmentation generator progressively generates text fragments between two keywords in an autoregressive manner within the skeleton of the reply sentence, and the process is carried out from left to right until the entire reply sentence is completely generated.
[0010] Preferably, obtaining the skeleton of the reply sentence comprises the following steps: using vocabulary masking technology to replace the specific values in all text data in the dialogue action with the corresponding slot names in the dialogue action, 0 ={x0,x1,...,x T} is defined as the skeleton of the reply sentence generated by the sentence planner based on the input dialogue action; where x0 is the lexical token of the action type of the dialogue action, which controls the discourse style of the entire reply sentence, x1,...,x T Each of is a lexical token representing a specific slot in the dialogue act.
[0011] Preferably, generating the entire reply sentence comprises the following steps: progressively replacing the text between two keywords in the skeleton of the reply sentence with the symbol @ from right to left, obtaining a global information and a corresponding triplet as the input of the segmentation generator in each stage; wherein the symbol @ is used to clearly indicate the specific location of text generation; modeling a progressive sequence S of K stages: S = {X 0 ,X 1 ,...,X K}; for k∈{0,...,K-1}, X K-1 Is to get X KCondition, a small fragment of text is generated for a reply at each stage until the whole sentence is completed, where the value of K is the same as the number of keywords in the dialogue action; the global information and triples of each stage are respectively passed through the global information encoder and the triple encoder to obtain the neural network hidden representation matrix of the two; the neural network hidden representation matrix is fused, and the size of the fused information matrix is the same as the output of the triple encoder, which is sent to the decoder to obtain the text fragment of this stage. This process is repeated for each stage, so as to recursively obtain the reply sentence template, that is, X K ; Replace the slot values in the template of the reply statement with the corresponding values in the dialogue action to obtain the final reply statement.
[0012] Preferably, in the case where there is no text to be generated between the two keywords, the vocabulary token [None] is used as a label generated in this stage.
[0013] Preferably, a multi-head attention mechanism is used to fuse the neural network hidden representation matrix, which is expressed as follows:
[0014] a=MultiHead(Enc tri (t),Enc glo (g),Enc glo (g))
[0015] Among them, t and g represent triples and global information respectively, and the calculation result a will be passed to the decoder.
[0016] Preferably, the method further comprises the following steps: using the triple as a keyword for information retrieval, searching for corresponding text segments in a retrieval material library constructed based on the training set to form a text segment set; introducing a retrieval encoder in the retriever, denoted as Enc mem , used to map each text in the retrieved text fragment set to its hidden representation, combined with the first encoding vector of the global information, and encoded and further scored through the retrieval encoder; the first M retrieved text fragments will send the collaborative scoring scores to the decoder to assist the text fragment decoding at the current stage; where M is a preset integer.
[0017] Preferably, the lth text segment z in the text segment set l The correlation score with the current global information is obtained by the following formula:
[0018] s l =Sigmoid(Linear(g v ; z lv ))
[0019] Among them; represents vector splicing, g v and zlv Enc glo (g) and Enc mem (z l ) at the hidden representation of the “[start]” lexical token;
[0020] At each time step t, the generated text sequence of this stage is recorded as y 1:t-1 , the decoder uses the calculation results a and y at the same time 1:t-1 To generate a hidden state h t , then t It will be transformed into a probability distribution covering the vocabulary through a linear mapping and Softmax function:
[0021] P v =Softmax(W v ·h t +b v )
[0022] From {Enc mem (z i )} to extract a semantic embedding vector set
[0023] Among them, z i is one of the M text segments retrieved, L i is the length of this text fragment;
[0024] The cross attention covering all retrieved text segments is calculated as:
[0025]
[0026]
[0027] Among them, α i,j Yes i The attention score for the jth vocabulary token in , c t is a weighted fusion of the lexical tokens in the retrieved utterance, s i Yes i The correlation score of , β is a trainable scalar used to control the influence of the bias score on the attention score, W m and W c These are all trainable parameters.
[0028] Preferably, the attention score is also considered as the probability of directly copying its corresponding vocabulary token during the generation process, and the final vocabulary probability at this time step is calculated as:
[0029]
[0030] Where I is the indicator function, λt is a gating probability calculated by the Feed-Forward network:
[0031] λ t =FeedForward(h t ,c t ).
[0032] A computer-readable storage medium stores a computer program, wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0033] The beneficial effects of the present invention are: providing a task-based dialogue sentence response generation method and storage medium based on deep learning, by constructing a two-stage neural network model, including a sentence planner and a segment generator, which can first generate the skeleton of the response sentence and then generate the response sentence; then through the training of the model, it is possible to imitate human language habits well under the premise of ensuring that the generated discourse is highly controllable and basically does not produce slot errors.
[0034] Furthermore, the method proposes a retrieval-enhanced piecewise autoregressive neural network model, which further enables the generated reply sentences to well imitate human language habits while basically not making slot errors. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a schematic diagram of a method for generating task-based dialogue sentence responses based on deep learning in an embodiment of the present invention.
[0036] Figure 2 It is a schematic diagram of a method for training a sentence planner and a segment generator of a neural network model in an embodiment of the present invention.
[0037] Figure 3 This is an example of segmented generation of reply sentences in an embodiment of the present invention.
[0038] Figure 4 It is a schematic diagram of a method for generating an entire reply sentence in an embodiment of the present invention.
[0039] Figure 5 This is an example of data processing in an embodiment of the present invention.
[0040] Figure 6 It is a schematic diagram of a method for introducing a retrieval mechanism in an embodiment of the present invention.
[0041] Figure 7 It is a schematic diagram of another method for generating task-based dialogue sentence responses based on deep learning in an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the technical problems, technical solutions and beneficial effects to be solved by the embodiments of the present invention more clearly understood, the present invention is further described in detail 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 invention and are not used to limit the present invention.
[0043] It should be noted that when a component is referred to as being "fixed to" or "disposed on" another component, it can be directly on the other component or indirectly on the other component. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or indirectly connected to the other element. In addition, connection can be used for both fixing and circuit connection.
[0044] It should be understood that the orientation or position relationship indicated by terms such as "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside" and "outside" are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0045] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0046] The present invention aims to solve the problem that slot errors are inevitably generated when generating task-based dialogue sentences based on data-driven and neural network methods.
[0047] In order to reduce the accumulated errors between modules in the process and accurately transmit the specified constraint information, the present invention plans to design a neural network model with controllable modeling and retrieval enhancement for the response generation module. For this task, the present invention proposes a new model training method, which models the subsequent generation task as a natural language generation task under hard constraints based on the input dialogue action, and further introduces a retrieval mechanism to assist in the generation of speech segments, thereby ensuring that the machine can generate high-quality dialogue sentences close to human language under the premise of highly controllable responses.
[0048] like Figure 1 As shown, the present invention provides a task-based dialogue sentence response generation method based on deep learning, characterized in that it includes the following steps:
[0049] S1: construct a neural network model, wherein the neural network model includes a sentence planner and a segment generator, wherein the sentence planner is used to generate a skeleton of a reply sentence, and the segment generator is used to generate a reply sentence;
[0050] S2: training the sentence planner and the segmentation generator of the neural network model through the dialogue actions and corresponding reply sentences in the training set to obtain a trained neural network model;
[0051] S3: Utilize the trained neural network model to automatically generate a response statement using a given dialogue action as input.
[0052] The neural network model constructed by the present invention is two-stage, including a sentence planner and a segment generator. Different from the existing model that directly generates a whole sentence based on dialogue actions, the present invention can first generate the skeleton of the reply sentence and then generate the reply sentence. By training the model, the generated reply sentence can well imitate human language habits while basically not generating slot errors.
[0053] like Figure 2 As shown, training the sentence planner and segment generator of the neural network model includes the following steps:
[0054] S21: Using a vocabulary masking technique to replace specific values in all text data with corresponding slot names in the dialogue action, the dialogue action after vocabulary masking is passed through the sentence planner to obtain a skeleton of a reply sentence, which includes the dialogue action and a series of semantically sorted slots;
[0055] S22: The segmentation generator gradually generates text segments between two keywords in an autoregressive manner within the skeleton of the reply sentence, and the process is performed from left to right until the entire reply sentence is completely generated.
[0056] like Figure 3 As shown, the technology of the present invention gradually generates a task-based dialogue sentence based on dialogue actions.
[0057] In the model training and reasoning process, we first obtain the skeleton of the reply sentence, which includes the following steps:
[0058] Use the existing vocabulary masking technology to replace the specific values in all text data with the corresponding slot names in the dialogue action; then 0 ={x0,x1,...,x T} is defined as the response sentence skeleton generated by the sentence planner based on the input dialogue action.
[0059] Among them, x0 is the lexical token of the action type of the dialogue action, which controls the discourse style of the entire reply sentence, and x1,...,xT Each of is a lexical token representing a specific slot in a dialogue act.
[0060] The subsequent process is then treated as a natural language generation task under hard constraints.
[0061] like Figure 4 As shown, generating the entire reply statement includes the following steps:
[0062] The text between two keywords in the skeleton of the reply sentence is replaced with the symbol @ from right to left step by step, and a global information and a corresponding triple are obtained as the input of the segmentation generator in each stage; wherein the symbol @ is used to clearly indicate the specific location of text generation;
[0063] Model a K-stage progressive sequence S: S = {X 0 ,X 1 ,...,X K}; for k∈{0,...,K-1}, X K-1 Is to get X K A small fragment of text is generated for a reply at each stage until the whole sentence is completed, where the value of K is the same as the number of keywords in the dialogue action.
[0064] The global information and triples at each stage are respectively passed through the global information encoder and triple encoder to obtain the neural network hidden representation matrix of the two;
[0065] The neural network hidden representation matrix is fused, and the size of the fused information matrix is the same as the output of the triple encoder, which is sent to the decoder to obtain the text fragment of this stage. This process is repeated for each stage, so as to recursively obtain the reply sentence template, that is, X K ;
[0066] The slot values in the template of the reply statement are replaced with the corresponding values in the dialogue action to obtain a final reply statement.
[0067] Different from the prior art method for this task that generates an entire reply at once based on the dialogue action, the present invention processes data in a manner suitable for the proposed model training.
[0068] like Figure 5 As shown in Figure 1, for a lexically masked reply, the text between two keywords is replaced with the symbol @ from right to left. In this way, a global information and a corresponding triplet can be obtained as the input of the segmentation generator in each stage. The three modules on the lower left represent the global information, and the three modules on the lower right represent the triplet consisting of the dialogue action and the keywords on both sides of the lexical token @. For k∈{1,...,K}, Xk The italicized and bold part of the stage is X k-1 The generation process is the reverse process of data preparation. The special symbol @ is used to clearly indicate the specific location of text generation. In the case where there is no text to be generated between two keywords, a special vocabulary token, [none], is selected as the generated label in this stage. The process of generating the entire reply sentence is based on the skeleton of the reply sentence X. 0 , we can get the triple corresponding to this stage, namely "<notice><notice>[name]", and the global information of this stage "<notice>@[name][phone][SEP]", where the special symbol "@" is used to clearly indicate the location of the text to be generated in this stage. Optionally, this symbol can be replaced by any other symbol that has no special meaning to the model.
[0069] In order to make the model simulate human language better, the present invention also introduces a retrieval mechanism. For this process, the present invention uses triples as keys, and classifies the text fragments in each reply sentence into a specific set according to the corresponding key within the entire training set for retrieval. It should be noted that due to the diversity of human language and the richness of sentence structure, most of the above sets have rich text fragments.
[0070] like Figure 6 As shown, the method of the present invention also includes introducing a retrieval mechanism, which specifically includes the following steps:
[0071] Using the triples as keywords for information retrieval, searching for corresponding text fragments in a retrieval material library constructed based on the training set to form a text fragment set;
[0072] A retrieval encoder is introduced into the retriever, denoted as Enc mem , used to map each text in the retrieved text segment set to its hidden representation, combined with the first encoding vector of the global information, and encoded and further scored by the retrieval encoder;
[0073] The first M retrieved text segments send their collaborative scoring scores to the decoder to assist in decoding the text segment at the current stage;
[0074] Wherein, M is a preset integer.
[0075] In order to eliminate the problems of semantic discontinuity and clumsy expression that may exist in the two-step model, a retrieval mechanism is further introduced into the model to improve the completeness and fluency of the generated responses.
[0076] Specifically, if Figure 7 As shown in the figure, the dialogue action after lexical masking first passes through the sentence planner to obtain the skeleton of the reply sentence (i.e., the semantically ordered dialogue action). Figure 5 The data construction method shown in the figure obtains the global information and triples of each stage as the input of the segmentation generator of each stage. The global information and triples of each stage are respectively passed through the global information encoder and the triple encoder to obtain the neural network hidden representation matrix of the two. In order to fuse the global and local information, the multi-head attention mechanism is used to fuse the two. Specifically, the output of the triple encoder is used as the K of the multi-head attention input, and the output of the global information encoder is used as the Q and V of the multi-head attention input. The size of the fused information matrix is the same as the output of the triple encoder and is sent to the decoder. The triple is also used as a keyword for information retrieval. The corresponding text fragment is retrieved in the retrieval material library constructed based on the training set. The first encoding vector ([start] bit) of the global information is combined with the retrieval encoder for encoding and further scoring. The first M retrieved text fragments will send the collaborative scoring scores to the decoder to assist the decoding of the text fragment at the current stage.
[0077] like Figure 7 As shown, unlike the existing methods that directly generate whole sentence models based on dialogue actions, the technology of the present invention mainly consists of a two-stage model: a sentence planner and a segment generator. Figure 7 It is the connection relationship in the training stage, that is, the sentence planner and segment generator are trained through the dialogue actions and corresponding reply sentences in the training set. The sentence planner outputs the reply sentence skeleton according to the dialogue actions, and the segment generator generates a text fragment for the current stage each time based on the reply sentence skeleton, thereby gradually constructing a reply sentence template. At the end, a reply sentence generation neural network model for a task-oriented dialogue system is obtained.
[0078] The generation stage uses the trained model to generate response sentences using given dialogue actions as input.
[0079] Continue as Figure 7 As shown in the figure, since the slots in the dialogue action do not have to appear in the reply sentence in the original order, the sentence planner is first applied to output a reply sentence skeleton based on the dialogue action, which contains the dialogue action and a series of semantically sorted slots. The sentence planner can ensure that the slots of the input dialogue action appear accurately in the reply sentence. Then the segmentation generator gradually generates text segments between two keywords in an autoregressive manner within the generated skeleton. This process proceeds from left to right until the entire sentence is completely generated.
[0080] First, the sentence planner is used to reorder the input dialogue actions that have been lexically masked. For example, the dialogue action after lexical masking is (<notification>[phone][name]). Since the slot order in the final reply sentence may be different from the above slot order, the above dialogue actions are slot-sorted through a sentence planner with a restrictive decoding strategy sorting module to obtain a sentence skeleton, such as (<notification>[name][phone][SEP]), where <notification> is the action type and [SEP] is a special symbol that controls the end of the sentence.
[0081] Alternatively, the sentence planner can be implemented by various existing end-to-end neural network models, that is, any method that satisfies the requirement that the input is a text sequence and the output is also a text sequence. It should be noted that in order to ensure that the input and output slot sequences differ only in order, in the inference phase, the method restricts the output vocabulary tokens of each step of the model to be selected only from the input slots, and the selected slots cannot be selected again until all the slots in the input are generated. In this way, the sentence skeleton X can be further obtained by concatenating the action type and the generated slot sequence. 0 .
[0082] Based on sentence skeleton X 0 , we can get the triple corresponding to this stage, namely "<notice><notice>[name]", and the global information of this stage "<notice>@[name][phone][SEP]", where the special symbol "@" is used to clearly indicate the location of the text to be generated in this stage. Optionally, this symbol can be replaced by any other symbol that has no special meaning to the model.
[0083] Global information encoder (denoted as Enc glo ) and triple encoder (denoted as Enc tri ) First, the global information "<notification>@[name][phone][SEP]" and the triple "<notification><notification>[name]" are encoded respectively. Optionally, the above two encoders will add the special vocabulary token [start] to the front of the input sequence to obtain the overall vector representation of the encoded text sequence. There are many specific implementation methods of the encoder, such as Transformer structure or LSTM structure encoder.
[0084] In order to fuse the global information with the triple information, a multi-head attention mechanism is optionally used to fuse the results of the above two encoders. This process is expressed as:
[0085] a=MultiHead(Enc tri (t),Enc glo (g),Enc glo (g))
[0086] Among them, t and g represent triples and global information respectively, and the calculation result a will be passed to the decoder. Other fusion methods can also be used here, such as vector concatenation.
[0087] Optionally, the triples are used to retrieve the corresponding text fragment set. In the retriever, the method introduces a retrieval encoder (denoted as Enc mem ) to map each text in the retrieved text fragment set to its hidden representation. For example, the triple in the current stage is "<notice><notice>[name]", and this is used as a keyword to search for possible text fragments corresponding to the triple in the retrieval library composed of training data, such as "I know there is one", "I found one", etc. The text fragments that appear between the two vocabulary tokens "<notice>[name]" in the training set are uniformly sent to the retrieval encoder for encoding to obtain the hidden representation. Take the lth text fragment z in the set l For example, we can further obtain its relevance score with the current global information through the following formula:
[0088] s l =Sigmoid(Linear(g v ; z lv ))
[0089] Among them; represents vector splicing, g v and z lv Enc glo (g) and Enc mem (z l ) in the hidden representation of the "[start]" lexical token. The scoring method can be completed by other neural networks or activation functions, but it is necessary to ensure that a score is obtained for each sentence that can reflect the degree of match between the retrieval material (and text fragment) and the current stage.
[0090] Then, for the decoder, at each time step t, the generated text sequence of this stage is recorded as y 1:t-1 , the decoder uses both a and y 1:t-1 To generate a hidden state h t , then t It will be transformed into a probability distribution covering the vocabulary through a linear mapping and Softmax function:
[0091] P v =Softmax(W v ·h t +b v )
[0092] In order to effectively integrate the additional retrieval information, the first M text segments are first retrieved according to the relevance scores, where M is an integer number that can be set according to actual conditions.
[0093] Then directly from {Enc mem (z i )} to extract a semantic embedding vector set where z i is one of the M text segments retrieved, L i is the length of this text segment. Inspired by the related work in the field of machine translation, in order to enable the gradient information to be passed back from the decoder to the scoring network for calculating the correlation coefficient, the method converts s i Send to the decoder as z i For example, if "I know there is one" and "I found one" get relevance scores of 0.5 and 0.8 respectively, the decoder will refer more to the retrieved text segment "I found one" to generate the current segment during the decoding process.
[0094] In this way, a criss-cross attention covering all retrieved texts can be calculated as:
[0095]
[0096]
[0097] Among them, α i,j Yes i The attention score for the jth vocabulary token in , c t is a weighted fusion of the lexical tokens in the retrieved utterance, s i Yes i The correlation score of , β is a trainable scalar used to control the influence of the bias score on the attention score, W m and W c These are all trainable parameters.
[0098] Optionally, h t Updated to h t and c t sum.
[0099] In addition, the attention score is also considered as the probability of directly copying its corresponding vocabulary token during the generation process, and the final vocabulary probability at this time step is calculated as:
[0100]
[0101] Where I is the indicator function, λ t is a gating probability calculated by the Feed-Forward network:
[0102] λ t =FeedForward(h t,c t )
[0103] At this point, we can get the text fragment generated in each stage for the global information and triple information of each stage. For example, for the global information "<notification>@[name][phone][SEP]" and the triple "<notification><notification>[name]", the generated text fragment is "I found it", then we can get the next stage, that is, Figure 1 Stage X 1 , further update the global information to "<Notification> I found [name]@[phone][SEP]", and then obtain X 1 The triplet of the phase "<notification>[name][phone number]" is used to convert this X 1 The global information of the stage "<notification> I found [name]@[phone] [SEP]" and the triple "<notification> [name] [phone]" are generated as described above. The same process generates the text fragment of the next stage "and" to obtain Figure 1 Global information X in 2 , and then recursively generate the template X of the whole sentence 3 ,like Figure 1 shown.
[0104] Finally, based on the generated template such as "<notification> I found [name] and [phone] is its phone number [SEP]", the specific values in the dialogue action before lexical masking are backfilled into each slot, and the auxiliary slots (i.e., dialogue action type <notification>, [SEP]) are deleted to obtain the final reply sentence, such as "I found KFC and 123456789 is its phone number".
[0105] For the generation of responses for task-based dialogue systems, this method has the advantages of both traditional rule-based methods and the recently popular data-driven and neural network-based methods. It can well imitate human language habits while ensuring that the generated discourse is highly controllable and basically produces no slot errors.
[0106] Furthermore, the method proposes a retrieval-enhanced piecewise autoregressive neural network model, which enables the generated reply sentences to well imitate human language habits while basically not making slot errors.
[0107] An embodiment of the present application also provides a control device, including a processor and a storage medium for storing a computer program; wherein the processor is used to execute at least the method described above when executing the computer program.
[0108] An embodiment of the present application also provides a storage medium for storing a computer program, which at least performs the method described above when executed.
[0109] An embodiment of the present application further provides a processor, which executes a computer program and at least performs the method described above.
[0110] The storage medium may be implemented by any type of volatile or non-volatile storage device, or a combination thereof. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory may be a disk memory or a tape memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAMEnhanced Synchronous Dynamic Random Access Memory), synchronous link dynamic random access memory (SLDRAM), direct memory bus random access memory (DRRAM). The storage media described in the embodiments of the present invention are intended to include, but are not limited to, these and any other suitable types of memory.
[0111] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0112] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0113] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0114] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.
[0115] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0116] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0117] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0118] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0119] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art of the present invention, several equivalent substitutions or obvious variations can be made without departing from the concept of the present invention, and the performance or use is the same, which should be regarded as belonging to the protection scope of the present invention.
Claims
1. A method for generating task-based dialogue sentence responses based on deep learning, characterized in that: The steps include: S1: construct a neural network model, wherein the neural network model includes a sentence planner and a segment generator, wherein the sentence planner is used to generate a skeleton of a reply sentence, and the segment generator is used to generate a reply sentence; S2: training the sentence planner and the segmentation generator of the neural network model through the dialogue actions and corresponding reply sentences in the training set to obtain a trained neural network model; S3: using the trained neural network model to automatically generate a reply statement with a given dialogue action as input; Training the sentence planner and the segment generator of the neural network model comprises the following steps: S21: Using a vocabulary masking technique to replace specific values in all text data with corresponding slot names in the dialogue action, the dialogue action after vocabulary masking is passed through the sentence planner to obtain a skeleton of a reply sentence, which includes the dialogue action and a series of semantically sorted slots; S22: the segmentation generator gradually generates text segments between two keywords in an autoregressive manner within the skeleton of the reply sentence, and the process is performed from left to right until the entire reply sentence is completely generated; Obtaining the skeleton of the reply sentence includes the following steps: The specific values in all text data in the dialogue action are replaced with the corresponding slot names in the dialogue action by using the vocabulary masking technology. 0 ={x0,x1,...,x T } is defined as the skeleton of the reply sentence generated by the sentence planner based on the input dialogue action; Among them, x0 is the lexical token of the action type of the dialogue action, which controls the discourse style of the entire reply sentence, x1,...,x T Each of is a lexical token representing a specific slot in the dialogue act; Generating the entire reply statement includes the following steps: The text between two keywords in the skeleton of the reply sentence is replaced with the symbol @ from right to left step by step, and a global information and a corresponding triple are obtained as the input of the segmentation generator in each stage; wherein the symbol @ is used to clearly indicate the specific location of text generation; Model a K-stage progressive sequence S: S = {X 0 ,X 1 ,...,X K }; for k∈{0,...,K-1}, X K-1 Is to get X K A small fragment of text is generated for a reply at each stage until the whole sentence is completed, where the value of K is the same as the number of keywords in the dialogue action; The global information and triples at each stage are respectively passed through the global information encoder and triple encoder to obtain the neural network hidden representation matrix of the two; The neural network hidden representation matrix is fused, and the size of the fused information matrix is the same as the output of the triple encoder, which is sent to the decoder to obtain the text fragment of this stage. This process is repeated for each stage, so as to recursively obtain the reply sentence template, that is, X K ; The slot values in the template of the reply statement are replaced with the corresponding values in the dialogue action to obtain a final reply statement.
2. The method for generating task-based dialogue sentence responses based on deep learning according to claim 1, characterized in that: In the case where there is no text to be generated between the two keywords, the vocabulary token [None] is used as the generation label for this stage.
3. The method for generating task-based dialogue sentence responses based on deep learning according to claim 1, characterized in that: The multi-head attention mechanism is used to fuse the neural network hidden representation matrix, which is expressed as follows: a=MultiHead(Enc tri (t),Enc glo (g),Enc glo (g)) Among them, t and g represent triples and global information respectively, and the calculation result a will be passed to the decoder.
4. The method for generating task-based dialogue sentence responses based on deep learning according to claim 1, characterized in that: The following steps are also included: Using the triples as keywords for information retrieval, searching for corresponding text fragments in a retrieval material library constructed based on the training set to form a text fragment set; A retrieval encoder is introduced into the retriever, denoted as Enc mem , used to map each text in the retrieved text segment set to its hidden representation, combined with the first encoding vector of the global information, and encoded and further scored by the retrieval encoder; The first M retrieved text segments send their collaborative scoring scores to the decoder to assist in decoding the text segment at the current stage; Wherein, M is a preset integer.
5. The method for generating task-based dialogue sentence responses based on deep learning according to claim 4, characterized in that: The lth text segment z in the text segment set l The correlation score with the current global information is obtained by the following formula: S l =Sigmoid(Linear(g v ;z lv )) in; represents vector concatenation, g v and z lv EnC glo (g) and Enc mem (z l ) at the hidden representation of the "[start]" lexical token; At each time step t, the generated text sequence of this stage is recorded as y 1:t-1 , the decoder uses the calculation results a and y at the same time l:t-1 To generate a hidden state h t , then t It will be transformed into a probability distribution covering the vocabulary through a linear mapping and Softmax function: P v =Softmax(W v ·h t +b v ) From {Enc mem (z i )} to extract a semantic embedding vector set Among them, z i is one of the M text segments retrieved, L i is the length of this text fragment; The cross attention covering all retrieved text segments is calculated as: Among them, α i,j Yes i The attention score for the jth vocabulary token in , c t is a weighted fusion of the lexical tokens in the retrieved utterance, s i Yes i The correlation score of , β is a trainable scalar used to control the influence of the bias score on the attention score, W m and W c These are all trainable parameters.
6. The method for generating task-based dialogue sentence responses based on deep learning according to claim 4, characterized in that: The attention score is also considered as the probability of directly copying its corresponding vocabulary token during generation, and the final vocabulary probability at this time step is calculated as: Where I is the indicator function, λ t is a gating probability calculated by the Feed-Forward network: λ t =FeedForward(h t ,c t )。 7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
