Extractive text summary generation method, device, computer equipment and storage medium
By performing sentence numbering, word segmentation processing and information entropy calculation on the training corpus, selecting sentences with high contribution to train neural networks to generate text summary, solving the problems of lengthy abstracts and low information in the existing technology, and achieving higher quality text summary generation.
Patent Information
- Application Number
- CN202210433352.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-24
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2042-04-24
AI Technical Summary
The digest generated by existing text summary techniques is lengthy and has low information, which makes it impossible to accurately reflect the content information of the original text.
By obtaining the training corpus, conducting sentence numbering and word segmentation processing, calculating word-level and phrase-level information entropy, extracting sentence feature vectors, selecting target training sentences based on the contribution degree, training the pre-constructed multi-layer neural network model, and generating a text summary.
Improve the amount and quality of text summary information to ensure the effectiveness of obtaining information.
Smart Images

Figure CN114706973B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer device, and storage medium for generating an extractive text summary. Background Art
[0002] With the development of internet technology and the rise of self-media platforms, the amount of information on the internet has grown exponentially. People are exposed to a vast amount of information every day, including current affairs news, trending topics, social chats, lectures, and academic papers. In this complex and diverse internet environment, quickly and efficiently accessing valuable information is crucial. To alleviate the reading pressure caused by excessive information and help users quickly access relevant information from the internet, automatic text summarization technology has emerged. Automatic text summarization technology extracts a concise and coherent passage from a single text or a collection of texts, reflecting the core content of the original text. This makes it easier for users to retrieve and search for the information they need, reducing reading pressure.
[0003] Currently, the main text summarization technologies are divided into two categories based on their generation method: extractive and generative. The former uses various methods to directly select certain sentences from the compressed text to form a text summary; the latter uses neural networks to directly compress the original text into a shorter text sequence as the final text summary. However, these methods are prone to generating words and phrases that are not grammatically correct or factually correct. Therefore, in practice, extractive and generative summarization technologies are still in a stage of coexistence and development, and the choice can be made according to the situation.
[0004] TextRank is a classic method in the development of text summarization technology. It scores each sentence in the compressed text, using the resulting score as its weight. Finally, it selects a specified number of sentences with the highest weights to form the final text summary. However, the parameters in its calculation formula are often set based on subjective experience, making it difficult to achieve ideal results in practice.
[0005] In recent years, many researchers have proposed extractive text summarization models based on neural networks. For example, the NeuSUM model breaks the current situation in which sentence scoring and selection are separate components of extractive summarization, combining these two components for model training. In the REFRESH model, text summarization is treated as a sentence sorting task and trained using reinforcement learning, with the reward value being the ROUGE metric. Other researchers have proposed text summarization methods based on pretrained language models, such as BertSum. This model uses the pretrained language model Bert to obtain the sentence vector for each sentence in the compressed text and then captures document-level semantic features for summary extraction.
[0006] The above models usually use the cross entropy loss function to train and update the model, which makes the trained model prone to selecting lengthy and low-information sentences as text summaries. Summary of the Invention
[0007] The purpose of the embodiments of the present application is to propose an extractive text summary generation method, apparatus, computer device and storage medium to solve the problem that the text summaries generated in the related art are lengthy and have low information content, resulting in the text summaries not accurately reflecting the content information of the original text.
[0008] In order to solve the above technical problems, the present application provides an extractive text summarization method, which adopts the following technical solutions:
[0009] Obtaining training corpus, and numbering each sentence in the training corpus;
[0010] Perform word segmentation on each of the numbered sentences to obtain a word segmentation result;
[0011] Calculate the word-level information entropy and phrase-level information entropy of each sentence according to the word segmentation results;
[0012] Performing feature extraction on the sentence to obtain a sentence feature vector;
[0013] Obtaining sentence-level information entropy of the sentence according to the sentence feature vector;
[0014] Calculating the contribution of the sentence based on the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy;
[0015] Selecting a target training sentence based on the contribution, and training a pre-built multi-layer neural network model according to the target training sentence to obtain a text summary generation model;
[0016] Obtain a target text, input the target text into the text summary generation model, and output a text summary.
[0017] Furthermore, the step of calculating the word-level information entropy and phrase-level information entropy of each sentence according to the word segmentation results includes:
[0018] Determining the word probability of each word in the word segmentation result;
[0019] The word-level information entropy is obtained by calculating the word probability;
[0020] Extracting a target phrase from the word segmentation result and determining a phrase probability of the target phrase;
[0021] The phrase-level information entropy is obtained according to the phrase probability calculation.
[0022] Furthermore, the step of obtaining the sentence-level information entropy of the sentence according to the sentence feature vector includes:
[0023] Calculating the similarity between each sentence, and obtaining the sentence occurrence frequency of each sentence according to the similarity;
[0024] The sentence-level information entropy is obtained by calculating the frequency of occurrence of the sentences.
[0025] Furthermore, the step of calculating the contribution of a sentence based on the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy includes:
[0026] Determine weight coefficients corresponding to the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy, respectively;
[0027] According to the weight coefficient, the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy are weighted and summed to obtain the contribution of the sentence.
[0028] Furthermore, the step of inputting the target training sentence into a pre-built multi-layer neural network model for training to obtain a text summary generation model includes:
[0029] Calculating an action value score based on the target training sentence;
[0030] Inputting the target training sentence into the multi-layer neural network model and outputting a prediction result;
[0031] A loss function is determined according to the action value score and the predicted classification result, the multi-layer neural network model is iteratively updated based on the loss function, and the trained multi-layer neural network model is output as a text summary generation model.
[0032] Furthermore, the steps of determining a loss function according to the action value score and the predicted classification result, iteratively updating the multi-layer neural network model based on the loss function, and outputting the trained multi-layer neural network model as a text summary generation model include:
[0033] Calculating a logarithm of the prediction result, multiplying the logarithm by the action value score to obtain a product value, and taking the negative value of the product value as a loss function;
[0034] Adjusting model parameters of the multi-layer neural network model based on the loss function;
[0035] When the iteration end condition is met, the text summary generation model is generated according to the model parameters.
[0036] Furthermore, the step of selecting a target training sentence based on the contribution includes:
[0037] Sorting the sentences according to the contribution to obtain a sorting result;
[0038] A preset number of sentences are selected from the sorting results as target training sentences.
[0039] In order to solve the above technical problems, the present application also provides an extractive text summary generation device, which adopts the following technical solution:
[0040] An acquisition module is used to acquire training corpus and number each sentence in the training corpus;
[0041] A word segmentation module is used to perform word segmentation processing on each of the numbered sentences to obtain a word segmentation result;
[0042] A first calculation module is used to calculate the word-level information entropy and phrase-level information entropy of the sentence according to the word segmentation result;
[0043] A feature extraction module, configured to extract features from the sentence and obtain a sentence feature vector;
[0044] A second calculation module is used to obtain the sentence-level information entropy of the sentence according to the sentence feature vector;
[0045] A third calculation module is used to calculate the contribution of the sentence based on the word-level information entropy, the phrase-level information entropy and the sentence-level information entropy;
[0046] A training module, configured to select target training sentences based on the contribution, and train a pre-built neural network based on the target training sentences to obtain a text summarization model;
[0047] The generation module is used to obtain a target text, input the target text into the text summary generation model, and output a text summary.
[0048] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0049] The computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the above-mentioned extractive text summary generation method when executing the computer-readable instructions.
[0050] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0051] The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the extractive text summary generation method described above.
[0052] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0053] The present application obtains training corpus, numbers each sentence in the training corpus; performs word segmentation on each numbered sentence to obtain a word segmentation result; calculates the word-level information entropy and phrase-level information entropy of each sentence according to the word segmentation result; performs feature extraction on the sentence to obtain a sentence feature vector; obtains the sentence-level information entropy of the sentence according to the sentence feature vector; calculates the contribution of the sentence according to the word-level information entropy, phrase-level information entropy and sentence-level information entropy; selects target training sentences based on the contribution, trains a pre-built neural network based on the target training sentences, and obtains a text summary generation model; obtains a target text, inputs the target text into the text summary generation model, and outputs a text summary; the present application obtains a text summary generation model by selecting target training sentences based on the contribution to train the neural network, which can increase the information content of the text summary, further improve the quality of the text summary, and ensure the effectiveness of the information obtained. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the solutions in this application, a brief introduction will be given below to the drawings required for use in the description of the embodiments of this application. Obviously, the drawings described below are some embodiments of this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0055] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0056] Figure 2 A flowchart of an embodiment of the extractive text summary generation method according to the present application;
[0057] Figure 3 1 is a schematic structural diagram of an embodiment of an extractive text summary generation device according to the present application;
[0058] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit this application. The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0060] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0061] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0062] This application provides an extractive text summary generation method involving artificial intelligence, which can be applied to Figure 1 In the illustrated system architecture 100, the system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 is used as a medium for providing communication links between the terminal devices 101, 102, and 103 and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0063] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0064] Terminal devices 101, 102, and 103 can be various electronic devices with display screens and support web browsing, including but not limited to smartphones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV), laptop computers, desktop computers, etc.
[0065] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0066] It should be noted that the extractive text summary generation method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the extractive text summary generation device is generally set in the server / terminal device.
[0067] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0068] Continue to refer Figure 2 , shows a flowchart of an embodiment of the extractive text summary generation method according to the present application, comprising the following steps:
[0069] Step S201: obtain training corpus and number each sentence in the training corpus.
[0070] In this embodiment, the training corpus can be obtained from public datasets, such as the CNN / DailyMail dataset, the LCSTS dataset, the NLPCC2017 dataset, etc., wherein the CNN / DailyMail dataset is an English dataset, and the LCSTS dataset and the NLPCC2017 dataset are Chinese text datasets.
[0071] A training corpus is obtained, and sentences in the training corpus are numbered, starting from the first sentence of the training corpus to the last sentence, to obtain sentence numbers S_ID, where S_ID = {1, 2, 3, ...,}.
[0072] Step S202: perform word segmentation on each numbered sentence to obtain a word segmentation result.
[0073] It should be understood that there are natural separators in English texts, but there are no special symbols to separate words in Chinese. In addition, Chinese words are mostly two-character and multi-character words. Word segmentation is a crucial step. The accuracy of word segmentation will have an important impact on subsequent steps.
[0074] In this embodiment, a word segmenter may be used for word segmentation, including the Jieba Chinese word segmenter, Hanlp word segmenter, foolnltk word segmenter, and pullword online word segmentation engine, etc. The word segmentation tool is not limited here.
[0075] Step S203: Calculate the word-level information entropy and phrase-level information entropy of each sentence based on the word segmentation results.
[0076] In this embodiment, the steps of calculating the word-level information entropy of each sentence based on the word segmentation results are as follows:
[0077] Determine the word probability of each word in the word segmentation result;
[0078] The word-level information entropy is calculated based on the word probability.
[0079] Specifically, use SW ik Represents the i-th sentence S i The word k in the word SW ik The frequency of occurrence in the entire training corpus is taken as the probability of the word appearing P(SW ik ), then sentence S i The word-level information entropy calculation method is as follows:
[0080] H(SW ik )=-∑ k=1 P(SW ik )logP(SW ik );
[0081] Among them, H(SW ik ) represents sentence S i The word-level information entropy of .
[0082] In this embodiment, the steps of calculating the phrase-level information entropy of each sentence based on the word segmentation results are as follows:
[0083] Extract the target phrase from the word segmentation result and determine the phrase probability of the target phrase;
[0084] The phrase-level information entropy is calculated based on the phrase probability.
[0085] Specifically, the N-gram model can be used to extract target phrases. N-Gram is an algorithm based on a statistical language model. Its basic idea is to perform a sliding window operation of size N on the byte content of the text, forming a sequence of byte segments of length N. For example, N can be 3 or 4. When N is 3, a 3-gram represents a 3-character phrase, that is, the 3-character phrase in the word segmentation result is extracted as the target phrase; similarly, when N is 4, the 4-character phrase in the word segmentation result is extracted as the target phrase.
[0086] In this embodiment, SNG iw Represents sentence S i The phrase w in the phrase SNG iw The frequency of occurrence in the entire training corpus is taken as the phrase probability P(SNG iw ), then sentence S i The phrase-level information entropy calculation method is as follows:
[0087] H(SNG iw )=-∑ w=1 P(SNG iw )logP(SNG iw );
[0088] Among them, H(SNG iw ) represents sentence S i The phrase-level information entropy of .
[0089] This embodiment calculates the information entropy of different dimensions of sentences, which can lay the foundation for subsequent selection of sentences with high information content for model training.
[0090] Step S204: extract features from the sentence to obtain a sentence feature vector.
[0091] In this embodiment, feature extraction is performed on each sentence to obtain a sentence representation vector, a sentence feature vector. The sentence feature vector can be extracted by inputting the sentence into a feature vector extraction model for processing. The feature vector extraction model includes but is not limited to a CNN (Convolutional Neural Networks) model, an RNN (Recurrent Neural Network) model, and a BERT (Bidirectional Encoder Representations from Transformers) model, etc., which are not limited here.
[0092] As a specific implementation method, the sentence can be input into S iTo the BERT model, the BERT model includes at least an input layer, a feature extraction layer, and an output layer. Specifically, the sentence S i The input is fed into the BERT model’s input layer for vector conversion to obtain the sentence vector corresponding to the sentence. The sentence vector is then extracted through the feature extraction layer, and the sentence feature vector Vs is output through the output layer. i .
[0093] Step S205: Obtain sentence-level information entropy of the sentence according to the sentence feature vector.
[0094] In some optional implementations, the similarity between each sentence is calculated, the sentence occurrence frequency of each sentence is obtained based on the similarity, and the sentence-level information entropy is calculated based on the sentence occurrence frequency.
[0095] In this embodiment, the sentence S is calculated by the similarity function i The similarity between the sentence and other sentences in the training corpus.
[0096] Specifically, calculate the sentence feature vectors of other sentences in the training corpus and sentence S i Sentence feature vector Vs i Similarity SS i , Statistics Vs i The number of sentences whose similarity exceeds the preset threshold S_T (a value between 0 and 1) is Sim_N(i), and the sentence S i The frequency of occurrence of sentences P(SS i ), using the following formula:
[0097]
[0098] Where i is the sentence number and N_S represents the total number of sentences in the training corpus.
[0099] Then sentence S i The sentence-level information entropy calculation method is as follows:
[0100] H(SS i )=-∑ k=1 P(SS ik )logP(SS ik );
[0101] Among them, H(SS i ) represents the sentence-level information entropy.
[0102] This embodiment calculates the information entropy of the sentence dimension, which also lays the foundation for the subsequent selection of sentences with high information content for model training.
[0103] Step S206: Calculate the contribution of the sentence based on the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy.
[0104] Among them, the contribution of a sentence is the importance of the sentence.
[0105] In this embodiment, the weight coefficients corresponding to the word-level information entropy, phrase-level information entropy and sentence-level information entropy are determined respectively, and the word-level information entropy, phrase-level information entropy and sentence-level information entropy are weighted and summed according to the weight coefficients to obtain the contribution of the sentence.
[0106] Among them, the weight coefficient is pre-set, and the contribution of the sentence is calculated using the following formula:
[0107] CS i =αH(SW ik )+βH(SNG iw )+γH(SS i );
[0108] Among them, α, β and γ are the weight coefficients of word-level information entropy, phrase-level information entropy and sentence-level information entropy, respectively, and their values range from 0 to 1.
[0109] This embodiment calculates the contribution of a sentence, so that a summary can be generated based on prior information, thereby increasing the information content of the text summary.
[0110] Step S207 : selecting a target training sentence based on the contribution, and training the pre-built neural network according to the target training sentence to obtain a text summary generation model.
[0111] In this example, sentences are selected through reinforcement learning to train the text summarization model. Before training, the following definitions are made in advance:
[0112] Define reinforcement learning actions: select a sentence from the set each time.
[0113] Define the action set for reinforcement learning: Before each round of action, calculate the contribution of the sentences in the training corpus and sort them in descending order. Select the top N sentences as target training sentences to form an action set. Once a sentence has been selected, its contribution will no longer be calculated in the next round of action.
[0114] Define the reward function: Use the ROUGE-i value, a common indicator for evaluating the quality of text summarization, where i represents the number of words in the N-gram phrase, usually taking a value of 1, 2, 3, or 4.
[0115] Calculate ROUGE-N average ROUGE ave Use the following formula:
[0116]
[0117] If the action in round t makes ROUGE ave Compared with the previous round, the decrease and increase are respectively given different value scores S t , the formula is as follows:
[0118]
[0119] It should be understood that since the action score after each round of selection will have an impact on subsequent actions, and this impact will gradually decay as the number of iterations increases, it is also necessary to calculate the potential value score after each round of action.
[0120] Define the value decay coefficient λ, and the score of the t-th action is S t , the calculation formula of the final action value score S is:
[0121]
[0122] In this embodiment, a multi-layer neural network model corresponding to N action categories is pre-constructed, a preset number N of target training sentences selected according to contribution are input into the multi-layer neural network model, and the multi-layer neural network model is trained and updated according to the action value score to maximize the action value score, wherein N is a natural number greater than zero.
[0123] It should be noted that the multi-layer neural network model only outputs one result each time. N actions means that the multi-layer neural network model needs to output N results, that is, the generated summary contains N sentences.
[0124] As a specific implementation method, the multi-layer neural network model includes an input layer, a first hidden layer, a second hidden layer and an output layer. The input layer inputs a vector v; the weight matrix of the first hidden layer is set to w1, the relu activation function is adopted, and the bias is b1, then the output of the first hidden layer is o1=relu(w1*v+b1); the weight matrix of the second hidden layer is set to w2, the relu activation function is adopted, and the bias is b2, then the output of the second hidden layer is o2=relu(w2*o1+b2); the output layer adopts a softmax layer, o2 is input into the softmax layer, and o3 is obtained through the softmax layer, o3 is the probability Pa of each action.
[0125] In order to achieve better summary generation effect, more hidden layers can be set according to actual conditions.
[0126] Step S208: Obtain the target text, input the target text into the text summary generation model, and output the text summary.
[0127] Obtain the target text to be summarized and input it into the text summary generation model, and then output the text summary.
[0128] This application obtains a text summary generation model by selecting target training sentences according to contribution to train a neural network, which can increase the amount of information in the text summary, further improve the quality of the text summary, and ensure the effectiveness of obtaining information.
[0129] In some optional implementations of this embodiment, the step of inputting the target training sentence into the pre-built multi-layer neural network model for training to obtain the text summarization generation model includes:
[0130] Calculate the action value score based on the target training sentence;
[0131] Input the target training sentence into the multi-layer neural network model and output the prediction result;
[0132] The loss function is determined according to the action value score and the predicted classification result. The multi-layer neural network model is iteratively updated based on the loss function, and the trained multi-layer neural network model is output as the text summary generation model.
[0133] Among them, the action value score S can be calculated according to the above formula. The target training sentence is input into the multi-layer neural network model, passed through the input layer, hidden layer, and predicted by the softmax layer in sequence to obtain the probability corresponding to each action, and the sentence corresponding to the probability is output. This sentence is the sentence with the highest predicted probability in this action.
[0134] In some optional implementations, the steps of determining the loss function based on the action value score and the predicted classification result are as follows:
[0135] Calculate the logarithm of the prediction result, multiply the logarithm by the action value score to get the product value, and take the negative value of the product value as the loss function. The calculation method of the loss function is as follows:
[0136] Loss=-S×logPa t ;
[0137] Among them, Pa t represents the probability of taking action in round t.
[0138] In this embodiment, the model parameters of the multi-layer neural network model are adjusted based on the loss function, and when the iteration end condition is met, a text summary generation model is generated according to the model parameters.
[0139] Specifically, the model parameters of the multi-layer neural network model are adjusted based on the loss function value, and iterative training continues. The model is trained to a certain level, at which point the model performance reaches an optimal state and the loss function value hardly changes, which is called convergence. The model converges when the iteration end condition is met. After the model converges, the final multi-layer neural network model is output as the text summarization model based on the final adjusted model parameters.
[0140] This application uses reinforcement learning to train a pre-built multi-layer neural network model as a text summary generation model, which can improve the quality of generated text summaries.
[0141] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0142] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware via computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes in the above-described method embodiments. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0143] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0144] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of an extractive text summary generation device. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0145] like Figure 3 As shown, the extractive text summary generation device 300 of this embodiment includes: an acquisition module 301, a word segmentation module 302, a first calculation module 303, a feature extraction module 304, a second calculation module 305, a third calculation module 306, a training module 307, and a generation module 308. Among them:
[0146] The acquisition module 301 is used to acquire training corpus and number each sentence in the training corpus;
[0147] The word segmentation module 302 is used to perform word segmentation processing on each of the numbered sentences to obtain a word segmentation result;
[0148] The first calculation module 303 is used to calculate the word-level information entropy and phrase-level information entropy of the sentence according to the word segmentation results;
[0149] The feature extraction module 304 is used to extract features from the sentence to obtain a sentence feature vector;
[0150] The second calculation module 305 is used to obtain the sentence-level information entropy of the sentence according to the sentence feature vector;
[0151] The third calculation module 306 is used to calculate the contribution of the sentence based on the word-level information entropy, the phrase-level information entropy and the sentence-level information entropy;
[0152] The training module 307 is used to select target training sentences based on the contribution, and train the pre-built neural network according to the target training sentences to obtain a text summary generation model;
[0153] The generation module 308 is used to obtain a target text, input the target text into the text summary generation model, and output a text summary.
[0154] The above-mentioned extractive text summary generation device can increase the information content of the text summary, further improve the quality of the text summary, and ensure the effectiveness of obtaining information by selecting target training sentences according to the contribution degree to train the neural network to obtain a text summary generation model.
[0155] In this embodiment, the first calculation module 303 includes a probability determination submodule and a calculation submodule, wherein:
[0156] The probability determination submodule is used to determine the word probability of each word in the word segmentation result;
[0157] The calculation submodule is used to calculate the word-level information entropy according to the word probability;
[0158] The probability determination submodule is further configured to extract a target phrase from the word segmentation result and determine the phrase probability of the target phrase;
[0159] The calculation submodule is further configured to calculate the phrase-level information entropy according to the phrase probability.
[0160] This embodiment calculates the information entropy of different dimensions of sentences, which can lay the foundation for subsequent selection of sentences with high information content for model training.
[0161] In this embodiment, the second calculation module 305 includes a similarity submodule and a calculation submodule, wherein:
[0162] The similarity submodule is used to calculate the similarity between each sentence and obtain the sentence occurrence frequency of each sentence based on the similarity;
[0163] The calculation submodule is used to calculate the sentence-level information entropy according to the frequency of occurrence of the sentence.
[0164] This embodiment calculates the information entropy of the sentence dimension, which also lays the foundation for the subsequent selection of sentences with high information content for model training.
[0165] In this embodiment, the third calculation module 306 includes a weight submodule and a summation submodule, wherein:
[0166] The weight submodule is used to determine the weight coefficients corresponding to the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy respectively;
[0167] The summation submodule is used to perform weighted summation on the word-level information entropy, the phrase-level information entropy and the sentence-level information entropy according to the weight coefficient to obtain the contribution of the sentence.
[0168] This embodiment can determine the importance of a sentence by calculating the contribution of the sentence, so that a summary can be generated based on prior information, thereby increasing the information content of the text summary.
[0169] In some optional implementations of this embodiment, the training module 307 includes a value calculation submodule, a prediction submodule, and an iteration submodule, wherein:
[0170] The value calculation submodule is used to calculate the action value score based on the target training sentence;
[0171] The prediction submodule is used to input the target training sentence into the multi-layer neural network model and output the prediction result;
[0172] The iterative submodule is used to determine the loss function according to the action value score and the predicted classification result, iteratively update the multi-layer neural network model based on the loss function, and output the trained multi-layer neural network model as a text summary generation model.
[0173] This embodiment uses reinforcement learning to train a pre-built multi-layer neural network model as a text summary generation model, which can improve the quality of generated text summaries.
[0174] In this embodiment, the iterative submodule includes a calculation unit, an adjustment unit, and a model generation unit, wherein:
[0175] The calculation unit is used to calculate the logarithm of the prediction result, multiply the logarithm by the action value score to obtain a product value, and take the negative value of the product value as the loss function;
[0176] An adjustment unit is used to adjust the model parameters of the multi-layer neural network model based on the loss function;
[0177] The model generation unit is used to generate the text summary generation model according to the model parameters when the iteration end condition is met.
[0178] This embodiment trains the optimization model using the prediction results and action value scores, so that high-quality sentences have a higher probability of appearing in the text summary, thereby improving the quality of the text summary.
[0179] In some optional implementations, the training module 307 further includes a sorting submodule and a selection submodule, wherein:
[0180] The sorting submodule is used to sort the sentences according to the contribution to obtain a sorting result;
[0181] The selection submodule is used to select a preset number of sentences from the sorting results as target training sentences.
[0182] This embodiment can ensure the effectiveness of information acquisition in text summarization by selecting sentences based on contribution to train the model.
[0183] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0184] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0185] The computer device may be a desktop computer, notebook computer, PDA, cloud server, etc. The computer device may interact with the user via a keyboard, mouse, remote control, touchpad, or voice control device.
[0186] The memory 41 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as the computer-readable instructions of the extractive text summarization method. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.
[0187] In some embodiments, the processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to execute computer-readable instructions stored in the memory 41 or process data, such as executing computer-readable instructions for the extractive text summarization method.
[0188] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
[0189] This embodiment implements the steps of the extractive text summary generation method in the above embodiment when the processor executes computer-readable instructions stored in the memory. By selecting target training sentences based on the contribution degree to train the neural network to obtain a text summary generation model, the information content of the text summary can be increased, the quality of the text summary can be further improved, and the effectiveness of the information obtained can be ensured.
[0190] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the above-mentioned extractive text summary generation method. By selecting target training sentences according to the contribution degree to train the neural network to obtain a text summary generation model, the information content of the text summary can be increased, the quality of the text summary can be further improved, and the effectiveness of obtaining information can be ensured.
[0191] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0192] Obviously, the embodiments described above are only some of the embodiments of the present application, rather than all of the embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned specific embodiments, or to make equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the present application specification and the accompanying drawings, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present application.
Claims
1. A method for generating an extractive text summary, characterized in that: The steps include: Obtaining training corpus, and numbering each sentence in the training corpus; Perform word segmentation on each of the numbered sentences to obtain a word segmentation result; Calculate the word-level information entropy and phrase-level information entropy of each sentence according to the word segmentation results; Performing feature extraction on the sentence to obtain a sentence feature vector; Obtaining sentence-level information entropy of the sentence according to the sentence feature vector; Calculating the contribution of the sentence based on the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy; Based on the contribution, N sentences are selected as target training sentences, the target training sentences are formed into an action set, and a pre-built multi-layer neural network model is trained based on the target training sentences to obtain a text summarization model; wherein, each sentence in the target training sentences is an action, and the multi-layer neural network model outputs only one result at a time, and a total of N results need to be output; Obtaining a target text, inputting the target text into the text summary generation model, and outputting a text summary; The step of calculating the word-level information entropy and phrase-level information entropy of each sentence according to the word segmentation results includes: Determining the word probability of each word in the word segmentation result; The word-level information entropy is obtained by calculating the word probability; Extracting a target phrase from the word segmentation result and determining a phrase probability of the target phrase; Calculating the phrase-level information entropy based on the phrase probability; The step of obtaining the sentence-level information entropy of the sentence according to the sentence feature vector includes: Calculating the similarity between each sentence, and obtaining the sentence occurrence frequency of each sentence according to the similarity; The sentence-level information entropy is obtained by calculating the frequency of occurrence of the sentences.
2. The extractive text summarization method according to claim 1, characterized in that: The step of calculating the contribution of a sentence based on the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy includes: Determine weight coefficients corresponding to the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy, respectively; According to the weight coefficient, the word-level information entropy, the phrase-level information entropy, and the sentence-level information entropy are weighted and summed to obtain the contribution of the sentence.
3. The extractive text summarization method according to claim 1, wherein: The step of inputting the target training sentence into a pre-built multi-layer neural network model for training to obtain a text summary generation model includes: Calculating an action value score based on the target training sentence; Inputting the target training sentence into the multi-layer neural network model and outputting a prediction result; A loss function is determined according to the action value score and the predicted classification result, the multi-layer neural network model is iteratively updated based on the loss function, and the trained multi-layer neural network model is output as a text summary generation model.
4. The extractive text summarization method according to claim 3, wherein: The steps of determining a loss function according to the action value score and the predicted classification result, iteratively updating the multi-layer neural network model based on the loss function, and outputting the trained multi-layer neural network model as a text summary generation model include: Calculating a logarithm of the prediction result, multiplying the logarithm by the action value score to obtain a product value, and taking the negative value of the product value as a loss function; Adjusting model parameters of the multi-layer neural network model based on the loss function; When the iteration end condition is met, the text summary generation model is generated according to the model parameters.
5. The extractive text summarization method according to claim 1, wherein: The step of selecting a target training sentence based on the contribution comprises: Sorting the sentences according to the contribution to obtain a sorting result; A preset number of sentences are selected from the sorting results as target training sentences.
6. An extractive text summary generation device, characterized in that: include: An acquisition module is used to acquire training corpus and number each sentence in the training corpus; A word segmentation module is used to perform word segmentation processing on each of the numbered sentences to obtain a word segmentation result; A first calculation module is used to calculate the word-level information entropy and phrase-level information entropy of the sentence according to the word segmentation result; A feature extraction module, configured to extract features from the sentence and obtain a sentence feature vector; A second calculation module is used to obtain the sentence-level information entropy of the sentence according to the sentence feature vector; A third calculation module is used to calculate the contribution of the sentence based on the word-level information entropy, the phrase-level information entropy and the sentence-level information entropy; A training module is configured to select N sentences as target training sentences based on the contribution, form an action set from the target training sentences, and train a pre-built multi-layer neural network model based on the target training sentences to obtain a text summarization model; wherein each sentence in the target training sentences is an action, and the multi-layer neural network model outputs only one result at a time, and a total of N results need to be output; A generation module, configured to obtain a target text, input the target text into the text summary generation model, and output a text summary; The first calculation module includes a probability determination submodule and a calculation submodule, wherein: The probability determination submodule is used to determine the word probability of each word in the word segmentation result; The calculation submodule is used to calculate the word-level information entropy according to the word probability; The probability determination submodule is further configured to extract a target phrase from the word segmentation result and determine the phrase probability of the target phrase; The calculation submodule is further configured to calculate the phrase-level information entropy based on the phrase probability; The second calculation module includes a similarity submodule and a calculation submodule, wherein: The similarity submodule is used to calculate the similarity between each sentence and obtain the sentence occurrence frequency of each sentence based on the similarity; The calculation submodule is used to calculate the sentence-level information entropy according to the frequency of occurrence of the sentence.
7. A computer device comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the extractive text summarization method according to any one of claims 1 to 5 when executing the computer-readable instructions.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the extractive text summarization method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Abstract generation method and device, server and storage medium
CN109657054A
Text abstract generation method and device, electronic equipment and storage medium
CN114138936A