A one-to-many dialogue generation method and device based on semantic perception

By introducing a semantic perception mechanism into the dialogue generation model, identifying the emotions of the input statements and selecting the appropriate decoder, the problem of traditional models generating high-frequency meaningless replies is solved, and personalized, high-quality and diverse dialogue generation is achieved. Improved user experience.

CN114416948BActive Publication Date: 2024-12-17ZHUHAI DADI SOFTWARE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210052665.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-18
Publication Date
2024-12-17
Estimated Expiration
2042-01-18

AI Technical Summary

Technical Problem

The traditional open field dialogue generation model cannot effectively capture the hidden characteristics of different emotions, resulting in high-frequency meaningless replies generated and poor user experience.

Method used

Using a one-to-many dialogue generation method based on semantic perception, by introducing recognition networks and classifiers, identifying the emotions or actions of input statements, selecting decoders of different categories, forcing the hidden space features to decouple into subspaces of different semantic classes, thus Generate personalized, high-quality, and diverse text.

Benefits of technology

By identifying and selecting the appropriate decoder, more personalized, high-quality, interpretable and diverse conversations are generated, improving the interpretability and user experience of text generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416948B_ABST
    Figure CN114416948B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of dialogue systems, and in particular to a one-to-many dialogue generation method and device based on semantic perception, comprising obtaining real-time input questions and sending them into a trained dialogue generation model, wherein the dialogue generation model obtains diverse replies according to the input questions, and the dialogue generation model comprises an input encoder, an output encoder, a recognition network, a priori network, a classifier, a no emotion decoder, a positive decoder, and a negative decoder; the model of the present invention is divided into two training processes, namely, pre-training and training; the present invention introduces a controllable variable capable of identifying the emotion or action of a dialogue into the model, selects decoders of different categories through the controllable variable, and forces latent space features to be decoupled into subspaces of different semantic categories during the training process, so that dialogues of the same semantic category can be mapped to similar positions in the latent space, thereby generating personalized, high-quality, interpretable, and diverse texts.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of dialogue systems, and in particular to a one-to-many dialogue generation method and device based on semantic perception. Background Art

[0002] Dialogue systems are mainly divided into task-oriented dialogue systems and open dialogue systems. With the rapid development of neural networks in recent years, dialogue systems have gradually shifted from early statistical language model models to generative models based on deep sequence models.

[0003] Although generative models improve the performance of open dialogue systems, such black-box models still have problems with low credibility of prediction results and poor interpretability. To address the above problems, existing technologies use unsupervised models to generate more interpretable and controllable dialogues, and then propose a prior model that couples dense vectors and symbolic vectors based on latent space energy. Then, an exponential mixture distribution is introduced to capture the hidden semantic relationship between the mixed components and the data, resulting in a more interpretable latent space. However, the above dialogue model still cannot effectively capture the different generation logics of the decoder for the latent features of different emotions, and cannot solve the problem of the singleness of the decoder's responses. Therefore, when conducting human-computer dialogues, high-frequency meaningless responses are generated, resulting in a poor user experience. Summary of the invention

[0004] In order to solve the problem that different emotional actions are mixed together in the traditional open-domain dialogue generation model, which tends to generate high-frequency meaningless replies. The present invention provides a one-to-many dialogue generation method based on semantic perception, which obtains real-time input questions and feeds the real-time input questions into a trained dialogue generation model. The dialogue generation model obtains diverse replies based on the input questions. The dialogue generation model includes an input encoder, an output encoder, a recognition network, a priori network, a classifier, a no emotion decoder, a positive decoder, and a negative decoder.

[0005] The training process of the dialogue generation model includes two processes: pre-training and training, which are specifically expressed as follows:

[0006] 101. Obtain multiple groups of dialogue samples to pre-train the input encoder, output encoder, recognition network, prior network, classifier, and pre-trained decoder. The pre-training process includes:

[0007] S11. Preprocess multiple groups of dialogue samples, each group of dialogue samples includes questions, replies and sentiment labels of the questions;

[0008] S12. extract a group of dialogue samples from the multiple groups of preprocessed dialogue samples, and send the preprocessed questions and replies in the dialogue samples to the input encoder and the output encoder for encoding, respectively, to obtain a question vector representation and a reply vector representation;

[0009] S13. Send the problem vector representation into the prior network to obtain the parameters of the prior distribution, send the reply vector representation into the recognition network to obtain the parameters of the approximate posterior distribution, calculate the KL divergence of the prior distribution and the approximate posterior distribution, and calculate the KL divergence loss;

[0010] S14. Obtain latent variables based on the parameters of the approximate posterior distribution, input the latent variables into the classifier to calculate the normalized probability that the current dialogue sample belongs to each category, take the category with the largest normalized probability as the classification result, and calculate the classification loss;

[0011] S15. Using the hidden variable as the initial state of the pre-trained decoder, inputting the reply into the pre-trained decoder to obtain the output result, and calculating the reconstruction expected loss based on the output result;

[0012] S16. Add the KL divergence loss, classification loss, and reconstruction expectation loss, and update the parameters of the dialogue generation model through gradient back propagation. After the parameters are updated, return to step S12 for iteration until the parameters converge to complete the pre-training of the dialogue generation model.

[0013] 102. After completing the pre-training, fix the parameters of the input encoder, output encoder, recognition network, prior network and classifier, and divide the dialogue samples into three types of dialogue data according to no emotion, positive emotion and negative emotion, which are used for no emotion decoder, positive decoder and negative decoder respectively. Use the reconstruction loss function to train the three decoders in turn until the parameters of the three decoders converge to complete the training of the dialogue generation model.

[0014] Furthermore, Word2vec is used to preprocess multiple groups of dialogue samples, including obtaining the question word embedding sequence {e(C1), e(C2), ..., e(C n )} and the reply word embedding sequence {e(X1),e(X2),...,(X n )}, e(·) represents the word embedding of the words in the dialogue sample, {C1,C2,...,C n} is the question in the dialogue sample, {X1,X2,...,X n} is the response in the dialogue sample.

[0015] Furthermore, the formula for calculating KL divergence is:

[0016]

[0017] Among them, μ and σ are the parameters of the approximate posterior distribution, μ' and σ' are the parameters of the prior distribution, dz is the dimension of the latent variable, and q φ represents the approximate posterior distribution, represents the prior distribution, and j represents the current number of dimensions.

[0018] Furthermore, in step S14, the latent variables are obtained by reparameterization according to the parameters of the approximate posterior distribution, and the reparameterization is expressed as:

[0019] z=μ+σε;

[0020] Among them, ε is sampled from the standard Gaussian distribution, z is the latent variable, and μ and σ are the Gaussian distribution parameters of the approximate posterior distribution.

[0021] Furthermore, in step S15, the hidden variable is converted into a tensor of the same dimension as the pre-trained decoder through a multi-layer perceptron mlp, so as to be used as the initialization hidden state h0 and the initialization cell state c0 of the pre-trained decoder.

[0022] Furthermore, the pre-training loss function composed of KL divergence loss, classification loss and reconstruction expectation loss in step S16 is:

[0023]

[0024] Among them, -E qφ(z|X,C) [·] represents the reconstruction expectation loss, KL(·) represents the KL divergence loss, NLLLoss(·) represents the classification loss, X represents the reply, C represents the question, z represents the latent variable, label represents the emotion label of the question, P(E) represents the normalized probability that the current dialogue sample belongs to each category, P θ (X|z,C) represents the conditional probability distribution, q φ (z|X,C) represents the approximate posterior distribution, represents the prior distribution, φ, θ is the parameter of the probability distribution.

[0025] Furthermore, the normalized probability P(E) is obtained through the classifier. The classifier includes a multi-layer perceptron and a softmax layer. The hidden variable is the input of the multi-layer perceptron. The output of the multi-layer perceptron is used as the input of the softmax layer. The output of the softmax layer is P(E), which is expressed as:

[0026] p(E) = Clf(z);

[0027] Clf(z)=softmax(o);

[0028] o = MLP(z);

[0029] Among them, Clf(·) represents the classifier, MLP(·) represents the multi-layer perceptron, softmax(·) represents the softmax layer, and o represents the output of the multi-layer perceptron.

[0030] A one-to-many dialogue generation device based on semantic perception, comprising:

[0031] An acquisition module is used to acquire input sentences in real time;

[0032] An encoder module, used to encode the input sentence of the acquisition module to obtain a vector representation of the input sentence;

[0033] The recognition module is used to fit the vector representation obtained by the encoder module to obtain latent variables containing dialogue category information;

[0034] A classification module, used to determine the semantic classification result of the input sentence according to the latent variables;

[0035] The generation module is used to determine the corresponding decoder according to the semantic classification result and generate a corresponding semantic response according to the decoder.

[0036] Beneficial effects of the present invention:

[0037] The present invention introduces a controllable variable that can identify the emotion or action of the conversation into the model. The controllable variable is used to select decoders of different categories and force the latent space features to be decoupled into subspaces of different semantic categories during the training process, so that conversations of the same semantic category can be mapped to similar positions in the latent space, thereby generating personalized, high-quality, interpretable and diverse texts.

[0038] The dialogue generation model constructed by the present invention selects a decoder through the results of a classifier, and is better than other decoder models that use only a single type of decoder or pre-training in terms of various indicators of text generation quality. The model of the present invention can generate higher quality and more diverse dialogues. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 Generate a model structure diagram for the dialogue of the present invention;

[0040] Figure 2 Visual results of latent variables for datasets with sentiment labels;

[0041] Figure 3 Visual results of latent variables for datasets with behavioral labels. DETAILED DESCRIPTION

[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0043] A semantically aware open-domain one-to-many dialogue generation method is proposed based on the optimization scheme SCVAE proposed by the conditional variational autoencoder (CVAE). By introducing an explicit controllable variable to force the latent space to decouple, different categories of dialogues are mapped to different positions in the latent space. The latent space is represented as a multi-dimensional Gaussian distribution separated by category. Figure 1 As shown, it includes obtaining real-time input questions, feeding the real-time input questions into the trained dialogue generation model, and the dialogue generation model obtains diverse replies based on the input questions. The dialogue generation model includes an input encoder, an output encoder, a recognition network, a priori network, a classifier, a no emotion decoder, a positive decoder, and a negative decoder.

[0044] The dialogue generation model constructed by the present invention can generate multiple different responses from a question. The multiple different responses depend on the sampling of the latent space, and the dialogue generated by each sampling is different. The role of multiple decoders is that the dialogues generated by different decoders carry different emotions, so it is called semantically aware one-to-many dialogue. The specific application process is that after the model encodes the problem, the dialogue semantics is classified, and the corresponding decoder is selected according to the classification result to generate different dialogues with corresponding semantics.

[0045] The answer text generated by the decoder during the training process has the characteristics of personalization, high quality, interpretability, and diversity. In one embodiment, the training process of the dialogue generation model includes two processes: pre-training and training, which are specifically expressed as follows:

[0046] 101. Obtain multiple groups of dialogue samples to pre-train the dialogue generation model. In the pre-training process, noemotion decoder, positive decoder, and negative decoder are not trained, and a pre-trained decoder is added. Since different types of dialogues use the same encoder and classifier during training, it is necessary to pre-train with ordinary dialogue generation tasks and classification tasks in the pre-training stage to obtain a better classifier and an encoder that can encode different semantic dialogues. The parameters of the encoder and classifier will be fixed during the training stage so that the encoder and classifier will not change during the training stage. The pre-trained decoder will not be used after pre-training, and will only be used for classification tasks in the pre-training stage.

[0047] The pre-training process includes:

[0048] S11. Preprocess multiple groups of dialogue samples, each group of dialogue samples includes questions, replies and sentiment labels of the questions;

[0049] S12. extract a group of dialogue samples from the multiple groups of preprocessed dialogue samples, and send the preprocessed questions and replies in the dialogue samples to the input encoder and the output encoder for encoding, respectively, to obtain a question vector representation and a reply vector representation;

[0050] S13. Send the problem vector representation into the prior network to obtain the parameters of the prior distribution, send the reply vector representation into the recognition network to obtain the parameters of the approximate posterior distribution, calculate the KL divergence of the prior distribution and the approximate posterior distribution, and calculate the KL divergence loss;

[0051] S14. Obtain latent variables based on the parameters of the approximate posterior distribution, input the latent variables into the classifier to calculate the normalized probability that the current dialogue sample belongs to each category, take the category with the largest normalized probability as the classification result, and calculate the classification loss;

[0052] S15. Using the hidden variable as the initial state of the pre-trained decoder, inputting the reply into the pre-trained decoder to obtain the output result, and calculating the reconstruction expected loss based on the output result;

[0053] S16. Add the KL divergence loss, classification loss, and reconstruction expectation loss, and update the parameters of the dialogue generation model through gradient back propagation. After the parameters are updated, return to step S12 for iteration until the parameters converge to complete the pre-training of the dialogue generation model.

[0054] 102. After completing the pre-training, fix the parameters of the input encoder, output encoder, recognition network, prior network and classifier, and classify the conversation samples into three categories: no emotion, positive emotion and negative emotion, which are used to train the noemotion decoder, positive decoder and negative decoder respectively.

[0055] Preferably, the training process of the no emotion decoder includes:

[0056] S21. Preprocessing the emotion-free dialogue data pairs, where the emotion-free dialogue data pairs include questions, replies, and emotion-free labels of questions;

[0057] S22. Extract one group from the plurality of groups of preprocessed emotionless dialogue data pairs, and send the emotionless dialogue data pairs in the group to the input encoder and the output encoder for encoding, respectively, to obtain a first question vector representation and a first reply vector representation;

[0058] S23. Send the first question vector representation into the prior network to obtain the first parameter of the prior distribution, and send the first reply vector representation and the first question vector representation into the recognition network to obtain the first parameter of the approximate posterior distribution;

[0059] S24. Obtain a first latent variable according to the first parameter of the approximate posterior distribution, input the first latent variable into the decoder to obtain a first output result, and calculate a first reconstruction loss according to the first output result; update the parameters of the noemotion decoder through gradient back propagation, and after the parameters are updated, return to step S22 for iteration until the parameters converge to complete the training of the no emotion decoder.

[0060] The positive emotion dialogue data includes questions, replies, and positive emotion labels of questions; the negative emotion dialogue data includes questions, replies, and negative emotion labels of questions; the positive decoder and negative decoder are trained according to the training process of the no emotion decoder.

[0061] In one embodiment, the pre-training process is a process of optimizing the input encoder, the output encoder, the recognition network, the prior network, the classifier, and the pre-trained decoder. The data used is a plurality of groups of dialogue samples with emotion labels (C, X, E), where C is the question text sequence {C1, C2, ..., C n}, X is the reply text sequence {X1,X2,...,X n}, E is the sentiment label of the question text. The label of the question text is used to generate a response corresponding to the sentiment of the question text.

[0062] Word2vec is used to embed the dialogue samples. The question word embedding sequence is represented as {e(C1), e(C2),..., e(C n )}, the reply word embedding sequence is represented as {e(X1),e(X2),...,(X n )}, e(·) represents word embedding for text words, e(X i ),e(C i )∈R D , D=300.

[0063] Both the input encoder and the output encoder are implemented using bidirectional LSTM. The input encoder embeds the question word into a dense question vector representation, and the output encoder embeds the reply word into a dense reply vector representation. After obtaining the question vector representation and the reply vector representation, they need to be fitted into Gaussian parameters of the latent space Gaussian distribution. This embodiment is implemented using two multi-layer perceptrons, namely a recognition network and a priori network.

[0064] The recognition network is used to fit the Gaussian distribution parameters μ and σ of the approximate posterior distribution, and the prior network is used to fit the Gaussian distribution parameters μ' and σ' of the prior distribution. After calculating the Gaussian parameters μ, σ, μ', and σ' of the approximate posterior distribution and the prior distribution, in order to decouple the latent space features into subspaces of different semantic categories, the Gaussian parameters are used to calculate the KL divergence of the approximate posterior distribution and the prior distribution, and the approximate posterior distribution and the prior distribution are approximated by the KL divergence. The calculation formula of the KL divergence is:

[0065]

[0066] Among them, μ and σ are the parameters of the approximate posterior distribution, μ' and σ' are the parameters of the prior distribution, dz is the dimension of the latent variable, and q φ represents the approximate posterior distribution (recognition network), represents the prior distribution (prior network), and j represents the current number of dimensions.

[0067] Because the sampling process is irreversible, direct sampling from the latent space will lead to optimization failure, so the latent variable z is reparameterized, z = μ + σε, ε is sampled from the standard Gaussian distribution; during training, the latent variable z is also sampled from the approximate posterior distribution. During testing, since the reply cannot be used and only the question can be used, the latent variable z = μ' + σ'ε is reparameterized from the prior distribution.

[0068] In the pre-training process, the latent variable z is the input of the classifier and the initial hidden state of the decoder. The classifier includes a multi-layer perceptron and a softmax layer. The latent variable is the input of the multi-layer perceptron. The output of the multi-layer perceptron is used as the input of the softmax layer. The output of the softmax layer is the normalized probability P(E) that the current dialogue sample belongs to each category, which is expressed as:

[0069] p(E) = Clf(z);

[0070] Clf(z)=softmax(o);

[0071] o = MLP(z);

[0072] Among them, Clf(·) represents the classifier, MLP(·) represents the multi-layer perceptron, softmax(·) represents the softmax layer, and o represents the output of the multi-layer perceptron.

[0073] The classifier is trained in the supervised way as above, and the trained model will map different data to different positions in the latent space according to their categories. Conversation data of the same category will be mapped to relatively close positions, and data of different categories will be mapped to farther positions.

[0074] Since the dimension of the latent variable is different from that of the decoder hidden state, the latent variable is converted into a tensor of the same dimension as the decoder through a multi-layer perceptron mlp before decoding, so as to serve as the decoder's initial hidden state h0 and initial cell state c0.

[0075] The hidden variable is used as the initial state of the pre-trained decoder. During training, the input of each unit of the decoder is the word corresponding to the reply text. During testing, the input of the first unit of the decoder is the start label <sos>(Start of sentence), the input of the next unit is the output of the previous unit until the end tag is generated <eos>(End of sentence).

[0076] Finally, the words generated by each unit of the decoder are combined in order and the start and end tags are removed to obtain the generated dialogue response.

[0077] During the pre-training process, the pre-training loss function composed of KL divergence loss, classification loss and reconstruction expectation loss is:

[0078]

[0079] Among them, -E qφ(z|X,C) [logP θ (X|z,C)] represents the expected reconstruction loss, represents KL divergence loss, NLLLoss(P(E), label) represents classification loss, X represents reply, C represents question, z represents latent variable, label represents emotion label of question, P(E) represents normalized probability that current dialogue sample belongs to each category, P θ (X|z,C) represents the conditional probability distribution, q φ (z|X,C) represents the approximate posterior distribution, represents the prior distribution, φ, θ is the parameter of the probability distribution.

[0080] The reconstruction loss function used in the training process is the reconstruction expected loss in the pre-training process, expressed as:

[0081]

[0082] X 1 Indicates the response in the dialogue sample of the category, C 1 represents the question in the dialogue sample of the category, z 1 represents the hidden variable of a decoder training process, P θ (X 1 |z 1 ,C 1 ) represents the conditional probability distribution, φ, θ is the parameter of the probability distribution.

[0083] Preferably, Figure 2 The figure below is the visual result in the latent space, which records the original distribution of the data with emotion labels in the latent space and the decoupled distribution after using the model of the present invention. This shows that the model of the present invention can encode the conversation into different positions in the latent space according to the category.

[0084] Figure 3 It is a visual result in the latent space, which records the original distribution of the data with behavior labels in the latent space and the decoupled distribution after using the model of the present invention. It shows that the model of the present invention can encode the conversation into different positions in the latent space by category.

[0085] The text generation quality of the optimized model is compared with other dialogue generation models on several evaluation indicators (BLEU, METEOR, ROUGE, Distinct-2, ACC). The indicator results are shown in Tables 1 and 2.

[0086] Table 1 is the evaluation index results with emotion labels. The table records the effect of each category of decoders (no emotion, positive, negative, and decoders during pretraining) in the model of the present invention on generating dialogues under the dataset with emotion labels, as well as the results of the model of the present invention and other models on five evaluation indicators. The model of the present invention is higher than other models in BLEU and METEOR, lower than Seq2seq and Transformer in ROUGE, and only lower than Transformer in DIST-2, indicating that the model of the present invention is superior to other models.

[0087] Table 1 Evaluation index results with sentiment labels

[0088]

[0089] Table 2 shows the evaluation index results with behavior labels. The table records the effect of each category of decoders (no emotion, positive, negative, and decoders during pretraining) in the model of the present invention in generating dialogues under the data set with behavior labels, as well as the results of the model of the present invention and other models on 5 evaluation indicators. The model of the present invention is better than other models in the evaluation indicators BLEU, METEOR, and ROUGE, and is only lower than Transformer in Dist-2. Therefore, the quality of text generation by the model of the present invention using the results of the classifier is better than other models that only use a single type of decoder or a decoder model during pretraining in terms of various indicators.

[0090] Table 2 Evaluation results with behavior labels

[0091]

[0092] The results in Tables 1 and 2 also show that the emotion and behavior labels of the conversation have a certain degree of influence on the generation of text. In terms of the three indicators based on word overlap rate, BLEU, METEOR, and ROUGE, the model of the present invention has better results, indicating that the model of the present invention can generate higher quality conversations. In terms of the Dist-2 indicator, the present invention is also better than most models, which shows that the model of the present invention can generate diverse conversations. When the model of the present invention correctly identifies the emotion and behavior labels in the conversation, it can improve the performance of the conversation reply, achieve better results, and have generalization ability.

[0093] A one-to-many dialogue generation device based on semantic perception, comprising:

[0094] An acquisition module is used to acquire input sentences in real time;

[0095] An encoder module, used to encode the input sentence of the acquisition module to obtain a vector representation of the input sentence;

[0096] The recognition module is used to fit the vector representation obtained by the encoder module to obtain latent variables containing dialogue category information;

[0097] A classification module, used to determine the semantic classification result of the input sentence according to the latent variables;

[0098] The generation module is used to determine the corresponding decoder according to the semantic classification result and generate a corresponding semantic response according to the decoder.

[0099] Specifically, the generation module selects the corresponding decoder to generate a semantically correct response based on the classification result of the input sentence. The sentences generated for the same question are different each time, because the ε in the step z = μ + σε is randomly sampled from a standard Gaussian distribution. Due to the classification task during pre-training, sentences of different categories are sampled at different locations in the latent space, such as Figure 2 As shown in the decoupled latent space distribution in Fig. 2, different categories of dialogues are encoded in different positions in the latent space.

[0100] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.< / eos> < / sos>

Claims

1. A one-to-many dialogue generation method based on semantic perception, characterized in that: Obtain real-time input questions and feed them into the trained dialogue generation model. The dialogue generation model obtains diverse responses based on the input questions. The dialogue generation model includes an input encoder, an output encoder, a recognition network, a priori network, a classifier, a no emotion decoder, a positive decoder, and a negative decoder. The training process of the dialogue generation model includes two processes: pre-training and training, which are specifically expressed as follows:

101. Obtain multiple groups of dialogue samples to pre-train the input encoder, output encoder, recognition network, prior network, classifier, and pre-trained decoder. The pre-training process includes: S11. Preprocess multiple groups of dialogue samples, each group of dialogue samples includes questions, replies, and sentiment labels of the questions; S12. extract a group of dialogue samples from the multiple groups of preprocessed dialogue samples, and send the preprocessed questions and replies in the dialogue samples to the input encoder and the output encoder for encoding, respectively, to obtain a question vector representation and a reply vector representation; S13. Send the problem vector representation into the prior network to obtain the parameters of the prior distribution, send the reply vector representation into the recognition network to obtain the parameters of the approximate posterior distribution, calculate the KL divergence of the prior distribution and the approximate posterior distribution, and calculate the KL divergence loss; S14. Obtain latent variables based on the parameters of the approximate posterior distribution, input the latent variables into the classifier to calculate the normalized probability that the current dialogue sample belongs to each category, take the category with the largest normalized probability as the classification result, and calculate the classification loss; S15. Using the hidden variable as the initial state of the pre-trained decoder, inputting the reply into the pre-trained decoder to obtain the output result, and calculating the reconstruction expected loss based on the output result; S16. Add the KL divergence loss, classification loss, and reconstruction expectation loss, and update the parameters of the dialogue generation model through gradient back propagation. After the parameters are updated, return to step S12 for iteration until the parameters converge to complete the pre-training of the dialogue generation model.

102. After completing the pre-training, fix the parameters of the input encoder, output encoder, recognition network, prior network and classifier, and divide the dialogue samples into three types of dialogue data according to no emotion, positive emotion and negative emotion, which are used for noemotion decoder, positive decoder and negative decoder respectively. Use the reconstruction loss function to train the three decoders in turn until the parameters of the three decoders converge to complete the training of the dialogue generation model.

2. The method for generating a one-to-many dialogue based on semantic perception according to claim 1, characterized in that: Word2vec is used to preprocess multiple groups of dialogue samples, including obtaining the question word embedding sequence {e(C1), e(C2),..., e(C n )} and the reply word embedding sequence {e(X1),e(X2),...,(X n )}, e(·) represents the word embedding of the words in the dialogue sample, {C1,C2,...,C n } is the question in the dialogue sample, {X1,X2,...,X n } is the response in the dialogue sample.

3. The method for generating a one-to-many dialogue based on semantic perception according to claim 1, characterized in that: The formula for calculating KL divergence is: Among them, μ and σ are the parameters of the approximate posterior distribution, μ' and σ' are the parameters of the prior distribution, dz is the dimension of the latent variable, and q φ represents the approximate posterior distribution, represents the prior distribution, and j represents the current number of dimensions.

4. The method for generating a one-to-many dialogue based on semantic perception according to claim 1, characterized in that: In step S14, the latent variables are obtained by reparameterization according to the parameters of the approximate posterior distribution, and the reparameterization is expressed as: z=μ+σε; Among them, ε is sampled from the standard Gaussian distribution, z is the latent variable, and μ and σ are the Gaussian distribution parameters of the approximate posterior distribution.

5. The method for generating one-to-many dialogues based on semantic perception according to claim 1, characterized in that: In step S15, the hidden variable is converted into a tensor of the same dimension as the pre-trained decoder through a multi-layer perceptron mlp, so that it is used as the initialization hidden state h0 and the initialization cell state c0 of the pre-trained decoder.

6. The method for generating a one-to-many dialogue based on semantic perception according to claim 1, characterized in that: The pre-training loss function composed of KL divergence loss, classification loss and reconstruction expectation loss in step S16 is: Among them, -E qφ(z|X,C) [·] represents the reconstruction expectation loss, KL(·) represents the KL divergence loss, NLLLoss(·) represents the classification loss, X represents the reply, C represents the question, z represents the latent variable, label represents the emotion label of the question, P(E) represents the normalized probability that the current dialogue sample belongs to each category, P θ (X|z,C) represents the conditional probability distribution, q φ (z|X,C) represents the approximate posterior distribution, represents the prior distribution, φ, θ is the parameter of the probability distribution.

7. The method for generating a one-to-many dialogue based on semantic perception according to claim 6, characterized in that: The normalized probability P(E) is obtained through the classifier. The classifier includes a multi-layer perceptron and a softmax layer. The hidden variable is the input of the multi-layer perceptron. The output of the multi-layer perceptron is used as the input of the softmax layer. The output of the softmax layer is P(E), which is expressed as: p(E) = Clf(z); Clf(z)=softmax(o); o = MLP(z); Among them, Clf(·) represents the classifier, MLP(·) represents the multi-layer perceptron, softmax(·) represents the softmax layer, and o represents the output of the multi-layer perceptron.

8. A one-to-many dialogue generation device based on semantic perception, used to implement the one-to-many dialogue generation method based on semantic perception according to any one of claims 1 to 7, characterized in that: include: An acquisition module is used to acquire input sentences in real time; An encoder module, used to encode the input sentence of the acquisition module to obtain a vector representation of the input sentence; The recognition module is used to fit the vector representation obtained by the encoder module to obtain latent variables containing dialogue category information; A classification module, used to determine the semantic classification result of the input sentence according to the latent variables; The generation module is used to determine the corresponding decoder according to the semantic classification result and generate a corresponding semantic response according to the decoder.