A method for automatically generating Internet news content based on big data
By using the Transformer model and dynamic programming search strategy in news text generation, the problem that traditional methods cannot effectively use news keywords to generate complex content and factual consistency errors is solved, and the authenticity and timeliness of news text generation are improved.
Patent Information
- Application Number
- CN202310448620.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2043-04-24
AI Technical Summary
Traditional news text generation methods cannot effectively use news keywords to generate complex and complete news content, and are prone to factual consistency errors, causing the generated news to lose authenticity.
A large-scale model based on Transformer is used for pre-training and parameter fine-tuning, and the MSP, TCR, and TCM pre-training tasks are combined to mine the relationship between news keywords and text, and the text generation search strategy of dynamic programming is used to reduce fact consistency errors.
It improves the authenticity and timeliness of news text generation, can effectively extract information from news keywords and generate complex and complete news content, reducing factual consistency errors.
Smart Images

Figure CN116483990B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of text generation, and in particular relates to a method for automatically generating Internet news content based on big data. Background Art
[0002] With the continuous development and popularization of the Internet, the way people get news has also changed dramatically. Traditional media paper newspapers and TV news have gradually been replaced by Internet news, and with the rise of mobile Internet and social media, people's demand for news content has become more and more urgent. However, due to the complexity and timeliness of news content, traditional news editing methods can no longer meet people's needs. Manual editing requires a lot of time and energy to handle all aspects of news events, and cannot track and process a large amount of information in a timely manner. Therefore, the application of artificial intelligence technology has become increasingly important in news editing.
[0003] The method of automatic generation of Internet news content based on artificial intelligence can automatically collect and process information from various sources through natural language processing and machine learning technology, and generate news content that meets readers' needs and news style. This method can greatly improve the efficiency and accuracy of news editing, and can meet people's needs for timeliness and diversity of news content. It is one of the important technical means of Internet news editing.
[0004] For news text generation, traditional methods mainly discuss two aspects of text generation models. The first aspect is the model training part. Traditional methods mostly use large-scale pre-training models. The model frameworks are different, but the pre-training tasks are basically MLM (Mask Language Model), DAE (Denoising AutoEncode) and other tasks. The basic principle is to mask, delete or add vocabulary-level tokens in the original text, but such generation models are not suitable for the text expansion task of generating news content based on news keywords; the second aspect is text search and decoding. Traditional methods mostly use greedy search or beam search. This method can get a solution with high rationality in a shorter running time, but due to the particularity of news broadcasting, this type of method is prone to factual consistency errors, resulting in the loss of authenticity of the news. Summary of the invention
[0005] In order to solve the problems existing in the above prior art, the present invention proposes a method for automatically generating Internet news content based on big data, which method comprises: obtaining news text data; cleaning the news text data; dividing the cleaned news text data into unlabeled text and labeled text; inputting the unlabeled text data into a large-scale model based on Transformer for pre-training, and inputting the labeled text into the trained large-scale model for parameter fine-tuning to obtain a perfect news text content generation model; obtaining news keywords, inputting the news keywords into the news text content generation model, and adopting a dynamic programming text generation search strategy to obtain the generated news broadcast content.
[0006] Beneficial effects of the present invention:
[0007] The present invention adopts three pre-training tasks for mining the relationship between news keywords and original texts, which solves the difficulty of extracting effective information from simple keywords and expanding complex and complete news content in news text generation. The relationship between news keywords and texts is fully mined through TCR and TCM pre-training tasks, and the artificial writing habit information of news texts is also learned; for artificial grammar, semantics, common words, idiomatic expressions and other information in news texts, the present invention learns this information by proposing MSP tasks; at the same time, in response to factual consistency errors in traditional news text generation methods, the present invention proposes a text search decoding strategy based on dynamic programming, which greatly reduces factual consistency errors in news text generation and improves the authenticity and timeliness of generated texts. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 It is the overall flow chart of the present invention;
[0009] Figure 2 illustrative diagrams of three pre-training tasks of the present invention;
[0010] Figure 3 This is an example diagram of the text search decoding strategy based on dynamic programming of the present invention. DETAILED DESCRIPTION
[0011] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0012] A method for automatically generating Internet news content based on big data, such as Figure 1As shown, the method includes: obtaining news text data; cleaning the news text data; dividing the cleaned news text data into unlabeled text and labeled text; inputting the unlabeled text data into a large-scale model based on Transformer for pre-training, and inputting the labeled text into the trained large-scale model for parameter fine-tuning to obtain a complete news text content generation model; obtaining news keywords, inputting the news keywords into the news text content generation model, and using a dynamic programming text generation search strategy to obtain the generated news broadcast content.
[0013] In this embodiment, the process of training the news text generation model and searching and decoding the text includes:
[0014] S1: Obtain news text data and corresponding news keywords; clean the text data for illegal words and noise data, divide it into unlabeled data sets and labeled data sets, divide the labeled data sets into training sets and test sets, and obtain the TopK keywords and key sentences of the unlabeled text based on the corpus data.
[0015] S2: The unlabeled dataset is fed into a large-scale Transformer-based model for three pre-training tasks: MSP, TCR, and TCM. By reasonably allocating the loss weights of the three pre-training tasks, the loss ratio is made to reach 1:1:1, and a pre-trained model is obtained after pre-training in the news text field.
[0016] S3: Send the labeled data to the pre-trained Transformer model for model fine-tuning.
[0017] S4: The test data is sent to the fine-tuned Transformer model, and then the text generation search strategy based on dynamic programming is used, and then the news text generation content is obtained through post-processing.
[0018] like Figure 2 As shown in the figure, the process of performing the MSP (Mask Sentence Predicition) task is as follows:
[0019] Step 1: Feed the unlabeled and labeled text data into the Word2Vector model to train a word vector model for news text.
[0020] Step 2: Feed the unlabeled text corpus into the Word2Vector model to obtain the paragraph word vector moment W of each sample, and then take the average to obtain the sample paragraph vector C;
[0021] Step 3: Segment the unlabeled text corpus according to standard punctuation marks to obtain a sentence set S for each sample. Send each sentence into the Word2Vector model, and average the word vectors obtained as the sentence vector Vector_S. According to the cosine similarity, the K most different sentences with the original text are obtained. The calculation formula is:
[0022]
[0023] Among them, Sentence represents the selected sentence, Rank topK It means that the K sentences with the highest similarity are obtained after sorting the output results, Vector_Si represents the sentence vector obtained from the i-th sentence set, and C represents the original text.
[0024] Step 4: Mark the top K sentences as [MASK], and let the top K sentences be Sentence1, .... Sentence k , then the label of the training sample is marked as [Sentence1, [SEP], Sentence2, [SEP], ... [SEP], Sentence k ] Finally, the label and the training text after MASK are sent to the tokenizer for word vector embedding layer encoding and then sent to the encoding layer and decoding layer of Transformer respectively.
[0025] Step 5: By Figure 2 The specific input of the MSP task in the above example shows that the input to the encoding layer is A_C_E, and the input to the decoder is ABC, where each token represents a sentence. Then, in the training process of step 4, the distribution probability of the model for each tag token is obtained. The model predicts the probability of the target word for the vocabulary, so the loss function is defined as the cross entropy loss of each token. At the same time, the weight is added to the first token of the K key sentences when calculating the loss function. Assume that the weight matrix W, then the loss function formula is:
[0026]
[0027] Among them, N represents the length of the vocabulary, y 1c represents the symbolic function (0 or 1), if the true category of sample 1 is equal to c, it takes 1, otherwise it takes 0; W represents the loss weight added according to whether it is the first token of the sentence, p 1c Indicates the predicted probability that sample 1 belongs to category c, Sentence i Represents the i-th sentence.
[0028] Depend on Figure 2It can be seen that the next Sentence Token D of the original article AB C is output from the decoding layer.
[0029] like Figure 2 As shown in the figure, the process of performing the TCR (Token Content Recovery) task is as follows:
[0030] Step 1: Feed the unlabeled and labeled text data into the Word2Vector model to train a word vector model for news text.
[0031] Step 2: Feed the unlabeled text corpus into the Word2Vector model to obtain the paragraph word vector moment W of each sample, and then take the average to obtain the sample paragraph vector C;
[0032] Step 3: Split the unlabeled text corpus into words to obtain the word set T of each word. Send each word into the Word2Vector model to obtain the word vector Vector_T. According to the cosine similarity, the K different Token-level keywords with the highest similarity to the original text are obtained. The calculation formula is:
[0033]
[0034] Step 4: Integrate the training data into [Token1, [SEP], Token2, [SEP], ..., Token k ], the original sample text is regarded as a label, and is sent to the tokenizer for embedding encoding, and finally sent to the Encoder and Decoder of the Transformer respectively.
[0035] Step 5: The input to Encoder is the filtered TopK keywords, and the input to Decoder is the original text. In the training process of step 4, the distribution probability of the model for each tag Token is obtained. The model predicts the probability of the target word for the vocabulary, so the loss function is defined as the cross entropy loss of each Token, and the loss weight is increased when the classification is wrong. The loss function formula is:
[0036]
[0037] Among them, N represents the length of the vocabulary, y ij represents the sign function (0 or 1), if the true category of sample i is equal to j, it takes 1, otherwise it takes 0, α represents the loss weight when the classification is correct, β represents the loss weight when the classification is wrong, p ij represents the predicted probability that sample i belongs to category j, and ? represents the ternary operator.
[0038] Finally, by Figure 2 It can be seen that the model outputs the content at the Word Token level after ABCD in the original sentence: E.
[0039] like Figure 2 As shown in the figure, the process of performing TCM (Token Content Matching / keyword original text matching) task is as follows:
[0040] Step 1: Feed the unlabeled and labeled text data into the Word2Vector model to train a word vector model for news text.
[0041] Step 2: Feed the unlabeled text corpus into the Word2Vector model to obtain the paragraph word vector moment W of each sample, and then take the average to obtain the sample paragraph vector C;
[0042] Step 3: Split the unlabeled text corpus into words to obtain the word set T of each word. Send each word into the Word2Vector model to obtain the word vector Vector_T. According to the cosine similarity, the K different Token-level keywords with the highest similarity to the original text are obtained. The calculation formula is:
[0043]
[0044] Step 4: Take half of the samples in the unlabeled data, [MASK] the keywords in the original text, and concatenate the keywords of the sample with the original text into new training data [Token1, [SEP], Token2, [SEP], ..., Content], send it to the tokenizer for word embedding layer encoding, and then send it to the encoding layer of the Transformer. At the same time, mark the sample label as a true sample.
[0045] Step 5: Take the other half of the samples from the unlabeled data, perform [MASK] on the keywords in the original text, shuffle all the keywords of the samples, and take out K different keywords. Concatenate the selected keywords with the original text into new training data [Token1, [SEP], Token2, [SEP], ..., Content], send it to the tokenizer for word embedding layer encoding, and then send it to the encoding layer of the Transformer. At the same time, mark the sample label as a fake sample.
[0046] Step 6: Concatenate the keywords and input text into [B, [SEP], D, [SEP], A, B, C, D, E] and input them into the encoding layer. After the training data is sent to the encoding layer, take out the Last_hidden_state of the last encoding layer, perform average pooling and then pass it through the fully connected layer for binary classification, and calculate the binary classification cross entropy loss function at the same time.
[0047] like Figure 3 As shown in the figure, the text search decoding strategy based on dynamic programming has the following main processes:
[0048] Step 1: Assume the dynamic programming DP array, Dp i Indicates that the token i is the maximum probability of the decoded text at the end, let string Sentence array, Sentence i Indicates that the token i The decoding text of the end of the decoding text when the probability of the concatenation reaches the maximum. Set the maximum length of the text search decoding Max_len, and iterate the entire search algorithm Max_len rounds. Initially, Dp [CLS] The probability value of is set to 1.
[0049] Step 2: In one iteration, first enumerate the Dp array and set the current enumeration as Dp i If the enumeration is , skip this enumeration and encode Decoder_input_ids as Sentence i , sent to the decoding layer, and the original sample code is sent to the encoding layer.
[0050] Step 3: Get the current predicted probability value logits for each Token from step 2, and enumerate all Token situations at the same time, setting the currently enumerated Token as Token j , then the current multiplication probability is prob = logits j *Dp i , prob and Dp j For comparison, if prob is greater than Dp j , then update Dp j And Sentence j Set as Sentence i With Token j connection.
[0051] Step 4: Complete one iteration.
[0052] Step 5: After completing the Max_len rounds of iterations, Sentence [END] Output the result as decoded text.
[0053] The above embodiments further illustrate the purpose, technical solutions and advantages of the present invention in detail. It should be understood that the above embodiments are only preferred implementation modes of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made to the present invention within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for automatically generating Internet news content based on big data, characterized in that: include: Acquire news text data; clean the news text data; divide the cleaned news text data into unlabeled text and labeled text; Input unlabeled text data into a large-scale Transformer-based model for pre-training, and input labeled text into the trained large-scale model for parameter fine-tuning to obtain a complete news text content generation model; obtain news keywords, input the news keywords into the news text content generation model, and use a dynamic programming text generation search strategy to obtain the generated news broadcast content; Pre-training large-scale Transformer-based models involves: S1: Divide the labeled data set into a training set and a test set, where the training set is used to train the model for the task, and the test set is used to test the trained model; S2: Extract the top K keywords and key sentences from the text in the unlabeled dataset; S3: Input the top K keywords and key sentences in the unlabeled dataset into a large-scale Transformer-based model to perform three pre-training tasks: MSP, TCR, and TCM. The process of performing the MSP pre-training task includes: obtaining the TopK sentences including Sentence1, .... Sentence k ; Mark the TopK sentences as [MASK]; Label the TopK sentences to get [Sentence1,[SEP],Sentence2,[SEP],...[SEP],Sentence k ]; Input the labeled data into MASK for masking, input the masked text into the tokenizer for word vector embedding layer encoding, input the encoded data into the encoding layer and decoding layer of Transformer to obtain the logits output by the model, and calculate the loss function of the model through the output logits and the true label; The process of performing TCR pre-training tasks includes: integrating the training data into [Token1,[SEP],Token2,[SEP],...,Token k ], and regard the original sample text as the label; input the integrated data and label into the tokenizer for word vector embedding layer encoding, and send the encoded data into the encoding layer and decoding layer of the Transformer respectively to obtain the logits output by the model, and calculate the loss function of the TCR pre-training task through the output logits and the true label; The process of TCM pre-training task includes: taking half of the samples in the unlabeled data, [MASK] the keywords in the original text, and splicing the keywords of the sample with the original text into new training data [Token1, [SEP], Token2, [SEP], ..., Content], input it into the tokenizer for word vector embedding layer encoding, input the encoded data into the encoding layer of Transformer, obtain the decoded data, and mark the data as true samples; take the other half of the samples in the unlabeled data, perform [MASK] on the keyword part in the original text, and at the same time, shuffle the keywords of all the samples taken out and take out K different keywords, concatenate the selected keywords with the original text into new training data [Token1, [SEP], Token2, [SEP], ..., Content], send it into the tokenizer for word vector embedding layer encoding, input the encoded data into the encoding layer of Transformer for decryption, and mark the decoded samples as false samples; take out the Last_hidden_state of the last encoding layer, do average pooling, and then pass through the fully connected layer for binary classification, and calculate the binary classification cross entropy loss function; S4: Calculate the loss functions of the three training tasks, and use the weight distribution method to fuse the loss functions to obtain the model loss function; S5: Continuously adjust the model parameters and complete the model training when the loss function converges.
2. The method for automatically generating Internet news content based on big data according to claim 1, characterized in that: Cleaning news text data includes cleaning illegal words and noise data from the text data.
3. The method for automatically generating Internet news content based on big data according to claim 1, characterized in that: The process of extracting the top K keywords and key sentences includes: Step 1: Input the unlabeled and labeled text data into the Word2Vector model to train a word vector model for news text. Step 2: Feed the unlabeled text corpus into the trained Word2Vector model to obtain the paragraph word vector moment W of each sample, sum up all the paragraph word vector moments W and take the average to obtain the sample paragraph vector C; Step 3: Segment the unlabeled text corpus according to standard punctuation marks to obtain a sentence set S for each sample. Input each sentence into the Word2Vector model to obtain the sentence vector Vector_S of the average word vector. Use cosine similarity to calculate the similarity score between the sample paragraph vector C and the sentence vector Vector_S, and select the K different sentences with the highest similarity to the original text.
4. The method for automatically generating Internet news content based on big data according to claim 1, characterized in that: The process of obtaining the generated news report content by adopting the text generation search strategy of dynamic programming includes: Step 1: Assume the dynamic programming DP array, the string Sentence array, the maximum length Max_len of the text search decoding, and the iteration Max_len rounds; initially, Dp [CLS] The probability value of is set to 1; where Dp i Indicates that the token i is the maximum probability value of the decoded text at the end, Sentence i Indicates that the token i The decoding text of the ending is the decoding text when the probability of concatenation reaches the maximum; Step 2: Enumerate the Dp array, the current enumeration is Dp i If the enumeration reaches , skip this enumeration and encode Decoder_input_ids as Sentence i , and input it into Decoder, and input the sample original text encoding into Encoder; Step 3: Get the current predicted probability value logits for each Token from step 2, and enumerate all Token situations at the same time, setting the currently enumerated Token as Token j , then the current multiplication probability is prob = logits j *Dp i , prob and Dp j For comparison, if prob is greater than Dp j , then update Dp j And Sentence j Set as Sentence i , and with Token j connection; Step 4: Complete one round of iteration, and the number of iterations increases by 1; Step 5: After completing the Max_len rounds of iterations, Sentence [END] Output the result as decoded text.
