Comment generation model training method and device, information generation method and device

By introducing the self-attention mechanism and emotion and stance control information into the review generation model, the problem of uncontrollable review generation in the existing technology is solved, and high-accuracy and controllable review generation is achieved.

CN117591948BActive Publication Date: 2024-09-03北京中科闻歌科技股份有限公司
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410082714.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-19
Publication Date
2024-09-03
Estimated Expiration
2044-01-19

AI Technical Summary

Technical Problem

Existing review generation technology is difficult to handle long-distance dependencies and controllable emotional polarity, stance and other characteristics, resulting in uncontrollable generated content, and the application of large-scale pre-trained language models in self-attention mechanisms has not been fully utilized.

Method used

Using a large-scale pre-trained language model combined with a self-attention mechanism, by introducing control information of emotion and stance, the display text and emotional stance text are modeled through the encoder and decoder, and the global feature vector of the comment is generated, and cross-entropy loss is used function and backpropagation algorithm for model training to achieve controllable comment generation.

Benefits of technology

The reliability and accuracy of the review generation model are improved, the generated review result information is controllable, and the reliability and application breadth of the model are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117591948B
    Figure CN117591948B
Patent Text Reader

Abstract

The present disclosure provides a review generation model training method and device, which relates to the field of artificial intelligence technology, specifically to the technical fields of natural language processing, deep learning, large models, etc. The specific implementation scheme is: obtain a text sample set, the text sample set includes: a first text sample, the first text sample includes: display text and emotional stance text related to the display text; obtain a pre-built review generation network, the review generation network includes: an encoder and a decoder, the encoder models the display text and the emotional stance text respectively, and obtains a review global feature vector; the decoder is used to decode the review global feature vector to obtain review result information; the first text sample selected from the text sample set is input into the review generation network to obtain the review result information output by the review generation network; based on the review result information, a trained review generation model is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, specifically to technical fields such as natural language processing, deep learning, and large models, and can be applied to scenarios such as artificial intelligence content generation, and in particular to a comment generation model training method and device, information generation method and device, electronic device, and computer-readable storage medium. Background Art

[0002] Comment generation technology aims to automatically generate a series of diverse comment texts related to the input content based on input information such as titles and texts (such as short texts on social media, long news articles, etc.) through natural language processing technology. It can enhance the fun of community interaction, increase reader engagement, and help relevant departments predict negative public opinion and guide positive public opinion. Summary of the invention

[0003] The present disclosure provides a review generation model training method and device, an information generation method and device, an electronic device, and a computer-readable storage medium.

[0004] According to a first aspect, a comment generation model training method is provided, the method comprising: obtaining a text sample set, the text sample set comprising: at least one first text sample, the first text sample comprising: a display text and an emotional stance text related to the display text; obtaining a pre-constructed comment generation network, the comment generation network comprising: an encoder and a decoder, the encoder models the display text and the emotional stance text respectively, obtains and concatenates the feature vector of the display text and the feature vector of the emotional stance, and obtains a global feature vector of the comment; the decoder is used to decode the global feature vector of the comment to obtain comment result information; the first text sample selected from the text sample set is input into the comment generation network to obtain comment result information output by the comment generation network; based on the comment result information, the comment loss value of the comment generation network is calculated; based on the comment loss value, the comment generation network is trained to obtain a trained comment generation model.

[0005] According to the second aspect, an information generation method is provided, which includes: obtaining a text to be processed and a sentiment stance text of the text to be processed; inputting the text to be processed and the sentiment stance text of the text to be processed into a comment generation model generated by the method described in any implementation method of the first aspect to obtain a comment result text.

[0006] According to a third aspect, a comment generation model training device is provided, which includes: a sample acquisition unit, configured to acquire a text sample set, the text sample set includes: at least one first text sample, the first text sample includes: a display text and an emotional stance text related to the display text; a network acquisition unit, configured to acquire a pre-constructed comment generation network, the comment generation network includes: an encoder and a decoder, the encoder models the display text and the emotional stance text respectively, obtains and concatenates the feature vector of the display text and the feature vector of the emotional stance, and obtains a global feature vector of the comment; the decoder is used to decode the global feature vector of the comment to obtain comment result information; a comment acquisition unit, configured to input the first text sample selected from the text sample set into the comment generation network, and obtain comment result information output by the comment generation network; a calculation unit, configured to calculate the comment loss value of the comment generation network based on the comment result information; a model acquisition unit, configured to train the comment generation network based on the comment loss value, and obtain a trained comment generation model.

[0007] According to the fourth aspect, an information generating device is provided, which includes: a text acquisition unit, configured to acquire the text to be processed and the emotional stance text of the text to be processed; an input unit, configured to input the text to be processed and the emotional stance text of the text to be processed into a comment generation model generated by the device described in any implementation method of the third aspect, to obtain a comment result text.

[0008] According to the fifth aspect, an electronic device is provided, which includes: at least one processor; and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in any implementation of the first aspect or the second aspect.

[0009] According to a sixth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method described in any implementation of the first aspect or the second aspect.

[0010] The review generation model training method and device provided by the embodiment of the present disclosure, first, obtain a text sample set, the text sample set includes: at least one first text sample, the first text sample includes: display text and emotional stance text related to the display text; second, obtain a pre-built review generation network, the review generation network includes: an encoder and a decoder, the encoder models the display text and the emotional stance text respectively, obtains and splices the feature vector of the display text and the feature vector of the emotional stance, and obtains the global feature vector of the review; the decoder is used to decode the global feature vector of the review to obtain the review result information; thirdly, the first text sample selected from the text sample set is input into the review generation network to obtain the review result information output by the review generation network; then, based on the review result information, the review loss value of the review generation network is calculated; finally, based on the review loss value, the review generation network is trained to obtain the trained review generation model. The review generation model disclosed in the present disclosure adds subjective texts of dimensions such as emotion and stance in real scenes during the training process, which can make the generated review result information controllable and improve the reliability and accuracy of the review generation model.

[0011] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0013] Figure 1 is a flowchart of an embodiment of a method for training a review generation model according to the present disclosure;

[0014] Figure 2 is a structural schematic diagram obtained by commenting on the global feature vector in the embodiment of the present disclosure;

[0015] Figure 3 is a flow chart of an embodiment of the information generation method according to the present disclosure;

[0016] Figure 4 It is a structural diagram of an embodiment of outputting a reply result text through a comment generation model in an embodiment of the present disclosure;

[0017] Figure 5 is a structural schematic diagram of an embodiment of a review generation model training device according to the present disclosure;

[0018] Figure 6 is a schematic structural diagram of an embodiment of an information generating device according to the present disclosure;

[0019] Figure 7It is a block diagram of an electronic device used to implement the comment generation model training method or information generation method of the embodiment of the present disclosure. DETAILED DESCRIPTION

[0020] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0021] Although great progress has been made in the research of generative pre-trained language models in recent years, controllable comment generation is still a challenging and understudied task because comments in real scenarios often contain subjectivity in dimensions such as emotions and positions, as well as features such as multiple rounds of comment replies, which usually lead to uncontrollable generated content.

[0022] Existing comment generation technologies usually use traditional recurrent neural networks for feature modeling, which can only capture limited-length context information, have difficulty handling long-distance dependencies, and cannot effectively model controllable features such as sentiment polarity and stance. Large-scale pre-trained language models have been proven by researchers to be able to better solve the long-distance dependency problem through self-attention mechanisms; combined with discrete or continuous prompt tuning techniques, they can integrate additional information and achieve control over generated content.

[0023] Based on this, the present invention proposes a review generation model training method, which improves the review generation task based on a large-scale pre-trained language model and realizes the generation of controllable reviews by introducing additional control information. Figure 1 A process 100 according to an embodiment of a review generation model training method disclosed herein is shown. The review generation model training method includes the following steps:

[0024] Step 101, obtaining a text sample set.

[0025] In this embodiment, the execution subject on which the review generation model training method runs can obtain the text sample set in various ways. For example, the execution subject can obtain the text sample set stored in the database server through a wired connection or a wireless connection. For another example, the user can obtain the text sample set collected by the terminal by communicating with the terminal.

[0026] Here, the text sample set may include at least one text sample, the text sample includes at least one first text sample, the first text sample includes: display text and emotional stance text related to the display text, the first text sample may also include: the true value of the comment result information of the display text, through which the true value can provide a basis for calculating the comment loss value during the comment generation network training process.

[0027] In a specific example, the text sample set includes more than 200,000 public news data (including titles and texts), and each piece of news data may include historical comments or may not include historical comments. When the news data does not include historical comments, the news data is the first text sample, and the emotional stance text in the first text sample is news data that includes both emotional and stance controllable information.

[0028] Step 102, obtaining a pre-built comment generation network.

[0029] Among them, the comment generation network includes: an encoder and a decoder. The encoder models the display text and the emotional stance text respectively, obtains and concatenates the feature vector of the display text and the feature vector of the emotional stance, and obtains the global feature vector of the comment; the decoder is used to decode the global feature vector of the comment to obtain the comment result information.

[0030] In this embodiment, the comment generation network adopts a large-scale pre-trained language architecture. The large-scale pre-trained language architecture can better solve the long-distance dependency problem through the self-attention mechanism.

[0031] In this embodiment, the large-scale pre-trained language architecture is a natural language processing model based on deep learning. It can automatically generate sentences, paragraphs or articles that conform to language rules mainly by learning a large amount of text data. The core idea of ​​the large language model is to use deep neural networks to learn the grammar, semantics and other features of natural language, so as to predict the probability of the next word to appear and generate new sentences based on these probabilities.

[0032] In this embodiment, the comment generation network includes an encoder and a decoder, wherein two special identifiers are added to the word segmenter in the encoder: <sentiment>and <stance>As the starting symbols of sentiment polarity and stance information respectively, Figure 2 As shown in the figure, sentiment polarity and stance information are continuous prompt words, which do not contain specific semantic information. The implicit features of the control information of the identifier can be learned separately through model training, prompting the model that the next position corresponding to the identifier is sentiment polarity or stance information, thereby realizing external controllable information modeling. After encoding through the encoder of the comment generation network, its feature vector matrix representation Esentiment and Estance are obtained respectively: Esentiment = Embed(" <sentiment>”),Estance = Embed(" <stance>”). Then customize the sentiment polarity tag Tag-0 and stance tag Tag-1. Both are discrete prompt words and can be defined by natural language. Their modeling method is similar to the news content information modeling, and both map natural language into a high-dimensional semantic space. For example, sentiment polarity tags can be defined as "positive", "negative", and "neutral"; stance tags can be defined as "supporting the views of a certain party" or "not supporting the views of a certain party".

[0033] In this embodiment, the emotion stance text may include emotion text and / or stance text, wherein the emotion text corresponds to the emotion polarity label and the stance text corresponds to the stance information. The emotion feature vector ETag-0 may be obtained by modeling the emotion polarity label of the emotion text by the encoder, and the stance feature vector ETag-1 may be obtained by modeling the stance label of the stance text by the encoder.

[0034] In this embodiment, the display text is text data displayed on a web page or application. For example, the display text includes an article abstract, title, body, etc.

[0035] In this embodiment, the above-mentioned modeling of the display text and the emotional stance text respectively, obtaining and splicing the feature vector of the display text and the feature vector of the emotional stance, and obtaining the global feature vector of the comment includes: segmenting the display text through a word segmenter to obtain multiple sub-words, encoding each sub-word through the encoder of the comment generation network to obtain the feature vector of the display text; determining the emotional text and / or stance text in the emotional stance text; modeling the emotional text and / or stance text to obtain the feature vector of the emotional text (emotional continuous prompt word feature vector and emotional discrete prompt word feature vector), and / or the feature vector of the stance text (stance continuous prompt word feature vector and stance prompt word feature vector), splicing the feature vector of the display text, the feature vector of the emotional text and / or the feature vector of the stance text to obtain the global feature vector of the comment. Figure 2 As shown, the global feature vector of comments is E, E = Concat(Esentiment, ETag-0, Estance, ETag-1, ES). The global feature vector of comments E combines the continuous cue word features (Esentiment, Estance) as control information, the discrete cue word features (ETag-0, ETag-1) as sentiment and stance labels, and the feature vector ES of the display text (such as news title or text).

[0036] exist Figure 2 In the preprocessed data sample, the external controllable information including sentiment polarity and stance information is first modeled. First, the extended continuous prompt words (including the starting identifier of sentiment polarity and stance) are randomly initialized. <sentiment>and <stance>)’s embedding layer; then, the encoder of the comment generation network encodes the custom discrete prompt words, including the sentiment polarity label and the stance label, and obtains their feature representations ETag-0 and ETag-1; finally, the global feature vector of the comment is obtained by concatenating the word embedding feature matrices of the two.

[0037] Step 103: input a first text sample selected from the text sample set into a comment generation network to obtain comment result information output by the comment generation network.

[0038] In this embodiment, the execution subject can select a first text sample from the text sample set obtained in step 101, and execute the training steps from step 103 to step 105 to complete an iterative training of the comment generation network. Among them, the selection method and the number of selected first text samples from the text sample set are not limited in this application, and the number of iterative training of the comment generation network is not limited. For example, in one iterative training, multiple continuous first text samples can be randomly selected, and the comment loss value of the comment generation network can be calculated by the selected first text samples, and the parameters of the comment generation network can be adjusted; or other text samples other than the first text sample in the text sample set can be selected, and the other text samples and the first text samples can be used to simultaneously calculate the multiple losses of the comment generation network, and the parameters of the comment generation network can be adjusted.

[0039] Step 104, based on the comment result information, calculate the comment loss value of the comment generation network.

[0040] In this embodiment, during each iterative training of the comment generation network, a first text sample is selected from the text sample set, and the selected first text sample is input into the comment generation network. Based on the loss function pre-set for the comment generation network and the true value in the first text sample, the comment loss value of the comment generation network is calculated.

[0041] In this embodiment, the cross entropy loss function can be used as the loss function. The cross entropy loss function calculates the comment loss value based on the difference between the comment result information generated by the comment generation network and the reference comment text (the true value in the first text sample), and then updates the parameters of the comment generation network through the back propagation algorithm to minimize the loss value. Assume that the reference comment text sequence is y and the model output sequence is , then the cross entropy loss function is as shown in formula (1).

[0042] Wherein, in formula (1), T represents the length of the target comment text sequence, V represents the vocabulary size in the decoder, yt,j represents the true prediction value at the t-th position in the reference comment, and if the label of the t-th position of the reference comment sequence is j, then yt,j = 1, otherwise it is 0. represents the probability of label j at the tth position in the comment sequence generated by the comment generation network.

[0043] (1)

[0044] By minimizing the cross entropy loss function, the output of the review generation network can be made close to the reference review sequence, thereby realizing the training of the review generation model.

[0045] Optionally, the loss function of the comment generation network can adopt a mean square error function, which is the expectation of the square of the difference between the predicted value and the true value of the comment generation network. During the iterative training process of the comment generation network, the gradient descent algorithm can be used to minimize the comment loss value of the comment generation network, thereby iteratively optimizing the network parameters of the comment generation network.

[0046] The original meaning of gradient is a vector, which means that the directional derivative of a loss function at that point reaches the maximum value along that direction, that is, the loss function changes fastest along that direction at that point and the rate of change is the largest. In deep learning, the main task of neural networks is to find the optimal network parameters (weights and biases) during learning. The optimal network parameters are also the parameters when the loss function is minimized.

[0047] Step 105: Based on the comment loss value, the comment generation network is trained to obtain a trained comment generation model.

[0048] In this embodiment, the comment generation model is a trained comment generation model obtained after adjusting the parameters of the comment generation network through multiple iterative training. The comment loss value of the comment generation network can be used to detect whether the comment generation network meets the training completion conditions. After the comment generation network meets the training completion conditions, the comment generation model is obtained.

[0049] Optionally, in this embodiment, in response to the comment generation network not meeting the training completion condition, the relevant parameters in the comment generation network are adjusted so that the comment loss value of the comment generation network converges, and the above-mentioned training steps 103-105 are continued to be executed based on the adjusted comment generation network.

[0050] In this optional implementation, when the comment generation network does not meet the training completion conditions, adjusting the relevant parameters of the comment generation network can help converge the comment loss value of the comment generation network.

[0051] The review generation model training method provided in this embodiment can automatically generate prompt word text, greatly reducing the time and labor of manual input, especially for large-scale text processing tasks, improving the efficiency of text processing tasks. In addition, the automatically generated prompt word text can provide a standardized text description, which is helpful for unified communication and search of text content.

[0052] The review generation model training method provided by the embodiment of the present disclosure first obtains a text sample set, the text sample set includes: at least one first text sample, the first text sample includes: display text and emotional stance text related to the display text; secondly, obtains a pre-built review generation network, the review generation network includes: an encoder and a decoder, the encoder models the display text and the emotional stance text respectively, obtains and splices the feature vector of the display text and the feature vector of the emotional stance, and obtains the global feature vector of the review; the decoder is used to decode the global feature vector of the review to obtain the review result information; thirdly, the first text sample selected from the text sample set is input into the review generation network to obtain the review result information output by the review generation network; from this, based on the review result information, the review loss value of the review generation network is calculated; finally, based on the review loss value, the review generation network is trained to obtain the trained review generation model. The review generation model disclosed in the present disclosure adds subjective texts of dimensions such as emotion and stance in real scenes during the training process, which can make the generated review result information controllable and improve the reliability and accuracy of the review generation model.

[0053] In some embodiments of the present disclosure, the above-mentioned text sample set also includes: at least one second text sample, the second text sample includes: display text and emotional stance text and historical comment text related to the display text, the encoder is also used to model the historical comment text, obtain comment features, and splice the comment features in the comment global feature vector to obtain the reply global feature vector; the decoder is used to decode the reply global feature vector to obtain reply result information; the method also includes: inputting the second text sample selected from the text sample set into the comment generation network to obtain the reply result information output by the comment generation network; based on the reply result information, calculating the reply loss value of the comment generation network; based on the reply loss value and the comment loss value, training the comment generation network to obtain a trained comment generation model.

[0054] In this embodiment, the text sample set also includes: a second text sample set, the second text sample set includes: display text, emotional stance text related to the display text, and historical comment text, wherein the historical comment text is the text after commenting on the display text in a specified web page or application.

[0055] In a specific example, the emotional stance text in the second text sample set may be a first sub-sample that includes only emotional controllable information, news data, and historical commentary texts, such as the first sub-sample is 50,000 pieces of high-quality news and commentary data containing only emotional controllable information, which is used to train emotional controllable capabilities; the second text sample set may also be a second sub-sample that includes only stance controllable information, news data, and historical commentary texts, and the second sub-sample is 20,000 pieces of high-quality news and commentary data containing only stance controllable information, which is used to train stance controllable capabilities.

[0056] In this embodiment, during the comment generation network training process, when the encoder receives the first text sample, the comment generation network generates comment result information; when the encoder receives the second text sample, the comment generation network generates reply result information, wherein the reply result information is the comment result information generated again by the comment generation network based on the second text sample, and the comment result information is the information obtained after replying to the historical comment results and the display text.

[0057] In this embodiment, when the comment generation network receives the first text sample and the second text sample, a comment loss value is calculated for the first text sample, and a reply loss value is calculated for the second text sample, wherein the comment loss value and the reply loss value can both be calculated using the cross entropy loss function.

[0058] In this embodiment, the above-mentioned training of the comment generation network based on the reply loss value and the comment loss value to obtain the trained comment generation model includes: taking the reply loss value and the comment loss value as the total loss value of the comment generation network, and minimizing the total loss value of the comment generation network using the gradient descent algorithm, that is, when the total loss value meets the training completion condition, the comment generation model is obtained. When the total loss value does not meet the training completion condition, the parameters of the comment generation are adjusted until the comment generation network meets the training completion condition.

[0059] In this embodiment, since some data in the text sample set include historical comment texts and some data do not include historical comment texts, it can be considered that the comment generation network training using the first text sample and the second text sample is a joint training for the subtasks of comment generation, and only the features of the corresponding parts need to be modularly spliced. After the text samples of each subtask are subjected to word embedding feature extraction and combined with the segment embedding vector Eseg, the comment generation network training is performed using the cross entropy loss as the loss function, and the loss value is calculated based on the difference between the reply result information of the comment generation network and the reference comment, and then the parameters of the comment generation network are updated through the back propagation algorithm to minimize the loss value.

[0060] In the method for training a comment generation model provided in this embodiment, the text sample set also includes: a second text sample, the second text sample includes a historical comment text, wherein the historical comment text is a text corresponding to the comment result information, and the comment generation network is trained by the second text sample, so that the comment generation network can process both the first text sample and the second text sample, and different result information is given to the first sample text and the second text sample respectively, thereby improving the wide application of the comment generation model and improving the generalization ability of the comment generation model.

[0061] In some optional implementations of the present disclosure, the comment generation network is trained based on the reply loss value and the comment loss value to obtain a trained comment generation model, including: determining the weight of the first text sample based on the number of first text samples in the text sample set; determining the weight of the second text sample based on the number of second text samples in the text sample set; multiplying the comment loss value by the weight of the first text sample to obtain a first loss value; multiplying the reply loss value by the weight of the second text sample to obtain a second loss value; in response to the sum of the first loss value and the second loss value satisfying a training completion condition, obtaining a comment generation model corresponding to the corresponding comment generation network.

[0062] In an optional implementation of this embodiment, the number of the first text samples and the number of the second text samples are pre-configured numbers when configuring the text sample set, and the number of the first text samples and the number of the second text samples can be set based on the training requirements of the comment generation model, for example, the number of the first text samples is greater than the number of the second text samples. The weights of the comment loss value and the reply loss value are set based on the number of the first text samples and the number of the second text samples, and the focus of different samples can be set for the comment generation model.

[0063] In an optional implementation of this embodiment, the above training completion condition includes at least one of the following: the number of training iterations of the text generation network reaches a predetermined iteration threshold, and the sum of the first loss value and the second loss value of the text generation network is less than the predetermined loss value threshold. The predetermined iteration threshold is an empirical value obtained based on the loss value of the text generation network. For example, the predetermined iteration threshold of the text generation network is 50,000 times. The predetermined loss value threshold of the text generation network is 0.01.

[0064] The method for obtaining a comment generation model provided by this optional implementation manner determines respective weights by the number of first text samples and the number of second text samples, and determines the total loss value of the comment generation network (the sum of the first loss value and the second loss value) based on the weights. When the total loss value of the text generation network meets the training completion condition, the text generation network is used as the comment generation model, thereby providing a reliable implementation method for the training of the comment generation model.

[0065] Optionally, the comment generation network is trained based on the reply loss value and the comment loss value to obtain a trained comment generation model, including: adding the comment loss value and the reply loss value to obtain a total loss value; in response to the total loss value satisfying the training completion condition, obtaining a comment generation model corresponding to the corresponding comment generation network.

[0066] Furthermore, based on the comment generation model training method provided in the above embodiment, the present disclosure also provides an embodiment of an information generation method. The information generation method of the present disclosure combines artificial intelligence fields such as natural language processing and deep learning.

[0067] See also Figure 3 , shows a process 300 according to an embodiment of the information generation method of the present disclosure. The information generation method provided in this embodiment includes the following steps:

[0068] Step 301, obtaining the text to be processed and the sentiment stance text of the text to be processed.

[0069] In this embodiment, the text to be processed can be one or more of the abstract, text, title, etc. of the article on the Internet or application. The emotional text and stance text of the text to be processed are the positive or negative evaluations provided by people or machines for the text to be processed after reading the text to be processed. The text to be processed is processed by the comment generation model to obtain the comment result text. The execution subject of the information generation method can obtain the text to be processed in a variety of ways. For example, the execution subject can obtain the text to be processed and the emotional stance text of the text to be processed stored in the database server through a wired connection or a wireless connection. For another example, the execution subject can also receive the text to be processed and the emotional stance text of the text to be processed collected by a terminal or other device in real time.

[0070] Step 302: input the text to be processed and the sentiment stance text of the text to be processed into a comment generation model, and output the comment result text.

[0071] In this embodiment, the execution subject can input the to-be-processed text obtained from step 301 into the comment generation model, thereby obtaining the comment result text of the to-be-processed text. It should be noted that the comment result text includes the generated text, which is a newly generated text after evaluating the to-be-processed text relative to the to-be-processed text, and the emotion and stance of the generated text are also related to the emotion stance text of the to-be-processed text.

[0072] In this embodiment, the comment generation model can be adopted as described above. Figure 1 The specific training process can be found in Figure 1 The relevant description of the embodiments will not be repeated here.

[0073] In this embodiment, the comment generation model includes: an encoder and a decoder, and the step 302 includes: inputting the text to be processed and the sentiment stance text of the text to be processed into the encoder to obtain the global feature vector of the comment output by the encoder, and the global feature vector of the comment is obtained by concatenating the feature vector of the sentiment stance identifier, the feature vector of the sentiment stance discrete prompt word and the feature vector of the text to be processed; inputting the global feature vector of the comment into the decoder to obtain the comment result text output by the decoder.

[0074] In this embodiment, the feature vector of the emotion stance identifier includes: the emotion continuous prompt word feature vector and the stance continuous prompt word feature vector; the feature vector of the emotion stance discrete prompt word includes: the emotion discrete prompt word feature vector and the stance prompt word feature vector.

[0075] The information generation method provided by the embodiment of the present disclosure obtains the text to be processed and the emotional stance text of the text to be processed; the text to be processed and the emotional stance text of the text to be processed are input into the comment generation model generated by the comment generation model training method of the embodiment, and the comment result text of the text to be processed is obtained. Therefore, the comment generation model can be used to reliably generate comment information for the text to be processed and the emotional stance text of the text to be processed, thereby improving the effectiveness of comment information generation.

[0076] In some embodiments of the present disclosure, the above-mentioned comment generation model is also trained based on a second text sample, and the second text sample includes: display text and emotional stance text and historical comment text related to the display text. The method also includes: inputting the text to be processed, the emotional stance text of the text to be processed, and the comment result text into the comment generation model to obtain the reply result text output by the comment generation model.

[0077] In this embodiment, the second text sample adds historical comment text relative to the first text sample, and the historical comment text is the text after commenting on the display text. It is the comment result text obtained after the comment generation model analyzes the display text and the emotional stance text of the display text.

[0078] In this embodiment, the comment generation model is also trained based on the second text sample. Since the second text sample also includes historical evaluation text compared to the first text sample, the comment generation model trained based on the first text sample and the second text sample has better generalization than the comment generation model trained only based on the first text sample, thereby improving the comprehensiveness of the model's analysis of information.

[0079] In this embodiment, the reply result text is the text that the model responds to the comment result text after re-analyzing the comment result file.

[0080] In the information generation method provided in this embodiment, the comment generation model is also trained based on the second text sample, and the text to be processed, the text to be processed and the comment result text are input into the comment generation model to obtain the reply result text output by the comment generation model, thereby improving the reliability of the generation result output by the model.

[0081] In some optional implementations of the present disclosure, the above-mentioned comment generation model includes: an encoder and a decoder, and the text to be processed, the sentiment stance text of the text to be processed, and the comment result text are input into the comment generation model to obtain the reply result text output by the comment generation model, including: inputting the text to be processed, the sentiment stance text of the text to be processed, and the comment result text into the encoder to obtain the reply global feature vector output by the encoder, and the reply global feature vector is obtained by concatenating the feature vector of the sentiment stance identifier, the feature vector of the sentiment stance discrete prompt word, the feature vector of the text to be processed, and the feature vector of the comment result text; inputting the reply global feature vector into the decoder to obtain the reply result text output by the decoder.

[0082] In real scenarios, there are often multiple rounds of comment replies (i.e., multiple rounds of comment result texts), that is, a reply to a comment and further replies to the reply content. The present invention proposes a solution for jointly modeling news content and multiple rounds of comments.

[0083] Introduce the start tag" <start>" and the closing tag " <end>" respectively represent the start and end positions of the text to be processed and the result text of each round of comments, and learn their feature vector representations Estart and Eend respectively through the training process of the encoder. Since both the text to be processed and the result text of comments are contextual information relied on to generate new comments, they can be identified with the same tags. Among them, ESnews is the feature vector representation of the text to be processed (such as the news title or text content) embedded with the start tag and the end tag; EScomment is the feature vector representation of the result text of comments, which is concatenated by the content features of n (n is a natural number greater than or equal to 1) rounds of historical comments embedded with the start tag and the end tag EScomment_i.

[0084] Estart = Embed(" <start>")

[0085] Duck = Embed(" <end>”)

[0086] ESnews = Concat(Estart, ES, Eend)

[0087] EScomment = Concat(EScomment_i), i=0,1,...,n

[0088] The global feature vector Etoken of the reply to the text to be processed, which contains controllable sentiment polarity and stance polarity information and integrates multiple rounds of historical comment information, is expressed as:

[0089] Etoken = Concat(Esentiment, ETag-0, Estance, ETag-1, ESnews,EScomment)

[0090] The method for obtaining the reply result text provided in this embodiment inputs the text to be processed, the emotional stance text of the text to be processed, and the comment result text into the encoder to obtain the reply global feature vector output by the encoder, and inputs the reply global feature vector into the decoder to obtain the reply result text output by the decoder.

[0091] In some embodiments of the present disclosure, the above-mentioned information generation method also includes: using different segment identifiers to represent different feature vectors in the reply global feature vector; multiplying the segment identifier with the embedding matrix to obtain a segment embedding vector; the encoder is also used to obtain the segment embedding vector, and add the reply global feature vector to the segment embedding vector to obtain an added vector, and input the added vector into the input layer of the encoder.

[0092] In this embodiment, the embedding matrix may be a vector embedding matrix that is learnable in the vector space of the comment generation model.

[0093] In this embodiment, the reply global feature vector is divided into three segments, and a segment identifier is assigned to each input token, and the segment identifier is represented by a binary vector. Among them, the feature vector of the emotional stance text is the first segment (represented by [0,1]), the display text (such as news title and text content) is the second segment (represented by [1, 0]), and the comment feature of the historical comment text is the third segment (represented by [0, 1]). Multiply each segment identifier with a learnable embedding matrix Eseg_lookup ∈ ℝ(S, d_model) to obtain the corresponding segment embedding vector Eseg. In this way, the comment generation model can distinguish different semantic areas based on the segment embedding vector of the segment embedding. Finally, the reply global feature vector (belonging to the word embedding vector) Etoken and the segment embedding Eseg are added and enter the input layer of the model together. By integrating these different embedding information into the reply global feature vector, the model can simultaneously use word and segment information to perform self-attention mechanism calculation and feature extraction.

[0094] The information generation method provided in this embodiment uses different segment identifiers to represent different feature vectors in the reply global feature vector, multiplies the segment identifier with the embedding matrix to obtain a segment embedding vector; based on the reply global feature vector and the segment embedding vector, an addition vector is obtained, and the addition vector is input into the decoder, so that the decoder can fully understand the segmented feature vectors in the reply global feature vector, and can make the decoder more clear about the semantic definition of each segment feature vector in the reply global feature, thereby improving the reliability of the reply result text.

[0095] Optionally, the above-mentioned information generation method also includes: using different segment identifiers to represent different feature vectors in the reply global feature vector; multiplying the segment identifier with the embedding matrix to obtain a segment embedding vector; the encoder is also used to obtain the segment embedding vector, and splice the reply global feature vector with the segment embedding vector to obtain a spliced ​​vector, and input the spliced ​​vector into the input layer of the encoder.

[0096] like Figure 4 The structure diagram of an embodiment of outputting reply result text through the comment generation model is shown. Figure 4 In the example, the text to be processed is news content, the sentiment stance text is controllable information, and the comment result text is historical comments. The news content, controllable information, and historical comments are input into the encoder of the comment generation model. The encoder extracts word embedding features to obtain word embedding features. The vector representation of the word embedding features is the reply global feature vector. The encoder or the execution subject also performs segment embedding feature annotation on the reply global feature vector to finally obtain a joint feature vector, where the joint feature vector can be the sum of the reply global feature vector and the segment embedding vector, or can be obtained by concatenating the reply global feature vector and the segment embedding vector.

[0097] In natural language generation tasks, the choice of generation algorithm plays a vital role in generation quality and diversity. Although the traditional greedy-based sequence generation algorithm can produce accurate results to a certain extent, it usually tends to select the words with the highest probability, which will lead to the lack of diversity in the generated comment content, being too monotonous and repetitive; moreover, the greedy-based sequence generation algorithm is prone to problems in the generation of long sentences or complex language structures, because it only focuses on the best choice of the current step and ignores the global consistency, and cannot generate long comment content well. For this reason, the present disclosure adopts a sampling-based Top-p algorithm to enhance the diversity of reply result text generation when generating comments by autoregression.

[0098] In some optional implementations of the present embodiment, the decoder includes a vocabulary, and the reply global feature vector is input into the decoder, and the reply result text output by the decoder includes: inputting the reply global feature vector into the decoder, obtaining the decoder's prediction probability for each predicted word in the reply result text, the prediction probability being the probability value of each word in the vocabulary; arranging all probability values ​​in the prediction probability in descending order to obtain an arrangement sequence of each predicted word; based on the arrangement sequence, obtaining a minimum vocabulary set; based on the minimum vocabulary set, obtaining the vocabulary of each predicted word in the reply result text.

[0099] In this embodiment, when the decoder predicts the reply result text, it can obtain the predicted words corresponding to each word in the reply result text, each predicted word has a corresponding prediction probability, and each prediction probability corresponds to each word in the vocabulary, that is, each predicted word has a probability value equal to the number of words in the vocabulary, and each probability value corresponds to a word. The probability values ​​of each predicted word are sorted to obtain the arrangement sequence of the predicted word.

[0100] In this embodiment, the arrangement sequence may be a sequence obtained by sorting all probability values ​​of each predicted word. After the probability values ​​are sorted, the corresponding word sorting result can also be obtained.

[0101] In this embodiment, the minimum vocabulary set is a reflection of the vocabulary sorting result, which may be an ascending order of the vocabulary corresponding to all probability values ​​of the predicted words, or a descending order of the vocabulary corresponding to some probability values ​​of the predicted words.

[0102] In this embodiment, the minimum vocabulary set is a vocabulary set obtained after selecting multiple words from the order of vocabulary words in the vocabulary table corresponding to the arrangement sequence.

[0103] In this embodiment, the vocabulary of each predicted word in the reply result text may be a vocabulary randomly selected from the minimum vocabulary set, or may be a vocabulary with the largest probability value selected from the minimum vocabulary set.

[0104] The method for obtaining the reply result text provided in this embodiment can make full use of the probability distribution information when generating the reply result text, and dynamically select the vocabulary of the reply result text generated at the current time step according to the probability distribution, thereby improving the diversity and stability of the vocabulary generation of the reply result text.

[0105] In some optional implementations of the present disclosure, the above-mentioned obtaining of the minimum vocabulary set based on the permutation sequence includes: sequentially calculating the cumulative values ​​of the predicted probabilities in the permutation sequence; in response to the cumulative value being greater than a preset threshold, obtaining a vocabulary corresponding to the predicted probability in the cumulative value from the vocabulary, and using the obtained vocabulary as the minimum vocabulary set.

[0106] In this embodiment, the diversity and uncertainty in the generation process are controlled by dynamically selecting the minimum vocabulary set with a probability accumulation greater than a certain threshold. Assume that at each time step t of the generation, a candidate vocabulary table V is given, which contains the probability distribution P of subwords. For each word v ∈ V, its probability is P(v), as shown in formula (2). A minimum vocabulary set z with a probability accumulation greater than a preset threshold is selected, and then random sampling is performed from the minimum vocabulary set z. z represents the minimum vocabulary set, which contains all words with a probability greater than or equal to the threshold p.

[0107] z = {v | P(v) ≥ p} (2)

[0108] Specifically:

[0109] First, sort the probability distributions P in descending order of probability.

[0110] The probability accumulation is then calculated until the cumulative probability is greater than a preset threshold p (such as 0.75).

[0111] Then, the words whose cumulative probability is greater than the threshold p are selected as the minimum vocabulary set z.

[0112] Finally, random sampling is performed from the minimum vocabulary set z.

[0113] In the process of generating the reply result text, random sampling is performed from the minimum vocabulary set, and one vocabulary is selected as the vocabulary generation result of the reply result text of the current time step. When the preset threshold p is small (close to 0), this embodiment will select several words with the highest probability as the minimum vocabulary set, and the generated results will tend to be very certain and repetitive. This is because a smaller threshold will limit the diversity of the generated results, and only a few high-probability words will be selected, resulting in a relatively simple generated text. When the preset threshold p is large (close to 1), this embodiment will select more words as the minimum vocabulary set, and the generated results will be more diverse and have a certain degree of randomness. A larger threshold allows more words with lower probabilities to participate in sampling, thereby increasing the diversity of the generated results.

[0114] The method for obtaining the reply result text provided in this embodiment selects a minimum vocabulary set whose probability accumulation is greater than a preset threshold in the process of generating the reply result text, and then randomly samples from the minimum vocabulary set. By controlling the preset threshold p, the vocabulary in the reply result text generated at the current time step is dynamically selected according to the probability distribution, thereby improving the diversity and quality of the reply result text generation.

[0115] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a review generation model training device, which is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0116] like Figure 5 As shown, the comment generation model training device 500 provided in this embodiment includes: a sample acquisition unit 501, a network acquisition unit 502, a comment acquisition unit 503, a calculation unit 504, and a model acquisition unit 505. Among them, the sample acquisition unit 501 can be configured to acquire a text sample set, the text sample set includes: at least one first text sample, the first text sample includes: a display text and an emotional stance text related to the display text. The network acquisition unit 502 can be configured to acquire a pre-built comment generation network, the comment generation network includes: an encoder and a decoder, the encoder models the display text and the emotional stance text respectively, obtains and concatenates the feature vector of the display text and the feature vector of the emotional stance, and obtains a comment global feature vector; the decoder is used to decode the comment global feature vector to obtain comment result information. The comment acquisition unit 503 can be configured to input the first text sample selected from the text sample set into the comment generation network to obtain the comment result information output by the comment generation network. The calculation unit 504 can be configured to calculate the comment loss value of the comment generation network based on the comment result information. The model obtaining unit 505 may be configured to train the review generation network based on the review loss value to obtain a trained review generation model.

[0117] In this embodiment, in the review generation model training device 500, the specific processing of the collection sample acquisition unit 501, the network acquisition unit 502, the review acquisition unit 503, the calculation unit 504, and the model acquisition unit 505 and the technical effects thereof can be referred to respectively. Figure 1 The relevant descriptions of step 101, step 102, step 103, step 104, and step 105 in the corresponding embodiments are not repeated here.

[0118] In some optional implementations of the present embodiment, the above-mentioned text sample set also includes: at least one second text sample, the second text sample includes: display text and emotional stance text and historical comment text related to the display text, the encoder is also used to model the historical comment text, obtain comment features, and splice the comment features in the comment global feature vector to obtain the reply global feature vector; the decoder is used to decode the reply global feature vector to obtain reply result information; the above-mentioned device 500 also includes: a reply training unit, which is configured to: input the second text sample selected from the text sample set into the comment generation network to obtain the reply result information output by the comment generation network; based on the reply result information, calculate the reply loss value of the comment generation network; based on the reply loss value and the comment loss value, train the comment generation network to obtain a trained comment generation model.

[0119] In some optional implementations of the present embodiment, the reply training unit is further configured to: determine the weight of the first text sample based on the number of first text samples in the text sample set; determine the weight of the second text sample based on the number of second text samples in the text sample set; multiply the comment loss value by the weight of the first text sample to obtain a first loss value; multiply the reply loss value by the weight of the second text sample to obtain a second loss value; in response to the sum of the first loss value and the second loss value satisfying the training completion condition, obtain a comment generation model corresponding to the corresponding comment generation network.

[0120] The review generation model training device provided by the embodiment of the present disclosure, first, the set sample acquisition unit 501 acquires a text sample set, the text sample set includes: at least one first text sample, the first text sample includes: display text and emotional stance text related to the display text; secondly, the network acquisition unit 502 acquires a pre-built review generation network, the review generation network includes: an encoder and a decoder, the encoder models the display text and the emotional stance text respectively, obtains and splices the feature vector of the display text and the feature vector of the emotional stance, and obtains the review global feature vector; the decoder is used to decode the review global feature vector to obtain the review result information; thirdly, the review acquisition unit 503 inputs the first text sample selected from the text sample set into the review generation network to obtain the review result information output by the review generation network; from this, the calculation unit 504 calculates the review loss value of the review generation network based on the review result information; finally, the model acquisition unit 505 trains the review generation network based on the review loss value to obtain the trained review generation model. The review generation model disclosed in the present disclosure adds subjective texts of dimensions such as emotion and stance in real scenes during the training process, which can make the generated review result information controllable and improve the reliability and accuracy of the review generation model.

[0121] Further references Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an information generating device, which is similar to Figure 3 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0122] like Figure 6 As shown, the information generation device 600 provided in this embodiment includes: a text acquisition unit 601, and an input unit 602. The text acquisition unit 601 can be configured to acquire the text to be processed and the emotional stance text of the text to be processed. The input unit 602 can be configured to input the text to be processed and the emotional stance text of the text to be processed as described above. Figure 5 In the comment generation model generated by the device described in the embodiment, a comment result text is obtained.

[0123] In this embodiment, in the information generating device 600, the specific processing of the text obtaining unit 601 and the input unit 602 and the technical effects thereof can be referred to in Figure 3 The relevant descriptions of step 301 and step 302 in the corresponding embodiment are not repeated here.

[0124] In some optional implementations of this embodiment, the comment generation model is also trained based on a second text sample, the second text sample includes: display text and emotional stance text and historical comment text related to the display text, and the information generation device 600 further includes: a reply unit (not shown in the figure). The reply unit is configured to: input the text to be processed, the emotional stance text of the text to be processed, and the comment result text into the comment generation model, and obtain the reply result text output by the comment generation model.

[0125] In some optional implementations of the present embodiment, the comment generation model includes: an encoder and a decoder, and the input unit 602 is further configured to: input the text to be processed, the sentiment stance text of the text to be processed, and the comment result text into the encoder to obtain a global feature vector of the reply output by the encoder, and the global feature vector of the reply is obtained by concatenating the feature vector of the sentiment stance identifier, the feature vector of the sentiment stance discrete prompt word, the feature vector of the text to be processed, and the feature vector of the comment result text; input the global feature vector of the reply into the decoder to obtain the reply result text output by the decoder.

[0126] In some optional implementations of this embodiment, the apparatus 600 further includes: a segmentation unit (not shown in the figure). The segmentation unit may be configured to use different segment identifiers to represent different feature vectors in the restored global feature vector; multiply the segment identifier by the embedding matrix to obtain a segment embedding vector; the encoder is further configured to obtain the segment embedding vector, add the restored global feature vector to the segment embedding vector to obtain an added vector, and input the added vector into the input layer of the encoder.

[0127] In some optional implementations of this embodiment, the above-mentioned decoder includes a vocabulary, and the above-mentioned input unit 602 is further configured to: input the reply global feature vector into the decoder to obtain the decoder's predicted probability for each predicted word in the reply result text, the predicted probability being the probability value of each word in the vocabulary; arrange all probability values ​​in the predicted probability in descending order to obtain an arrangement sequence of each predicted word; based on the arrangement sequence, obtain a minimum vocabulary set; based on the minimum vocabulary set, obtain the vocabulary of each predicted word in the reply result text.

[0128] In some optional implementations of this embodiment, the input unit 602 is further configured to: calculate the cumulative value of the predicted probability in the arrangement sequence in sequence; in response to the cumulative value being greater than a preset threshold, obtain the vocabulary corresponding to the predicted probability in the cumulative value from the vocabulary, and use the obtained vocabulary as the minimum vocabulary set.

[0129] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0130] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0131] like Figure 7 As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0132] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0133] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as a review generation model training method or an information generation method. For example, in some embodiments, the review generation model training method or the information generation method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the review generation model training method or the information generation method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the review generation model training method or the information generation method in any other appropriate manner (eg, by means of firmware).

[0134] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0135] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable review generation model training device, an information generation device, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0136] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0137] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0138] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0139] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0140] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0141] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.< / end> < / start> < / end> < / start> < / stance> < / sentiment> < / stance> < / sentiment> < / stance> < / sentiment>

Claims

1. A review generation model training method, the method comprising: Acquire a text sample set, the text sample set comprising: at least one first text sample and at least one second text sample, the first text sample comprising: display text and emotional stance text related to the display text, the emotional stance text being news data including both emotional polarity and stance information; the second text sample comprising: display text and emotional stance text and historical comment text related to the display text; the historical comment text being text after commenting on the display text in the second text sample in a specified webpage or application; A pre-built comment generation network is obtained, and the comment generation network includes: an encoder and a decoder, wherein the word segmenter of the encoder has two special identifiers, and the two special identifiers serve as the start symbols of the sentiment polarity and the stance information, and the implicit features of the control information of the two special identifiers are learned separately through model training to prompt the model that the next position corresponding to the two special identifiers is the sentiment polarity or the stance information, and the encoder models the display text, the two special identifiers and the sentiment stance text respectively, obtains and splices the feature vector of the display text, the discrete prompt word feature vectors of the two special identifiers and the feature vector of the sentiment stance, and obtains a global feature vector of the comment, and the encoder is also used to model the historical comment text to obtain comment features, and splice the comment features in the comment global feature vector to obtain a global feature vector of the reply; the decoder is used to decode the global feature vector of the comment to obtain comment result information; the decoder is used to decode the global feature vector of the reply to obtain reply result information; Inputting a first text sample selected from the text sample set into a comment generation network to obtain comment result information output by the comment generation network; inputting a second text sample selected from the text sample set into the comment generation network to obtain reply result information output by the comment generation network; Based on the comment result information, calculating the comment loss value of the comment generation network; Based on the reply result information, calculating the reply loss value of the comment generation network; Based on the comment loss value and the reply loss value, the comment generation network is trained to obtain a trained comment generation model.

2. According to the method of claim 1, the step of training the comment generation network based on the reply loss value and the comment loss value to obtain a trained comment generation model comprises: Determining a weight of the first text sample based on the number of the first text samples in the text sample set; Determining a weight of the second text sample based on the number of the second text samples in the text sample set; Multiplying the comment loss value by the weight of the first text sample to obtain a first loss value; Multiplying the restoration loss value by the weight of the second text sample to obtain a second loss value; In response to the sum of the first loss value and the second loss value satisfying the training completion condition, a comment generation model corresponding to the corresponding comment generation network is obtained.

3. A method for generating information, the method comprising: Obtaining a text to be processed and a sentiment stance text of the text to be processed; The text to be processed and the emotional stance text of the text to be processed are input into the comment generation model generated by the method described in claim 1 or 2 to obtain the comment result text.

4. According to the method of claim 3, the comment generation model is also trained based on a second text sample, and the second text sample includes: The display text and the emotional stance text and historical comment text related to the display text, the method further includes: The text to be processed, the emotional stance text of the text to be processed, and the comment result text are input into the comment generation model to obtain the reply result text output by the comment generation model.

5. The method according to claim 4, wherein: The comment generation model includes: an encoder and a decoder. The text to be processed, the sentiment stance text of the text to be processed, and the comment result text are input into the comment generation model to obtain the reply result text output by the comment generation model. The method includes: Input the text to be processed, the sentiment stance text of the text to be processed, and the comment result text into the encoder to obtain a reply global feature vector output by the encoder, wherein the reply global feature vector is obtained by concatenating the feature vector of the sentiment stance identifier, the feature vector of the sentiment stance discrete prompt word, the feature vector of the text to be processed, and the feature vector of the comment result text; The reply global feature vector is input into the decoder to obtain the reply result text output by the decoder.

6. The method according to claim 5, wherein: The method further comprises: Using different segment identifiers to represent different feature vectors in the reply global feature vector; Multiplying the segment identifier with the embedding matrix to obtain a segment embedding vector; The encoder is also used to obtain the segment embedding vector, add the restored global feature vector to the segment embedding vector to obtain an added vector, and input the added vector into the input layer of the encoder.

7. The method according to claim 5, wherein: The decoder includes a vocabulary, and the step of inputting the reply global feature vector into the decoder to obtain the reply result text output by the decoder includes: Inputting the reply global feature vector into the decoder to obtain the prediction probability of the decoder for each predicted word in the reply result text, wherein the prediction probability is the probability value of each word in the vocabulary; Arrange all probability values ​​in the predicted probability in descending order to obtain an arrangement sequence of each predicted word; Based on the permutation sequence, a minimum vocabulary set is obtained; Based on the minimum vocabulary set, the vocabulary of each predicted word in the reply result text is obtained.

8. The method according to claim 7, wherein: The minimum vocabulary set obtained based on the arrangement sequence includes: Calculating the cumulative value of the predicted probabilities in the arrangement sequence in sequence; In response to the cumulative value being greater than a preset threshold, a vocabulary corresponding to the predicted probability in the cumulative value is obtained from the vocabulary, and the obtained vocabulary is used as a minimum vocabulary set.

9. A review generation model training device, the device comprising: The sample acquisition unit is configured to acquire a text sample set, the text sample set comprising: at least one first text sample and at least one second text sample, the first text sample comprising: a display text and an emotional stance text related to the display text, the emotional stance text being news data including both emotional polarity and stance information; the second text sample comprising: a display text and an emotional stance text and a historical comment text related to the display text; the historical comment text being text after a comment text on the display text in the second text sample is made in a specified webpage or application; The network acquisition unit is configured to acquire a pre-built comment generation network, wherein the comment generation network includes: an encoder and a decoder, wherein the word segmenter of the encoder has two special identifiers, and the two special identifiers serve as the start symbols of the sentiment polarity and the stance information, and the implicit features of the control information of the two special identifiers are learned separately through model training to prompt the model that the next position corresponding to the two special identifiers is the sentiment polarity or the stance information, the encoder models the display text, the two special identifiers and the sentiment stance text respectively, obtains and concatenates the feature vector of the display text, the discrete prompt word feature vectors of the two special identifiers and the feature vector of the sentiment stance, and obtains a global feature vector of the comment, the encoder is also used to model the historical comment text to obtain comment features, and concatenates the comment features in the global feature vector of the comment to obtain a global feature vector of the reply; the decoder is used to decode the global feature vector of the comment to obtain comment result information; the decoder is used to decode the global feature vector of the reply to obtain reply result information; A comment obtaining unit is configured to input a first text sample selected from the text sample set into a comment generation network to obtain comment result information output by the comment generation network; and input a second text sample selected from the text sample set into the comment generation network to obtain reply result information output by the comment generation network; a calculation unit configured to calculate a comment loss value of the comment generation network based on the comment result information, and to calculate a reply loss value of the comment generation network based on the reply result information; The model obtaining unit is configured to train the comment generation network based on the comment loss value and the reply loss value to obtain a trained comment generation model.

10. An information generating device, comprising: A text acquisition unit, configured to acquire a text to be processed and a sentiment stance text of the text to be processed; The input unit is configured to input the text to be processed and the emotional stance text of the text to be processed into the comment generation model generated by the device described in claim 9 to obtain the comment result text.

11. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

12. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • News comment generation method, system and equipment and storage medium

    CN114492407A

  • Comment content generation method and device, storage medium and electronic equipment

    CN114584841A

  • Comment information generation method and device and storage medium

    CN114818690A

  • Comment generation method and system, storage medium and electronic equipment

    CN116402064A

  • Systems and methods for machine content generation

    US20220237368A1