A method, device and storage medium for generating comment information
By identifying key word segments and target topic word segments in the comment information generation model, the problem of monotonous comment information in existing technologies is solved, and more diverse comment information is generated.
Patent Information
- Application Number
- CN202110119102.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-28
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2041-01-28
AI Technical Summary
Existing comment information generation frameworks based on long short-term memory networks and sequence-to-sequence structures generate comment information that lacks richness and fails to fully consider the reader's comment perspective and the importance of word segmentation in the text.
By determining the key word set and target topic word set of the text to be processed, target comment information is generated. The similarity of word segments and the probability of topic association are calculated using the first prediction sub-model and the second prediction sub-model, and the comment information is generated by combining the attention mechanism.
The generated comments are richer and more diverse, taking into account the important information in the text and the reader's perspective, thus enhancing the diversity and richness of the comments.
Smart Images

Figure CN114818690B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular, to a comment information generation method and device and storage medium. BACKGROUND
[0002] With the popularity of various reading websites, users will comment on various texts in a reading website during browsing the reading website to express their views on the texts and highlight the main information of the texts. Therefore, in order to facilitate users to comment on the texts, an automatic comment information generation technology is proposed.
[0003] The automatic comment information generation technology is to automatically generate comment information based on a given text. At present, a comment information generation framework based on a sequence-to-sequence (seq2seq, S2S) structure of a long short term memory network (LSTM) is mainly used to generate comment information. The framework mainly includes an encoder and a decoder.
[0004] The process of generating comment information through the framework is as follows: the text contained in the text is input into the encoder, and the encoder encodes the text to obtain a semantic vector of the text; then the encoder generates a semantic vector of a word in the comment information by applying an attention mechanism to the semantic vector of the text, and converts the semantic vector of the word into a word to generate the comment information. Obviously, the comment information generated only according to the words in the text is not rich enough. SUMMARY
[0005] The present application provides a comment information generation method, device and storage medium to improve the richness of comment information.
[0006] In a first aspect, the present application provides a comment information generation method, which comprises:
[0007] determining a key word set corresponding to the text to be processed based on a first similarity between each word contained in the text to be processed and a corresponding title, and the title representing the core content of the text to be processed;
[0008] determining a target topic and a corresponding target topic word set corresponding to the text to be processed based on a second similarity between each word contained in the text to be processed and each preset topic, wherein each target topic represents a recommended comment angle for the text to be processed, and each target topic corresponds to at least one topic word;
[0009] generating target comment information of the text to be processed based on the key word set and the target topic word set.
[0010] In a second aspect, the present application implements a device for generating review information, which comprises:
[0011] a first determining unit configured to determine a set of key words corresponding to the text to be processed based on a first similarity between each word in the text to be processed and the title, the title representing the core content of the text to be processed;
[0012] a second determining unit configured to determine a target topic and a corresponding set of topic words corresponding to the text to be processed based on a second similarity between each word in the text to be processed and each preset topic, wherein each target topic represents a recommended review angle for the text to be processed, and each target topic corresponds to at least one topic word;
[0013] a generating unit configured to generate target review information of the text to be processed based on the set of key words and the set of topic words.
[0014] In a possible implementation, the first determining unit is specifically configured to:
[0015] input each word in the text to be processed and the title into a first prediction sub-model of a trained review information generation model to determine the first similarity between each word and the title;
[0016] determine a first selected probability corresponding to each word based on the first similarity, the first selected probability representing a probability of each word being selected as a key word;
[0017] select at least one word from each word in the text to be processed to form the set of key words based on the first selected probability corresponding to each word.
[0018] In a possible implementation, the first determining unit is specifically configured to:
[0019] determine a second selected probability of each word based on the first selected probability of each word, wherein a difference between each second selected probability and 0 or 1 is less than a preset value, and each second selected probability represents a probability of the corresponding word being selected as a key word;
[0020] select a word whose difference between the second selected probability and 1 is less than the preset value from each word in the text to be processed as a key word based on the second selected probability of each word, and form the set of key words.
[0021] In a possible implementation, the first determining unit determines a second selected probability of each word based on the first selected probability of each word, and is specifically configured to:
[0022] determine the second selection probability of the respective word based on the first selection probability of the respective word through a Gumbel-Softmax distribution; or
[0023] determine the second selection probability of the respective word based on the first selection probability of the respective word through a Bernoulli distribution.
[0024] In a possible implementation, the second determination unit is specifically configured to:
[0025] input each word included in the text to be processed into a second prediction sub-model of the trained comment information generation model;
[0026] determine a second similarity between each word and each preset topic based on each preset topic in the second prediction sub-model, and determine a topic associated with each word based on the obtained second similarity;
[0027] determine a topic selection probability of each topic based on the number of words associated with the obtained topic;
[0028] determine a target topic corresponding to the text to be processed based on the topic selection probability of each topic.
[0029] In a possible implementation, the second prediction sub-model is an MLP including a Softmax function, and the second prediction sub-model is trained in the following manner:
[0030] perform a loop iteration training on the second prediction sub-model according to the first prediction training sample in the first prediction training sample data set, and output the trained second prediction sub-model when a preset convergence condition is met, wherein the following operations are performed in one loop iteration training process:
[0031] select a first prediction training sample from the first prediction training sample data set, wherein the first prediction training sample includes a historical text and a corresponding at least one first historical comment information, and the historical text includes at least one historical word;
[0032] input the at least one historical word included in the historical text in the first prediction training sample into the pre-constructed second prediction sub-model;
[0033] obtain a topic associated with each historical word based on each preset topic in the pre-constructed second prediction sub-model through a Softmax function;
[0034] determine a prediction topic selection probability of each topic based on the number of historical words associated with the obtained topic;
[0035] The first loss function is constructed based on the real topic selection probability and the predicted topic selection probability corresponding to each topic, and the parameter of the second prediction sub-model is adjusted based on the first loss function, wherein the real topic selection probability is determined according to at least one first historical comment information corresponding to the historical text.
[0036] In a possible implementation, the real topic selection probability is determined in the following manner:
[0037] The at least one first historical comment information in the first prediction training sample is input into the topic perception sub-model of the trained comment information generation model;
[0038] The first semantic vector of each first historical comment information is obtained based on the topic perception sub-model, and the first historical topic corresponding to the corresponding first historical comment information is determined based on the obtained first semantic vector of each first historical comment information respectively.
[0039] The historical topic selection probability of each first historical topic is determined based on the number of first historical comment information associated with the obtained first historical topic respectively, and the historical topic selection probability is taken as the real topic selection probability.
[0040] In a possible implementation, the topic perception sub-model is trained in the following manner:
[0041] The topic perception sub-model is subjected to cyclic iteration training according to the second prediction training sample in the second prediction training sample data set, and the trained topic perception sub-model is output when a preset convergence condition is met; wherein the following operations are performed in one cyclic iteration training process:
[0042] The second prediction training sample is selected from the second prediction training sample data set, wherein the second prediction training sample contains at least one second historical comment information;
[0043] Each second historical comment information in the second prediction training sample is input into the pre-constructed topic perception sub-model to determine the second semantic vector corresponding to each second historical comment information;
[0044] The second historical topic corresponding to the corresponding second historical comment information is determined based on the second semantic vector corresponding to each second historical comment information, and the posterior topic selection probability is determined based on the second historical topic;
[0045] The second loss function is constructed based on the second semantic vector and the posterior topic selection probability, and the parameter of the topic perception sub-model is adjusted based on the second loss function.
[0046] In a possible implementation, the second loss function is constructed based on the second semantic vector and the posterior topic selection probability, comprising:
[0047] reconstruct the corresponding predicted review information based on the second semantic vector;
[0048] construct a second loss function based on a distance between the predicted review information, the posterior topic selection probability and the corresponding prior topic selection probability, and aligning the second semantic vector to a topic vector of the corresponding topic.
[0049] In a possible implementation, the generating unit is specifically configured to:
[0050] input the set of key tokens and the set of target topic tokens into a review information generation submodule of the trained review information generation model, perform a plurality of rounds of review token set prediction through the review information generation submodule, and generate the target review information based on a review token set output by the last round of prediction;
[0051] The process of each round of review token prediction is as follows:
[0052] determine, according to the review tokens in the review token set predicted in the previous round, a third selection probability of each key token in the set of key tokens, a fourth selection probability of each topic token in the set of target topic tokens, and a fifth selection probability of each high-frequency token in the set of preset high-frequency tokens through an attention mechanism;
[0053] predict the review token of the current round from the set of key tokens, the set of target topic tokens or the set of high-frequency tokens according to the third selection probability, the fourth selection probability and the fifth selection probability, wherein the third selection probability, the fourth selection probability and the fifth selection probability respectively represent the probability of each key token, each topic token and each high-frequency token being selected as a review token.
[0054] In a third aspect, an embodiment of the present application provides a device for generating review information, including a memory and a processor, wherein the memory is configured to store computer instructions, and the processor is configured to execute the computer instructions to implement the method for generating review information provided by the embodiment of the present application.
[0055] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores computer instructions, and the computer instructions are executed by a processor to implement the method for generating review information provided by the embodiment of the present application.
[0056] The present application has the following beneficial effects:
[0057] The embodiment of the present application provides a kind of comment information generation method, device and storage medium;In the embodiment of the present application, in the process of generating comment information for processing text, first, each word included in the processing text and title are acquired, and the title is used to represent the core content of the processing text;After that, at least one word is selected from each word of the processing text to form a key word set according to the first similarity between the title and each word of the processing text, and the key word set is used to represent the important information of the processing text, that is, to extract important information from the processing text;At the same time, based on the second similarity between each word included in the processing text and each preset topic, the target topic corresponding to the processing text and the corresponding target topic word set are determined, each target topic represents a recommended comment angle for the processing text, and each target topic corresponds to at least one topic word, i.e., the comment angle of the reader for the processing text can be determined;After that, based on the key word set and the target topic word set, the target comment information of the processing text is generated;
[0058] The comment information generation scheme provided by the embodiment of the present application not only depends on each word included in the processing text, but also pays more attention to the key word in the processing text and the topic word corresponding to the processing text. When generating target comment information, the important information of the processing text and the comment angle of the reader are considered, so that the generated comment information is more diversified.
[0059] Other vectors and advantages of the present application will be described in the subsequent specification, and it will become apparent from the specification, or by practicing the present application. The purpose and other advantages of the present application can be achieved and obtained by the structure specially pointed out in the written specification, claims, and drawings. BRIEF DESCRIPTION OF DRAWINGS
[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0061] Figure 1 A schematic diagram of generating comment information in related art;
[0062] Figure 2 A schematic diagram of the network structure of LSTM;
[0063] Figure 3 A schematic diagram of an application scenario;
[0064] Figure 4 A schematic diagram of the structure of the comment information generation model in the training process provided by the embodiment of the present application;
[0065] Figure 5 a network structure schematic diagram of an MLP;
[0066] Figure 6 a method flowchart for training a first prediction sub-model provided by an embodiment of the present application;
[0067] Figure 7 a schematic diagram for topic clustering according to historical comment information provided by an embodiment of the present application;
[0068] Figure 8 a method flowchart for training a topic perception sub-model provided by an embodiment of the present application;
[0069] Figure 9 a method flowchart for training a second prediction sub-model provided by an embodiment of the present application;
[0070] Figure 10 a schematic diagram of a comment information generation model in a comment information generation process provided by an embodiment of the present application;
[0071] Figure 11 a method flowchart for comment information generation provided by an embodiment of the present application;
[0072] Figure 12 a whole method flowchart for comment information generation provided by an embodiment of the present application;
[0073] Figure 13 a device structure diagram for comment information generation provided by an embodiment of the present application;
[0074] Figure 14 a computing device structure diagram provided by an embodiment of the present application. DETAILED DESCRIPTION
[0075] In order to make the purposes, technical solutions and beneficial effects of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0076] The terms "first", "second", and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.
[0077] The following explains some terms used in the embodiments of the present application to facilitate understanding by those skilled in the art.
[0078] 1. Artificial Intelligence (AI) is the use of digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is the design principle and implementation method of various intelligent machines, so that the machine has the functions of perception, reasoning and decision-making.
[0079] Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, both hardware and software technologies. Artificial intelligence basic technologies generally include technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc.
[0080] 2. Nature Language processing (NLP) is an important direction in the field of computer science and artificial intelligence. It studies various theories and methods that can realize effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language used in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question and answer, knowledge graph, etc.
[0081] 3. Machine learning is a multi-disciplinary subject, involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, etc. It is a subject that studies how computers simulate or implement human learning behavior to acquire new knowledge or skills, and reorganize existing knowledge structure to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental approach to making computers intelligent, and its applications are widespread in various fields of artificial intelligence. Machine learning usually includes artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, etc.
[0082] 4、Long Short Term Memory networks (LSTM) is a kind of time recurrent neural network, which is specially designed to solve the long-term dependence problem existing in general recurrent neural network (RNN). It is mainly used to process and predict problems related to the time axis of event occurrence. Such as text related problems and time sequence related problems. Text related problems mainly natural language processing, text processing and other context have certain correlation problems, also including dialogue system, sentiment analysis, machine translation and the like. The time sequence related problem is the time sequence prediction problem, such as predicting weather, temperature and the like. At the same time, LSTM can be used as a complex nonlinear unit to construct a larger deep neural network. In the embodiment of the application, LSTM is used to construct a comment information generation model, that is, the comment information generation model provided in the embodiment of the application contains LSTM.
[0083] 5、Tranformer is a language sequence processing model based on attention mechanism. Transformer uses attention mechanism to mine the relevance between words and words in text, so that the model learns the context semantic vector of the word, improves the output effect of the model, and also uses attention mechanism to realize fast parallel, and improves the slow training of recurrent neural network (RNN).
[0084] 6、Multilayer Perceptron (MLP) is also called Artificial Neural Network (ANN), which is a kind of feedforward artificial neural network model. It maps multiple input data sets to a single output data set, and is mainly used for classification processing of data.
[0085] 7、Cluster analysis, also known as group analysis, is a statistical analysis method for studying (sample or index) classification problems, and is also an important algorithm for data mining. Cluster analysis is composed of several patterns. Usually, a pattern is a vector of metrics or a point in a multi-dimensional space, wherein the cluster analysis content is very rich, including system clustering method, ordered sample clustering method, dynamic clustering method, fuzzy clustering method, graph clustering method, cluster prediction method and the like.
[0086] Cluster analysis is based on similarity, and the patterns in a cluster have more similarity than the patterns not in the same cluster. In natural science and social science, there are a large number of classification problems. The so-called class is a collection of similar elements, and clustering is to gather similar elements together.
[0087] 8、Posterior topic selection probability can also be called "posterior topic distribution", and prior topic selection probability can also be called "prior topic distribution", "pre-test topic distribution" or "pre-test topic distribution".
[0088] Prior topic selection probability is independent of experimental results or random sampling, and is reflected in the probability obtained according to other related parameters before the statistical test is performed.
[0089] Posterior topic selection probability is the real topic selection probability obtained according to the results after the statistical test is performed.
[0090] 9、Bernoulli distribution is also called two-point distribution or 0-1 distribution, which is a discrete distribution with two possible results. 1 represents success, and the probability of occurrence is p (where 0 < p < 1). 0 represents failure, and the probability of occurrence is q = 1-p. For example, in the embodiments of the present application, the two results of Bernoulli distribution, 1 represents selecting the word as the key word, and 0 represents not selecting the word as the key word.
[0091] The design idea of the embodiments of the present application is briefly introduced as follows.
[0092] The present application mainly generates corresponding comment information automatically based on the given text. In the related art of automatically generating comment information, a comment generation framework based on a sequence-to-sequence structure of a long short-term memory network is mainly used to generate comment information. The framework mainly includes an encoder and a decoder. Figure 1 An exemplary schematic diagram of generating comment information in the related art is provided.
[0093] In the related art, when generating comment information, the text is first segmented into an encoder, the encoder encodes the text segmentation to obtain the semantic vector corresponding to the text segmentation. Then the decoder generates the semantic vector of the comment segmentation in the comment by applying an attention mechanism to the semantic vector of the text segmentation and converts it into a specific comment segmentation, and further generates comment information according to the comment segmentation.
[0094] Obviously, in the related art of automatically generating comment information, the process of generating comment information is mainly based on each word in the text, without considering the reader factor, i.e. the recommended comment angle corresponding to the text, and without considering the importance of each word in the text, resulting in single and boring comment information.
[0095] Different readers have different comment angles for different texts or the same text; each word in the text also has corresponding importance, and the key word in the text can more intuitively reflect the core content, main idea and the like of the text to be expressed.
[0096] Therefore, the embodiment of the present application adopts artificial intelligence, machine learning and natural language processing technology, and proposes a method, device and storage medium for generating review information. In the process of generating review information, the embodiment of the present application determines a key word set, a target topic corresponding to the to-be-processed text and a corresponding target topic word set according to each word in the to-be-processed text; and then generates target review information according to the target topic word set and the key word set. The target topic is used to represent the recommended review angle of the to-be-processed text, which can also be called the predicted review angle of the reader to the to-be-processed text, and the target topic word set contains at least one topic word corresponding to the review angle, so the topic word is important information used for generating review information for the corresponding review angle. The key word set contains at least one key word extracted from the to-be-processed text, representing important information extracted from the word set of the to-be-processed text. It can be seen that the embodiment of the present application considers the review angle corresponding to the to-be-processed text and the importance of each word in the to-be-processed text in the process of generating target review information, so that the generated review information is more diverse.
[0097] The method for generating review information proposed in the embodiment of the present application can be divided into a training part of a review information generation model and an application part of the review information generation model. The review information generation model mainly contains a topic perception sub-model, a first prediction sub-model, a second prediction sub-model and a review generation sub-model.
[0098] In the embodiment of the present application, the review information generation model automatically generates review information mainly according to the target topic word set and the key word set corresponding to the to-be-processed text.
[0099] The key word in the key word set is determined based on the importance score or probability (i.e., the first selected probability in the embodiment of the present application) output by the first prediction sub-model for each word in the to-be-processed text;
[0100] The target topic word set is obtained from the topic perception sub-model based on the topic selected probability of each topic corresponding to the to-be-processed text output by the second prediction sub-model for the to-be-processed text; and the topic perception sub-model stores each topic and the corresponding topic word set, which is determined by the topic perception sub-model based on a large amount of historical review information.
[0101] In the embodiment of the present application, the trained topic perception sub-model can output the real topic selected probability corresponding to the historical review information of any historical text, which can be used to assist in training the second prediction sub-model.
[0102] Therefore, in the embodiments of the present application, the topic perception sub-model should be trained first to obtain a trained topic perception sub-model; then, based on the real topic selection probability corresponding to the historical text output by the trained topic perception sub-model and the topic segmentation set corresponding to each topic, other sub-models are trained.
[0103] (I) Training part of the comment information generation model:
[0104] 1. First prediction sub-model:
[0105] The third prediction training sample data set used to train the first prediction sub-model is obtained, and the third prediction training sample data set includes historical texts, specifically including the title information and the text information corresponding to each historical text.
[0106] According to the third prediction training sample in the third prediction training sample data set, the first prediction sub-model is executed for cyclic iteration training, and when the preset convergence condition is met, the trained first prediction sub-model is output, wherein the following operations are performed in one cyclic iteration training process:
[0107] The historical title vector of the historical text and each historical segmentation vector contained in the historical text are input into the first prediction sub-model constructed in advance;
[0108] The first historical selection probability of each historical segmentation vector corresponding to the historical segmentation being selected as a historical key segmentation is determined and output by the first prediction sub-model constructed in advance;
[0109] Based on each first historical selection probability, the historical segmentation is selected and a historical key segmentation set is formed;
[0110] In order to encourage the historical key segmentation in the historical key segmentation set to be less, the L1 norm loss function is designed in the embodiments of the present application, and the first prediction sub-model is adjusted based on the L1 norm loss function.
[0111] In the embodiments of the present application, the historical title vector of the historical text and each historical segmentation vector contained in the historical text are obtained by encoding the historical text based on the encoder of the LSTM structure or the encoder of the Transformer structure.
[0112] Taking the historical title vector and each historical segmentation vector of the historical text obtained based on the encoder of the LSTM structure as an example; Figure 2 The network structure schematic diagram of the LSTM is exemplarily provided. In combination with Figure 2 It can be seen that the LSTM contains a plurality of neurons, and the use of any one neuron of the LSTM is introduced below.
[0113] First, the context vector ht-1 and the historical word vector x t As input, the memory cell state C t-1 of the previous neuron through the forget gate t ; where f t = 1 means complete retention, and f t = 0 means complete discard.
[0114] Secondly, the context vector h t-1 output by the previous neuron and the historical word vector x t input by the current neuron are taken as input to obtain the memory cell state C' t of the current neuron through the input gate t The probability i t is calculated using i t .
[0115] The memory cell state of the current neuron is updated using C t-1 and C' t , and the updated memory cell state is C t .
[0116] Finally, the context vector h t-1 output by the previous neuron and the historical word vector x t input by the current neuron are taken as input to obtain the memory cell state C t retained by the output gate t , and C t is multiplied by o t after being processed by an activation function to obtain the context vector h t of the current neural output, which is a historical content vector of the historical text containing a historical title vector of the historical text and a historical body vector of the historical text, and the corresponding historical word vector can be obtained through each neuron.
[0117] 2. Topic-aware sub-model:
[0118] A second prediction training sample data set for training the topic-aware sub-model is obtained, which contains a large amount of second historical review information, i.e., the second prediction training sample;
[0119] According to the second historical review information in the second prediction training sample data set, the topic-aware sub-model is trained in a loop iteration, and when the preset convergence condition is met, the trained topic-aware sub-model is output; wherein the following operations are performed in one loop iteration training process:
[0120] inputting the second historical review information into a pre-constructed topic-aware sub-model;
[0121] obtaining a second semantic vector of the second historical review information through the pre-constructed topic-aware sub-model, performing reconstruction processing based on the second semantic vector to obtain predicted review information, obtaining a posterior topic candidate probability corresponding to the second historical review information based on the second semantic vector, and determining a topic vector corresponding to the second historical review information based on the posterior topic candidate probability of the second historical review information;
[0122] constructing a second loss function based on the predicted review information, the posterior topic candidate probability corresponding to the second historical review information, and the topic vector corresponding to the second historical review information, and performing parameter adjustment on the topic-aware sub-model based on the second loss function.
[0123] 3. The second prediction sub-model:
[0124] obtaining a first prediction training sample data set for training the second prediction sub-model, the first prediction training sample data set containing a large amount of historical text and corresponding first historical review information, the historical text and the corresponding first historical review information being the first prediction training sample;
[0125] performing cyclic iteration training on the second prediction sub-model according to the first prediction training sample in the first prediction training sample data set, and outputting the trained second prediction sub-model when a preset convergence condition is met, wherein the following operations are performed in one cyclic iteration training process:
[0126] selecting a first prediction training sample from the first prediction training sample data set, wherein the first prediction training sample contains historical text and corresponding first historical review information, and the historical text contains at least one historical word segmentation;
[0127] inputting the at least one historical word segmentation contained in the historical text in the first prediction training sample into the pre-constructed second prediction sub-model;
[0128] determining the topic associated with each historical word segmentation through the pre-constructed second prediction sub-model;
[0129] determining the predicted topic candidate probability of each topic based on the number of historical word segmentations associated with each topic, i.e., determining the predicted topic candidate probability corresponding to the historical text;
[0130] The first loss function is constructed based on the real topic selection probability and the predicted topic selection probability corresponding to each topic, that is, the first loss function is constructed based on the real topic selection probability and the predicted topic selection probability corresponding to the historical text; and the second prediction sub-model is adjusted in parameters based on the first loss function, wherein the real topic selection probability is determined according to the first historical comment information corresponding to the historical text.
[0131] 4. The comment information generation sub-model:
[0132] The historical key word segmentation set corresponding to the historical text obtained based on the first prediction sub-model and the historical topic segmentation set corresponding to the historical text obtained based on the second prediction sub-model are input into the pre-constructed comment information generation sub-model;
[0133] The comment information corresponding to the historical text is output by the pre-constructed comment information generation sub-model;
[0134] The fourth loss function is constructed based on the comment information corresponding to the historical text, and the comment information generation sub-model is adjusted in parameters based on the fourth loss function.
[0135] In the embodiments of the present application, when the comment information generation model is trained, the sub-models can also be jointly trained.
[0136] (II) Use part of the comment information generation model:
[0137] In the use process of the comment information generation model, the target topic segmentation set and the key word segmentation set corresponding to the to-be-processed text are mainly determined. The target topic segmentation set is selected from the topic segmentation set and each topic stored in the topic perception sub-model based on the topic selection probability of each topic corresponding to the to-be-processed text. Therefore, in the use process, the topic perception sub-model can be removed, and only the each topic and the corresponding topic segmentation set obtained through the topic perception sub-model are retained.
[0138] In the embodiments of the present application, after the to-be-processed text is determined, each word segmentation and the corresponding title contained in the to-be-processed text are obtained, and the title is used to represent the core content of the to-be-processed text;
[0139] Each word segmentation and the title of the to-be-processed text are input into the first prediction sub-model of the trained comment information generation model, the first similarity between each word segmentation and the title contained in the to-be-processed text is determined through the first prediction sub-model, and the first selection probability of each word segmentation being selected as a key word segmentation is determined based on the first similarity; then the key word segmentation is selected from each word segmentation contained in the to-be-processed text based on the first selection probability, and a key word segmentation set is formed; at the same time;
[0140] Each word segment of the text to be processed is input into the second prediction sub-model of the trained comment information generation model. The second prediction sub-model determines the second similarity between each word segment of the text to be processed and each preset topic, and determines the topic selection probability of each topic corresponding to the text to be processed based on the second similarity. Then, based on the topic selection probability of each topic corresponding to the text to be processed, the target topic and the corresponding target topic word set are determined from each topic and the corresponding topic word set stored in the topic awareness sub-model. Each target topic represents a recommended comment perspective for the text to be processed, and each target topic corresponds to at least one topic word.
[0141] Finally, based on the key word segmentation set and the target topic word segmentation set, the target comment information of the text to be processed is generated.
[0142] Obviously, in this embodiment of the application, when the comment information is automatically generated by the comment information generation model, the important information in the text to be processed and the comment perspective corresponding to the text to be processed are considered, so the generated target comment information is rich and diverse.
[0143] After introducing the design concept of the embodiments of this application, the following is a brief introduction to the application scenarios to which the technical solutions of the embodiments of this application can be applied. It should be noted that the application scenarios described below are only for illustrating the embodiments of this application and are not intended to limit the scope. In specific implementation, the technical solutions provided by the embodiments of this application can be flexibly applied according to actual needs.
[0144] like Figure 3 The diagram shown is an application scenario provided by an embodiment of this application. The application scenario includes a terminal device 30 (such as, but not limited to, 30-1 or 30-2 shown in the figure) and a server 31.
[0145] The terminal device 30 is an electronic device used by the user, which has various reading software installed and running, as well as a website with reading commenting functions. The terminal device 30 can be a personal computer, mobile phone, tablet computer, laptop, e-book reader, or other computer device; the terminal device 30 can also be a chatbot.
[0146] Server 31 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0147] In a possible implementation, the terminal device 30 and the server 31 can communicate through a communication network, which is a wired network or a wireless network. Therefore, the terminal device 30 and the server 31 can be directly or indirectly connected through wired or wireless communication. For example, the terminal device 30 can also be indirectly connected to the server 31 through a wireless access point 32, or the terminal device 30 can be directly connected to the server 31 through the Internet, which is not limited in the present application.
[0148] Since the training process of the comment information generation model needs to use a large amount of training sample data, in the embodiment of the present application, the training process of the comment information generation model is deployed in the server 30, and a large amount of historical text and historical comment information corresponding to each historical text can be stored in the server 30 for training of the comment information generation model. After obtaining the trained comment information generation model based on the training method in the embodiment of the present application, the trained comment information generation model can be deployed on the terminal device 30, or can be deployed on the server 31, or part of the sub-models in the comment information generation model can be deployed on the terminal device 30, and the remaining sub-models can be deployed on the server 31.
[0149] Taking the terminal device 30 as a tablet computer as an example:
[0150] When the comment information generation model is deployed on the terminal device 30, when the reader reads the text such as news or novel in the tablet computer, the tablet computer can obtain the text currently read by the reader as the to-be-processed text, then obtain the key word set and the target topic word set corresponding to the to-be-processed text, and then generate at least one target comment information corresponding to the to-be-processed text based on the key word set and the target topic word set, and present the target comment information to the reader through the display page of the tablet computer, so that the reader can select the target comment information for direct publishing or re-editing and publishing.
[0151] When the comment information generation model is deployed on the server 31, when the reader reads the text such as news or novel in the tablet computer, the tablet computer can obtain the text currently read by the reader as the to-be-processed text, then notify the server 31 of the to-be-processed text, at this time the server 31 receives the to-be-processed text sent by the tablet computer, and obtains the key word set and the target topic word set corresponding to the to-be-processed text, then generates at least one target comment information corresponding to the to-be-processed text based on the key word set and the target topic word set, and then returns the generated target comment information to the tablet computer, so as to present the target comment information to the reader through the display page of the tablet computer, so that the reader can select the target comment information for direct publishing or re-editing and publishing.
[0152] When the comment information generation model part sub-model is deployed in the terminal device 30, and the remaining sub-models are deployed in the server 31, for example, the first prediction sub-model, the second prediction sub-model, and the text information generation sub-model are deployed in the terminal device 30, and the topic awareness sub-model is deployed on the server 31, that is, the topic segmentation set corresponding to each topic obtained by training is stored on the server 31. At this time, when the reader reads the text such as news or novel reading in the tablet computer, the tablet computer can obtain the text currently read by the reader as the to-be-processed text; then the tablet computer obtains the key segmentation set corresponding to the to-be-processed text based on the first prediction sub-model, and determines the topic selection probability of each topic corresponding to the to-be-processed text based on the second prediction sub-model, and transmits the topic selection probability of each topic to the server 31. The server 31 obtains the corresponding target topic segmentation set based on the topic selection probability of each topic, and feeds back the target topic segmentation set to the tablet computer. At this time, the tablet computer generates at least one piece of target comment information corresponding to the to-be-processed text based on the key segmentation set and the target topic segmentation set, and presents the target comment information to the reader through the display page of the tablet computer, so that the reader can select the target comment information for direct publishing, or edit and publish the target comment information. It should be noted that in the embodiment of the present application, the first prediction sub-model, the second prediction sub-model, and the topic awareness sub-model can also be deployed in the server 31, and the comment information generation sub-model can be deployed in the terminal device 30, and the like. Details are not described herein.
[0153] Taking the terminal device 30 as a chat robot as an example:
[0154] The chat robot obtains the reading currently read by the reader, and obtains the comment information for the reading. For details, refer to the application scenario of the terminal device 30 being a tablet computer. However, when the terminal device 30 is a chat robot, the chat robot directly outputs the obtained comment information in the form of voice output after obtaining the comment information, and does not modify the comment information. That is, the reader and the chat robot discuss the same reading.
[0155] In a possible implementation, the chat robot can obtain the reading currently read by the reader in the following manner: receiving the reading sent by a terminal device such as a mobile phone or a tablet computer in a wireless manner, the reading being sent by the reader after triggering a sending instruction in the terminal device such as a mobile phone or a tablet computer; or receiving a keyword sent by the reader through a handwriting input manner or a voice input manner, and obtaining the keyword based on the keyword scanning.
[0156] In a possible implementation, the to-be-processed text can come from a browser web page, text information matched with user input query information, or a data source such as a public number article, which is not limited in the present application.
[0157] In a possible application scenario, the cloud storage technology can be used to save the training sample data set used for training the comment information generation model, or the topic segmentation set corresponding to each topic obtained through training.
[0158] In a possible application scenario, in order to reduce the communication delay, the server 31 can be deployed in each region, or in order to load balance, different servers 31 can be used to serve the regions corresponding to the terminal devices 30. The plurality of servers 31 can also share data through a block chain, and the plurality of servers 31 correspond to a data sharing system formed by the plurality of servers 31. For example, the terminal device 30 is located at a location a, and is in communication connection with the server 31. The terminal device 30 is located at a location b, and is in communication connection with other servers 31.
[0159] Each server 31 in the data sharing system has a node identifier corresponding to the server 31, and each server 31 in the data sharing system can store the node identifiers of other servers 31 in the data sharing system, so as to subsequently broadcast the generated block to other servers 31 in the data sharing system according to the node identifiers of the other servers 31. Each server 31 can maintain a node identifier list as shown in the following table, and store the server 31 name and the node identifier in the node identifier list. The node identifier can be an Internet Protocol (IP) address or any other information that can be used to identify the node. In Table 1, only the IP address is used as an example for description.
[0160] Table 1
[0161] Background server name Node identification Node 1 119.113.131.174 Node 2 118.116.189.143 … … Node N 119.124.789.238
[0162] Based on the above application scenarios, the method for generating comment information provided by the exemplary embodiments of the present application will be described in combination with the above-described application scenarios and the accompanying drawings. It should be noted that the above-described application scenarios are only used to facilitate the understanding of the spirit and principles of the present application, and the embodiments of the present application are not limited in this respect.
[0163] In the embodiments of the present application, the method for automatically generating the comment information for the to-be-processed text is based on the trained comment information generation model, that is, each word segment contained in the to-be-processed text is input into the trained comment information generation model, and finally the comment information generation model outputs the target comment information for the to-be-processed text. Therefore, the comment information generation model should be trained in the embodiments of the present application; and then the trained comment information generation model is used to generate the corresponding target comment information for any to-be-processed text.
[0164] In the following embodiments, the training process of the comment information generation model and the use process of the comment information generation model in the embodiments of the present application are described respectively.
[0165] Embodiment one: the training process of the comment information generation model
[0166] It should be noted that the structure of the comment information generation model is only used to make the embodiments of the present application clearer and more explicit, and cannot represent the actual division of the structures of the various sub-models. Figure 4 Figure 4 The structure diagram of the comment information generation model provided in the embodiments of the present application is exemplarily provided.
[0167] As can be seen from Figure 4 , the comment information generation model mainly includes a topic perception sub-model, a first prediction sub-model, a second prediction sub-model and a comment information generation sub-model. It should be noted that there is a certain association relationship between the various sub-models, Figure 4 It should be noted that the structure division of each sub-model shown in the figure is only used to make the embodiments of the present application clearer and more explicit, and cannot represent the actual division of the structures of the various sub-models.
[0168] When the target comment information is generated by the trained comment information generation model, the first prediction sub-model is mainly used to determine the first selection probability of each word segment contained in the to-be-processed text, the first selection probability is used to represent the probability of each word segment being selected as a key word segment, and then the key word segment set is determined based on the first selection probability; and
[0169] The second prediction sub-model is used to determine the topic selection probability of each topic corresponding to the to-be-processed text, and then based on the determined topic selection probability, the target topic and the corresponding target topic word segment set are selected from each topic and the corresponding topic word segment set determined in advance by the trained topic perception sub-model, each target topic represents a recommended comment angle for the to-be-processed text, and each target topic corresponds to at least one topic word segment;
[0170] Finally, the comment information generation sub-model is used to generate the target comment information of the to-be-processed text based on the key word segment set and the target topic word segment set.
[0171] Therefore, the process of training the comment information generation model can be seen as training each sub-model separately and then combining the separately trained sub-models.
[0172] In this embodiment, when training the second prediction sub-model, the actual topic selection probability output by the already trained topic awareness sub-model is required to assist in the training. Therefore, in this embodiment, the topic awareness sub-model should be trained before training the second prediction sub-model.
[0173] The training process of each sub-model in the comment information generation model in the embodiments of this application is described below.
[0174] First prediction sub-model:
[0175] In one possible implementation, the first predictor sub-model is an MLP, or the first predictor sub-model is an MLP connected to a Gumbel-Softmax distribution. Figure 5 An example diagram of the network structure of an MLP is provided.
[0176] from Figure 5 As can be seen from the diagram, the MLP consists of three layers: an input layer, a hidden layer, and an output layer. Neurons in each layer are connected to all neurons in adjacent layers, i.e., fully connected; neurons within the same layer are not connected to each other.
[0177] Each neuron has a weight for an input, a bias, and an activation function. When the third prediction training sample from the third prediction training dataset used to train the first prediction sub-model is provided to the MLP network, it passes through the first layer of neurons (multiplied by the weights, added to the bias, and activated once), yielding the output. The output of the first layer then becomes the input of the second layer, and so on, until the output layer is reached, yielding the target output. Next, following the direction of reducing the error between the target output and the actual output, the connection weights are adjusted layer by layer from the output layer through each intermediate layer, thus adjusting the parameters of the first prediction sub-model, and finally returning to the input layer. MLP relies on this mechanism for computation and prediction.
[0178] Therefore, in this embodiment of the application, MLP is used to predict the similarity between each historical word in the historical text and the title corresponding to the historical text, so as to predict the first historical selection probability of each historical word in the historical text being selected as a key word.
[0179] When the first predictor model is an MLP connected Gumbel-Softmax distribution, in order to realize the end-to-end training of the model, the Gumbel-Softmax distribution is selected in the training process, and the Gumbel-Softmax distribution is used to make the first selected probability tend to 0 or 1, that is, the second historical selected probability of each historical word in the predicted historical text is selected as a key word;
[0180] The Gumbel-Softmax distribution is:
[0181]
[0182]
[0183] wherein, represents the second selected probability, ∈ j is a random sample of Gumbel(0, 1), and τ represents the heat of each word.
[0184] In the embodiment of the application, before training the first predictor model, a third prediction training sample data set used for training the first predictor model should be obtained, and the third prediction training sample data set includes historical texts, and specifically includes title information and body information corresponding to each historical text.
[0185] Then, according to the third prediction training sample in the third prediction training sample data set, the first predictor model is executed for cyclic iteration training, and when a preset convergence condition is met, the trained first predictor model is output. Figure 6 An example is provided for the method flowchart for training the first predictor model in the embodiment of the application, taking one cycle iteration training as an example, wherein the following operations are performed in the one cycle iteration training process:
[0186] Step S600, inputting a historical title vector h te of a historical text and each historical word vector contained in the historical text into the first predictor model constructed in advance;
[0187] wherein, the historical title vector h te of the historical text and each historical word vector contained in the historical text are obtained by inputting the title information and the body information of the historical text into an encoder of an LSTM structure or an encoder of a Transformer structure.
[0188] Step S601, determining, by the first predictor model constructed in advance, a first historical similarity between each historical word and each title word in the historical title based on
[0189] Each first historical similarity is determined based on a distance between each historical title segmentation vector in the historical title and each historical segmentation vector.
[0190] In step S602, a first historical selected probability of a corresponding historical segmentation being selected as a historical key segmentation is determined based on each first historical similarity by a first prediction sub-model constructed in advance, and is output.
[0191] In step S603, a historical segmentation is selected based on each first historical selected probability, and a historical key segmentation set is formed.
[0192] In step S604, an L1 norm loss function is determined based on a number of historical key segmentations in the historical key segmentation set. And the first prediction sub-model is parameter adjusted based on the L1 norm loss function.
[0193] In the embodiment of the present application, in order to encourage the first prediction sub-model to close more gates and select fewer historical key segmentations to form the historical key segmentation set, the L1 norm item of all gates is added to the loss item in the embodiment of the present application Wherein the L1 norm item is a loss function designed in the training process of the first prediction sub-model, and thus the first prediction sub-model is parameter adjusted based on the L1 norm loss function.
[0194] Topic perception sub-model:
[0195] The topic perception sub-model is a model constructed for all reader-perceived topics of historical review information, and is mainly used to learn the semantic vector of historical review information and mine reader-perceived topics from historical review information. In order to achieve this goal, a variational generative clustering algorithm is designed in the topic perception sub-model in the embodiment of the present application, and the variational generative clustering algorithm can be jointly trained with the entire review information generation model in an end-to-end manner, Figure 7 An example is provided to show a schematic diagram of topic clustering according to historical review information, wherein the black filled part represents a historical review information set of a first type of topic, and the white filled part represents a historical review information set of a second type of topic.
[0196] In the embodiment of the present application, before training the topic perception sub-model, a second prediction training sample data set for training the topic perception sub-model should be obtained first, and the second prediction training sample data set contains a large amount of second historical review information, i.e., the second historical review information is the second prediction training sample.
[0197] Then, the topic perception sub-model is trained by cyclic iteration according to the second historical review information in the second prediction training sample data set, and when a preset convergence condition is met, the trained topic perception sub-model is output.Figure 8 An example is provided to train the first prediction sub-model in the embodiment of the application. The flow chart of the method is shown in the following, taking one cycle iteration training as an example. In the process of one cycle iteration training, the following operations are performed:
[0198] Step S800, input the second historical review information into the pre-constructed topic perception sub-model;
[0199] In the embodiment of the application, each second historical review information Y is represented by a bag-of-words vector.
[0200] Since the topic perception sub-model is a generative model, the second semantic vector of each second historical review information is reconstructed to obtain the predicted review information. Therefore, the second semantic vector of the second historical review information should be obtained by the pre-constructed topic perception sub-model.
[0201] Step S801, obtain the second semantic vector of the second historical review information by the pre-constructed topic perception sub-model;
[0202] In the embodiment of the application, after the second historical review information Y is input into the pre-constructed topic perception sub-model, a title c corresponding to the second historical review information is generated according to the previous title category distribution p(c); and the second semantic vector z of the second historical review information is conditionally generated according to the Gaussian distribution p(z|c).
[0203] Step S802, reconstruct the second semantic vector of the second historical review information by the pre-constructed topic perception sub-model to obtain the predicted review information;
[0204] The predicted review information y is reconstructed by the pre-constructed topic perception sub-model based on the semantic vector of the second historical review information by the conditional distribution p(y|z);
[0205] According to the above process of generating the predicted review information y, the joint probability p(y, z, c) is decomposed as:
[0206] p(y,z,c)=p(y|z)p(z|c)p(c)
[0207] In the embodiment of the application, after the second semantic vector of the second historical review information is determined, the posterior topic selection probability of the second historical review information corresponding to the second semantic vector can be determined; and the topic vector corresponding to the second historical review information is determined based on the posterior topic selection probability of the second historical review information.
[0208] In step S803, the posterior topic selection probability q(c|z) and the corresponding topic vector μ corresponding to the second historical review information are determined based on the second semantic vector of the second historical review information through the pre-constructed topic-aware sub-model.
[0209] In the training process, the weighted topic vector is calculated based on the posterior topic selection probability q(c|z) in the following way:
[0210]
[0211] In step S804, the second loss function is constructed based on the predicted review information, the posterior topic selection probability and the corresponding topic vector, and the parameter adjustment of the topic-aware sub-model is performed based on the second loss function.
[0212] Using Jensen's inequality, the log-likelihood can be expressed as:
[0213]
[0214] where L ELBO is the evidence lower bound (ELBO), and q(z,c|y) is the posterior topic selection probability, which can be factorized as follows:
[0215] q(z,c|y)=q(z|y)q(c|z)
[0216] Therefore, L ELBO can be rewritten as:
[0217]
[0218] where the first term is the reconstruction term and the predicted review information obtained by performing reconstruction processing, encouraging the model to reconstruct the input. The second term is to align the second semantic vector z of the input second historical review information Y with the topic vector corresponding to the corresponding topic c, where q(c|z) can be regarded as the clustering result of the input second historical review information Y. The last term is used to reduce the distance between the posterior topic selection probability q(c|z) and the prior topic selection probability p(c).
[0219] Therefore, based on the reconstructed review information, the posterior topic selection probability corresponding to the second historical review information, and the topic vector corresponding to the second historical review information, the second loss function constructed is and the parameter adjustment of the topic-aware sub-model is performed based on the second loss function.
[0220] To prevent the posterior topic selection probability q(c|z) from collapsing, all second historical review information is clustered into the corresponding topics, and the prior topic selection probability p(c) is set as a uniform distribution p(c) = 1 / k. p(z|c) is a parameterized diagonal Gaussian function as follows:
[0221]
[0222] where μ c is the mean Gaussian of topic c, which is also the topic vector of topic c. A parameterized diagonal Gaussian function q(z|y) is adopted:
[0223] μ = l1(h), log σ = l2(h)
[0224]
[0225] where l1 and l2 are linear transformations, and h is obtained by encoding the second historical review information through a review information encoder, which includes an MLP with a tanh activation function. In addition, an MLP classifier is used to predict the topic distribution q(c|z). p(y|z) is modeled by a review information decoder, which is a single-layer MLP with a softmax activation function in the last layer.
[0226] After training, the topic vectors are only obtained from the historical review information corpus in the training set. These topic vectors can be used to control the generated diverse review information, i.e., these topic vectors are applied to the automatic review information generation process.
[0227] Second prediction sub-model:
[0228] In the embodiments of the present application, the second prediction sub-model is an MLP including a Softmax function, which is mainly used to predict the topic selection probability of each topic corresponding to the historical text, i.e., to predict the topic distribution, in the training process.
[0229] In the embodiments of the present application, before training the second prediction sub-model, a first prediction training sample data set for training the second prediction sub-model should be obtained, which includes a large amount of historical texts and corresponding first historical review information, i.e., first prediction training samples.
[0230] Then, according to the first prediction training samples in the first prediction training sample data set, the second prediction sub-model is subjected to a loop iteration training, and when a preset convergence condition is met, the trained second prediction sub-model is output. Figure 9An example is provided to illustrate the method flowchart for training the second prediction sub-model in the embodiments of the present application, taking one cycle iteration training as an example, wherein the following operations are performed during one cycle iteration training:
[0231] Step S900, selecting a first prediction training sample from the first prediction training sample data set, wherein the first prediction training sample contains historical text and corresponding first historical review information, and the historical text contains at least one historical segmented word.
[0232] Step S901, inputting the at least one historical segmented word contained in the historical text in the first prediction training sample into the pre-constructed second prediction sub-model.
[0233] In the embodiments of the present application, inputting the at least one historical segmented word contained in the historical text in the first prediction training sample into the pre-constructed second prediction sub-model means inputting the historical segmented word vector into the pre-constructed second prediction sub-model, and the historical segmented word vector is obtained by inputting the at least one historical segmented word contained in the historical text into an encoder of LSTM structure or an encoder of Transformer structure.
[0234] Step S902, determining the topic associated with each historical segmented word by the pre-constructed second prediction sub-model.
[0235] In the embodiments of the present application, the second prediction sub-model contains each preset topic, and determines the second historical similarity between each historical segmented word and each preset topic, so as to determine the topic associated with each historical segmented word based on the second historical similarity.
[0236] Step S903, respectively determining the prediction topic selection probability of each topic based on the number of historical segmented words associated with each topic.
[0237] In the embodiments of the present application, the prediction topic selection probability of each topic is used to represent the prediction topic selection probability corresponding to the historical text.
[0238] In the embodiments of the present application, the second prediction sub-model predicts the prediction topic selection probability corresponding to the historical text based on p(c|X)=MLP(h e ).
[0239] Step S904, constructing a first loss function Ltop=D KL (q(c|z)||p(c|X)) based on the real topic selection probability and the prediction topic selection probability corresponding to each topic, and adjusting the parameters of the second prediction sub-model based on the first loss function.
[0240] In the embodiment of the present application, the probability of the real topic being selected corresponding to each topic, i.e., the probability of the real topic being selected corresponding to the historical text, is determined based on the first historical comment information corresponding to the historical text by using the trained topic perception sub-model.
[0241] The probability of the real topic being selected corresponding to the historical text is determined in the following manner:
[0242] The first historical comment information corresponding to the historical text is input into the trained topic perception sub-model.
[0243] The second semantic vector of the first historical comment information is obtained by using the trained topic perception sub-model.
[0244] In the embodiment of the present application, after the first historical comment information is input into the pre-constructed topic perception sub-model, a title c corresponding to the first historical comment information is generated according to the previous title category distribution p(c); and the first semantic vector of the first historical comment information is conditionally generated according to the Gaussian distribution p(z|c).
[0245] After the first semantic vector of the second historical comment information is determined, the posterior probability of the topic being selected corresponding to the first historical comment information is determined based on the first semantic vector, and the posterior probability of the topic being selected determined at this time is the probability of the real topic being selected corresponding to the historical text.
[0246] The comment information generation sub-model:
[0247] In the embodiment of the present application, the comment information generation sub-model is a decoder with an attention mechanism in an LSTM structure or a decoder with an attention mechanism in a Transformer structure.
[0248] In the training process, the historical key word segmentation set obtained based on the first prediction sub-model is input into the pre-constructed comment information generation sub-model; and
[0249] The probability of the topic being selected corresponding to each topic of the historical text according to the second prediction sub-model is input into the pre-constructed comment information generation sub-model from the historical topic word segmentation set of the historical text obtained from each topic stored in the topic perception sub-model with the corresponding topic word segmentation set.
[0250] The comment information of the historical text is predicted and output by the pre-constructed comment information generation sub-model based on the historical key word segmentation set, the historical topic word segmentation set, and the pre-stored high-frequency word segmentation set.
[0251] The fourth loss function Lce is constructed based on the comment information of the historical text, and the parameter adjustment of the comment information generation sub-model is performed based on the fourth loss function.
[0252] In the embodiment of the present application, the fourth loss function can be determined according to the fluency of the comment information corresponding to the historical text.
[0253] In a possible implementation, the comment information generation model is trained as a whole, that is, the topic perception sub-model, the first prediction sub-model, the second prediction sub-model, and the comment information generation sub-model are jointly trained.
[0254] In the joint training process, the overall target to be optimized is:
[0255] L = λ1L ELBO + λ2Lsal+ λ3Lce+ λ4Ltop
[0256] Wherein, λ1, λ2, λ3, λ4 are four hyperparameters, L ELBO is the loss function corresponding to the topic perception sub-model, Lsal is the loss function corresponding to the first prediction sub-model, Lce is the loss function corresponding to the comment information generation sub-model, and Ltop is the loss function corresponding to the second prediction sub-model. The overall target is mainly used to balance the influence between each sub-model.
[0257] It should be noted that the preset convergence condition in each training process described above can be that the corresponding loss value reaches a set first threshold, or the number of training reaches a set second threshold.
[0258] After obtaining the trained comment information generation model, the target comment information is automatically generated based on the trained comment information generation model. Since in the process of automatically generating the target comment information, the target topic corresponding to the to-be-processed text and the corresponding target topic segmentation set, and the key segmentation set corresponding to the to-be-processed text are determined.
[0259] In the process of determining the target topic corresponding to the to-be-processed text and the corresponding target topic segmentation set, the topic selection probability of each topic corresponding to the to-be-processed text is determined through the trained second prediction sub-model, and then the target topic and the corresponding target topic segmentation set are selected from each topic and the corresponding topic segmentation set stored in the trained topic perception sub-model. In this process, the topic perception sub-model can not be used, and only the result output by the trained topic perception sub-model can be used, so when the trained comment information generation model is used to automatically generate the comment information, the structure of the trained topic perception sub-model can be removed from the comment information generation model. Please refer to Figure 10 , Figure 10 An exemplary schematic diagram of the trained comment information generation model in the comment information generation process in the embodiment of the present application is provided.
[0260] Embodiment two: use process of the comment information generation model
[0261] Please refer to Figure 11 , Figure 11 An exemplary method for generating review information in the embodiments of the present application is provided, which comprises the following steps:
[0262] In step S1101, a set of key words corresponding to the text to be processed is determined based on the first similarity between each word in the text to be processed and the corresponding title.
[0263] After determining the text to be processed, the title T={t1, t2, …, tm} and the body B={b1, b2, …, bn} of the text to be processed are obtained, i.e., the set of words X=[T, B] corresponding to the text to be processed, which contains each word in the text to be processed.
[0264] In a possible implementation, each word X=[T, B] contained in the text to be processed and the determined title T={t1, t2, …, tm} are input into a first prediction sub-model of the trained review information generation model; the first prediction sub-model determines the first selected probability corresponding to each word in combination with the title.
[0265] In a possible implementation, each word vector contained in the text to be processed and the determined title vector can also be input into the first prediction sub-model of the trained review information generation model; based on the first prediction sub-model, the first selected probability of the corresponding word of each word vector is determined in combination with the title vector.
[0266] Wherein, each word vector and the title vector are obtained by inputting each word X=[T, B] and the title T={t1, t2, …, tm} of the text to be processed into the encoder of the LSTM structure of the trained review information generation model or the encoder of the Transformer structure of the trained review information generation model for encoding processing. Taking the encoder of the bidirectional LSTM structure as an example, the title vector is the last hidden vector in the two directions of the LSTM structure.
[0267] In the embodiments of the present application, the first prediction sub-model is MLP, and the first selected probability can be determined by the following formula:
[0268]
[0269] Wherein, is each word vector, h te is the title vector.
[0270] Specifically, a first distance between each word segmentation vector and the title vector can be determined based on the first prediction sub-model; a first similarity between each word segmentation and the title can be determined based on the first distance; and a first selected probability corresponding to each word segmentation can be determined based on the first similarity, the first selected probability being used to represent a probability of each word segmentation being selected as a key word segmentation.
[0271] The smaller the distance between the word segmentation vector and the title vector, the higher the first similarity between the word segmentation and the title, and the greater the first selected probability of the word segmentation being selected as a key word segmentation.
[0272] After determining the first selected probability corresponding to each word segmentation, at least one word segmentation is selected from each word segmentation included in the to-be-processed text to form a key word segmentation set based on the first selected probability corresponding to each word segmentation.
[0273] In one possible implementation, a word segmentation whose corresponding first selected probability is greater than a third threshold value is selected as a key word segmentation, for example, the third threshold value is 95%, and when the first selected probability of a word segmentation t2 is 96%, the word segmentation t2 is selected as a key word segmentation.
[0274] In one possible implementation, when at least one word segmentation is selected from each word segmentation included in the to-be-processed text to form a key word set based on the first selected probability corresponding to each word segmentation, after the first selected probability is determined, a second selected probability of each word segmentation can also be determined based on the first selected probability of each word segmentation, wherein a difference between each second selected probability and 0 or 1 is less than a preset value; that is, even if the first selected probability tends to 0 or 1, the corresponding second selected probability is obtained. Therefore, the second selected probability is also used to represent the probability of the corresponding word segmentation being selected as a key word segmentation.
[0275] The first selected probability of each word segmentation tends to 0 or 1 to obtain the corresponding second selected probability mainly in the following ways:
[0276] Method one: the second selected probability of each word segmentation is determined by Gumbel-Softmax distribution; wherein the formula corresponding to Gumbel-Softmax distribution is as follows:
[0277]
[0278]
[0279] wherein, represents the second selected probability, ∈ j is a random sample of Gumbel(0, 1), and τ represents the heat of each word segmentation.
[0280] In the first mode, the second selected probability of each word is more close to 0 or 1, and at this time, the second selected probability close to 1 is selected from each word in the to-be-processed text as a key word, that is, the difference between the value of the second selected probability and 1 is less than a preset value, and the word is selected as a key word, and then the key word set is formed based on the selected word.
[0281] For example, the first selected probability of a word t2 is 99.3%, and the first selected probability can be made more close to 1 through the Gumbel-Softmax distribution, and at this time, the second selected probability obtained after the first selected probability is made through the Gumbel-Softmax distribution can be 99.99%, which is more close to 1, and therefore the word t2 is selected as a key word.
[0282] The second mode is to determine the second selected probability of the corresponding word through the Bernoulli distribution.
[0283] In the second mode, the first selected probability is used to parameterize the Bernoulli distribution, and the binary gate of each word can be obtained from the Bernoulli distribution, and the specific formula is as follows:
[0284] g i ~ Bernoulli (β i )
[0285] Where g i represents the second selected probability, and β i represents the first selected probability.
[0286] At this time, the second selected probability is 0 or 1, and the second selected probability is 1 is selected from each word in the to-be-processed text as a key word, and a key word set is formed.
[0287] For example, the first selected probability of a word t2 is 99.3%, and the first selected probability can be made more close to 1 through the Bernoulli distribution, and at this time, the second selected probability obtained after the first selected probability is made through the Bernoulli distribution can be 99.99%, which is more close to 1, and therefore the word t2 is selected as a key word.
[0288] In step S1102, based on the second similarity between each word in the to-be-processed text and each preset topic, the target topic corresponding to the to-be-processed text and the corresponding target topic word set are determined.
[0289] Each target topic represents a recommended comment angle for the to-be-processed text, and each target topic corresponds to at least one topic word.
[0290] After obtaining each word vector contained in the to-be-processed text through the encoder of the LSTM structure of the trained review information generation model or the encoder of the Transformer structure of the trained review information generation model, each word vector contained in the to-be-processed text is input into a second prediction sub-model of the trained review information generation model.
[0291] So that the second prediction sub-model determines a second similarity between each word and each preset topic vector based on each word vector and each preset topic vector respectively, and determines a topic c associated with each word vector corresponding to each word based on each obtained second similarity respectively, and then determines a topic selection probability p(c|X) of each topic c based on the number of words associated with each topic c obtained respectively, that is, determines the topic selection probability p(c|X) of each topic corresponding to the to-be-processed text. At this time, the second prediction sub-model outputs the topic selection probability p(c|X) of each topic corresponding to the to-be-processed text.
[0292] In the embodiment of the present application, the second prediction sub-model inputs the output topic selection probability of each topic into the topic perception sub-model of the trained review information generation model. Since the topic perception sub-model stores each topic and the corresponding topic word set or topic vector Therefore, the target topic and the corresponding target topic word set can be selected from the topic perception sub-model storing each topic and the corresponding topic word set based on the topic selection probability of each topic.
[0293] For example, the topic selection probability of each topic corresponding to the to-be-processed text is 50% for topic c1, 35% for topic c2, and 10% for topic c3, etc. At this time, it is assumed that the topic c1 with the maximum topic selection probability value is selected, and the topic vector μ1 corresponding to the topic c1 is determined from the topic perception sub-model storing each topic and the corresponding topic word set or topic vector It should be noted that the topic with the maximum topic selection probability is only an example, and multiple topics and the corresponding topic word sets can be selected to generate review information in the embodiment of the present application.
[0294] In step S1103, the target review information of the to-be-processed text is generated based on the key word set and the target topic word set.
[0295] After the key word set and the target topic word set are determined, the key word set and the target topic word set are input into the review information generation sub-model of the trained review information generation model. So that the review information generation sub-model generates the target review information of the to-be-processed text according to the key word set, the target topic word set, and the pre-stored high-frequency word set.
[0296] In the embodiment of the present application, the comment information generation sub-model is a decoder with attention mechanism in an LSTM structure or a decoder with attention mechanism in a Transformer structure.
[0297] In a possible implementation, when generating the target comment information of the to-be-processed text according to the key word segmentation set, the target topic word segmentation set and the pre-stored high-frequency word segmentation set by the comment information generation sub-model, a plurality of rounds of comment word segmentation prediction need to be performed to obtain a comment word segmentation sequence or a comment word segmentation set, and the target comment information is generated based on the comment word segmentation sequence or the comment word segmentation set output by the last round of prediction.
[0298] In each round of comment word segmentation prediction, the process is as follows:
[0299] According to the comment words in the comment word segmentation sequence predicted in the previous round, the third selection probability of each key word in the key word segmentation set, the fourth selection probability of each topic word in the target topic word segmentation set and the fifth selection probability of each high-frequency word in the pre-set high-frequency word segmentation set are determined by the attention mechanism.
[0300] According to the weighted values of the third selection probability, the fourth selection probability and the fifth selection probability, the comment word of the current round is predicted from the key word segmentation set, the target topic word segmentation set or the high-frequency word segmentation set, wherein the third selection probability, the fourth selection probability and the fifth selection probability respectively represent the probability of each key word, each topic word and each high-frequency word being selected as a comment word.
[0301] For reference Figure 12 , Figure 12 An exemplary overall method flowchart for generating comment information in the embodiment of the present application is provided, including the following steps:
[0302] Step S1200, encoding each word X i in the to-be-processed text based on the encoder of the LSTM structure to determine the word vector of each word in the to-be-processed text and the title vector h te corresponding to the to-be-processed text.
[0303] The title T = {t1, t2, …, tm} and the body B = {b1, b2, …, bn} of the to-be-processed text, so each word X i in the to-be-processed text = [T, B] = {t1, t2, …, tm, b1, b2, …, bn}.
[0304] Step S1201, inputting the title vector h te and each word vector input into the first prediction model, to obtain a first selected probability β output by the first prediction model for each segmented vector i ;
[0305] wherein the first selected probability is determined based on a formula .
[0306] Step S1202, using each first selected probability to parameterize a Bernoulli distribution g i ~ Bernoulli(β i , respectively, to determine a corresponding second selected probability g i , the second selected probability g i is 0 or 1.
[0307] Step S1203, selecting segmented words with the second selected probability of 1 to form a key segmented word set.
[0308] Step S1204, inputting each segmented vector into a second prediction model to obtain a topic selection probability p(c|X) of each topic for the text to be processed output by the second prediction model;
[0309] wherein the topic selection probability of each topic is determined based on .
[0310] Step S1205, based on the topic selection probability p(c|X) of each topic, determining a target topic corresponding to the text to be processed and a corresponding target topic segmented word set from the topics and corresponding topic segmented word sets determined by the trained topic perception sub-model;
[0311] Step S1206, generating target review information based on the key segmented word set and the target topic segmented word set.
[0312] Based on the same inventive concept, the embodiments of the present application also provide a device 1300 for generating review information, Figure 13 exemplarily provides a device in the embodiments of the present application, which comprises:
[0313] A first determination unit 1301 is configured to determine a key segmented word set corresponding to the text to be processed based on a first similarity between each segmented word contained in the text to be processed and a corresponding title, the title representing the core content of the text to be processed.
[0314] A second determination unit 1302 is configured to determine a target topic and a corresponding target topic segmented word set corresponding to the text to be processed based on a second similarity between each segmented word contained in the text to be processed and each preset topic, wherein each target topic represents a recommended review angle for the text to be processed, and each target topic corresponds to at least one topic segmented word.
[0315] The generating unit 1303 is configured to generate target review information of the to-be-processed text based on the key word set and the target topic word set.
[0316] In a possible implementation, the first determining unit 1301 is specifically configured to:
[0317] input each word and title contained in the to-be-processed text into a first prediction sub-model of the trained review information generation model, and determine a first similarity between each word and the title;
[0318] determine a first selected probability corresponding to each word based on the first similarity, where the first selected probability is used to represent a probability that each word is selected as a key word;
[0319] select at least one word from each word contained in the to-be-processed text to form the key word set based on the first selected probability corresponding to each word.
[0320] In a possible implementation, when the first determining unit 1301 selects at least one word from each word contained in the to-be-processed text to form the key word set based on the first selected probability corresponding to each word:
[0321] determine a second selected probability of each word based on the first selected probability of each word, where a difference between each second selected probability and 0 or 1 is less than a preset value, and each second selected probability is used to represent a probability that each word is selected as a key word;
[0322] select, as a key word, a word whose difference between the second selected probability and 1 is less than the preset value from each word contained in the to-be-processed text based on the second selected probability of each word, and form the key word set.
[0323] In a possible implementation, when the first determining unit 1301 determines the second selected probability of each word based on the first selected probability of each word:
[0324] determine the second selected probability of each word based on the first selected probability of each word in a Gumbel-Softmax distribution manner; or
[0325] determine the second selected probability of each word based on the first selected probability of each word in a Bernoulli distribution manner.
[0326] In a possible implementation, the second determining unit 1302 is specifically configured to:
[0327] input each word contained in the to-be-processed text into a second prediction sub-model of the trained review information generation model;
[0328] determine a second similarity between each word segmentation and each preset topic based on each preset topic in the second prediction sub-model, and determine a topic associated with each word segmentation based on the obtained second similarity;
[0329] determine a topic selection probability of each topic based on the obtained number of word segmentations associated with each topic;
[0330] determine a target topic corresponding to the text to be processed based on the topic selection probability of each topic.
[0331] In a possible implementation, the second prediction sub-model is an MLP including a Softmax function, and the second prediction sub-model is obtained by training in the following manner:
[0332] performing recurrent iterative training on the second prediction sub-model according to the first prediction training sample in the first prediction training sample data set, and outputting the trained second prediction sub-model when a preset convergence condition is met, wherein the following operations are performed in one recurrent iterative training process:
[0333] selecting the first prediction training sample from the first prediction training sample data set, wherein the first prediction training sample includes a historical text and corresponding at least one first historical comment information, and the historical text includes at least one historical word segmentation;
[0334] inputting the at least one historical word segmentation included in the historical text in the first prediction training sample into the pre-constructed second prediction sub-model;
[0335] obtaining a topic associated with each historical word segmentation by the Softmax function based on each preset topic in the pre-constructed second prediction sub-model;
[0336] determining a predicted topic selection probability of each topic based on the obtained number of historical word segmentations associated with each topic;
[0337] constructing a first loss function based on the real topic selection probability and the predicted topic selection probability corresponding to each topic, and adjusting the parameters of the second prediction sub-model based on the first loss function, wherein the real topic selection probability is determined according to the at least one first historical comment information corresponding to the historical text.
[0338] In a possible implementation, the real topic selection probability is determined in the following manner:
[0339] inputting the at least one first historical comment information in the first prediction training sample into the topic-aware sub-model of the trained comment information generation model;
[0340] The first semantic vector of each first historical comment information is obtained based on the topic perception sub-model, and a first historical topic corresponding to each first historical comment information is determined based on the obtained first semantic vector of each first historical comment information respectively.
[0341] Based on the number of first historical comment information associated with each first historical topic obtained, the historical topic selection probability of each first historical topic is determined respectively, and the historical topic selection probability is taken as the true topic selection probability.
[0342] In a possible implementation, the topic perception topic sub-model is obtained by training in the following manner:
[0343] According to the second prediction training sample in the second prediction training sample data set, the topic perception sub-model is subjected to a loop iteration training, and when a preset convergence condition is met, a trained topic perception sub-model is output; wherein, in a loop iteration training process, the following operations are performed:
[0344] The second prediction training sample is selected from the second prediction training sample data set, wherein the second prediction training sample contains at least one second historical comment information;
[0345] Each second historical comment information in the second prediction training sample is input into the pre-constructed topic perception sub-model to determine a second semantic vector corresponding to each second historical comment information;
[0346] Based on the second semantic vector corresponding to each second historical comment information, a second historical topic corresponding to the corresponding second historical comment information is determined, and a posteriori topic selection probability is determined based on the second historical topic;
[0347] A second loss function is constructed based on the second semantic vector and the posteriori topic selection probability, and the parameters of the topic perception sub-model are adjusted based on the second loss function.
[0348] In a possible implementation, the second loss function is constructed based on the second semantic vector and the posteriori topic selection probability, which includes:
[0349] Based on the second semantic vector, the corresponding prediction comment information is reconstructed;
[0350] Based on the distance between the prediction comment information, the posteriori topic selection probability and the corresponding priori topic selection probability, and the alignment of the second semantic vector to the topic vector of the corresponding topic, the second loss function is constructed.
[0351] In a possible implementation, the generation unit 1303 is specifically configured to:
[0352] input the key word segmentation set and the target topic word segmentation set into a comment information generation submodule of the trained comment information generation model, perform multi-round comment word segmentation set prediction through the comment information generation submodule, and generate target comment information based on a comment word segmentation set output by the last round of prediction;
[0353] The process of each round of comment word segmentation prediction is as follows:
[0354] According to the comment words in the comment word segmentation set predicted in the previous round, the third selection probability of each key word in the key word segmentation set, the fourth selection probability of each topic word in the target topic word segmentation set, and the fifth selection probability of each high-frequency word in the preset high-frequency word segmentation set are determined through an attention mechanism.
[0355] According to the third selection probability, the fourth selection probability, and the fifth selection probability, a comment word in the current round is predicted from the key word segmentation set, the target topic word segmentation set, or the high-frequency word segmentation set, where the third selection probability, the fourth selection probability, and the fifth selection probability respectively represent the probability of each key word, each topic word, and each high-frequency word being selected as a comment word.
[0356] For the convenience of description, each of the above submodels is described as a unit (or module) according to function. Of course, the functions of the units (or modules) can be implemented in the same or multiple software or hardware when implementing the present application.
[0357] After introducing the method and device for generating comment information of the exemplary embodiments of the present application, the computing device for generating comment information of another exemplary embodiment of the present application is introduced.
[0358] Those skilled in the art can understand that each aspect of the present application can be implemented as a system, a method, or a program product. Therefore, each aspect of the present application can be specifically implemented as a complete hardware embodiment, a complete software embodiment (including firmware, microcode, etc.), or an embodiment combining hardware and software, which can be collectively referred to as "circuitry", "module", or "system".
[0359] In one possible implementation, the comment information generation computing device provided by the embodiments of the present application can at least include a processor and a memory. The memory stores program code, which, when executed by the processor, causes the processor to perform any step in the comment information generation method of various exemplary embodiments of the present application.
[0360] The comment information generation computing device 1400 according to this embodiment of the present application will be described below with reference to Figure 14 The comment information generation computing device 1400 according to this embodiment of the present application will be described below with reference to Figure 14The comment information generation computing device 1400 is merely an example and should not limit the function and usage range of the embodiments of the present application.
[0361] As shown in Figure 14 , the sub-models of the computing device 1400 can include, but are not limited to, the at least one processor 1401, the at least one memory 1402, and the bus 1403 connecting different system sub-models (including the memory 1402 and the processor 1401).
[0362] The bus 1403 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a processor or local bus using any of a variety of bus architectures.
[0363] The memory 1402 can include a readable medium in the form of volatile memory, such as a random access memory (RAM) 14021 and / or a cache memory 14022, and can further include a read-only memory (ROM) 14023.
[0364] The memory 1402 can also include a program / utility 14025 having a set of program modules 14024, including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or a combination thereof can include implementation of a network environment.
[0365] The computing device 1400 can also communicate with one or more external devices 1404 such as a keyboard, a pointing device, etc. and can communicate with one or more devices that enable a user to interact with the computing device 1400 and / or any devices (e.g., a router, a modem, etc.) that enable the computing device 1400 to communicate with one or more other computing devices. Such communication can occur via an input / output (I / O) interface 1405. Still yet, the computing device 1400 can communicate with one or more networks such as a local area network (LAN), a wide area network (WAN), and / or the Internet through a network adapter 1406. As Figure 14 indicated, the network adapter 1406 communicates with the other modules of the computing device 1400 through the bus 1403. It should be appreciated that the Figure 14 other hardware and / or software modules can be used in conjunction with the computing device 1400, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.
[0366] In some possible implementation, each of the aspects of the method for generating comment information provided in the present application can also be implemented in the form of a program product, which includes program codes for causing a computer device to perform the steps of the method for generating comment information according to various exemplary embodiments of the present application described above in the specification when the program product is run on the computer device.
[0367] The program product can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any suitable combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disc, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0368] The program product of the short message sending control of the embodiments of the present application can adopt a portable compact disc read-only memory (CD-ROM) and include program codes, and can be run on a computing device.
[0369] The readable signal medium can include a data signal carried in a baseband or as a carrier wave in a propagated data signal, in which the readable program codes are carried. Such a propagated data signal can take on many forms, including but not limited to electro-magnetic signal, optical signal, or any suitable combination of the above. The readable signal medium can also be any readable medium that can send, propagate or transfer program codes for use by or in connection with an instruction execution system, apparatus or device.
[0370] The program codes contained on the readable medium can be transmitted by any suitable medium, including but not limited to wireless, wired, optical cable, RF, or the like, or any suitable combination of the above.
[0371] The program codes for performing the operations of the present application can be written in any combination of one or more programming languages, including an object-oriented programming language, such as Java, C++, and the like, and a conventional procedural programming language, such as the "C" language or the like.
[0372] It should be noted that, although several units or sub-units of the apparatus are mentioned in the foregoing detailed description, such division into units or sub-units is merely exemplary and not mandatory. Indeed, according to an embodiment of the application, the features and functionalities of two or more units described above can be embodied in one unit. Conversely, the features and functionalities of one unit described above can be further divided into several units.
[0373] Moreover, while operations of the methods of the present application are described in a particular order in the figures, this is not required or implied in any way as to the order of the operations or that all operations be performed to achieve desirable results. Additionally or alternatively, certain steps can be omitted, combined into a single step, and / or separated into multiple steps.
[0374] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the claims and their equivalents, the application can be practiced otherwise than as specifically described.
Claims
1. A method of generating comment information, characterized by, The method comprises: determining a key word set corresponding to the to-be-processed text based on a first similarity between each word included in the to-be-processed text and a title, the title representing a core content of the to-be-processed text; determining a target topic corresponding to the to-be-processed text and a target word set corresponding to the target topic based on a second similarity between each word included in the to-be-processed text and each preset topic, wherein each target topic represents a recommended comment angle for the to-be-processed text, and each target topic corresponds to at least one topic word; generating target comment information of the to-be-processed text based on the key word set and the target word set.
2. The method of claim 1, wherein, The method comprises: inputting each word included in the to-be-processed text and the title into a first prediction sub-model of a trained comment information generation model to determine the first similarity between the word and the title; determining a first selected probability corresponding to each word based on the first similarity, the first selected probability representing a probability of each word being selected as a key word; selecting at least one word from each word included in the to-be-processed text to form the key word set based on the first selected probability corresponding to each word.
3. The method of claim 2, wherein, The method comprises: determining a second selected probability of each word based on the first selected probability of each word, wherein a difference between each second selected probability and 0 or 1 is less than a preset value, and each second selected probability represents a probability of each word being selected as a key word; selecting a word whose difference between the second selected probability and 1 is less than the preset value from each word included in the to-be-processed text as a key word based on the second selected probability of each word, and forming the key word set.
4. The method of claim 3, wherein, The method comprises: determining a second selected probability of each word through a Gumbel-Softmax distribution based on the first selected probability of each word; or determining a second selected probability of each word through a Bernoulli distribution based on the first selected probability of each word.
5. The method of claim 1, wherein, The method comprises: inputting each word included in the to-be-processed text into a second prediction sub-model of a trained comment information generation model; determining a second similarity between each word and each preset topic in the second prediction sub-model based on each preset topic, and determining a topic associated with each word based on each obtained second similarity. determine topic selection probabilities of the topics based on the number of the segmented words associated with each topic; determine the target topic corresponding to the text to be processed based on the topic selection probabilities of the topics.
6. The method of claim 5, wherein, The second prediction sub-model is a multi-layer perception (MLP) including a Softmax function, and is trained in the following manner: perform a loop iteration training on the second prediction sub-model according to the first prediction training samples in the first prediction training sample data set, and output the trained second prediction sub-model when a preset convergence condition is met, wherein the following operations are performed in one loop iteration training process: select a first prediction training sample from the first prediction training sample data set, wherein the first prediction training sample includes a historical text and corresponding at least one first historical comment information, and the historical text includes at least one historical segmented word; input the at least one historical segmented word included in the historical text in the first prediction training sample into the pre-constructed second prediction sub-model; obtain topics associated with each historical segmented word based on each preset topic in the pre-constructed second prediction sub-model through a Softmax function; determine prediction topic selection probabilities of the topics based on the number of the historical segmented words associated with each topic; construct a first loss function based on the real topic selection probabilities corresponding to each topic and the prediction topic selection probabilities, and adjust parameters of the second prediction sub-model based on the first loss function, wherein the real topic selection probabilities are determined according to at least one first historical comment information corresponding to the historical text.
7. The method of claim 6, wherein, The real topic selection probabilities are determined in the following manner: input the at least one first historical comment information in the first prediction training sample into the topic-aware sub-model of the trained comment information generation model; obtain first semantic vectors of each first historical comment information based on the topic-aware sub-model, and determine first historical topics corresponding to the corresponding first historical comment information based on each obtained first semantic vector; determine historical topic selection probabilities of each first historical topic based on the number of the first historical comment information associated with each first historical topic, and take the historical topic selection probabilities as the real topic selection probabilities.
8. The method of claim 7, wherein, The topic-aware sub-model is trained in the following manner: perform a loop iteration training on the topic-aware sub-model according to the second prediction training samples in the second prediction training sample data set, and output the trained topic-aware sub-model when a preset convergence condition is met; wherein the following operations are performed in one loop iteration training process: select a second prediction training sample from the second prediction training sample data set, wherein the second prediction training sample includes at least one second historical comment information; input each second historical comment information in the second prediction training sample into the pre-constructed topic-aware sub-model to determine a second semantic vector corresponding to the second historical comment information; determine a second historical topic corresponding to the corresponding second historical review information based on the second semantic vector corresponding to the second historical review information, and determine a posterior topic selection probability based on the second historical topic; construct a second loss function based on the second semantic vector and the posterior topic selection probability, and adjust parameters of the topic perception sub-model based on the second loss function.
9. The method of claim 8, wherein, The second loss function is constructed based on the second semantic vector and the posterior topic selection probability, comprising: reconstructing the corresponding predicted review information based on the second semantic vector; constructing a second loss function based on the distance between the predicted review information, the posterior topic selection probability and the corresponding prior topic selection probability, and aligning the second semantic vector to a topic vector corresponding to the topic.
10. The method of any one of claims 1-9, wherein, The target review information of the text to be processed is generated based on the key word segmentation set and the target topic word segmentation set, comprising: inputting the key word segmentation set and the target topic word segmentation set into a review information generation sub-module of a trained review information generation model, performing multiple rounds of review word segmentation set prediction through the review information generation sub-module, and generating the target review information based on the review word segmentation set output by the last round of prediction; Wherein, the process of each round of review word segmentation set prediction is: determining the third selection probability of each key word in the key word segmentation set, the fourth selection probability of each topic word in the target topic word segmentation set, and the fifth selection probability of each high-frequency word in the preset high-frequency word set through attention mechanism according to the review words in the review word segmentation set predicted in the previous round; predicting the review word of the current round from the key word segmentation set, the target topic word segmentation set or the high-frequency word set according to the third selection probability, the fourth selection probability and the fifth selection probability, wherein the third selection probability, the fourth selection probability and the fifth selection probability respectively represent the probability of selecting the key word, the topic word and the high-frequency word as the review word.
11. An apparatus for generating comment information, the apparatus comprising: The device comprises: The first determination unit is configured to determine a key word segmentation set corresponding to the text to be processed based on a first similarity between each word included in the text to be processed and a corresponding title, wherein the title represents the core content of the text to be processed. The second determination unit is configured to determine a target topic and a corresponding target topic word segmentation set corresponding to the text to be processed based on a second similarity between each word included in the text to be processed and each preset topic, wherein each target topic represents a recommended review angle for the text to be processed, and each target topic corresponds to at least one topic word. The generation unit is configured to generate target review information of the text to be processed based on the key word segmentation set and the target topic word segmentation set.
12. The apparatus of claim 11, wherein, The first determination unit is specifically configured to: input each word included in the text to be processed and the title into a first prediction sub-model of a trained review information generation model to determine the first similarity between the words and the title; determine a first selected probability corresponding to each word based on the first similarity, the first selected probability being used to represent a probability of each word being selected as a key word; select at least one word from each word included in the text to be processed to form the key word set based on the first selected probability corresponding to each word.
13. The apparatus of claim 11, wherein, The second determining unit is specifically configured to: input each word included in the text to be processed into a second prediction sub-model of the trained comment information generation model; determine a second similarity between each word and each preset topic in the second prediction sub-model based on each preset topic, and determine a topic associated with each word based on each obtained second similarity; determine a topic selected probability of each topic based on a number of words associated with each topic; determine a target topic corresponding to the text to be processed based on the topic selected probability of each topic.
14. An apparatus for generating comment information, characterized by comprising: The device comprises a memory and a processor, wherein the memory is configured to store computer instructions, and the processor is configured to execute the computer instructions to implement the method according to any one of claims 1-10.
15. A computer-readable storage medium, characterized in that, A computer readable storage medium stores computer instructions, and the computer instructions are executed by a processor to implement the method according to any one of claims 1-10.
Citation Information
Patent Citations
Comment generation method and device, server and storage medium
CN110263340A
Social network comment generation method based on LSTM
CN110390018A