A method and system for generating dialogue based on bidirectional asynchronous sequence

Through the dialogue generation method of bidirectional asynchronous sequence, the answer text is generated by combining the reverse decoder and the forward encoder, and the penalty weight calculation is used to cut the meaningless content, which solves the problem of meaningless sentences and insufficient knowledge information in the existing technology, and improves the efficiency Quality and relevance of conversation generation.

CN114492464BActive Publication Date: 2024-10-29ZHEJIANG UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202210083371.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-25
Publication Date
2024-10-29
Estimated Expiration
2042-01-25

AI Technical Summary

Technical Problem

Existing data-driven neural network dialogue generation models tend to generate meaningless sentences, and the encoder cannot capture enough knowledge information. Moreover, due to the complexity of human language, the quality of probabilistic expression generation is difficult to meet the requirements of language semantics.

Method used

A bidirectional asynchronous sequence dialogue generation method is used to generate the first half and second half of the answer text through a reverse decoder and a forward encoder, and the meaningless repeated words in the answer text are trimmed through penalty weight calculation to improve the quality of the answer text.

Benefits of technology

The generated answer text has higher relevance and quality, avoids the occurrence of meaningless sentences, and improves the richness and grammatical quality of the output results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114492464B_ABST
    Figure CN114492464B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for generating a dialogue based on a two-way asynchronous sequence, comprising: S1 obtaining a dialogue text, identifying keywords in the dialogue text, and generating a word vector corresponding to the keyword; S2 generating a sentence vector of the dialogue text based on the word vector obtained in S1; S3 calculating the similarity between the sentence vector of the dialogue text obtained in S2 and the sentence vector of a sample question in a knowledge question and answer database, generating an answer set including multiple candidate answers and the word vector corresponding to the candidate answers; S4 obtaining an initial answer text based on the answer set generated in S3 and the corresponding word vector through a two-way asynchronous sequence algorithm; S5 correcting the initial answer text and outputting a final answer text. The present invention also provides a system for implementing the above method. The answer text generated by the method of the present invention is accompanied by more extended content, and the problem of repeated words is avoided by the correction algorithm, further improving the quality of the answer text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of artificial intelligence, neural networks and natural language processing, and in particular to a dialogue generation method and system based on a bidirectional asynchronous sequence. Background Art

[0002] Human-computer dialogue has always been a hot research field in natural language processing. Diversity and uncertainty are key factors that make human-computer dialogue more "real". Thanks to the development of neural networks, data-driven generative dialogue models have shown great potential in flexibility and interactive freedom.

[0003] Before the widespread application of neural networks, the main methods for dialogue generation tasks relied on statistical methods and retrieval methods, which were not only limited to specific fields, but also required artificially set rules for guidance in most tasks. After the emergence of neural networks, especially the widespread application of convolutional neural networks in the field of image processing and the excellent results of recurrent neural networks in the field of text processing, the use of neural networks for dialogue generation has also become a hot research project. Compared with traditional statistical methods, retrieval methods, and specified rule methods, the use of neural networks for dialogue generation is less restricted, can be learned on any data set, and can achieve excellent results after full fitting. Even if a specific field data set is used, or the data set contains a lot of noise, the neural network model can still fully extract knowledge from the data set. And with the development and open source of various deep learning frameworks, neural network models have become easier to write, further promoting the trend of using neural network models for dialogue generation.

[0004] However, the performance of existing data-driven neural network dialogue generation models is not good, mainly due to three problems:

[0005] (1) The model prefers meaningless safe general sentences, such as "something" and "I don't know". These responses are reasonable, but contain almost no valuable knowledge information. The reason for this is that the decoder tends to choose to generate a safe response with the maximum estimated probability by using beam search.

[0006] (2) The encoder cannot capture enough knowledge information to provide to the decoder for decoding.

[0007] (3) Due to the complexity of human languages, the quality of probabilistic generation is usually difficult to meet the requirements of language semantics.

[0008] Patent document CN113705255A discloses a corpus translation method, device and electronic device, wherein the method includes: a first neural network model performs a first corpus translation processing task on a corpus sample, and obtains a first corpus translation result generated based on the preamble of the corpus sample; a second neural network model performs a second corpus translation processing task on the corpus sample, and obtains a second corpus translation result generated based on a context word set of the corpus sample, and finally generates a translation sentence based on the two translation results. The method translates the same sentence, and after recognition by different neural networks, fills the translation sentence in a manner similar to cloze. The method can ensure that the output translation sentence is richer in content, but the two networks are not related to each other, resulting in a low correlation between the generated first corpus translation result and the second corpus translation result, and the two contents may be completely unrelated, making the entire translation sentence meaningless.

[0009] Patent document CN111782788A discloses a method for generating emotional responses for an open domain dialogue system, including preprocessing the input and response sentences of each sample in the corpus based on a word embedding table and a VAD emotional dictionary to obtain a word embedding sequence and an emotional embedding sequence of the input and response; concatenating the word embedding and the emotional embedding to expand the word embedding and introduce the emotional distribution information of the response to the model, introducing the emotional distribution information of the response to the model by the concatenated sequence, encoding the concatenated sequence in the encoder to obtain a semantic representation vector containing emotional information for the input and response; finally, predicting the approximation of the conditional prior distribution and the posterior distribution through the semantic representation vector and sampling latent variables, and reconstructing the emotional distribution of the response and response through the latent variables. The method generates multiple responses through sampling probability, and generates emotional response sentences based on the model and the VAD dictionary. The method can only identify the response sentence corresponding to the input for the question sentence, and the output response sentence may have repeated words in the output sentence because the sampling results are too similar. Summary of the invention

[0010] In order to solve the above problems, the present invention provides a dialogue generation method based on a bidirectional asynchronous sequence, which generates a first half answer text and a second half answer text with a certain degree of correlation through a reverse decoder and a forward encoder, thereby avoiding meaningless sentences; further, a penalty weight calculation method is used to trim meaningless repeated words in the answer text, thereby improving the quality of the answer text.

[0011] A method for generating a dialogue based on a bidirectional asynchronous sequence, comprising:

[0012] S1 obtains the conversation text, identifies the keywords in the conversation text, and generates word vectors corresponding to the keywords;

[0013] S2 generates sentence vectors of the conversation text based on the word vectors obtained in S1;

[0014] S3 calculates the similarity between the sentence vector of the dialogue text obtained in S2 and the sentence vector of the sample question in the knowledge question-answering database, and generates an answer set including multiple candidate answers and word vectors corresponding to the candidate answers, wherein the number of candidate answers is manually set. The higher the number, the richer the relevant information of the final output content, and the smaller the number, the more consistent the final output content is with the semantics of the dialogue text;

[0015] S4 obtains the initial answer text through a bidirectional asynchronous sequence algorithm based on the candidate answers and corresponding word vectors in the answer set obtained by S3;

[0016] S5 modifies the initial answer text and outputs the final answer text.

[0017] Preferably, S2 specifically includes:

[0018] S2.1 converts the keyword word vector into a word vector matrix;

[0019] S2.2 generates the hidden vector corresponding to each keyword through the Bi-LSTM network;

[0020] S2.3 links the hidden vectors of all keywords to obtain the sentence vector of the corresponding dialogue text.

[0021] Preferably, the knowledge question and answer base in S3 is a triplet of input sample questions and corresponding candidate answers, which is obtained by training a two-layer Bi-LSTM network.

[0022] Through recognition and training of the same type of neural network, the final output results are more consistent with the pre-training content.

[0023] Preferably, the S4 bidirectional asynchronous sequence algorithm decodes the candidate answers and corresponding word vectors in the answer set based on a reverse decoder and a forward decoder.

[0024] Preferably, the reverse decoder and the forward decoder decode the candidate answers and the corresponding word vectors in the answer set, specifically:

[0025] S4.1 Select the candidate answer with the highest similarity from the answer set as the starting word;

[0026] S4.2 generates the first half of the answer text in reverse order through the reverse decoder based on the starting word and the corresponding word vector;

[0027] S4.3 After flipping the first half of the answer text, identify and obtain the sentence vector of the first half of the answer text;

[0028] S4.4 calculates the similarity between the sentence vector obtained in S4.3 and the sentence vector of the sample question in the knowledge question and answer database again to obtain the corresponding answer set;

[0029] S4.5 generates the second half of the answer text through a forward decoder based on the semantic information of the first half of the answer text and the word vectors of the candidate answers in the answer set obtained in S4.4;

[0030] S4.6 links the sentence vectors of the first half of the answer text and the second half of the answer text to obtain the initial answer text.

[0031] Based on the semantic information of the first half of the answer text, the generated second half of the answer text has a higher correlation with the first half of the answer text, and the effective content of the generated initial answer text is richer.

[0032] Preferably, the initial answer text is corrected in S5 by detecting the number of occurrences of word vectors of words or \ and short sentences, and the text is corrected after penalty weight calculation, thereby improving the quality of the output result by cutting out meaningless content in the initial answer text.

[0033] Preferably, the penalty weight calculation is specifically as follows:

[0034]

[0035] Where N is the length of the detected repetitive interval, s t is the generated response corresponding to time t, x i is the generated preposition vector, p(s t |x i ) is s t In the generated x i The generation probability under the condition is output trimming for words or short sentences that appear more than 3 times.

[0036] The present invention also provides a system based on the above method, which can output high-quality reply text with extended knowledge information by simply inputting dialogue questions.

[0037] A system for implementing the above-mentioned dialogue generation method comprises:

[0038] Input module, used to obtain the dialogue text;

[0039] The knowledge question-answering module generates a corresponding answer set based on the acquired dialogue text;

[0040] The dialogue generation module generates the initial answer text based on the semantic information of the dialogue text and the corresponding answer set;

[0041] A correction module is used to trim and correct repeated words in the initial answer text;

[0042] The output module is used to output the corrected answer text.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] (1) The present invention takes keywords as the core and adopts a forward and reverse asynchronous generation method to generate reply text, which is different from the traditional Seq2Seq sequential generation, thereby avoiding the occurrence of invalid content.

[0045] (2) The present invention provides a repeated detection penalty weight calculation in the dialogue generation method, which solves the problem of repeated words and improves the grammatical quality of the generated sentences. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 A flow chart of the dialogue generation method provided by the present invention;

[0047] Figure 2 A schematic diagram of the system structure for implementing the dialogue generation method provided by the present invention. DETAILED DESCRIPTION

[0048] Build a knowledge question-answering database: First, prepare a set of sample questions and corresponding candidate answer knowledge triples, and learn the representation of sample questions through a two-layer Bi-LSTM network: the first layer obtains the word vector of the sample question keyword, and obtains the corresponding sentence vector through a simple word vector matrix link The second floor Based on this, the second layer hidden representation is calculated

[0049] The hidden state γ at time step t t Updated to:

[0050] o t =σ(W o [γ t-1 ,q t ]+b o )

[0051] γ t =o t *tanh(C t )

[0052] Among them, γ t-1 is the hidden state at the previous moment, q t is the input word at the current moment, C t is the neuron state at the current moment, b o is a constant term.

[0053] Then link each and get:

[0054]

[0055] Then, and After a maximum pooling layer, and Get the sentence vector of the final input question text:

[0056]

[0057] The final sentence vector representation of the input question sentence is:

[0058] h=[h1,h2,…,h n ]

[0059] The candidate answer sequence is processed through the Word2vec model to obtain the weight vector matrix E in the hidden layer ω , use E ω Convert candidate answer sequences into word vectors Where m is the length of the candidate answer.

[0060] Word vector based on candidate answer sequence Perform formal unification for subsequent model training and calculate the average embedding as the word vector of the candidate answer:

[0061]

[0062] Use the TransH model to pre-train all relations in the knowledge base to obtain the relation vector e i , the objective function L is:

[0063]

[0064]

[0065]

[0066]

[0067] Among them, r is each relationship vector, h and t are the head entity and tail entity associated with it, respectively, and w r is the hyperplane parameter obtained through training, γ is the marginal hyperparameter, and h ⊥ ,t ⊥ is the projection of h,t on the hyperplane.

[0068] The relationship vector ei The relational adapter of the two-layer Bi-LSTM network is input to obtain the intermediate vector, which is then extracted through the BERT layer. The relational vector r of the specified dimension P is calculated through the pooling layer. p :

[0069] r p =MAX_Pooling(BERT(Adapter(e i )),p)

[0070] Repeat the above process to get the final word vector for each candidate answer:

[0071] a=a ω +r p

[0072] Use a multilayer perceptron to calculate the sentence vector h of the sample question i And the word vector a of the candidate answer j The semantic similarity between:

[0073] R(h i ,a j )=MLP([h i ,a j ])

[0074] The hinge loss function is used for training to distinguish positive and negative samples of the relationship. The objective function L h,a for:

[0075] L h,a =∑max(0,γ-cos(h,a + )+cos(h,a - ))

[0076] Among them, γ is the marginal hyperparameter, a + is a positive sample, a - is a negative sample, and cos(h,a) is the cosine similarity.

[0077] Finally, after integrating the semantic relationship between all sample questions and the corresponding candidate answers, the knowledge question and answer database is constructed.

[0078] like Figure 1 As shown in the figure, a method for generating dialogue based on bidirectional asynchronous sequence:

[0079] S1 obtains the conversation text, identifies the keywords in the conversation text, and generates word vectors corresponding to the keywords;

[0080] S2 generates the sentence vector of the dialogue text based on the word vector obtained in S1, specifically:

[0081] S2.1 converts the keyword word vector into a word vector matrix;

[0082] S2.2 generates the hidden vector corresponding to each keyword through the Bi-LSTM network;

[0083] S2.3 links the hidden vectors of all keywords to obtain the sentence vector of the corresponding dialogue text;

[0084] Update the hidden state of the dialogue text by

[0085]

[0086]

[0087]

[0088] Will and Link them together to get the final sentence vector of the input dialogue text:

[0089]

[0090] S3 calculates the similarity between the sentence vector of the dialogue text obtained in S2 and the sentence vector of the sample question in the knowledge question and answer database, and generates an answer set including multiple candidate answers and the word vectors corresponding to the candidate answers, among which the top K candidate answers with the highest similarity are selected to form the answer set:

[0091]

[0092] where a j is the word vector of the jth relevant candidate knowledge, h i ′ is the sentence vector of the dialogue text, c ad is the knowledge relevance vector of the candidate answers in the answer set.

[0093] S4 obtains the initial answer text through a bidirectional asynchronous sequence algorithm based on the candidate answers and corresponding word vectors in the answer set obtained by S3;

[0094] S4.1 Select the candidate answer with the highest similarity from the answer set as the starting word;

[0095] S4.2 generates the first half of the answer text in reverse order through the reverse decoder based on the starting word and the corresponding word vector:

[0096] Update the hidden state at time step t where e bw is the word vector of the starting word, C t-1 is the context vector of the previous time step.

[0097] By calculating the probability of replying the first half of the sequence:

[0098]

[0099] where r k is the starting word, and the first half of the answer text sequence before the start is generated in reverse order (r k-1 ,r k-2 ,…,r1).

[0100] S4.3 After flipping the first half of the answer text, identify and obtain the sentence vector of the first half of the answer text;

[0101] S4.4 calculates the similarity between the sentence vector obtained in S4.3 and the sentence vector of the sample question in the knowledge question and answer database again to obtain the corresponding answer set:

[0102] The top K candidate answers with the highest similarity are selected to form the answer set:

[0103]

[0104] where a j is the word vector of the jth relevant candidate knowledge, h i ″ is the sentence vector of the first half of the answer text, c ab is the knowledge relevance vector of the candidate answers in the answer set;

[0105] S4.5 generates the second half of the answer text through the forward decoder based on the semantic information of the first half of the answer text and the word vectors of the candidate answers in the answer set obtained in S4.4:

[0106] Filter out the candidate answer word vector with the highest similarity as the starting word vector e fw ;

[0107] Update the hidden state at time step t

[0108] Among them C t-1 is the context vector of the previous time step.

[0109] Calculated by the probability of generating a sequence:

[0110]

[0111] Generate the second half of the answer text sequence.

[0112] S4.6 links the sentence vectors of the first half of the answer text and the second half of the answer text to obtain the initial answer text.

[0113] S5 modifies the initial answer text and outputs the final answer text:

[0114] During the generation process, if the word vector expression of a word or phrase is detected to have more than two repetitions with the three generated parts before it, a penalty weight is assigned to it to reduce the possibility of its generation. The penalty weight is calculated as:

[0115]

[0116] Where N is the length of the detected repetitive interval, s t is the generated reply content corresponding to time t, x i is the generated preposition vector, p(s t |x i ) is s t In the generated x i The probability of generation under the condition.

[0117] The generated results are tested once, and the output is trimmed if there are more than three repetitions, so as to ensure the quality of the final output results to the greatest extent.

[0118] like Figure 2 As shown, a system for implementing the above-mentioned dialogue generation method includes:

[0119] Input module, used to obtain the conversation text;

[0120] The knowledge question-answering module generates a corresponding answer set based on the acquired dialogue text;

[0121] The dialogue generation module generates the initial answer text based on the semantic information of the dialogue text and the corresponding answer set;

[0122] A correction module is used to trim and correct repeated words in the initial answer text;

[0123] The output module is used to output the corrected answer text.

[0124] The present invention is tested on the Reddit conversation dataset. In order to objectively evaluate the performance of the algorithm, the present invention uses the weighted sum of the two evaluation criteria, automatic evaluation and manual evaluation, to evaluate the generation effect in the selected test set, where the automatic evaluation indicators include: BLEU, perplexity and entity score.

[0125] Manual evaluation indicators include language level and knowledge level, and the scoring criteria for the language level are:

[0126] Generating a reply sentence - not fluent - grammatically incorrect, the score is 0;

[0127] Generating a reply sentence - incoherent - grammatically correct, the score is 1 point;

[0128] Generating a reply sentence - fluent - grammatically ambiguous, the score is 2 points;

[0129] Generate a reply sentence that is fluent and grammatically correct, and score 3 points.

[0130] The average of the evaluation results at the language level is taken as the final score at the language level. A score greater than 1 indicates that the generated result is acceptable at the language level, and a score greater than 2 indicates that the generated result is good at the language level.

[0131] The scoring criteria for the knowledge level are:

[0132] Generate a reply sentence - no relevant extension content is introduced at all, and the score is 0;

[0133] Generate a reply sentence - introduce some extended content, score 1 point;

[0134] Generate a response sentence - introduce all relevant extension content - low relevance, score 2 points;

[0135] Generate a response statement - introduce all relevant extension content - high relevance, score 3 points.

[0136] The mean of the evaluation results at the knowledge level is counted as the final score at the knowledge level. A score greater than 1 indicates that the generated result successfully introduces the extended content, and a score greater than 2 indicates that the generated result successfully and accurately introduces all relevant extended content.

[0137] The final test results are shown in the following table:

[0138]

[0139] The automatic evaluation results show that the problem of repeated words in the dialogue content generated by this method has been well solved, that is, the BLEU value is less than 1; at the same time, the dialogue generation system provided by the present invention has a perplexity of only 38.77 compared with similar models, and the quality of generated dialogue is better than the existing model; the manual evaluation results show that the dialogue content generated by this method has a relatively high score at the language level or the knowledge level, and the mean is greater than 2, which proves that this method has certain advantages over traditional dialogue generation methods.

Claims

1. A method for generating a dialogue based on a two-way asynchronous sequence, characterized in that: include: S1 obtains the conversation text, identifies the keywords in the conversation text, and generates word vectors corresponding to the keywords; S2 generates the sentence vector of the dialogue text based on the word vector obtained in S1, which is as follows: S2.1 converts the keyword word vector into a word vector matrix; S2.2 generates the hidden vector corresponding to each keyword through the Bi-LSTM network; S2.3 links the hidden vectors of all keywords to obtain the sentence vector of the corresponding dialogue text; S3 calculates the similarity between the sentence vector of the dialogue text obtained in S2 and the sentence vector of the sample question in the knowledge question and answer database, and generates an answer set including multiple candidate answers and word vectors corresponding to the candidate answers, wherein the knowledge question and answer database is a triple of input sample questions and corresponding candidate answers, which is obtained by training a two-layer Bi-LSTM network; S4 obtains the initial answer text based on the candidate answers and the corresponding word vectors in the answer set obtained in S3 through a bidirectional asynchronous sequence algorithm. The bidirectional asynchronous sequence algorithm is based on a reverse decoder and a forward decoder to decode the candidate answers and the corresponding word vectors in the answer set, specifically: S4.1 Select the candidate answer with the highest similarity from the answer set as the starting word; S4.2 generates the first half of the answer text in reverse order through the reverse decoder based on the starting word and the corresponding word vector; S4.3 After flipping the first half of the answer text, identify and obtain the sentence vector of the first half of the answer text; S4.4 calculates the similarity between the sentence vector obtained in S4.3 and the sentence vector of the sample question in the knowledge question and answer database again to obtain the corresponding answer set; S4.5 generates the second half of the answer text through a forward decoder based on the semantic information of the first half of the answer text and the word vectors of the candidate answers in the answer set obtained in S4.4; S4.6 links the sentence vectors of the first half of the answer text and the second half of the answer text to obtain an initial answer text; S5 modifies the initial answer text and outputs the final answer text. The initial answer text is modified by detecting the number of occurrences of word vectors of words or short sentences and modifying the text after penalty weight calculation. Specifically, it is as follows: Where N is the length of the detected repetitive interval, s t is the generated response corresponding to time t, x i is the generated preposition vector, p(s t |x i ) is s t In the generated x i The generation probability under the condition is output trimming for words or short sentences that appear more than 3 times.

2. A system for implementing the dialog generation method according to claim 1, characterized in that: include: Input module, used to obtain the dialogue text; The knowledge question-answering module generates a corresponding answer set based on the acquired dialogue text; The dialogue generation module generates the initial answer text based on the semantic information of the dialogue text and the corresponding answer set; A correction module is used to trim and correct repeated words in the initial answer text; The output module is used to output the corrected answer text.

Citation Information

Patent Citations

  • Emotion reply automatic generation method for open domain dialogue system

    CN111782788A

  • Corpus translation method and device and electronic equipment

    CN113705255A

  • Missing semantic information complementing method and device, computer equipment and storage medium

    CN108334487A

  • Large group interactions via mass communication network

    CN1427969A

  • Contextual and intent based natural language processing system and method

    US10943072B1