A method for generating an abstract and a related device
By calculating sentence similarity and weight, and combining the sentence-title similarity and keyword count, the sentence summary with the highest weight is generated. This solves the problems of high semantic repetition and limited application scenarios in existing technologies, and achieves efficient and accurate summary generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-16
- Publication Date
- 2026-03-20
AI Technical Summary
Existing extractive automatic summarization techniques tend to overlook sentences in non-primary categories, resulting in high semantic redundancy and missing important information in the generated summaries. Generative automatic summarization techniques, on the other hand, require a large amount of labeled data and the generation process is time-consuming, limiting their application scenarios.
By calculating the similarity and weight between sentences, sentence categories are divided, and the sentence with the highest weight is selected to generate a summary. The similarity between sentences and titles and the number of keywords are combined to train a generation model using a small amount of labeled data, and the summary is generated by combining extraction and generation techniques.
The generated summaries possess semantic diversity and comprehensive information, reducing model training costs and improving generation efficiency and accuracy, and are applicable to various text structures.
Smart Images

Figure CN116644176B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence (AI), and in particular to a summary generation method and a related device thereof. BACKGROUND
[0002] Automatic summary technology is a technology of automatically generating a summary by using a computer to automatically analyze a text and summarize content, that is, expressing main content of a text in a concise form according to a requirement of a user. The automatic summary technology can effectively help the user to find content of interest from an article retrieved by the user, and improve reading speed and quality.
[0003] At present, there are two types of automatic summary technology, one of which is extractive automatic summary technology, and the other of which is generative automatic summary technology. The extractive automatic summary technology can be implemented based on a textrank algorithm. An implementation process of the textrank algorithm is as follows: first, a target text (that is, a text to be generated as a summary) is analyzed to determine similarity between sentences in the target text. Then, based on the similarity between the sentences, all the sentences in the target text can be divided into multiple categories (also referred to as semantic clusters). Then, a number of sentences can be extracted from a certain category as a summary of the target text.
[0004] However, the similarity between the sentences of different categories is low, the textrank algorithm is limited by itself, and the attention of the algorithm is easily focused on a certain category (the number of sentences included in the category is usually the largest), and the remaining categories (the number of sentences included in the remaining categories is usually smaller) are easily ignored, resulting in that the finally generated summary only contains the sentences of a certain category, and does not contain the sentences of the remaining important categories, that is, the finally generated summary has high semantic repetition and lacks important information. SUMMARY
[0005] Embodiments of the present application provide a summary generation method and a related device thereof, and provide a new way to automatically generate a summary. The summary generated by the way has a certain degree of semantic diversity, and the information contained in the summary is comprehensive enough to accurately express the main content of the entire target text.
[0006] A first aspect of embodiments of the present application provides a summary generation method, which includes:
[0007] When it is needed to obtain the summary of the target text, the target text can be split to obtain a plurality of sentences of the target text (i.e. all the sentences of the target text). Then, the plurality of sentences of the target text can be analyzed by using the similarity algorithm to obtain the similarity between any two sentences of the plurality of sentences of the target text. For example, the plurality of sentences of the target text can be calculated by using the similarity algorithm to obtain a first matrix, the first matrix comprising the similarity between any two sentences of the plurality of sentences of the target text, i.e. the similarity between two sentences.
[0008] After obtaining the similarity between any two sentences of the plurality of sentences of the target text, the plurality of sentences of the target text can be divided into a plurality of categories based on the similarity between any two sentences of the plurality of sentences of the target text. For example, after obtaining the first matrix, the plurality of sentences of the target text can be divided into a plurality of categories (i.e. a plurality of semantic clusters) based on the first matrix, i.e. the similarity between the sentences can divide the plurality of sentences of the target text into a plurality of categories, each category comprising at least one sentence of the target text.
[0009] After obtaining the plurality of categories, the sentence with the largest weight in each category of the plurality of categories can also be determined based on the similarity and the target text. Further, the sentence with the largest weight in each category can be determined by the following way: after obtaining the similarity between any two sentences of the plurality of sentences of the target text, iterative operation can be performed based on the similarity to obtain the weight of each sentence of the target text. Then, the sentence with the largest weight in each category of the plurality of categories can be determined. For example, after obtaining the first matrix, iterative operation can be performed based on the first matrix to obtain a second matrix, the second matrix comprising the weight of each sentence of the target text, it is to be noted that the weight of any one sentence of the target text can also be understood as the importance of the sentence, if the weight of the sentence is larger, it means that the importance of the sentence is larger, if the weight of the sentence is smaller, it means that the importance of the sentence is smaller. Since the second matrix comprises the weight of each sentence of the plurality of sentences of the target text, the sentence with the largest weight in each category of the plurality of categories can be determined.
[0010] After determining the sentence with the largest weight in each category, the summary of the target text can be generated based on the part of the sentences.
[0011] As can be seen from the above method, after obtaining the plurality of sentences of the target text and the first matrix, the second matrix can be obtained by iterative operation based on the first matrix, the first matrix containing the similarity between any two sentences in the plurality of sentences, and the second matrix containing the weight of each sentence in the plurality of sentences. Then, the plurality of sentences can be divided into a plurality of categories based on the first matrix. Next, the sentence with the maximum weight in each category of the plurality of categories can be determined based on the second matrix. Finally, the summary of the target text is generated based on the sentence with the maximum weight. In the foregoing process, since the summary of the target text is derived from the sentence with the maximum weight in each category of the target text, the summary has a certain degree of semantic diversity, and the information contained in the summary is sufficient to accurately express the main content of the entire target text. It can be seen that the summary of the target text generated in this way has low semantic repetition between sentences and includes important information of the target text.
[0012] In a possible implementation, the method further includes: obtaining a third matrix and a fourth matrix, the third matrix containing the similarity between any one of the plurality of sentences and the title of the target text, and the fourth matrix containing the number of keywords contained in each sentence in the plurality of sentences; and obtaining the second matrix by iterative operation based on the first matrix includes: fusing the first matrix, the third matrix, and the fourth matrix to obtain a fifth matrix, and obtaining the second matrix by iterative operation based on the fifth matrix. In the foregoing implementation, after obtaining the target text, the following steps can be performed: (1) the title of the target text and the plurality of sentences of the target text can be calculated by using the same similarity algorithm to obtain the third matrix, the third matrix containing the similarity between any one of the plurality of sentences of the target text and the title of the target text; (2) the plurality of sentences of the target text can be detected by using a keyword detection algorithm to obtain the fourth matrix, the fourth matrix containing the number of keywords contained in each sentence in the plurality of sentences of the target text; and (3) after obtaining the third matrix and the fourth matrix, the first matrix, the third matrix, and the fourth matrix can be fused (which can also be understood as matrix merging) to obtain the fifth matrix. After obtaining the fifth matrix, the second matrix can be obtained by iterative operation based on the fifth matrix. It can be seen that, when obtaining the weight of the sentence, the present application not only considers the similarity between the sentences, but also considers the similarity between the sentences and the title, the number of keywords contained in the sentences, and other factors, so that the considered factors are more comprehensive, which is conducive to improving the accuracy of the weight of the sentence and further improving the quality of the summary of the target text.
[0013] In a possible implementation, if the first matrix is an n-row n-column matrix, the third matrix and the fourth matrix are n-row 1-column matrices, and n is the number of sentences, the first matrix, the third matrix, and the fourth matrix are fused to obtain a fifth matrix, including: performing normalization processing on the first matrix, the third matrix, and the fourth matrix to obtain a processed first matrix, a processed third matrix, and a processed fourth matrix, the i th column of the processed first matrix, the processed third matrix, and the processed fourth matrix all conform to a standard normal distribution, i = 1, …, n; performing addition processing on the i th column of the processed first matrix, the processed third matrix, the processed fourth matrix, and the i th positive value to obtain the i th column of the fifth matrix, and the i th column of the fifth matrix conforms to a normal distribution. In the foregoing implementation, if the first matrix is an n-row n-column matrix, and the third matrix and the fourth matrix are n-row 1-column matrices, the first matrix, the third matrix, and the fourth matrix can be normalized by column to obtain the processed first matrix, the processed third matrix, and the processed fourth matrix. It should be noted that the processed first matrix is still an n-row n-column matrix, and all elements in the i th column of the processed first matrix (i = 1, …, n) can conform to the standard normal distribution. Similarly, the processed third matrix is still an n-row 1-column matrix, all elements of the processed third matrix conform to the standard normal distribution, and the processed fourth matrix is still an n-row 1-column matrix, all elements of the processed fourth matrix conform to the standard normal distribution. It can be seen that the processed first matrix, the processed third matrix, and the processed third matrix are matrices of the same dimension, which is beneficial to subsequent matrix calculation.
[0014] Further, after obtaining the processed first matrix, the processed third matrix, and the processed fourth matrix, the i th column of the processed first matrix, the processed third matrix, the processed fourth matrix, and the i th positive value can be added to obtain the i th column of the fifth matrix. Due to the existence of the i th positive value, the i th column of the fifth matrix can conform to the normal distribution. The remaining columns of the processed first matrix can also be operated as the i th column of the processed first matrix, so the remaining columns of the fifth matrix can be obtained. In this way, the complete fifth matrix is obtained.
[0015] In a possible implementation, if the first matrix is an n-row and n-column matrix, the third matrix and the fourth matrix are 1-row and n-column matrices, and n is the number of sentences, the first matrix, the third matrix, and the fourth matrix are fused to obtain a fifth matrix, including: performing normalization processing on the first matrix, the third matrix, and the fourth matrix to obtain a processed first matrix, a processed third matrix, and a processed fourth matrix, a jth row of the processed first matrix and the processed third matrix and the processed fourth matrix all conform to a standard normal distribution, j = 1,..., n; performing addition processing on the jth row of the processed first matrix, the processed third matrix, the processed fourth matrix, and a jth positive value to obtain a jth row of the fifth matrix, and the jth row of the fifth matrix conforms to a normal distribution. In the foregoing implementation, if the first matrix is an n-row and n-column matrix, the third matrix and the fourth matrix are 1-row and n-column matrices, the first matrix, the third matrix, and the fourth matrix can be normalized by row to obtain the processed first matrix, the processed third matrix, and the processed fourth matrix. It should be noted that the processed first matrix is still an n-row and n-column matrix, and all elements in the jth row (j = 1,..., n) of the processed first matrix conform to the standard normal distribution. Similarly, the processed third matrix is still a 1-row and n-column matrix, all elements of the processed third matrix conform to the standard normal distribution, and the processed fourth matrix is still a 1-row and n-column matrix, all elements of the processed fourth matrix conform to the standard normal distribution. It can be seen that the processed first matrix, the processed third matrix, and the processed third matrix are matrices of the same dimension, which is beneficial to subsequent matrix calculation.
[0016] Further, after obtaining the processed first matrix, the processed third matrix, and the processed fourth matrix, the jth row of the processed first matrix, the processed third matrix, the processed fourth matrix, and a jth positive value can be added to obtain a jth row of the fifth matrix. Due to the existence of the jth positive value, the jth row of the fifth matrix conforms to the normal distribution. The remaining rows of the processed first matrix can also be operated as the jth row of the processed first matrix, so the remaining rows of the fifth matrix can be obtained. In this way, a complete fifth matrix is obtained.
[0017] In a possible implementation, the ith positive value can be obtained by: in the ith column of the processed first matrix, the processed third matrix, and the processed fourth matrix, the smallest element can be selected, and the smallest element is summed with a preset positive value to obtain the ith positive value.
[0018] In a possible implementation, the jth positive value can be obtained by: in the jth row of the processed first matrix, the processed third matrix and the processed fourth matrix, the smallest element is selected, and the smallest element is summed with a preset positive value to obtain the jth positive value.
[0019] In a possible implementation, the iterative operation based on the fifth matrix to obtain the second matrix includes: performing pth multiplication processing on the fifth matrix and the sixth matrix processed for the (p-1)th time to obtain the sixth matrix processed for the pth time, until the sixth matrix processed for the pth time meets a preset condition, where p=1, …, m, m≥1, the sixth matrix processed for the 0th time is a preset matrix, and the sixth matrix processed for the mth time is the second matrix. In the foregoing implementation, after the fifth matrix is obtained, the preset matrix (which is an n-row-1-column matrix or a 1-row-n-column matrix) can be obtained as the sixth matrix processed for the 0th time, and the fifth matrix and the sixth matrix processed for the 0th time are subjected to the 1st multiplication processing to obtain the sixth matrix processed for the 1st time. Then, the fifth matrix and the sixth matrix processed for the 1st time are subjected to multiplication processing to obtain the sixth matrix processed for the 2nd time, and so on, until the sixth matrix processed for the mth time obtained after the fifth matrix and the sixth matrix processed for the (m-1)th time are subjected to the mth multiplication processing meets the preset condition, and the sixth matrix processed for the mth time can be taken as the second matrix.
[0020] In a possible implementation, the similarity between any two sentences in any one category is greater than or equal to a preset similarity threshold, and the similarity between the sentences with the maximum weight in any two categories is less than the similarity threshold.
[0021] In a possible implementation, the generating of the summary of the target text based on the sentences with the maximum weight includes: processing the sentences with the maximum weight by using the summary generation model to obtain the summary of the target text. In the foregoing implementation, after the sentences with the maximum weight in each category are determined, the sentences can be input into the summary generation model, so that the summary generation model processes (which can also be understood as fine-tuning, for example, the summary generation model can adjust the grammatical structure and expression of the sentences) the sentences to obtain the summary of the target text.
[0022] The second aspect of the embodiment of the present application provides a model training method, which includes: obtaining a to-be-trained model and a real summary of a target text. The real summary of the target text is processed by using the to-be-trained model to obtain a predicted summary of the target text. Based on the real summary and the predicted summary of the target text, a target loss is obtained, which indicates the difference between the real summary and the predicted summary of the target text. Based on the target loss, the parameters of the to-be-trained model are updated until a model training condition is met, and a summary generation model is obtained.
[0023] The summary generation model obtained by the method has the capability of automatic summarization. In the process of model training, only a small amount of training data with known labels is needed to complete the training of the model, which is conducive to reducing the cost of model training, and the model is implemented based on the generative automatic summarization technology, which can be combined with the extractive automatic summarization technology to extract the summary of the text as a whole, which is conducive to expanding the application scenarios of the automatic summarization technology.
[0024] The third aspect of the embodiments of the present application provides a summary generation device, which comprises: a first acquisition module configured to acquire a plurality of sentences of a target text and similarities between any two sentences in the plurality of sentences, for example, the first acquisition module is configured to acquire a plurality of sentences of a target text and a first matrix, the first matrix comprising similarities between any two sentences in the plurality of sentences; a division module configured to divide the plurality of sentences into a plurality of categories based on the similarities, for example, the division module is configured to divide the plurality of sentences into a plurality of categories based on the first matrix; a selection module configured to determine the sentence with the maximum weight in each category of the plurality of categories based on the similarities and the target text, for example, the selection module comprises an operation module and a determination module, wherein the operation module is configured to perform iterative operation based on the similarities to obtain the weight of each sentence in the plurality of sentences, for example, the operation module is configured to perform iterative operation based on the first matrix to obtain a second matrix, the second matrix comprising the weight of each sentence in the plurality of sentences, and the determination module is configured to determine the sentence with the maximum weight in each category of the plurality of categories, for example, the determination module is configured to determine the sentence with the maximum weight in each category of the plurality of categories based on the second matrix; and a generation module configured to generate a summary of the target text based on the sentence with the maximum weight.
[0025] As can be seen from the above device: after acquiring the plurality of sentences of the target text and the first matrix, iterative operation can be performed based on the first matrix to obtain a second matrix, the first matrix comprising similarities between any two sentences in the plurality of sentences, and the second matrix comprising the weight of each sentence in the plurality of sentences. Then, the plurality of sentences can be divided into a plurality of categories based on the first matrix. Next, the sentence with the maximum weight in each category of the plurality of categories can be determined based on the second matrix. Finally, a summary of the target text is generated based on the sentence with the maximum weight. In the foregoing process, since the summary of the target text is derived from the sentence with the maximum weight in each category of the target text, it has a certain degree of semantic diversity, and the information contained in the summary is sufficient to accurately express the main content of the entire target text. It can be seen that the summary of the target text generated in this way has low semantic repetition between sentences and includes important information of the target text.
[0026] In a possible implementation, the apparatus further includes: a second acquisition module, configured to acquire a third matrix and a fourth matrix, the third matrix containing similarity between any one of the plurality of sentences and the title of the target text, and the fourth matrix containing the number of keywords contained in each of the plurality of sentences; and an operation module, configured to: fuse the first matrix, the third matrix, and the fourth matrix to obtain a fifth matrix; and perform iterative operation based on the fifth matrix to obtain the second matrix.
[0027] In a possible implementation, if the first matrix is an n-row and n-column matrix, the third matrix and the fourth matrix are n-row and 1-column matrices, and n is the number of sentences, the operation module is configured to: perform normalization processing on the first matrix, the third matrix, and the fourth matrix to obtain a processed first matrix, a processed third matrix, and a processed fourth matrix, the i-th column of the processed first matrix and the processed third matrix and the processed fourth matrix all conform to a standard normal distribution, i = 1, …, n; and perform addition processing on the i-th column of the processed first matrix, the processed third matrix, the processed fourth matrix, and an i-th positive value to obtain an i-th column of the fifth matrix, the i-th column of the fifth matrix conforming to a normal distribution.
[0028] In a possible implementation, if the first matrix is an n-row and n-column matrix, the third matrix and the fourth matrix are 1-row and n-column matrices, and n is the number of sentences, the operation module is configured to: perform normalization processing on the first matrix, the third matrix, and the fourth matrix to obtain a processed first matrix, a processed third matrix, and a processed fourth matrix, the j-th row of the processed first matrix and the processed third matrix and the processed fourth matrix all conform to a standard normal distribution, j = 1, …, n; and perform addition processing on the j-th row of the processed first matrix, the processed third matrix, the processed fourth matrix, and a j-th positive value to obtain a j-th row of the fifth matrix, the j-th row of the fifth matrix conforming to a normal distribution.
[0029] In a possible implementation, the i-th positive value is a sum of the smallest element in the i-th column of the processed first matrix, the processed third matrix, and the processed fourth matrix and a preset positive value.
[0030] In a possible implementation, the j-th positive value is a sum of the smallest element in the j-th row of the processed first matrix, the processed third matrix, and the processed fourth matrix and a preset positive value.
[0031] In a possible implementation, the operation module is configured to perform p-th multiplication processing on the fifth matrix and the sixth matrix after (p-1)-th processing to obtain the sixth matrix after p-th processing, until the sixth matrix after p-th processing meets a preset condition, where p=1, …, m, m>1, the sixth matrix after 0-th processing is the preset matrix, and the sixth matrix after m-th processing is the second matrix.
[0032] In a possible implementation, the similarity between any two sentences in any one category is greater than or equal to a preset similarity threshold, and the similarity between the sentences with the maximum weight in any two categories is less than the similarity threshold.
[0033] In a possible implementation, the generation module is configured to process the sentence with the maximum weight by using the summary generation model to obtain the summary of the target text.
[0034] The fourth aspect of the embodiment of the present application provides a model training apparatus, which comprises: a first acquisition module configured to acquire a to-be-trained model and a real summary of a target text; a processing module configured to process the real summary of the target text by using the to-be-trained model to obtain a predicted summary of the target text; a second acquisition module configured to acquire a target loss based on the real summary and the predicted summary of the target text, the target loss being used to indicate a difference between the real summary and the predicted summary of the target text; and an updating module configured to update parameters of the to-be-trained model based on the target loss until a model training condition is met, to obtain a summary generation model.
[0035] The summary generation model obtained by the apparatus has the capability of automatic summarization. In the process of model training, the training of the model can be completed by using only a small amount of training data with known labels, which is conducive to reducing the cost of model training, and the model is implemented based on the generative automatic summarization technology, can be combined with the extractive automatic summarization technology to extract the summary of the text as a whole, and is conducive to expanding the application scenarios of the automatic summarization technology.
[0036] The fifth aspect of the embodiment of the present application provides a summary generation apparatus, which comprises a memory and a processor; the memory stores code, and the processor is configured to execute the code, when the code is executed, the image classification apparatus executes the method according to the first aspect or any one of the possible implementation manners of the first aspect.
[0037] The sixth aspect of the embodiment of the present application provides a model training apparatus, which comprises a memory and a processor; the memory stores code, and the processor is configured to execute the code, when the code is executed, the model training apparatus executes the method according to the second aspect.
[0038] A seventh aspect of the embodiments of the present application provides a circuit system, comprising processing circuitry configured to perform the method according to the first aspect, any one of the possible implementation manners of the first aspect, or the second aspect.
[0039] An eighth aspect of the embodiments of the present application provides a chip system, comprising a processor, configured to invoke a computer program or computer instruction stored in a memory, so as to make the processor perform the method according to the first aspect, any one of the possible implementation manners of the first aspect, or the second aspect.
[0040] In a possible implementation manner, the processor is coupled with the memory through an interface.
[0041] In a possible implementation manner, the chip system further comprises the memory, and the memory stores the computer program or computer instruction.
[0042] A ninth aspect of the embodiments of the present application provides a computer storage medium, which stores a computer program, and the program, when executed by a computer, causes the computer to implement the method according to the first aspect, any one of the possible implementation manners of the first aspect, or the second aspect.
[0043] A tenth aspect of the embodiments of the present application provides a computer program product, which stores an instruction, and the instruction, when executed by a computer, causes the computer to implement the method according to the first aspect, any one of the possible implementation manners of the first aspect, or the second aspect.
[0044] In the embodiments of the present application, after the target text is obtained, the first matrix is obtained, and the first matrix comprises the similarity between any two sentences in the plurality of sentences, the second matrix is obtained by iterative operation based on the first matrix, and the second matrix comprises the weight of each sentence in the plurality of sentences. Then, the plurality of sentences can be divided into a plurality of categories based on the first matrix. Next, the sentence with the maximum weight in each category of the plurality of categories is determined based on the second matrix. Finally, the summary of the target text is generated based on the sentence with the maximum weight. In the foregoing process, since the summary of the target text is derived from the sentence with the maximum weight in each category of the target text, the summary has a certain degree of semantic diversity, and the information contained in the summary is sufficient to accurately express the main content of the entire target text. It can be seen that the summary of the target text generated in this way has low semantic repetition between sentences and includes important information of the target text.
[0045] Further, the embodiment of the present application combines the extractive automatic summarization technology and the generative automatic summarization technology, the result of the extractive automatic summarization technology is used as the input of the generative automatic summarization technology, and the output of the generative automatic summarization technology is used as the final result. It can be seen that the target text can be processed by the extractive automatic summarization technology first to obtain a preliminary summary. Then, the summary generation model processes the preliminary summary to obtain the final summary (i.e., the summary of the target text). Since the number of sentences contained in the preliminary summary is usually small (which can be regarded as a short text), the summary generation model needs to process less data when processing the preliminary summary, which is beneficial to shorten the time required for the model to generate the summary, which is equivalent to improving the performance of the model, thereby ensuring the quality of the final summary.
[0046] Further, the embodiment of the present application can be applied to target texts of various structures, that is, the summary generation of target texts of various structures can be realized, and the final summary can effectively represent the main content of the target text. It can be seen that the embodiment of the present application has good summary generation effect in various application scenarios.
[0047] Further, in the embodiment of the present application, when the sentences of the target text need to be classified, the target text can be analyzed in advance to obtain the relationship between the number of categories and the similarity threshold and the relationship between the number of sentences contained in the category and the similarity threshold, and then the number of categories is determined based on these relationships, thereby avoiding excessive human intervention.
[0048] Further, in the embodiment of the present application, when obtaining the weight of the sentence in the target text, not only the similarity between the sentences is considered, but also the similarity between the sentences and the title, the number of keywords contained in the sentence, and other factors are considered. The considered factors are more comprehensive, which is beneficial to improve the accuracy of the weight of the sentence, and further beneficial to improve the quality of the summary of the target text.
[0049] Further, the summary generation model trained by the embodiment of the present application has the ability of automatic summarization. In the process of model training, only a small amount of training data with known labels is needed to complete the training of the model, which is beneficial to reduce the cost of model training, and the model is realized based on the generative automatic summarization technology. It can be combined with the extractive automatic summarization technology to extract the summary of the text as a whole, which is beneficial to expand the application scenario of the automatic summarization technology. BRIEF DESCRIPTION OF DRAWINGS
[0050] Figure 1 A structural schematic diagram of an artificial intelligence main body framework;
[0051] Figure 2a A structural schematic diagram of a data sequence processing system provided by the embodiment of the present application;
[0052] Figure 2b Another structural diagram of a data sequence processing system provided by an embodiment of the present application;
[0053] Figure 2c A diagram of a related device for data sequence processing provided by an embodiment of the present application;
[0054] Figure 3 A diagram of a system 100 architecture provided by an embodiment of the present application;
[0055] Figure 4 A flow diagram of a summary generation method provided by an embodiment of the present application;
[0056] Figure 5 A diagram of a text cleaning process provided by an embodiment of the present application;
[0057] Figure 6 A diagram of category division provided by an embodiment of the present application;
[0058] Figure 7 A diagram of an analysis curve provided by an embodiment of the present application;
[0059] Figure 8 A diagram of experimental results provided by an embodiment of the present application;
[0060] Figure 9 A flow diagram of a model training method provided by an embodiment of the present application;
[0061] Figure 10 A structural diagram of a summary generation apparatus provided by an embodiment of the present application;
[0062] Figure 11 A structural diagram of a model training apparatus provided by an embodiment of the present application;
[0063] Figure 12 A structural diagram of an execution device provided by an embodiment of the present application;
[0064] Figure 13 A structural diagram of a training device provided by an embodiment of the present application;
[0065] Figure 14 A structural diagram of a chip provided by an embodiment of the present application. DETAILED DESCRIPTION
[0066] The embodiment of the present application provides a summary generation method and related equipment, and provides a new way of automatically generating a summary. The summary generated by the way has a certain degree of semantic diversity, and the information contained in the summary is comprehensive enough to accurately express the main content of the whole target text.
[0067] The terms "first", "second", etc. in the specification and claims of the present application and the above-described 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 terms used in this way can be interchanged under appropriate circumstances, and this is only a way of distinguishing the objects with the same attributes used in the description of the embodiments of the present application. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, so that the process, method, system, product or equipment containing a series of units does not have to be limited to those units, but can include other units not clearly listed or inherent to these processes, methods, products or equipment.
[0068] Automatic summary technology is a technology that automatically generates a summary by using a computer to automatically analyze and summarize the content of a text, that is, expressing the main content of the text in a concise form according to the requirements of a user. The automatic summary technology can effectively help the user to find the content of interest from the retrieved articles, and improve the reading speed and quality.
[0069] At present, there are two types of automatic summary technology, one of which is an extractive automatic summary technology, and the other of which is a generative automatic summary technology. The extractive automatic summary technology can be implemented based on a textrank algorithm. The implementation process of the textrank algorithm is as follows: first, analyze the target text (i.e., the text to be generated as a summary) to determine the similarity between each two sentences in the target text. Then, based on the similarity between the sentences, all the sentences of the target text can be divided into multiple categories (also referred to as multiple semantic clusters). Then, a number of sentences can be extracted from a certain category as the summary of the target text.
[0070] However, the similarity between different categories of sentences is low, and the textrank algorithm is limited by itself. The attention of the algorithm is easily focused on a certain category (which usually contains the largest number of sentences), and the remaining categories (which usually contain a smaller number of sentences) are easily ignored, resulting in the final generated summary containing only sentences from a certain category and not containing sentences from the remaining important categories. For example, suppose an article discusses the topic of "interference" and contains 100 sentences. After determining the similarity between each pair of sentences in the 100 sentences, the textrank algorithm can classify 80 sentences as "natural interference" and 20 sentences as "human interference". Then, the textrank algorithm will select several sentences from the "natural interference" category as the summary of the article. As can be seen, the summary generated in this way has the problems of high semantic repetition and missing important information.
[0071] Further, generative automatic summarization technology can be implemented based on neural network models in AI technology, which usually need a large amount of known labeled data (i.e., sentences extracted from text that can be used as summaries) for training. These data are often difficult to obtain in large quantities (e.g., it takes a lot of cost to obtain these data), which limits the application scenarios of generative automatic summarization technology.
[0072] Further, if there is a long text, using generative automatic summarization technology to generate the corresponding summary, the time required for the summary generation process is longer, i.e., the performance of the neural network model is slower, and the generation effect of the model is difficult to guarantee, because the generation process is uncontrollable, which may result in some errors in the final generated summary.
[0073] Further, the structure of the text is often diverse and does not have a unified format. Some automatic summarization techniques that rely on text structure cannot be applied to all types of text. For example, the extractive automatic summarization technique of extracting the first N sentences of the text as the summary of the text cannot represent the content of the article if it encounters an article with various subheadings. As can be seen, the application scenarios of this approach are also limited.
[0074] Further, when classifying, the number of categories into which the sentences of the text are divided often needs to be set manually in advance, which is not intelligent and may have precision bias.
[0075] To solve the above problems, an abstract generation method is provided in the embodiments of the present application, which can be implemented in combination with artificial intelligence (AI) technology. AI technology is a technology discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology obtains the best results by perceiving the environment, acquiring knowledge and using knowledge. In other words, artificial intelligence technology is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. Data processing using artificial intelligence is a common application of artificial intelligence.
[0076] First, the overall workflow of the artificial intelligence system is described, please refer to Figure 1 , Figure 1 is a structural schematic diagram of the artificial intelligence subject framework. The following describes the above artificial intelligence subject framework from two dimensions of "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). The "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, data undergoes a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value brought by artificial intelligence to the information technology industry from the underlying infrastructure of human intelligence, information (provision and processing technology implementation) to the industrial ecological process of the system.
[0077] (1) Infrastructure
[0078] The infrastructure provides computing power support for the artificial intelligence system, realizes communication with the outside world, and realizes support through the underlying platform. Communication with the outside world through sensors; computing power is provided by intelligent chips (CPU, NPU, GPU, ASIC, FPGA, etc. Hardware acceleration chips); the underlying platform includes distributed computing framework and network related platform guarantee and support, which can include cloud storage and computing, interconnection network, etc. For example, sensors and external communication obtain data, which are provided to intelligent chips in the distributed computing system provided by the underlying platform for calculation.
[0079] (2) Data
[0080] The data on the upper layer of the infrastructure is used to represent the data source in the field of artificial intelligence. Data involves graphics, images, speech, text, and also involves Internet of Things data of traditional devices, including business data of existing systems and sensing data such as force, displacement, liquid level, temperature, humidity, etc.
[0081] (3) Data processing
[0082] Data processing generally includes data training, machine learning, deep learning, search, reasoning, decision, etc.
[0083] Among them, machine learning and deep learning can model, extract, preprocess, train, etc. of the intelligent information of the data symbolization and formalization.
[0084] Reasoning refers to the process of simulating human intelligent reasoning methods in computers or intelligent systems, using formalized information to solve problems according to reasoning control strategies, and the typical function is search and matching.
[0085] Decision refers to the process of decision-making after intelligent information reasoning, which usually provides functions such as classification, sorting, prediction, etc.
[0086] (4) General ability
[0087] After the data mentioned above is processed, some general capabilities can be formed based on the results of data processing, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0088] (5) Intelligent products and industry applications
[0089] Intelligent products and industry applications refer to the products and applications of artificial intelligence systems in various fields, which are the packaging of the overall solution of artificial intelligence, and realize the application of intelligent information decision-making products. Its application fields mainly include: intelligent terminal, intelligent transportation, intelligent medical treatment, automatic driving, smart city, etc.
[0090] Next, several application scenarios of the present application are introduced.
[0091] Figure 2a A structural schematic diagram of a data sequence processing system provided by an embodiment of the present application is provided, which includes a user device and a data processing device. Among them, the user device includes a mobile phone, a personal computer or an intelligent terminal such as an information processing center. The user device is the initiator of data sequence processing, and serves as the initiator of data sequence processing request, which is usually initiated by the user through the user device.
[0092] The aforementioned data processing equipment can be cloud servers, network servers, application servers, management servers, or other devices or servers with data processing capabilities. The data processing equipment receives text processing requests from smart terminals through an interactive interface, and then performs text processing through a storage device for storing data and a processor for data processing, employing methods such as machine learning, deep learning, search, reasoning, and decision-making. The storage device in the data processing equipment can be a general term, including local storage and a database storing historical data. The database can be located on the data processing equipment or on other network servers.
[0093] exist Figure 2a In the data sequence processing system shown, the user equipment can receive user instructions. For example, the user equipment can acquire text input / selection by the user and then send a request to the data processing device, causing the data processing device to perform text processing applications on the text received by the user equipment, thereby obtaining the corresponding processing result for the text. For instance, the user equipment can acquire text input by the user (whether long or short), and then send a text processing request to the data processing device, causing the data processing device to process the text based on automatic summarization technology, thereby obtaining the processing result of the text, i.e., a summary of the text.
[0094] exist Figure 2a In this context, the data processing device can execute the summary generation method of the embodiments of this application.
[0095] Figure 2b This is another schematic diagram of the data sequence processing system provided in the embodiments of this application. Figure 2b In this context, the user equipment (UE) directly functions as a data processing device. This UE can directly acquire input from the user and process it directly through its own hardware. The specific process is similar to... Figure 2a Similar to the description above, it will not be repeated here.
[0096] exist Figure 2b In the data sequence processing system shown, the user equipment can receive instructions from the user. For example, the user equipment can obtain a text selected by the user and then perform text processing applications (e.g., text summarization) on the text to obtain the corresponding processing result for the text.
[0097] exist Figure 2b In this context, the user equipment itself can execute the summary generation method of the embodiments of this application.
[0098] Figure 2c This is a schematic diagram of a data sequence processing device provided in an embodiment of this application.
[0099] The aboveFigure 2a and Figure 2b The user equipment in the context can specifically be Figure 2c Local device 301 or local device 302 in the system. Figure 2a The data processing equipment in the middle can specifically be Figure 2c The execution device 210 in the process includes a data storage system 250 that can store the data to be processed by the execution device 210. The data storage system 250 can be integrated into the execution device 210 or set up in the cloud or on other network servers.
[0100] Figure 2a and Figure 2b The processor in the image can be trained on data using neural network models or other models (e.g., support vector machine-based models) for machine learning / deep learning, and then use the trained or learned models to perform image processing applications on the image to obtain the corresponding processing results.
[0101] Figure 3 A schematic diagram of the system 100 architecture provided in this application embodiment, in Figure 3 In this embodiment, the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with external devices. Users can input data to the I / O interface 112 through the client device 140. The input data may include various scheduled tasks, callable resources, and other parameters.
[0102] During the preprocessing of input data by the execution device 110, or during the calculation module 111 of the execution device 110 performing calculations and other related processing (such as implementing the neural network function in this application), the execution device 110 may call data, code, etc. in the data storage system 150 for corresponding processing, or store the data, instructions, etc. obtained from the corresponding processing into the data storage system 150.
[0103] Finally, I / O interface 112 returns the processing result to client device 140, thereby providing it to the user.
[0104] It is worth noting that the training device 120 can generate corresponding target models / rules based on different training data for different objectives or tasks. These target models / rules can then be used to achieve the aforementioned objectives or complete the aforementioned tasks, thereby providing the user with the required results. The training data can be stored in the database 130 and originates from training samples collected by the data acquisition device 160.
[0105] exist Figure 3In the case shown in FIG. 1, the user can manually give input data, which can be operated through the interface provided by the I / O interface 112. In another case, the client device 140 can automatically send input data to the I / O interface 112, and if the user needs to authorize the client device 140 to automatically send input data, the user can set the corresponding permission in the client device 140. The user can view the results output by the execution device 110 in the client device 140, and the specific presentation form can be a specific way such as display, sound, action, etc. The client device 140 can also act as a data collection end, collect the input data input into the I / O interface 112 and the output results output by the I / O interface 112 as new sample data, and store them into the database 130. Of course, the collection can also be performed without the client device 140, and the I / O interface 112 directly stores the input data input into the I / O interface 112 and the output results output by the I / O interface 112 as new sample data into the database 130.
[0106] It is worth noting that, Figure 3 The system architecture provided in the embodiments of the present application is only a schematic diagram, and the positional relationship between the devices, components, modules, etc. shown in the diagram does not constitute any limitation. For example, in Figure 3 , the data storage system 150 is an external memory relative to the execution device 110, and in other cases, the data storage system 150 can also be placed in the execution device 110. As shown in Figure 3 , the neural network can be trained by the training device 120.
[0107] The embodiments of the present application also provide a chip, which includes a neural network processor NPU. The chip can be arranged in the execution device 110 as shown in Figure 3 , to complete the calculation work of the calculation module 111. The chip can also be arranged in the training device 120 as shown in Figure 3 , to complete the training work of the training device 120 and output the target model / rule.
[0108] The neural network processor NPU is mounted on the host central processing unit (CPU) (host CPU) as a coprocessor, and tasks are allocated by the host CPU. The core part of the NPU is an operation circuit, and the controller controls the operation circuit to extract data in the memory (weight memory or input memory) and perform operation.
[0109] In some implementations, the arithmetic circuit includes a plurality of processing engines (PEs) inside. In some implementations, the arithmetic circuit is a two-dimensional systolic array. The arithmetic circuit can also be a one-dimensional systolic array or other electronic circuit capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit is a general-purpose matrix processor.
[0110] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit fetches the corresponding data of matrix B from the weight memory and caches it on each PE of the arithmetic circuit. The arithmetic circuit fetches the data of matrix A from the input memory and performs matrix operation with matrix B, and the partial result or final result of the matrix is saved in an accumulator.
[0111] The vector computation unit can further process the output of the arithmetic circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector computation unit can be used for network computation of non-convolution / non-FC layers in a neural network, such as pooling, batch normalization, local response normalization, etc.
[0112] In some implementations, the vector computation unit can store the processed output vector to the unified buffer. For example, the vector computation unit can apply a non-linear function to the output of the arithmetic circuit, such as a vector of accumulated values, to generate activation values. In some implementations, the vector computation unit generates normalized values, merged values, or both. In some implementations, the processed output vector can be used as activation input to the arithmetic circuit, such as for use in a subsequent layer in a neural network.
[0113] The unified memory is used to store input data and output data.
[0114] The weight data is transferred from the external memory to the input memory and / or the unified memory, from the external memory to the weight memory, and from the unified memory to the external memory by a direct memory access controller (DMAC).
[0115] The bus interface unit (BIU) is used to interact between the main CPU, the DMAC, and the instruction memory through a bus.
[0116] An instruction fetch buffer connected to the controller, for storing instructions used by the controller;
[0117] A controller for invoking the instructions cached in the instruction fetch buffer to implement the working process of the operation accelerator.
[0118] Generally, the unified memory, the input memory, the weight memory and the instruction fetch buffer are on-chip memories, and the external memory is a memory external to the NPU. The external memory can be a double data rate synchronous dynamic random access memory (DDR SDRAM), a high bandwidth memory (HBM) or other readable and writable memories.
[0119] Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the related terms and concepts related to neural networks involved in the embodiments of the present application will be introduced first.
[0120] (1) Neural network
[0121] The neural network can be composed of neural units. The neural unit can be an operation unit with xs and intercept 1 as inputs. The output of the operation unit can be:
[0122] (1)
[0123] wherein s = 1, 2, … n, n is a natural number greater than 1, Ws is the weight of xs, b is the bias of the neural unit. f is an activation function of the neural unit, which is used to introduce a nonlinear characteristic into the neural network to convert the input signal in the neural unit into an output signal. The output signal of the activation function can be used as the input of the next convolution layer. The activation function can be a sigmoid function. The neural network is a network formed by connecting many single neural units together, i.e. the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field, and the local receptive field can be a region composed of several neural units.
[0124] The work of each layer in the neural network can be expressed by a mathematical expression To describe: the work of each layer in the neural network from the physical layer can be understood as the transformation of the input space (a set of input vectors) to the output space (a set of output vectors) through five kinds of operations on the input space, which include: 1, dimensionality increase / decrease; 2, magnification / reduction; 3, rotation; 4, translation; 5, "bending". Among them, the operations of 1, 2, and 3 are completed by , the operation of 4 is completed by , and the operation of 5 is realized by . The reason why "space" is used here is because the objects being classified are not single things, but a class of things, and space refers to the collection of all individuals of this class. Among them, is a weight vector, and each value in this vector represents the weight value of a neuron in the layer of the neural network. This vector determines the spatial transformation of the input space to the output space described above, that is, the weight of each layer controls how to transform the space. The purpose of training a neural network is to ultimately obtain the weight matrix of all layers of the trained neural network (formed by many vectors ). Therefore, the training process of a neural network is essentially learning the way to control the spatial transformation, more specifically, learning the weight matrix.
[0125] Because we want the output of the neural network to be as close as possible to the value we really want to predict, we can update the weight vector of each layer of the neural network by comparing the predicted value of the current network with the target value we really want, and then adjusting the weight vector according to the difference between the two. (Of course, before the first update, there is usually an initialization process, that is, to pre-configure the parameters for each layer in the neural network) For example, if the network's predicted value is high, adjust the weight vector to make it predict lower, and keep adjusting until the neural network can predict the target value we really want. Therefore, it is necessary to define "how to compare the difference between the predicted value and the target value", which is the loss function (loss function) or objective function (objective function), which is an important equation for measuring the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, and then the training of the neural network becomes a process of trying to minimize this loss.
[0126] (2) Backpropagation algorithm
[0127] The neural network can adopt a back propagation (BP) algorithm to correct the size of the parameters in the initial neural network model in the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, the forward transmission of the input signal until the output generates an error loss, and the initial neural network model is updated by back propagating the error loss information, so as to make the error loss converge. The back propagation algorithm is a back propagation movement dominated by error loss, aiming to obtain the optimal parameters of the neural network model, such as the weight matrix.
[0128] The method provided in the present application is described below from the training side of the neural network and the application side of the neural network.
[0129] The model training method provided in the embodiments of the present application involves processing of data sequences, and can be applied to data training, machine learning, deep learning and the like. The training data (for example, the sentence with the largest weight in each category after the plurality of sentences of the text to be processed in the present application are divided into categories) is subjected to intelligent information modeling, extraction, preprocessing, training and the like in a symbolic and formal manner, and finally a trained neural network (such as the summary generation model in the present application) is obtained. In addition, the summary generation method provided in the embodiments of the present application can use the trained neural network described above, input the input data (for example, the sentence with the largest weight in each category after the plurality of sentences of the target text in the present application are divided into categories) into the trained neural network, and obtain the output data (such as the summary of the target text in the present application and the like). It should be noted that the model training method and the summary generation method provided in the embodiments of the present application are based on the same concept and are two parts of a system or two stages of an overall process: for example, the model training stage and the model application stage.
[0130] Figure 4 A flowchart of the summary generation method provided in the embodiments of the present application is shown in FIG. 1, which includes the following steps. Figure 4
[0131] 401、Obtain a plurality of sentences of a target text and a first matrix, the first matrix containing the similarity between any two sentences in the plurality of sentences.
[0132] In the present embodiment, when a summary of a certain original text is needed, the original text can be cleaned to obtain a cleaned text due to various problems (for example, invalid content, special symbols, quoted annotations and the like) in the original text that may affect the main text. In order to facilitate the introduction, the cleaned text can be referred to as a target text in the following, and the purpose of the present embodiment is to automatically generate a summary of the target text.
[0133] Specifically, the similarity between any two sentences in the plurality of sentences can be calculated byFigure 5 The original text is text cleaned (in the illustrated manner) Figure 5 An example of a text cleaning process provided by embodiments of the present application), so as to obtain a target text:
[0134] (1) Remove invalid content from the original text. For example, the invalid content in the original text can be text that is too short in the original text or text that is garbled in the original text, and the like.
[0135] (2) Remove the adverse effects of special symbols on the results of the original text segmentation. For example, in the original text, there is a sentence "Gujarat Act no. 28 of 2015". The period "." in "Gujarat Act no. 28 of 2015" has an adverse effect on the segmentation result of the sentence. "Gujarat Act no. 28 of 2015" can be modified to "Gujarat Act no-28 of 2015".
[0136] (3) Handle the adverse effects of reference annotations on the results of the original text segmentation. For example, in the original text, there is a sentence "e.g. enable cell growth.26 A scafford is required". The reference annotations "e.g." and "26" in "e.g. enable cell growth.26 A scafford is required" have an adverse effect on the segmentation result of the sentence. "e.g. enable cell growth.26 A scafford is required" can be modified to "enable cell growth. A scafford is required".
[0137] (4) Clean the original text using other cleaning rules.
[0138] (5) Remove the contents such as subtitles and footnotes in the original text to obtain the target text. It is worth noting that the contents such as subtitles and footnotes in the original text can be used as explicit summaries of the target text.
[0139] After obtaining the target text, a similarity algorithm (for example, Jaccard algorithm, Bert SimCSE algorithm, Roberta SimCSE algorithm, etc.) can be used to calculate the plurality of sentences (that is, all sentences) of the target text to obtain a first matrix, and the first matrix contains the similarity between any two sentences in the plurality of sentences of the target text. Assuming that the target text contains n sentences (n is a positive integer greater than or equal to 1), the first matrix can be an n-row-by-n-column matrix, where the element in the ith column and the jth row of the first matrix is the similarity between the ith sentence of the target text and the jth sentence of the target text, i = 1, …, n, j = 1, …, n. For example, the first matrix can be represented as SM n×n As shown in equation (2):
[0140] (2)
[0141] In the formula, is the similarity between the first sentence of the target text and the second sentence of the target text, is the similarity between the fourth sentence of the target text and the third sentence of the target text, and the remaining elements can also refer to the relevant description of and , which will not be repeated here.
[0142] 402、Based on the first matrix, an iterative operation is performed to obtain a second matrix, and the second matrix contains the weight of each sentence in the plurality of sentences.
[0143] After obtaining the first matrix, an iterative operation can be performed based on the first matrix to obtain a second matrix, and the second matrix contains the weight of each sentence in the target text. It should be noted that for any one sentence of the target text, the weight of the sentence can also be understood as the importance of the sentence. If the weight of the sentence is larger, it means that the importance of the sentence is greater, and if the weight of the sentence is smaller, it means that the importance of the sentence is smaller.
[0144] Specifically, the first matrix can be iteratively operated to obtain the second matrix in the following manner:
[0145] (1) After obtaining the target text, the title of the target text and the plurality of sentences of the target text can be calculated by using the same similarity algorithm to obtain a third matrix. The third matrix contains the similarity between any one of the plurality of sentences of the target text and the title of the target text. Since the target text contains n sentences, the third matrix can be an n-row 1-column matrix or a 1-row n-column matrix. If the third matrix is an n-row 1-column matrix, the element in the jth row of the third matrix is the similarity between the title of the target text and the jth sentence of the target text. If the third matrix is a 1-row n-column matrix, the element in the ith column of the third matrix is the similarity between the title of the target text and the ith sentence of the target text. For example, the third matrix can be an n-row 1-column matrix, which can be represented as TSM n×1 As shown in equation (3):
[0146] (3)
[0147] In the formula, is the similarity between the title of the target text and the first sentence of the target text, and the remaining elements can also refer to the related description part of , which will not be described here.
[0148] (2) After obtaining the target text, the plurality of sentences of the target text can be detected by using a keyword detection algorithm to obtain a fourth matrix. The fourth matrix contains the number of keywords contained in each sentence of the plurality of sentences of the target text. Since the target text contains n sentences, the fourth matrix can be an n-row 1-column matrix or a 1-row n-column matrix. If the fourth matrix is an n-row 1-column matrix, the element in the jth row of the fourth matrix is the number of keywords contained in the jth sentence of the target text. If the fourth matrix is a 1-row n-column matrix, the element in the ith column of the fourth matrix is the number of keywords contained in the ith sentence of the target text. For example, the fourth matrix can be an n-row 1-column matrix, which can be represented as KS n×1 As shown in equation (4):
[0149] (4)
[0150] In the formula, is the number of keywords contained in the first sentence of the target text, and the remaining elements can also refer to the related description part of , which will not be described here.
[0151] (3) After obtaining the third matrix and the fourth matrix, the first matrix, the third matrix, and the fourth matrix can be fused (which can also be understood as matrix merging) to obtain a fifth matrix. After obtaining the fifth matrix, iterative operation can be performed based on the fifth matrix to obtain the second matrix.
[0152] Further, in step (3), the first matrix, the third matrix and the fourth matrix can be fused by one of the following two ways to obtain the fifth matrix:
[0153] (3.1) If the third matrix and the fourth matrix are n rows and 1 column matrices, the first matrix, the third matrix and the fourth matrix can be normalized by column to obtain a processed first matrix, a processed third matrix and a processed fourth matrix. It should be noted that the processed first matrix is still an n row and n column matrix, and the element in the i-th column and the j-th row of the processed first matrix is the similarity between the i-th sentence of the normalized target text and the j-th sentence of the target text. Then, for any column of the processed first matrix, i.e. the i-th column of the processed first matrix (i = 1, …, n), all elements in the i-th column of the processed first matrix can conform to the standard normal distribution, for example, the processed first matrix can be represented as SMS n×n As shown in formula (5):
[0154] (5)
[0155] In the formula, is the similarity between the first sentence of the normalized target text and the second sentence of the target text, and all elements in the first column of the first matrix , , , conform to the standard normal distribution, and the remaining elements can refer to the related description part of , and the remaining columns can refer to the related description part of the first column, which will not be described here.
[0156] Similarly, the processed third matrix is still an n row and 1 column matrix, and the element in the j-th row of the processed third matrix is the similarity between the title of the normalized target text and the j-th sentence of the target text. Then, all elements of the processed third matrix conform to the standard normal distribution, for example, the processed third matrix can be represented as TSM n×1 As shown in formula (6):
[0157] (6)
[0158] In the formula, is the similarity between the title of the normalized target text and the first sentence of the target text, , , , conform to the standard normal distribution, and the remaining elements can refer to the related description part of , which will not be described here.
[0159] Similarly, the processed fourth matrix is still an n-row 1-column matrix, and the element in the jth row of the processed fourth matrix is the number of keywords contained in the jth sentence of the normalized target text. Then, all elements of the processed fourth matrix conform to the standard normal distribution, for example, the processed fourth matrix can be represented as KSS n×1 As shown in equation (7):
[0160] (7)
[0161] In the formula, is the number of keywords contained in the first sentence of the normalized target text, , , , , conform to the standard normal distribution, and the remaining elements can refer to the related description part of , which will not be repeated here.
[0162] After obtaining the processed first matrix, the processed third matrix, and the processed fourth matrix, the ith column of the processed first matrix, the processed third matrix, the processed fourth matrix, and the ith positive value are added to obtain the ith column of the fifth matrix, and the ith column of the fifth matrix conforms to the normal distribution (due to the existence of the ith positive value). It is worth noting that the ith positive value can be obtained by: in the ith column of the processed first matrix, the processed third matrix, and the processed fourth matrix, the smallest element can be selected, and the smallest element is summed with a preset positive value (for example, the preset positive value is 1, etc.) to obtain the ith positive value.
[0163] For the remaining columns of the processed first matrix, the operation (i.e., the aforementioned addition processing) on the ith column of the processed first matrix can also be performed, so the remaining columns of the fifth matrix can be obtained. In this way, the complete fifth matrix is obtained. For example, the fifth matrix can be represented as M n×n As shown in equation (8):
[0164] (8)
[0165] In the formula, the ith column of the fifth matrix is , is the ith column of the processed first matrix SMSn×n, , , , and The preset weights (the sum of the three weights is 1, and the sizes of the three weights can be set according to actual needs, which are not limited here), The i-th positive value, .
[0166] (3.2) If the third matrix and the fourth matrix are 1-row n-column matrices, the first matrix, the third matrix and the fourth matrix can be normalized by row to obtain a processed first matrix, a processed third matrix and a processed fourth matrix. It should be noted that the processed first matrix is still an n-row n-column matrix, and the element in the i-th column and the j-th row of the processed first matrix is the similarity between the i-th sentence of the normalized target text and the j-th sentence of the target text. Then, for any row of the processed first matrix, that is, the j-th row of the processed first matrix (j = 1, …, n), all elements in the j-th row of the processed first matrix can conform to the standard normal distribution.
[0167] Similarly, the processed third matrix is still a 1-row n-column matrix, and the element in the i-th column of the processed third matrix is the similarity between the title of the normalized target text and the i-th sentence of the target text. Then, all elements of the processed third matrix conform to the standard normal distribution.
[0168] Similarly, the processed fourth matrix is still a 1-row n-column matrix, and the element in the i-th column of the processed fourth matrix is the number of keywords contained in the i-th sentence of the normalized target text. Then, all elements of the processed fourth matrix conform to the standard normal distribution.
[0169] After obtaining the processed first matrix, the processed third matrix and the processed fourth matrix, the j-th row of the processed first matrix, the processed third matrix, the processed fourth matrix and the j-th positive value can be added to obtain the j-th row of the fifth matrix, and the j-th row of the fifth matrix conforms to the normal distribution. It should be noted that the j-th positive value can be obtained by: in the j-th row of the processed first matrix, the processed third matrix and the processed fourth matrix, the smallest element can be selected, and the smallest element is summed with the preset positive value (for example, the preset positive value is 1, etc.) to obtain the j-th positive value.
[0170] For the remaining rows of the processed first matrix, the same operation (i.e., the aforementioned addition processing) as for the j-th row of the processed first matrix can also be performed, so the remaining rows of the fifth matrix can be obtained. In this way, the complete fifth matrix is obtained.
[0171] Further, in step (3), the fifth matrix can be iteratively operated in the following manner to obtain the second matrix:
[0172] After obtaining the fifth matrix, the fifth matrix is multiplied by the sixth matrix obtained after the (p-1)th processing for the pth time to obtain the sixth matrix obtained after the pth processing, and so on, until the sixth matrix obtained after the pth processing meets the preset conditions, where p=1, ..., m, m≥1. Specifically, a preset matrix (which is an n-row, 1-column matrix or a 1-row, n-column matrix, and each element in the matrix is a preset value, the size of which can be set according to actual needs and is not restricted here) can be obtained as the sixth matrix obtained after the 0th processing, and the fifth matrix is multiplied by the sixth matrix obtained after the 0th processing for the 1st time to obtain the sixth matrix obtained after the 1st processing. Next, the fifth matrix is multiplied by the sixth matrix after the first processing to obtain the sixth matrix after the second processing, and so on, until the fifth matrix is multiplied by the sixth matrix after the (m-1)th processing for the mth time. If the resulting sixth matrix after the mth processing satisfies a preset condition (e.g., the sixth matrix after the mth processing has not changed compared to the sixth matrices after previous processing, meaning the sixth matrix obtained from the most recent multiplications tends to be stable), then the sixth matrix after the mth processing can be used as the second matrix. The second matrix is also an n-row, 1-column matrix or a 1-row, n-column matrix. If the second matrix is an n-row, 1-column matrix, the elements in the u-th row of the second matrix represent the weights of the u-th sentence of the target text, u = 1, ..., n. If the second matrix is a 1-row, n-column matrix, the elements in the r-th row of the second matrix represent the weights of the u-th sentence of the target text, u = 1, ..., n. For example, the sixth matrix after the p-th processing can be represented as B. p As shown in formula (9):
[0173] (9)
[0174] In the formula, This is the sixth matrix after the (p-1)th processing.
[0175] 403. Divide multiple sentences into multiple categories based on the first matrix.
[0176] After obtaining the second matrix, based on the first matrix, multiple sentences of the target text can be divided into multiple categories (i.e., multiple semantic clusters). That is, the similarity between sentences can classify multiple sentences of the target text into multiple categories, and each category contains at least one sentence from the target text. For example, as... Figure 6 As shown ( Figure 6 (A schematic diagram illustrating the category division provided in this application embodiment) Suppose a cleaned article contains 100 sentences. Based on the similarity between sentences, these 100 sentences can be divided into three categories: Category A, Category B, and Category C. Category A contains 50 sentences, Category B contains 30 sentences, and Category C contains 20 sentences. It should be noted that in... Figure 6In the example shown, dots represent sentences, lines connecting dots represent the similarity between sentences, and the length of the lines represents the degree of similarity.
[0177] Specifically, multiple sentences in the target text can be divided into multiple categories in the following way:
[0178] After obtaining the second matrix, since the first matrix contains the similarity between every pair of sentences in the target text, and the second matrix contains the weight of each sentence in the target text, the sentences in the target text can be divided into multiple categories by combining the similarity between sentences and the sentence weights. Within these multiple categories, the similarity between any two sentences in any category is greater than or equal to a preset similarity threshold, and the similarity between the sentences with the highest weight in any two categories is less than the preset similarity threshold. It is worth noting that the preset similarity threshold can be obtained in the following ways: such as... Figure 7 As shown ( Figure 7 (A schematic diagram of the analysis curve provided in the embodiments of this application) is obtained by analyzing the target text, and obtaining the relationship curve between the number of categories and the similarity threshold (i.e. Figure 7 Curve 1 in the figure), and the curve showing the relationship between the number of sentences contained in the category and the similarity threshold (i.e. Figure 7 (Curve 2 in the figure) Based on these two curves, it can be seen that as the similarity threshold increases, the number of categories decreases, and the number of sentences contained in each category increases. Therefore, the similarity threshold corresponding to the intersection of the two curves can be selected as the preset similarity threshold (e.g., Figure 7 The pre-set similarity threshold is 0.325, etc., which simultaneously determines the number of categories when classifying multiple sentences in the target text. Therefore, the similarity threshold obtained through this method (i.e., analyzing the target text to obtain the relationship between the number of categories and the similarity threshold, and the relationship between the number of sentences contained in a category and the similarity threshold) can be used as a classification standard for sentences, thereby accurately identifying multiple sentence categories. Compared to unsupervised clustering methods in related technologies, this method can simultaneously satisfy the specification of the number of clusters (categories) or the specification of the cluster distance (similarity threshold). If a method based on cluster distance (similarity threshold) is chosen, the weights of sentences in the second matrix can be combined to simplify the calculation of inter-class distances to complete the category division, effectively reducing the time complexity of the category division process, thus saving time costs and possessing sufficiently powerful performance.
[0179] 404. Based on the second matrix, determine the sentence with the highest weight in each of the multiple categories.
[0180] After obtaining the plurality of categories, since the second matrix comprises the weight of each sentence in the plurality of sentences of the target text, the sentence with the largest weight in each category can be determined from the plurality of categories.
[0181] 405. Generating the summary of the target text based on the sentence with the largest weight.
[0182] After determining the sentence with the largest weight in each category, the sentence can be input into a summary generation model (a trained neural network model) to process the sentence by the summary generation model (for example, the summary generation model can adjust the syntax and expression of the sentence, etc.), and obtain the summary of the target text.
[0183] It can be understood that the steps 401 to 402 implement an extractive automatic summarization technique, and the step 405 implements a generative automatic summarization technique, so the embodiment can be regarded as a combination of the extractive automatic summarization technique and the generative automatic summarization technique, the result of the extractive automatic summarization technique is used as the input of the generative automatic summarization technique, and finally the summary of the target text is output.
[0184] Further, in order to keep the number of sentences contained in the summary of the target text within a proper range, the number of sentences input into the summary generation model can be appropriately changed. For example, after determining the sentence with the largest weight in each category (the sentence is referred to as a sentence set to be input into the model hereinafter), if the number of sentences in the sentence set is less than the number of sentences contained in the explicit summary of the target text, a sentence can be selected from each category (for example, for any category, a sentence with the lowest similarity to the sentence with the largest weight in the category can be selected) and added to the sentence set, so that the number of sentences in the updated sentence set is greater than or equal to the number of sentences contained in the explicit summary of the target text. If the number of sentences in the sentence set is much greater than the number of sentences contained in the explicit summary of the target text, a part of the sentences in the sentence set can be appropriately deleted to control the number of sentences in the updated sentence set to be greater than or equal to the number of sentences contained in the explicit summary of the target text.
[0185] In addition, the summary generation method provided in the embodiment of the present application can also be experimented with the summary generation method of related technologies, and the experimental results are compared. The experimental results of the embodiment of the present application are shown in Tables 1 to 3:
[0186] Table 1
[0187] Rouge-1_p Rouge-1_r Rouge-1_f Mean:0.473621 Mean:0.413516 Mean:0.441532 Std:0.258386 Std:0.271154 Std:0.264616 Min:0.070229 Min:0.095077 Min:0.080785 25%:0.313629 25%:0.188237 25%:0.235268 50%:0.505412 50%:0.302077 50%:0.378143 70%:0.821636 70%:0.486534 70%:0.611165 Max:0.952684 Max:0.970364 Max:0.961442
[0188] Table 2
[0189] Rouge-2_p Rouge-2_r Rouge-2_f Mean:0.353311 Mean:0.232346 Mean:0.280336 Std:0.335484 Std:0.209967 Std:0.258284 Min:0.000000 Min:0.000000 Min:0.000000 25%:0.058439 25%:0.057518 25%:0.057975 50%:0.293531 50%:0.140548 50%:0.190082 70%:0.756445 70%:0.313329 70%:0.443114 Max:0.944226 Max:0.910378 Max:0.926953
[0190] Table 3
[0191] Rouge-L_p Rouge-L_r Rouge-L_f Mean:0.493885 Mean:0.413022 Mean:0.449849 Std:0.273202 Std:0.218731 Std:0.242951 Min:0.048181 Min:0.059077 Min:0.053075 25%:0.275182 25%:0.136154 25%:0.182171 50%:0.476133 50%:0.227463 50%:0.307855 70%:0.824682 70%:0.398821 70%:0.537637 Max:0.956734 Max:0.966314 Max:0.961501
[0192] In Table 1 to Table 3, the mean value of Rouge-1_f in Table 1 can be taken as index 1, the mean value of Rouge-2_f in Table 2 can be taken as index 2, and the mean value of Rouge-L_f in Table 3 can be taken as index 3, and presented in the form of percentage. Then, the index 1 of the embodiment of the present application is 44.1, the index 2 is 28, and the index 3 is 45. The experimental results of the embodiment of the present application and the experimental results of the related technologies are compared, and the comparison results are shown in Table 4 and Table 5:
[0193] Table 4
[0194] Evaluation index Industry standard Related technology 1 Embodiments of the present application Index 1 44.7 31.1 44.1 Index 2 21.4 19.8 28.0 Index 3 41.4 30.1 45.0
[0195] Table 5
[0196] Index 1 Index 2 Index 3 Industry standard 44.7 21.4 41.4 Related technology 2 44.51 21.58 41.24 Related technology 3 44.45 21.25 41.4 Related technology 4 44.38 21.53 41.17 Related technology 5 44.31 21.35 41.60 Related technology 6 44.2 21.17 41.30
[0197] Based on Table 4 and Table 5, compared with the industry standard, the embodiment of the present application has little difference in index 1, and has great improvement in index 2 and index 3. Compared with related technology 1 to related technology 6, the embodiment of the present application has little difference in index 1, and has great improvement in index 2 and index 3. Moreover, after multiple experiments, the number of sentences contained in the summary generated by the embodiment of the present application is as shown in Figure 8 Figure 8 is a schematic diagram of the experimental results provided by the embodiment of the present application), it can be seen that the number of sentences contained in the summary generated by the embodiment of the present application is mostly 6 to 8 sentences.
[0198] In the embodiment of the present application, after obtaining the plurality of sentences of the target text and the first matrix, the first matrix containing the similarity between any two sentences in the plurality of sentences, the second matrix containing the weight of each sentence in the plurality of sentences can be obtained by iterative operation based on the first matrix. Then, the plurality of sentences can be divided into a plurality of categories based on the first matrix. Next, the sentence with the largest weight in each category in the plurality of categories can be determined based on the second matrix. Finally, the summary of the target text is generated based on the sentence with the largest weight. In the foregoing process, since the summary of the target text is derived from the sentence with the largest weight in each category of the target text, it has a certain degree of semantic diversity, and the information contained in the summary is sufficient to accurately express the main content of the entire target text. It can be seen that the summary of the target text generated in this way has low semantic repetition between sentences and includes important information of the target text.
[0199] Further, the embodiment of the present application combines the extractive automatic summarization technology and the generative automatic summarization technology, the result of the extractive automatic summarization technology is taken as the input of the generative automatic summarization technology, and the output of the generative automatic summarization technology is taken as the final result. It can be seen that the target text can be processed by the extractive automatic summarization technology first to obtain a preliminary summary. Then, the summary generation model processes the preliminary summary to obtain the final summary (i.e., the summary of the target text). Since the number of sentences contained in the preliminary summary is usually small (which can be regarded as a short text), the summary generation model needs to process less data when processing the preliminary summary, which is beneficial to shorten the time required for the model to generate the summary, which is equivalent to improving the performance of the model, thereby ensuring the quality of the final summary.
[0200] Further, the embodiment of the present application can be applied to target texts of various structures, that is, the summary generation of target texts of various structures can be realized, and the final summary can effectively represent the main content of the target text. It can be seen that the embodiment of the present application has good summary generation effect in various application scenarios.
[0201] Further, in the embodiment of the present application, when the sentences of the target text need to be classified, the target text can be analyzed in advance to obtain the relationship between the number of categories and the similarity threshold and the relationship between the number of sentences contained in the category and the similarity threshold, and then the number of categories is determined based on these relationships, thereby avoiding excessive human intervention.
[0202] Further, in the embodiment of the present application, when obtaining the weight of the sentence in the target text, not only the similarity between the sentences is considered, but also the similarity between the sentence and the title, the number of keywords contained in the sentence, and other factors are considered. The considered factors are more comprehensive, which is beneficial to improve the accuracy of the weight of the sentence, and further beneficial to improve the quality of the summary of the target text.
[0203] Figure 9 A flowchart of a model training method provided by the embodiment of the present application is shown in FIG. 1. Figure 9 The method comprises the following steps.
[0204] 901, obtaining a to-be-trained model and a real summary of a target text.
[0205] In the embodiment, when a model with automatic summarization capability (i.e., capable of realizing generative automatic summarization technology) is needed, a to-be-trained model (i.e., an untrained neural network model) and a batch of training data are obtained. The batch of training data includes the real summary of the target text, i.e., the sentences in the target text that can be used as summaries. These sentences can be understood as labels of the target text, and these labels are known.
[0206] 902. The model to be trained is used to process the true summary of the target text to obtain the predicted summary of the target text.
[0207] After obtaining the true summary of the target text, the true summary can be input into the model to be trained, so that the model can process the true summary of the target text to obtain the predicted summary of the target text.
[0208] 903. Based on the true summary and predicted summary of the target text, obtain the target loss, which is used to indicate the difference between the true summary and the predicted summary of the target text.
[0209] After obtaining the predicted summary of the target text, since the true summary of the target text is known, a preset target loss function can be used to calculate the true summary and the predicted summary of the target text, thereby obtaining the target loss. The target loss can be used to indicate the difference between the true summary and the predicted summary of the target text.
[0210] 904. Based on the target loss, update the parameters of the model to be trained until the model training conditions are met, and obtain the summary generation model.
[0211] After obtaining the target loss, the model parameters of the model to be trained can be updated based on the target loss to obtain the updated model to be trained. Then, the next batch of training data is obtained, and the updated model to be trained is trained based on the next batch of training data (i.e., steps 902 to 904 are re-executed) until the model training conditions are met (e.g., the target loss converges, etc.), and the summary generation model can be obtained.
[0212] The summary generation model obtained in this application embodiment has the ability to automatically summarize. During the model training process, only a small amount of training data with known labels is needed to complete the model training, which helps to reduce the cost of model training. Moreover, the model is based on generative automatic summarization technology and can be combined with extractive automatic summarization technology to extract the summary of the text as a whole, which helps to expand the application scenarios of automatic summarization technology.
[0213] The above is a detailed description of the summary generation method and model training method provided in the embodiments of this application. The summary generation device and model training device provided in the embodiments of this application will be introduced below. Figure 10 A schematic diagram of the abstract generation apparatus provided in the embodiments of this application, as shown below. Figure 10 As shown, the device includes:
[0214] The first obtaining module 1001 is configured to obtain a plurality of sentences of a target text and similarities between any two sentences in the plurality of sentences. For example, the first obtaining module is configured to obtain a plurality of sentences of a target text and a first matrix, the first matrix comprising similarities between any two sentences in the plurality of sentences.
[0215] The operation module 1002 is configured to perform iterative operation based on the similarities to obtain a weight of each sentence in the plurality of sentences. For example, the operation module is configured to perform iterative operation based on the first matrix to obtain a second matrix, the second matrix comprising the weight of each sentence in the plurality of sentences.
[0216] The division module 1003 is configured to divide the plurality of sentences into a plurality of categories based on the similarities. For example, the division module is configured to divide the plurality of sentences into a plurality of categories based on the first matrix.
[0217] The determination module 1004 is configured to determine a sentence with the maximum weight in each category in the plurality of categories. For example, the determination module is configured to determine a sentence with the maximum weight in each category in the plurality of categories based on the second matrix.
[0218] The generation module 1005 is configured to generate a summary of the target text based on the sentence with the maximum weight. It is worth noting that the operation module 1002 and the determination module 1004 constitute the aforementioned selection module, and the selection module is configured to determine a sentence with the maximum weight in each category in the plurality of categories based on the similarities and the target text.
[0219] In the embodiments of the present application, after obtaining the plurality of sentences of the target text and the first matrix, iterative operation can be performed based on the first matrix to obtain the second matrix, the first matrix comprising similarities between any two sentences in the plurality of sentences, and the second matrix comprising a weight of each sentence in the plurality of sentences. Then, the plurality of sentences can be divided into a plurality of categories based on the first matrix. Next, a sentence with the maximum weight in each category in the plurality of categories can be determined based on the second matrix. Finally, a summary of the target text can be generated based on the sentence with the maximum weight. In the foregoing process, since the summary of the target text is derived from the sentence with the maximum weight in each category of the target text, it has a certain degree of semantic diversity, and the information contained in the summary is comprehensive enough to accurately express the main content of the entire target text. It can be seen that the summary of the target text generated in this way has low semantic repetition between sentences and includes important information of the target text.
[0220] Further, the embodiment of the present application combines the extractive automatic summarization technology and the generative automatic summarization technology, the result of the extractive automatic summarization technology is taken as the input of the generative automatic summarization technology, and the output of the generative automatic summarization technology is taken as the final result. It can be seen that the target text can be processed by the extractive automatic summarization technology first to obtain a preliminary summary. Then, the summary generation model processes the preliminary summary to obtain the final summary (i.e., the summary of the target text). Since the number of sentences contained in the preliminary summary is usually small (which can be regarded as a short text), the summary generation model needs to calculate a small amount of data when processing the preliminary summary, which is beneficial to shorten the time required for the model to generate the summary, which is equivalent to improving the performance of the model, thereby ensuring the quality of the final summary.
[0221] Further, the embodiment of the present application can be applied to target texts of various structures, that is, the summary generation of target texts of various structures can be realized, and the final summary can effectively represent the main content of the target text. It can be seen that the embodiment of the present application has good summary generation effect in various application scenarios.
[0222] Further, in the embodiment of the present application, when the sentences of the target text need to be classified, the target text can be analyzed in advance to obtain the relationship between the number of categories and the similarity threshold and the relationship between the number of sentences contained in the category and the similarity threshold, and then the number of categories is determined based on these relationships, thereby avoiding excessive human intervention.
[0223] Further, in the embodiment of the present application, when the weights of the sentences in the target text are obtained, not only the similarity between the sentences is considered, but also the similarity between the sentences and the title and the number of keywords contained in the sentences are considered. The considered factors are more comprehensive, which is beneficial to improve the accuracy of the weights of the sentences and further improve the quality of the summary of the target text.
[0224] In a possible implementation, the apparatus further includes a second obtaining module configured to obtain a third matrix and a fourth matrix, the third matrix containing the similarity between any one of the plurality of sentences and the title of the target text, and the fourth matrix containing the number of keywords contained in each of the plurality of sentences; and an operation module 1002 configured to: fuse the first matrix, the third matrix, and the fourth matrix to obtain a fifth matrix; and perform iterative operation based on the fifth matrix to obtain the second matrix.
[0225] In a possible implementation, if the first matrix is an n-row n-column matrix, the third matrix and the fourth matrix are n-row 1-column matrices, and n is the number of sentences, the operation module 1002 is configured to: perform normalization processing on the first matrix, the third matrix, and the fourth matrix to obtain a processed first matrix, a processed third matrix, and a processed fourth matrix, wherein the i-th column of the processed first matrix, the processed third matrix, and the processed fourth matrix all conform to a standard normal distribution, i = 1, …, n; and perform addition processing on the i-th column of the processed first matrix, the processed third matrix, the processed fourth matrix, and the i-th positive value to obtain the i-th column of a fifth matrix, wherein the i-th column of the fifth matrix conforms to a normal distribution.
[0226] In a possible implementation, if the first matrix is an n-row n-column matrix, the third matrix and the fourth matrix are 1-row n-column matrices, and n is the number of sentences, the operation module 1002 is configured to: perform normalization processing on the first matrix, the third matrix, and the fourth matrix to obtain a processed first matrix, a processed third matrix, and a processed fourth matrix, wherein the j-th row of the processed first matrix, the processed third matrix, and the processed fourth matrix all conform to a standard normal distribution, j = 1, …, n; and perform addition processing on the j-th row of the processed first matrix, the processed third matrix, the processed fourth matrix, and the j-th positive value to obtain the j-th row of a fifth matrix, wherein the j-th row of the fifth matrix conforms to a normal distribution.
[0227] In a possible implementation, the i-th positive value is a sum of the smallest element in the i-th column of the processed first matrix, the processed third matrix, and the processed fourth matrix and a preset positive value.
[0228] In a possible implementation, the j-th positive value is a sum of the smallest element in the j-th row of the processed first matrix, the processed third matrix, and the processed fourth matrix and a preset positive value.
[0229] In a possible implementation, the operation module 1002 is configured to perform p-th multiplication processing on the fifth matrix and a sixth matrix processed for p-1 times to obtain a sixth matrix processed for p-th time, until the sixth matrix processed for p-th time conforms to a preset condition, where p = 1, …, m, m ≥ 1, the sixth matrix processed for 0-th time is a preset matrix, and the sixth matrix processed for m-th time is the second matrix.
[0230] In a possible implementation, the similarity between any two sentences in any one category is greater than or equal to a preset similarity threshold, and the similarity between the sentences with the maximum weight in any two categories is less than the similarity threshold.
[0231] In one possible implementation, the generation module 1005 is used to process the sentence with the highest weight through a summary generation model to obtain a summary of the target text.
[0232] Figure 11 A schematic diagram of the model training apparatus provided in the embodiments of this application is shown below. Figure 11 As shown, the device includes:
[0233] The first acquisition module 1101 is used to acquire the model to be trained and the true summary of the target text.
[0234] The processing module 1102 is used to process the true summary of the target text through the model to be trained to obtain the predicted summary of the target text.
[0235] The second acquisition module 1103 is used to acquire a target loss based on the true summary and the predicted summary of the target text. The target loss is used to indicate the difference between the true summary and the predicted summary of the target text.
[0236] The update module 1104 is used to update the parameters of the model to be trained based on the target loss until the model training conditions are met, thus obtaining the summary generation model.
[0237] The summary generation model obtained in this application embodiment has the ability to automatically summarize. During the model training process, only a small amount of training data with known labels is needed to complete the model training, which helps to reduce the cost of model training. Moreover, the model is based on generative automatic summarization technology and can be combined with extractive automatic summarization technology to extract the summary of the text as a whole, which helps to expand the application scenarios of automatic summarization technology.
[0238] It should be noted that the information interaction and execution process between the modules / units of the above-mentioned device are based on the same concept as the method embodiment of this application, and the resulting technical effects are the same as those of the method embodiment of this application. For details, please refer to the description in the method embodiment shown above in the embodiment of this application, and it will not be repeated here.
[0239] This application also relates to an execution device. Figure 12 This is a schematic diagram of the execution device provided in an embodiment of this application. Figure 12 As shown, the execution device 1200 can specifically be a mobile phone, tablet, laptop, smart wearable device, server, etc., and is not limited here. Among them, the execution device 1200 can be deployed with... Figure 10 The summary generation apparatus described in the corresponding embodiment is used to implement Figure 4The function of the embodiment is corresponding to the function of the abstract generation. Specifically, the execution device 1200 includes a receiver 1201, a transmitter 1202, a processor 1203, and a memory 1204 (wherein the number of processors 1203 in the execution device 1200 can be one or more, Figure 12 In some embodiments of the present application, the receiver 1201, the transmitter 1202, the processor 1203, and the memory 1204 can be connected through a bus or other means.
[0240] The memory 1204 can include a read-only memory and a random access memory, and provide instructions and data for the processor 1203. A part of the memory 1204 can also include a non-volatile random access memory (NVRAM). The memory 1204 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or expanded sets thereof, wherein the operation instructions can include various operation instructions for implementing various operations.
[0241] The processor 1203 controls the operation of the execution device. In a specific application, various components of the execution device are coupled together through a bus system, which can include a data bus in addition to a power bus, a control bus, and a status signal bus, etc. However, in order to clearly illustrate, various buses are referred to as a bus system in the figure.
[0242] The method disclosed in the embodiments of the present application can be applied to the processor 1203 or implemented by the processor 1203. The processor 1203 can be an integrated circuit chip having a signal processing capability. In the implementation process, the steps of the above method can be completed by the integrated logic electric circuit or the instruction of the software form in the processor 1203. The processor 1203 can be a general processor, a digital signal processor (DSP), a microprocessor or a microcontroller. The processor 1203 can further include an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The processor 1203 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor or the like. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor to execute, or be executed by a combination of hardware and software modules in the code processor. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the storage 1204, and the processor 1203 reads the information in the storage 1204 and combines the hardware to complete the steps of the above method.
[0243] The receiver 1201 can be used to receive input digital or character information, and generate signal input related to the relevant settings and function control of the execution device. The transmitter 1202 can be used to output digital or character information through the first interface; the transmitter 1202 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1202 can also include a display device such as a display screen.
[0244] In an embodiment of the present application, in one case, the processor 1203 is configured to generate a summary of the target text by Figure 4 The summary generation model in the corresponding embodiment generates a summary of the target text.
[0245] The embodiments of the present application also relate to a training device, Figure 13 A structural schematic diagram of the training device provided in the embodiments of the present application is shown in FIG. 8. As shown in FIG. 8, the training device includes a processor 8001, a memory 8002, a receiver 8003 and a transmitter 8004. Figure 13As shown, the training device 1300 is implemented by one or more servers, which can be configured or have different performance, and can include one or more central processing units (CPUs) 1314 (e.g., one or more processors) and a memory 1332, one or more storage media 1330 (e.g., one or more mass storage devices) storing applications 1342 or data 1344. The memory 1332 and the storage media 1330 can be short-term or long-term storage. The programs stored in the storage media 1330 can include one or more modules (not shown in the figure), each of which can include a series of instruction operations in the training device. Further, the central processing unit 1314 can be configured to communicate with the storage media 1330 and execute the series of instruction operations in the storage media 1330 on the training device 1300.
[0246] The training device 1300 can also include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input / output interfaces 1358, or one or more operating systems 1341, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0247] In particular, the training device can perform Figure 9 the model training method in the corresponding embodiment.
[0248] The embodiments of the present application also relate to a computer readable storage medium storing a program for signal processing, which, when executed on a computer, causes the computer to perform the steps performed by the execution device as described above, or causes the computer to perform the steps performed by the training device as described above.
[0249] The embodiments of the present application also relate to a computer program product storing instructions, which, when executed by a computer, causes the computer to perform the steps performed by the execution device as described above, or causes the computer to perform the steps performed by the training device as described above.
[0250] The execution device, the training device or the terminal device provided by the embodiments of the present application can be a chip, which includes a processing unit, for example, a processor, and a communication unit, for example, an input / output interface, a pin or a circuit, etc. The processing unit can execute computer execution instructions stored in a storage unit, so that the chip in the execution device executes the data processing method described in the above embodiments, or so that the chip in the training device executes the data processing method described in the above embodiments. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc., and the storage unit can also be a storage unit outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0251] Specifically, refer to Figure 14 , Figure 14 A structural diagram of the chip provided by the embodiments of the present application is shown in FIG. 14. The chip can be a neural network processor NPU 1400, which is mounted on a host CPU as a coprocessor and is assigned tasks by the host CPU. The core part of the NPU is an operation circuit 1403, which extracts matrix data in a memory and performs multiplication operation under the control of a controller 1404.
[0252] In some implementations, the operation circuit 1403 internally includes a plurality of processing units (Process Engine, PE). In some implementations, the operation circuit 1403 is a two-dimensional systolic array. The operation circuit 1403 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 1403 is a general matrix processor.
[0253] For example, assuming that there are an input matrix A, a weight matrix B and an output matrix C. The operation circuit takes corresponding data of the matrix B from the weight memory 1402 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 1401 and performs matrix operation with the matrix B, and the partial result or final result of the obtained matrix is saved in an accumulator 1408.
[0254] The unified memory 1406 is used to store input data and output data. The weight data is transferred to the weight memory 1402 through the direct memory access controller (DMAC) 1405. The input data is also transferred to the unified memory 1406 through the DMAC.
[0255] The BIU (bus interface unit) 1413 is used for the interaction between the AXI bus and the DMAC and the instruction fetch buffer (IFB) 1409.
[0256] The BIU (bus interface unit) 1413 is used for the instruction fetch buffer 1409 to obtain instructions from the external memory, and is also used for the direct memory access controller 1405 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0257] The DMAC is mainly used to transfer the input data in the external memory DDR to the unified memory 1406, or to transfer the weight data to the weight memory 1402, or to transfer the input data to the input memory 1401.
[0258] The vector calculation unit 1407 includes a plurality of operation processing units, which further process the output of the operation circuit 1403 as needed, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / full connection layer network calculation in neural networks, such as batch normalization, pixel-level summation, upsampling of prediction label planes, etc.
[0259] In some implementations, the vector calculation unit 1407 can store the processed output vector to the unified memory 1406. For example, the vector calculation unit 1407 can apply a linear function; or, a nonlinear function to the output of the operation circuit 1403, such as linear interpolation on the prediction label planes extracted by the convolutional layer, and again, for example, a vector of accumulated values to generate activation values. In some implementations, the vector calculation unit 1407 generates normalized values, pixel-level summation values, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1403, for example, for use in subsequent layers in the neural network.
[0260] The controller 1404 is connected to the instruction fetch buffer 1409, which is used to store instructions used by the controller 1404;
[0261] The unified memory 1406, the input memory 1401, the weight memory 1402, and the instruction memory 1409 are on-chip memories. The external memory is private to the NPU hardware architecture.
[0262] Any of the processors mentioned above can be a general central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above programs.
[0263] It should be noted that the apparatus embodiments described above are merely illustrative, and the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e., they can be located in one place or distributed on multiple network units. Some or all of the modules can be selected to achieve the purpose of the embodiment according to actual needs. In addition, the connection relationship between the modules in the apparatus embodiment provided in the present application indicates that there is a communication connection between them, which can be implemented as one or more communication buses or signal lines.
[0264] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software and the necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. Generally, functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure for implementing the same function can also be various, such as analog circuits, digital circuits, or special circuits. However, for the present application, software program implementation is a better embodiment. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., including a plurality of instructions for making a computer device (which can be a personal computer, a training device, or a network device, etc.) execute the methods described in various embodiments of the present application.
[0265] In the above embodiments, all or part can be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, it can be implemented in the form of a computer program product in whole or in part.
[0266] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, training device or data center to another website, computer, training device or data center through wired (for example, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be stored by the computer or a data storage device such as a training device, a data center, etc. integrated with one or more available media sets. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)), etc.
Claims
1. A method for generating summaries, characterized in that, The method includes: Obtain multiple sentences of the target text and the similarity between any two sentences among the multiple sentences. The similarity between any two sentences among the multiple sentences is obtained through a first matrix, which contains the similarity between any two sentences. The sentences are divided into multiple categories based on the similarity. Obtain a third matrix and a fourth matrix, wherein the third matrix contains the similarity between any one of the plurality of sentences and the title of the target text, and the fourth matrix contains the number of keywords contained in each of the plurality of sentences; The first matrix, the third matrix, and the fourth matrix are normalized to obtain the processed first matrix, the processed third matrix, and the processed fourth matrix. The processed first matrix, the processed third matrix, and the processed fourth matrix are then added together to obtain the fifth matrix. The second matrix is obtained by multiplying the fifth matrix and the sixth matrix, and the second matrix contains the weight of each sentence in the plurality of sentences; A summary of the target text is generated based on the sentence with the highest weight in each category.
2. The method according to claim 1, characterized in that, If the first matrix is an n x n matrix, and the third and fourth matrices are n x 1 matrices, where n is the number of sentences, then fusing the first, third, and fourth matrices to obtain the fifth matrix includes: The first matrix, the third matrix, and the fourth matrix are normalized to obtain the processed first matrix, the processed third matrix, and the processed fourth matrix. The i-th column of the processed first matrix, the processed third matrix, and the processed fourth matrix all conform to a standard normal distribution, i=1,…,n. The i-th column of the processed first matrix, the processed third matrix, the processed fourth matrix, and the i-th positive value are added together to obtain the i-th column of the fifth matrix, which conforms to a normal distribution.
3. The method according to claim 1, characterized in that, If the first matrix is an n x n matrix, and the third and fourth matrices are 1 x n matrices, where n is the number of sentences, then fusing the first, third, and fourth matrices to obtain the fifth matrix includes: The first matrix, the third matrix, and the fourth matrix are normalized to obtain the processed first matrix, the processed third matrix, and the processed fourth matrix. The j-th row of the processed first matrix, the processed third matrix, and the processed fourth matrix all conform to a standard normal distribution, j=1,…,n. The j-th row of the processed first matrix, the processed third matrix, the processed fourth matrix, and the j-th positive value are added together to obtain the j-th row of the fifth matrix, which conforms to a normal distribution.
4. The method according to claim 2, characterized in that, The i-th positive value is the sum of the smallest element in the i-th column of the processed first matrix, the processed third matrix, and the processed fourth matrix, and a preset positive value.
5. The method according to claim 3, characterized in that, The j-th positive value is the sum of the smallest element in the j-th row of the processed first matrix, the processed third matrix, and the processed fourth matrix, and a preset positive value.
6. The method according to any one of claims 1 to 5, characterized in that, The iterative operation based on the fifth matrix to obtain the second matrix includes: The fifth matrix is multiplied by the sixth matrix after the (p-1)th processing for the pth time to obtain the sixth matrix after the pth processing, until the sixth matrix after the pth processing meets the preset conditions, where p=1, ..., m, m≥1, the sixth matrix after the 0th processing is the preset matrix, and the sixth matrix after the mth processing is used as the second matrix.
7. The method according to any one of claims 1 to 5, characterized in that, The similarity between any two sentences in any category is greater than or equal to a preset similarity threshold, and the similarity between the sentences with the highest weight in any two categories is less than the similarity threshold.
8. The method according to any one of claims 1 to 5, characterized in that, The process of generating a summary of the target text based on the sentence with the highest weight in each category includes: The summary generation model processes the sentence with the highest weight in each category to obtain a summary of the target text.
9. A summary generation apparatus, characterized in that, The device includes: The first acquisition module is used to acquire multiple sentences of the target text and the similarity between any two sentences among the multiple sentences. The similarity between any two sentences among the multiple sentences is acquired through a first matrix, which contains the similarity between the two sentences. A segmentation module is used to divide the multiple sentences into multiple categories based on the similarity. The second acquisition module is used to acquire a third matrix and a fourth matrix. The third matrix contains the similarity between any one of the plurality of sentences and the title of the target text, and the fourth matrix contains the number of keywords contained in each of the plurality of sentences. The selection module is configured to: normalize the first matrix, the third matrix, and the fourth matrix to obtain processed first matrix, processed third matrix, and processed fourth matrix; add the processed first matrix, the processed third matrix, and the processed fourth matrix to obtain a fifth matrix; and multiply the fifth matrix by the sixth matrix to obtain a second matrix, wherein the second matrix contains the weight of each sentence in the plurality of sentences; The generation module is used to generate a summary of the target text based on the sentence with the highest weight in each category.
10. The apparatus according to claim 9, characterized in that, If the first matrix is an n x n matrix, and the third and fourth matrices are n x 1 matrices, where n is the number of sentences, the operation module is used for: The first matrix, the third matrix, and the fourth matrix are normalized to obtain the processed first matrix, the processed third matrix, and the processed fourth matrix. The i-th column of the processed first matrix, the processed third matrix, and the processed fourth matrix all conform to a standard normal distribution, i=1,…,n. The i-th column of the processed first matrix, the processed third matrix, the processed fourth matrix, and the i-th positive value are added together to obtain the i-th column of the fifth matrix, which conforms to a normal distribution.
11. The apparatus according to claim 9, characterized in that, If the first matrix is an n x n matrix, and the third and fourth matrices are 1 x n matrices, where n is the number of sentences, the operation module is used for: The first matrix, the third matrix, and the fourth matrix are normalized to obtain the processed first matrix, the processed third matrix, and the processed fourth matrix. The j-th row of the processed first matrix, the processed third matrix, and the processed fourth matrix all conform to a standard normal distribution, j=1,…,n. The j-th row of the processed first matrix, the processed third matrix, the processed fourth matrix, and the j-th positive value are added together to obtain the j-th row of the fifth matrix, which conforms to a normal distribution.
12. The apparatus according to claim 10, characterized in that, The i-th positive value is the sum of the smallest element in the i-th column of the processed first matrix, the processed third matrix, and the processed fourth matrix, and a preset positive value.
13. The apparatus according to claim 11, characterized in that, The j-th positive value is the sum of the smallest element in the j-th row of the processed first matrix, the processed third matrix, and the processed fourth matrix, and a preset positive value.
14. The apparatus according to any one of claims 9 to 13, characterized in that, The operation module is used to perform a p-th multiplication process on the fifth matrix and the sixth matrix after the (p-1)th processing to obtain the sixth matrix after the p-th processing, until the sixth matrix after the p-th processing meets the preset conditions, where p=1, ..., m, m≥1, the sixth matrix after the 0th processing is the preset matrix, and the sixth matrix after the m-th processing is used as the second matrix.
15. The apparatus according to any one of claims 9 to 13, characterized in that, The similarity between any two sentences in any category is greater than or equal to a preset similarity threshold, and the similarity between the sentences with the highest weight in any two categories is less than the similarity threshold.
16. The apparatus according to any one of claims 9 to 13, characterized in that, The generation module is used to process the sentence with the highest weight in each category through a summary generation model to obtain a summary of the target text.
17. A summary generation apparatus, characterized in that, The apparatus includes a memory and a processor; the memory stores code, and the processor is configured to execute the code, wherein when the code is executed, the digest generation apparatus performs the method as described in any one of claims 1 to 8.
18. A computer storage medium, characterized in that, The computer storage medium stores one or more instructions that, when executed by one or more computers, cause the one or more computers to perform the method of any one of claims 1 to 8.
19. A computer program product, characterized in that, The computer program product stores instructions that, when executed by a computer, cause the computer to perform the method described in any one of claims 1 to 8.
Citation Information
Patent Citations
Abstraction generation method and device, terminal equipment and storage medium
CN110837556A
Text abstract generation method and device, electronic equipment and storage medium
CN111859932A
Multi-language multi-document abstract extraction method based on weighted TextRank
CN112948543A