Text abstract generation method and device
By clustering massive texts and combining large-scale language generation models and deep learning models to generate text summary, the problem of low generation efficiency in the existing technology is solved and accurate and efficient summary generation is achieved.
Patent Information
- Application Number
- CN202411638982.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-03-18
AI Technical Summary
When the prior art generates a large amount of text summary, it is difficult to achieve accurate and efficient processing, resulting in low generation efficiency.
By clustering multiple texts, only a large-scale language generation model is used to generate a central text summary for each category, and a pre-trained deep learning model is used to generate a non-central text summary based on the central text summary.
It realizes the accurate and efficient generation of the abstract of each text in a massive text, which not only takes advantage of the accuracy of the big model, but also takes advantage of the efficiency of the deep learning model.
Smart Images

Figure CN119646211A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method for generating a text summary, a device for generating a text summary, an electronic device, and a computer-readable storage medium. Background Art
[0002] Text summarization has a wide range of applications in many fields, such as generating paper summaries, news summaries, etc., to achieve a concise display of large amounts of content.
[0003] At present, a general-purpose large-scale language generation model similar to ChatGPT (hereinafter referred to as the big model) is usually used to generate text summaries. That is, the text to be summarized is input into the big model, and the summary of the text is generated by the big model. The output of the big model is the summary of the text.
[0004] The advantage of using a large model to generate text summaries is that it can achieve accurate generation of text summaries. However, it is precisely because of this advantage of the large model that the computational complexity of the large model is relatively high, which leads to a long time for the large model to generate a summary of a single text. For the massive amount of text generated on the Internet every day, it is obviously impossible to efficiently generate a summary of each text through a large model. It can be seen that how to accurately and efficiently generate a summary of each text in the massive amount of text is a problem that needs to be solved at present. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a method for generating a text summary, a device for generating a text summary, an electronic device, and a computer-readable storage medium, so as to accurately and efficiently generate a summary of each text in a massive amount of text.
[0006] In order to solve the above technical problems, the embodiments of the present application provide the following technical solutions:
[0007] The first aspect of the present application provides a method for generating a text summary, the method comprising: in response to summaries of multiple texts to be generated, obtaining clustering results of the multiple texts, the clustering results including at least one category and central text and non-central text under the corresponding category; using a large model to generate a summary of the central text under each category, the large model being a general-purpose large-scale language generation model similar to ChatGPT; determining the feature vectors of the central text and the non-central text under each category; based on the summary of the central text under each category, the feature vector of the central text and the feature vector of the non-central text, using a text summary model to generate a summary of the non-central text under each category, wherein the text summary model is a pre-trained deep learning model for extracting text summaries; based on the summary of the central text and the summary of the non-central text under each category, obtaining summaries of the multiple texts.
[0008] Compared with the prior art, the method for generating text summaries provided in the first aspect of the present application no longer generates summaries for each text separately through a large model, but clusters multiple texts and only generates summaries for one central text in each category using a large model. The summaries of non-central texts in a category are generated based on the summaries of central texts in the same category using a text summary model based on deep learning. In this way, the accuracy of text summaries generated by large models and the efficiency of text summary models in batch generation are utilized, so that the summaries of each text in a massive amount of text can be accurately and efficiently generated.
[0009] In some variation implementations of the first aspect of the present application, clustering results of multiple texts are obtained, including: obtaining multiple texts; clustering the multiple texts based on themes or contents to obtain at least one category and texts under the corresponding category; determining central texts and non-central texts in the texts under each category; and determining each category and its corresponding central texts and non-central texts as clustering results.
[0010] Clustering multiple texts based on topics or content can aggregate similar texts together to achieve precise clustering, thereby improving the accuracy of non-central text summary generation in each category.
[0011] In some modified implementations of the first aspect of the present application, in the text under each category, the central text and the non-central text are determined, including: calculating the feature vector of the text under each category; calculating the average vector corresponding to each category based on the feature vector of the text under each category; in each category, determining the text corresponding to the feature vector with the smallest difference from the average vector as the central text, and determining the text other than the central text as the non-central text, to obtain the central text and the non-central text under each category.
[0012] The central text is selected through the average vector of the category, so that the selected central text has the smallest overall difference with other non-central texts, which can reduce the probability of errors in generating summaries of non-central texts and improve the accuracy of non-central text summary generation.
[0013] In some modified implementations of the first aspect of the present application, the text corresponding to the feature vector with the smallest difference from the average vector is determined as the central text, including: when there are multiple feature vectors with the smallest difference from the average vector, determining multiple candidate texts corresponding to the multiple feature vectors with the smallest difference; calculating the data amount of each candidate text; and determining the candidate text with the smallest data amount as the central text.
[0014] When there are multiple central texts to be selected, selecting the text with the smallest amount of data as the central text can reduce the time spent on processing the central text in the large model, improve the efficiency of generating central text summaries, and further improve the efficiency of generating summaries of multiple texts.
[0015] In some modified implementations of the first aspect of the present application, a text summary model is used to generate a summary of the non-central text in each category based on the summary of the central text, the feature vector of the central text and the feature vector of the non-central text in each category, including: in each category, calculating the vector difference between the feature vector of the non-central text and the feature vector of the central text; inputting the summary of the central text in each category and the vector difference into the text summary model to obtain a summary of the non-central text in each category.
[0016] Compared with inputting the feature vectors of each text into the text summary model, inputting the vector difference between the non-central text and the central text into the text summary model can not only save the calculation steps of the vector difference for the text summary model, but also simplify the architecture of the text summary model, making the text summary model more lightweight, thereby improving the generation efficiency of non-text summaries.
[0017] In some changed implementations of the first aspect of the present application, before obtaining the clustering results of multiple texts, the method also includes: obtaining an original text summary model, the original text summary model includes a word embedding layer, a conversion module, a fully connected layer and a normalization layer, the word embedding layer is the same as the word embedding layer in the Bert deep learning model, and the number of conversion modules is less than the number of conversion modules in the Bert deep learning model; using training data to train the original text summary model to obtain a text summary model, wherein the training data includes feature vectors corresponding to the central corpus and non-central corpus under each category, and original summaries corresponding to the central corpus and non-central corpus under each category, the feature vectors corresponding to the central corpus and non-central corpus under each category, and the original summary corresponding to the central corpus are inputs for model training, and the original summary corresponding to the non-central corpus under each category is output from model training, and the original summary is generated based on the large model.
[0018] The text summary model uses the same structure as the Bert deep learning model, which can improve the efficiency of building the text summary model. In the text summary model, a smaller number of conversion modules are used, which can reduce the amount of calculation in the text summary model and improve the efficiency of text summary generation while ensuring that the accuracy of text summary generation is not significantly reduced. And using text summaries generated based on large models for training can improve the accuracy of the text summary model and the accuracy of non-text summary generation.
[0019] In some modified implementations of the first aspect of the present application, before obtaining the clustering results of multiple texts, the method also includes: determining whether each category corresponds to only one text; if so, determining a target text whose similarity with the subject or content of a text is greater than a preset similarity from a preset database, and determining the target text as the central text of the category to which the text belongs, and obtaining a summary of the target text from the preset database, wherein the preset database stores various texts and summaries generated based on a large model; if not, executing the step of obtaining the clustering results of multiple texts.
[0020] In the case where clustering cannot be achieved between multiple texts, by selecting other texts with similar contents outside the multiple texts as the central text, the summaries of the texts with similar contents have been obtained in advance through the large model. In this way, it is still possible to accurately and efficiently generate summaries of multiple texts.
[0021] According to a second aspect of the present application, there is provided a device for generating a text summary, the device comprising: an acquisition module for acquiring clustering results of the multiple texts in response to summaries of the multiple texts to be generated, the clustering results comprising at least one category and the central text and non-central text under the corresponding category; a first generation module for generating a summary of the central text under each category by using a large model, the large model being a general-purpose large-scale language generation model similar to ChatGPT; a determination module for determining feature vectors of the central text and non-central text under each category; a second generation module for generating a summary of the non-central text under each category by using a text summary model based on the summary of the central text under each category, the feature vector of the central text and the feature vector of the non-central text, wherein the text summary model is a pre-trained deep learning model for extracting text summaries; and a third generation module for obtaining summaries of the multiple texts based on the summary of the central text and the summary of the non-central text under each category.
[0022] The third aspect of the present application provides an electronic device, which includes: a processor, a memory, and a bus; wherein the processor and the memory communicate with each other through the bus; and the processor is used to call program instructions in the memory to execute the method in the first aspect.
[0023] A fourth aspect of the present application provides a computer-readable storage medium, the storage medium comprising: a stored program; wherein, when the program is running, the device where the storage medium is located is controlled to execute the method in the first aspect.
[0024] The text summary generation device provided in the second aspect, the electronic device provided in the third aspect, and the computer-readable storage medium provided in the fourth aspect of the present application have the same or similar beneficial effects as the text summary generation method provided in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0026] Figure 1 The process diagram of the method for generating a text summary in the embodiment of the present application is as follows: Figure 1 ;
[0027] Figure 2 The process diagram of the method for generating a text summary in the embodiment of the present application is as follows: Figure 2 ;
[0028] Figure 3 The process diagram of the method for generating a text summary in the embodiment of the present application is as follows: Figure 3 ;
[0029] Figure 4 A schematic diagram of the text summary model architecture and the non-text summary generation process in the embodiment of the present application;
[0030] Figure 5 The structure of the device for generating a text summary in the embodiment of the present application is shown in FIG. Figure 1 ;
[0031] Figure 6 The structure of the device for generating a text summary in the embodiment of the present application is shown in FIG. Figure 2 ;
[0032] Figure 7 Schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0034] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by technicians in the field to which this application belongs.
[0035] At present, the method of generating summaries of multiple texts is to input each text into a large model and obtain the summaries of each text. However, although the large model can achieve accurate generation of text summaries, the efficiency of generating text summaries is not high. Therefore, a technical solution is currently needed to achieve accurate and efficient generation of summaries of multiple texts.
[0036] In view of this, the embodiments of the present application provide a method for generating a text summary, a device for generating a text summary, an electronic device, and a computer-readable storage medium. Considering that the use of a large model can achieve accurate generation of text summaries, but the large model processes texts slowly, resulting in low efficiency in generating multiple text summaries. The text summary model based on deep learning can efficiently process a large amount of text, but the accuracy of the generated text summary is not high. If the large model and the text summary model can be used simultaneously in the generation of multiple text summaries, it is possible to achieve accurate generation of text summaries through the large model, and to efficiently generate summaries of multiple texts through the text summary model, thereby achieving accurate and efficient generation of multiple text summaries.
[0037] First, the method for generating a text summary provided in an embodiment of the present application is described in detail.
[0038] Figure 1 The process diagram of the method for generating a text summary in the embodiment of the present application is as follows: Figure 1 , see Figure 1 As shown, the method may include:
[0039] S11: In response to summaries of multiple texts to be generated, obtaining clustering results of the multiple texts.
[0040] The clustering result includes at least one category and central text and non-central text under the corresponding category.
[0041] When it is necessary to generate summaries of multiple texts, the execution entity of the method provided in the embodiment of the present application will receive multiple texts, and then start to use the method provided in the embodiment of the present application to generate a summary of each of the multiple texts.
[0042] The multiple texts here refer to the texts for which summary generation is required, such as new content generated on the Internet every day, weekly reports of all employees of a company, etc. The specific content of the multiple texts is not limited here.
[0043] After starting to generate summaries of multiple texts, first, the multiple texts need to be classified, that is, the clustering results of the multiple texts are obtained. The specific method of clustering multiple texts can be clustered according to the text type, or according to the theme or content of the text, which is not limited here.
[0044] At the same time, the central text and non-central text must be determined in each category. The central text under each category can be any text among all the texts under the category, or it can be a specified text among all the texts under the category. For the specified text, it can be determined by the number of words in the text. That is to say, under a certain category, determine the number of words of each text, and then use the text with the most words as the central text under the category. It can also be determined by the feature vector of the text. That is to say, under a certain category, select the text corresponding to the appropriate feature vector from the feature vectors of each text, and then use the text as the central text under the category. The specific method of determining the central text is not limited here.
[0045] S12: Use a large model to generate a summary of the central text in each category.
[0046] Among them, the large model is a general-purpose large-scale language generation model similar to ChatGPT.
[0047] The large model can accurately generate a summary of the text. However, the efficiency of generating text summaries through the large model is low. In this case, the large model can only generate a summary of the core text of each category to reduce the amount of text processed by the large model. The summary of the non-core text other than the core text in each category is generated based on the summary of the core text generated by the large model. This indirectly utilizes the advantage of the large model in generating accurate text summaries, while skipping the disadvantage of the large model in generating text summaries with low efficiency.
[0048] S13: Determine the feature vectors of the central text and the non-central text under each category.
[0049] Feature vectors can comprehensively and concisely represent the content of the text and improve the efficiency of subsequent text processing.
[0050] The feature vector of a text can be obtained by using one or more known text vector calculation methods. For example: use the Bert deep learning model to calculate the feature vector of a text, and connect the first embedding representation vectors of the last s transformers as the feature vector of the text. Because the Bert deep learning model converts each token into a vector with a dimension of 768, if the first embedding representation vector of the last transformer is taken as the feature vector of the text, then each text is represented by a vector with a dimension of 768. In this way, the consistency of multiple text feature vectors can be ensured, which facilitates the subsequent calculation between each text feature vector, thereby improving the accuracy of text summary generation. The number of s can be adjusted according to specific needs. The specific calculation method of the text feature vector is not limited here.
[0051] S14: Based on the summary of the central text in each category, the feature vector of the central text and the feature vector of the non-central text, a text summary model is used to generate a summary of the non-central text in each category.
[0052] Among them, the text summary model is a pre-trained deep learning model for extracting text summaries.
[0053] When training a text summary model, first, a large number of different training texts need to be collected. Then, a large model is used to generate a summary of each training text. And the feature vector of each training text is calculated. At the same time, these training texts are clustered, and the central text and non-central text are determined in each category. Finally, the summary and feature vector of the central text in each category and the feature vector of the non-central text are used as input to the model to be trained, and the summary of the non-central text in each category is used as output to the model to be trained. After the model is trained, it can be put into use.
[0054] When the text summary model is in use, for each category after multiple texts are clustered, the summary and feature vector of the central text and the feature vector of the non-central text are input into the model. The output of the model is the summary of the non-central text in the corresponding category.
[0055] S15: Based on the summary of the central text and the summary of the non-central text in each category, the summaries of multiple texts are obtained.
[0056] Next, an example is used to more clearly illustrate the method for generating a text summary provided in an embodiment of the present application.
[0057] Figure 2 The process diagram of the method for generating a text summary in the embodiment of the present application is as follows: Figure 2 , see Figure 2 As shown, text 1 to text 9 need to generate summaries respectively.
[0058] First, obtain the clustering results of text 1 to text 9, specifically: category a, category b, and category c. Category a corresponds to text 1 and text 2, category b corresponds to text 3, text 4, and text 5, and category c corresponds to text 6, text 7, text 8, and text 9. In category a, the central text is text 1, and the rest are non-central texts. In category b, the central text is text 3, and the rest are non-central texts. In category c, the central text is text 6, and the rest are non-central texts.
[0059] Then, text 1, text 3 and text 6 are respectively input into the large model to obtain summary 1 of text 1, summary 3 of text 3, and summary 6 of text 6.
[0060] Next, calculate the feature vectors of the central text and non-central text in each category and obtain feature vector 1 of text 1, feature vector 2 of text 2, feature vector 3 of text 3, feature vector 4 of text 4, feature vector 5 of text 5, feature vector 6 of text 6, feature vector 7 of text 7, feature vector 8 of text 8, and feature vector 9 of text 9.
[0061] Finally, for category a, the summary 1 of text 1, the feature vector 1 of text 1, and the feature vector 2 of text 2 are input into the text summary model to generate the summary 2 of text 2. For category b, the summary 3 of text 3, the feature vector 3 of text 3, the feature vector 4 of text 4, and the feature vector 5 of text 5 are input into the text summary model to generate the summary 4 of text 4 and the summary 5 of text 5. For category c, the summary 6 of text 6, the feature vector 6 of text 6, the feature vector 7 of text 7, the feature vector 8 of text 8, and the feature vector 9 of text 9 are input into the text summary model to generate the summary 7 of text 7, the summary 8 of text 8, and the summary 9 of text 9. Finally, the summaries 1-9 corresponding to text 1-text 9 are obtained.
[0062] As can be seen from the above content, the method for generating text summaries provided in the embodiment of the present application no longer generates summaries for each text separately through a large model, but clusters multiple texts and only generates summaries for one central text in each category using a large model. The summaries of non-central texts in a category are generated based on the summaries of central texts in the same category using a text summary model based on deep learning. In this way, the accuracy of text summaries generated by large models and the efficiency of batch generation of text summaries by text summary models are utilized, so that the summary of each text in a massive amount of text can be accurately and efficiently generated.
[0063] Furthermore, as a Figure 1 As a refinement and extension of the method shown, the embodiment of the present application also provides a method for generating a text summary.
[0064] Figure 3 The process diagram of the method for generating a text summary in the embodiment of the present application is as follows: Figure 3 , see Figure 3 As shown, the method may include:
[0065] S31: Obtain a text summarization model.
[0066] The text summarization model can generate a summary of another text based on the summary and feature vector of a certain text and the feature vector of another text. The text summarization model can use a known model with similar functions, or it can be built and trained by itself.
[0067] Specifically, the above step S31 may include:
[0068] Step A1: Get the original text summarization model.
[0069] That is the initial architecture for building a text summarization model.
[0070] When constructing the text summarization model in the early stage, the architecture of word embedding layer + conversion module + fully connected layer + normalization layer can be adopted.
[0071] The word embedding layer can be the same as the word embedding layer in the Bert deep learning model. While achieving accurate summary generation, it can also improve the efficiency of model construction.
[0072] The number of transformation modules, i.e., transformer blocks, can be smaller than that of the Bert deep learning model. The usual Bert deep learning model contains 12 transformation modules, while the text summary model only needs 1-3 transformation modules. While realizing text summary generation, it can reduce the model burden, reduce the amount of calculation in the model, and improve the efficiency of summary generation.
[0073] Fully connected layer, that is, full connection layer.
[0074] Normalization layer, that is, softmax layer.
[0075] The fully connected layer and normalization layer can convert the output of the last conversion module into a token of the text summary, realizing the standardized generation of the text summary.
[0076] In the text summary model, the input needs to be configured as the identification of the text, which can be the identity document (ID) of the text token or the serial number corresponding to all the characters in the text. If the ID actually input exceeds the maximum input width of the model, the length of the input ID will be truncated. It can be intercepted from the head or the tail. It needs to be determined based on the differences between the tokens of multiple texts, and the part with the largest difference is selected for interception. If the length of the input ID does not meet the input requirements of the model, the input ID will be padded with spaces before entering the model. This ensures that the summary can be generated every time, ensuring the smooth and correct generation of the text summary.
[0077] In addition to the above configurations for text summary input, there is also a configuration for inputting the vector difference between the feature vectors of two texts. The vector difference can be configured to be input through the conversion module. In this way, the vector difference can be prevented from undergoing useless processing in other layers and can be directly input into the summary generation step, further improving the efficiency of text summary generation.
[0078] The output of the text summary model needs to be configured as the identifier of the summary, which can be the ID of the summary token or the serial number corresponding to all the characters in the summary. This can reduce the computational burden of the model and improve the efficiency of summary generation.
[0079] Step A2: Use the training data to train the original text summary model to obtain a text summary model.
[0080] Among them, the training data includes the feature vectors corresponding to the central corpus and non-central corpus under each category, and the original summaries corresponding to the central corpus and non-central corpus under each category. The feature vectors corresponding to the central corpus and non-central corpus under each category, and the original summary corresponding to the central corpus are the input of model training, and the original summary corresponding to the non-central corpus under each category is the output of model training, and the original summary is generated based on the large model.
[0081] That is to say, in model training, multiple corpora are collected in advance, and then clustering is performed on the multiple corpora to obtain multiple categories and their corresponding corpora. Next, the feature vectors of each corpus under each category are calculated. Next, under each category, the average vector is calculated based on the feature vectors of each corpus, and then the corpus corresponding to the feature vector with the smallest difference from the average vector is selected as the central corpus, and the other corpora are non-central corpora. Next, the central corpus and non-central corpus under each category are processed using a large model to obtain the original summaries of the central corpus and non-central corpus of each category. Finally, the original summary of the central corpus of each category, the feature vector of the central corpus, and the feature vector of the non-central corpus are substituted into the model as input, and the original summary of the non-central corpus is substituted into the model as output for model training. Finally, a usable text summary model is obtained.
[0082] It should be noted that the corpus here is essentially the same as the text in the following text, but the specific content is different. The corpus here is actually the text used for model training, while the text involved in the following text is the text that actually needs to be extracted for summary.
[0083] S32: Acquire multiple texts.
[0084] For each text here, a summary needs to be generated.
[0085] S33: Clustering the multiple texts based on themes or contents to obtain at least one category and texts under the corresponding category.
[0086] After obtaining multiple texts, we first need to group the same texts together and distinguish different texts, that is, clustering, so that the subsequent text summary can be generated accurately and efficiently.
[0087] When clustering, you can cluster multiple texts by the subject or content of the text. Group texts with the same subject or content into one category. For example, group texts related to weather forecasts into one category, group texts related to current affairs into one category, and so on.
[0088] Of course, multiple texts can also be clustered by the number of identical topics (tokens) in the texts. Texts with the same token number greater than a preset number are classified into one category. The specific method used for clustering multiple texts is not limited here.
[0089] S34: Determine whether each category corresponds to only one text. If yes, execute S35; if no, execute S36.
[0090] In some cases, some texts are quite different from other texts and clustering may not be possible. In this case, some categories correspond to only one text. Using a large model to obtain a text summary for this text obviously cannot effectively improve the generation efficiency of text summaries under this category. To this end, a text with similar content can be found for this text from outside of multiple texts. The summaries of texts with similar content can be obtained in advance using a large model. In this way, this text under this category can achieve efficient generation of text summaries based on the text summary model, thereby improving the overall generation efficiency of multiple text summaries.
[0091] Texts with similar content can be obtained from a preset database. In the preset database, various texts and their summaries and feature vectors are pre-stored. The summaries of various texts are pre-generated based on the large model. For a single text under a certain category, the similarity between the text and each text in the preset database can be calculated in turn. When the similarity between a text in the preset database and the single text is calculated to be greater than the preset similarity, the text in the preset database is used as the central text under the category of the single text. The summary and feature vector of the central text can also be directly obtained from the preset database without the need for subsequent recalculation, thereby improving the efficiency of generating summaries of multiple texts.
[0092] In the specific judgment, for each category, check whether there is only one text corresponding to it. That is to say, a judgment is made for each category. In the judgment of a certain category, if there is only one text corresponding to it, it is judged as yes, and the category needs to be connected to S35. If there are two or more texts corresponding to it, it is judged as no, and the category needs to be connected to S36. If all categories correspond to two or more texts, all categories are connected to S36.
[0093] S35: determining a target text having a similarity with a subject or content of a text greater than a preset similarity from a preset database, determining the target text as a central text of a category to which the text belongs, and obtaining a summary of the target text from the preset database.
[0094] Among them, the preset database stores various texts and summaries generated based on the large model. The various texts here can be multiple texts involving different contents. The specific content and quantity of the various texts can be determined according to actual needs and are not specifically limited here.
[0095] Furthermore, the preset database can also store feature vectors of various texts. In this way, when the feature vector of the selected text in the preset database is needed later, it can be directly called from the preset database without calculation and generation, thereby improving the generation efficiency of the text summary.
[0096] For example, assume that a text a and its summary a and feature vector a as well as a text b and its summary b and feature vector b are stored in a preset database. The multiple texts include text 1, text 2, and text 3. After text clustering, category x includes text 1, and category y includes text 2 and text 3. At this time, category x includes only one text, and it is necessary to find the text that is most similar to text 1 from the preset database, such as text a. At this time, text a is used as the central text of category x, and text 1 is used as the non-central text of category x.
[0097] The central text and non-central text of category y are determined in text 2 and text 3.
[0098] When a category includes multiple texts, it is necessary to determine the central text from these texts. In addition to determining it based on the text's identification, the number of keywords, etc., it can also be determined based on the text's feature vector.
[0099] S36: In the texts under each category, determine the central text and the non-central text.
[0100] Specifically, the above step S36 may include:
[0101] Step B1: Calculate the feature vector of the text under each category.
[0102] For each text in each category, a feature vector is calculated once. The number of feature vectors calculated is the same as the number of texts to be summarized. The specific calculation method of the text feature vector can be found in the relevant description in the above embodiment, which will not be repeated here.
[0103] Step B2: Based on the feature vectors of the texts in each category, calculate the average vector corresponding to each category.
[0104] Under a category, there are multiple texts. Each text has a pre-calculated feature vector. The average of these multiple feature vectors is obtained to obtain the average vector of the corresponding category text. The specific calculation method of the average vector is the same as the calculation method of the average value of the conventional vector, which will not be repeated here.
[0105] Step B3: In each category, the text corresponding to the feature vector with the smallest difference from the average vector is determined as the central text, and the text other than the central text is determined as the non-central text, so as to obtain the central text and non-central text under each category.
[0106] For a category, each of the multiple texts corresponds to a feature vector. The category also corresponds to an average vector. Calculate the difference between each feature vector and the average vector. The text corresponding to the feature vector corresponding to the minimum difference is the text with the most central content among all the texts in the category. The difference in content between this text and other texts in the category is relatively average and not too large. Using this text as the central text and then as the basis for generating summaries of other texts in the category can reduce the probability of inaccurate summary generation due to excessive differences between the two texts, and improve the accuracy of summaries generated for non-central texts.
[0107] Of course, in addition to selecting the text corresponding to the feature vector with the smallest difference from the average vector as the central text, the text corresponding to the smallest or largest feature vector can also be selected as the central text. The specific method of selecting the central text based on the feature vector can be selected according to actual needs and is not limited.
[0108] In some cases, there are multiple texts with the same feature vector in a certain category, and the difference between the feature vectors of these texts and the average vector is the same. In this case, you can arbitrarily select a text as the central text in this category, or you can select a text as the central text in this category according to the amount of data.
[0109] Specifically, the above step B3 may include:
[0110] Step B31: When there are multiple feature vectors with the smallest difference from the average vector, multiple candidate texts corresponding to the multiple feature vectors with the smallest difference are determined.
[0111] Step B32: Calculate the data volume of each text to be selected.
[0112] The data volume here can refer to the size of the text or the number of characters contained in the text.
[0113] Step B33: Determine the candidate text with the smallest data volume as the central text.
[0114] For example, suppose that the texts corresponding to the feature vectors with the smallest difference from the average vector in category a are text 1, text 2, and text 3, and the data volume of text 1 is 1M, the data volume of text 2 is 2M, and the data volume of text 3 is 0.5M. At this time, text 3 is selected as the central text of category a, and text 1 and text 2 are non-central texts.
[0115] S37: Determine each category and its corresponding central text and non-central text as clustering results.
[0116] In the case of introducing text from a preset database, the clustering result includes the central text introduced from the preset database under the category and its summary and feature vector, as well as a non-central text originally after clustering.
[0117] In the case where texts are not introduced from the preset database, the clustering result includes the central text and non-central texts among the multiple texts originally clustered under the category.
[0118] S38: Use a large model to generate a summary of the central text in each category.
[0119] That is, the core text of each category is input into the big model, and each output of the big model is the summary of the core text of each category. For the core text introduced from the preset database, there is no need to use the big model to calculate the summary, and it can be directly obtained from the preset database.
[0120] S39: Determine the feature vectors of the central text and the non-central text under each category.
[0121] In the process of determining the central text and the non-central text under each category, if the determination is based on the feature vector, the feature vector of each text in the multiple texts has been calculated before. If the feature vectors of the multiple texts calculated before have been stored, they can be directly obtained from the corresponding storage location.
[0122] The feature vector of the central text introduced from the preset database can be directly obtained from the preset database.
[0123] At this point, in each category after the multiple texts are clustered, the summary of the central text, the feature vector of the central text, and the summary of the non-central text are all prepared. Next, the text summary model can be used to generate the summary of the non-central text.
[0124] In order to improve the efficiency of the text summary model in generating non-text summaries, in addition to directly inputting the summary of the central text, the feature vector of the central text, and the feature vector of the non-central text into the model, the data that can be processed can be pre-processed outside the model, and only necessary data can be input into the model, thereby reducing the complexity of the model and improving the efficiency of the model operation, thereby achieving efficient generation of non-text summaries.
[0125] S310: Under each category, calculate the vector difference between the feature vector of the non-central text and the feature vector of the central text.
[0126] In each category, calculate the vector difference between each non-central text and the central text in the feature vector. For example: Category a includes central text 1, non-central text 2 and non-central text 3. Calculate the vector difference between the feature vector of non-central text 2 and the feature vector of central text 1. Calculate the vector difference between the feature vector of non-central text 3 and the feature vector of central text 1. The number of categories into which multiple texts are clustered requires the number of categories into which vector differences need to be calculated. The number of vector differences that need to be determined is the same as the number of non-central texts in a certain category. The specific method for calculating vector differences is the same as the method for calculating the differences between conventional vectors, and will not be repeated here.
[0127] S311: Input the summary of the central text under each category and the vector difference into the text summary model to obtain the summary of the non-central text under each category.
[0128] That is to say, first input the summary of the central text under a category and the vector difference between a non-central text under the category and the central text into the text summary model. The output of the text summary model is the summary of the non-central text under this category. Then, the vector differences of other non-central texts under the category are input into the text summary model in the above manner, and finally the summaries of all non-central texts under the category are obtained. Next, the summaries of the central texts under other categories and the vector differences between the non-central text and the central text are input into the text summary model in the above manner, and finally the summary of each non-central text under each category is obtained.
[0129] S312: Obtain summaries of multiple texts based on the summary of the central text and the summary of the non-central text in each category.
[0130] After clustering multiple texts, the summary of the central text of each category is obtained using the large model. The summary of the non-central text of each category is obtained through the text summary model. By arranging the text summaries obtained by the two models, the summary of each text in the multiple texts is obtained, thereby achieving accurate and efficient generation of multiple text summaries.
[0131] Figure 4This is a schematic diagram of the text summary model architecture and the non-text summary generation process in the embodiment of this application, see Figure 4 As shown in the figure, the architecture of the text summary model can mainly include word embedding layer, transformer block, full connection layer and softmax layer.
[0132] In the use of the text summarization model, for a certain category, the summary of the central text is input into the model's word embedding layer as [CLS], token1, token2, ... The word embedding layer outputs word vectors wordembedding1, wordembedding2, wordembedding3, ..., wordembedding1, wordembedding2, wordembedding3, ..., and the vector difference (Δv-v) between the feature vectors of the non-central text and the central text. c ) is input into the transformer block. After multiple transformer blocks, the ID of the summary of the non-central text is output, i.e. [CLS], T1, T2, ... Then, it passes through the full connection layer and the softmax layer in turn to obtain the summary of the non-central text, i.e. [CLS], Output1, Output2, ... The Output corresponds to the summary of each non-central text. There are as many Outputs as there are non-central texts.
[0133] Finally, a specific example is used to clearly and completely illustrate the method for generating a text summary provided in the embodiment of the present application.
[0134] Suppose that you need to generate summaries for the texts 1-11 in Table 1 below. First, you need to cluster texts 1-11, with texts 1-3 belonging to category 1, …, and text 11 belonging to category 2. Then, calculate the feature vectors of texts 1-11 respectively. The feature vector of text 1 is [0.1334, 0.6434, -0.9793…], …. Next, determine the central text of each category. The central text of category 1 is text 1, ….
[0135] Table 1
[0136]
[0137]
[0138]
[0139] Next, the summary of the central text of each category is calculated through the large model. The summary of the central text 1 of category 1 is calculated using the large model. "From this afternoon (September 29) to tomorrow morning, Beijing will see significant rainfall, with moderate rain at night and strong northerly winds with gusts up to level 6 or 7. During the day tomorrow, Beijing will still see rain and strong winds, with the highest temperature only 21°C. The public needs to bring rain gear when going out, add clothes, and be careful to prevent colds." The result is "Beijing will see significant rainfall from this afternoon to tomorrow morning",...
[0140] Finally, under the same category, the text summary model is used to calculate the summary of the non-central text of each category, thereby obtaining each summary corresponding to texts 1 to 11. The results are shown in Table 2.
[0141] Table 2
[0142]
[0143]
[0144] At this point, the method for generating a text summary provided in the embodiments of the present application has been fully described.
[0145] Based on the same inventive concept, as an implementation of the above method, an embodiment of the present application also provides a device for generating a text summary.
[0146] Figure 5 The structure of the device for generating a text summary in the embodiment of the present application is shown in FIG. Figure 1 , see Figure 5 As shown, the device may include: an acquisition module 51, a first generation module 52, a determination module 53, a second generation module 54 and a third generation module 55.
[0147] The acquisition module 51 is used to acquire clustering results of the multiple texts in response to summaries of the multiple texts to be generated, where the clustering results include at least one category and central texts and non-central texts under the corresponding category.
[0148] The first generation module 52 is used to generate a summary of the core text in each category using a large model, where the large model is a general-purpose large-scale language generation model similar to ChatGPT.
[0149] The determination module 53 is used to determine the feature vectors of the central text and the non-central text in each category.
[0150] The second generation module 54 is used to generate a summary of the non-central text in each category based on the summary of the central text in each category, the feature vector of the central text and the feature vector of the non-central text, using a text summary model, wherein the text summary model is a pre-trained deep learning model for extracting text summaries.
[0151] The third generating module 55 is used to obtain summaries of multiple texts based on the summary of the central text and the summary of the non-central text in each category.
[0152] Furthermore, as a Figure 5 As a refinement and extension of the device shown, an embodiment of the present application also provides a device for generating a text summary.
[0153] Figure 6 The structure of the device for generating a text summary in the embodiment of the present application is shown in FIG. Figure 2 , see Figure 6 As shown, the device may include:
[0154] The model training module 61 includes: a model acquisition unit 611 and a model training unit 612 .
[0155] The model acquisition unit 611 is used to obtain the original text summary model. The original text summary model includes a word embedding layer, a conversion module, a fully connected layer and a normalization layer. The word embedding layer is the same as the word embedding layer in the Bert deep learning model, and the number of conversion modules is less than the number of conversion modules in the Bert deep learning model.
[0156] The model training unit 612 is used to train the original text summary model with training data to obtain a text summary model, wherein the training data includes the feature vectors corresponding to the central corpus and the non-central corpus under each category, and the original summaries corresponding to the central corpus and the non-central corpus under each category. The feature vectors corresponding to the central corpus and the non-central corpus under each category, and the original summary corresponding to the central corpus are the input of the model training, and the original summary corresponding to the non-central corpus under each category is the output of the model training, and the original summary is generated based on the large model.
[0157] The text clustering module 62 includes: a text acquisition unit 621 , a text clustering unit 622 , a judgment unit 623 , a text introduction unit 624 , a center determination unit 625 and a result determination unit 626 .
[0158] The text acquisition unit 621 is used to acquire multiple texts.
[0159] The text clustering unit 622 is used to cluster multiple texts based on themes or contents to obtain at least one category and texts under the corresponding category.
[0160] The judging unit 623 is used to judge whether each category corresponds to only one text. If so, the process proceeds to the center determining unit 625; if not, the process proceeds to the center determining unit 625.
[0161] The text introduction unit 624 is used to determine a target text whose similarity with the subject or content of a text is greater than a preset similarity from a preset database, determine the target text as the central text of a category to which the text belongs, and obtain a summary of the target text from the preset database, wherein the preset database stores various texts and their summaries generated based on a large model.
[0162] The center determination unit 625 is used to determine the center text and the non-center text in the text under each category.
[0163] The center determination unit 625 is specifically used to calculate the feature vector of the text under each category; based on the feature vector of the text under each category, the average vector corresponding to each category is calculated; in each category, the text corresponding to the feature vector with the smallest difference from the average vector is determined as the center text, and the text other than the center text is determined as the non-center text, so as to obtain the center text and non-center text under each category.
[0164] The center determination unit 625 is specifically used to determine multiple candidate texts corresponding to the multiple feature vectors with the smallest difference when there are multiple feature vectors with the smallest difference from the average vector; calculate the data volume of each candidate text; and determine the candidate text with the smallest data volume as the center text.
[0165] The result determination unit 626 is used to determine each category and its corresponding central text and non-central text as a clustering result.
[0166] The first generation module 63 is used to generate a summary of the central text in each category using a large model, where the large model is a general-purpose large-scale language generation model similar to ChatGPT.
[0167] The determination module 64 is used to determine the feature vectors of the central text and the non-central text in each category.
[0168] The second generating module 65 includes: a difference calculating unit 651 and an input unit 652 .
[0169] The difference calculation unit 651 is used to calculate the vector difference between the feature vector of the non-central text and the feature vector of the central text in each category.
[0170] The input unit 652 is used to input the summary of the central text in each category and the vector difference into the text summary model to obtain the summary of the non-central text in each category.
[0171] The third generating module 66 is used to obtain summaries of multiple texts based on the summary of the central text and the summary of the non-central text in each category.
[0172] It should be noted here that the description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0173] Based on the same inventive concept, an embodiment of the present application also provides an electronic device.
[0174] Figure 7 This is a schematic diagram of the structure of the electronic device in the embodiment of the present application, see Figure 7 As shown, the electronic device may include: a processor 71, a memory 72, and a bus 73; wherein the processor 71 and the memory 72 communicate with each other via the bus 73; the processor 71 is used to call program instructions in the memory 72 to execute the methods in one or more of the above embodiments.
[0175] It should be noted that the description of the above electronic device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the electronic device embodiment of this application, please refer to the description of the method embodiment of this application for understanding.
[0176] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium, which may include: a stored program; wherein, when the program is running, the device where the storage medium is located is controlled to execute the method in one or more of the above embodiments.
[0177] It should be noted here that the description of the above storage medium embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the storage medium embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0178] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for generating a text summary, characterized in that: The method comprises: In response to summaries of a plurality of texts to be generated, obtaining clustering results of the plurality of texts, the clustering results including at least one category and central texts and non-central texts under the corresponding category; A large model is used to generate a summary of the central text in each category, where the large model is a general-purpose large-scale language generation model similar to ChatGPT; Determine the feature vectors of the central text and the non-central text under each category; Based on the summary of the central text in each category, the feature vector of the central text and the feature vector of the non-central text, a text summary model is used to generate a summary of the non-central text in each category, wherein the text summary model is a pre-trained deep learning model for extracting text summaries; Based on the summary of the central text and the summary of the non-central text in each category, the summaries of the multiple texts are obtained.
2. The method according to claim 1, characterized in that The obtaining of clustering results of the plurality of texts comprises: Get multiple texts; Clustering the multiple texts based on themes or contents to obtain at least one category and texts under the corresponding category; Among the texts under each category, identify the central text and the non-central text; Each category and its corresponding central text and non-central text are determined as the clustering result.
3. The method according to claim 2, characterized in that In each category of text, the central text and non-central text are identified, including: Calculate the feature vector of the text under each category; According to the feature vector of the text under each category, calculate the average vector corresponding to each category; In each category, the text corresponding to the feature vector with the smallest difference from the average vector is determined as the central text, and the text other than the central text is determined as the non-central text, so as to obtain the central text and non-central text under each category.
4. The method according to claim 3, characterized in that The step of determining the text corresponding to the feature vector with the smallest difference from the average vector as the central text includes: When there are multiple feature vectors with the smallest difference from the average vector, multiple candidate texts corresponding to the multiple feature vectors with the smallest difference are determined; Calculate the data volume of each text to be selected; The candidate text with the smallest data volume is determined as the central text.
5. The method according to claim 1, characterized in that The method of using a text summary model to generate a summary of the non-central text in each category based on the summary of the central text in each category, the feature vector of the central text, and the feature vector of the non-central text includes: Under each category, the vector difference between the feature vector of the non-central text and the feature vector of the central text is calculated; The summary of the central text under each category and the vector difference are input into the text summary model to obtain the summary of the non-central text under each category.
6. The method according to claim 1, characterized in that Before obtaining the clustering results of the plurality of texts, the method further includes: Obtaining an original text summary model, wherein the original text summary model includes a word embedding layer, a conversion module, a fully connected layer, and a normalization layer, wherein the word embedding layer is the same as the word embedding layer in the Bert deep learning model, and the number of the conversion modules is less than the number of the conversion modules in the Bert deep learning model; The original text summary model is trained using training data to obtain the text summary model, wherein the training data includes feature vectors corresponding to the central corpus and non-central corpus under each category, and original summaries corresponding to the central corpus and non-central corpus under each category, the feature vectors corresponding to the central corpus and non-central corpus under each category, and the original summary corresponding to the central corpus are inputs for model training, and the original summary corresponding to the non-central corpus under each category is output from model training, and the original summary is generated based on the large model.
7. The method according to any one of claims 1 to 6, characterized in that Before obtaining the clustering results of the plurality of texts, the method further includes: Determine whether each category corresponds to only one text; If so, a target text whose similarity with the subject or content of the one text is greater than a preset similarity is determined from a preset database, and the target text is determined as the central text of the category to which the one text belongs, and a summary of the target text is obtained from the preset database, wherein the preset database stores various texts and summaries generated based on the large model; If not, the step of obtaining the clustering results of the multiple texts is performed.
8. A device for generating a text summary, characterized in that: The device comprises: An acquisition module, configured to acquire clustering results of the plurality of texts in response to summaries of the plurality of texts to be generated, wherein the clustering results include at least one category and central texts and non-central texts under the corresponding category; The first generation module is used to generate a summary of the central text in each category using a large model, where the large model is a general-purpose large-scale language generation model similar to ChatGPT; A determination module, used to determine the feature vectors of the central text and the non-central text under each category; A second generation module is used to generate a summary of the non-central text in each category using a text summary model based on the summary of the central text in each category, the feature vector of the central text, and the feature vector of the non-central text, wherein the text summary model is a pre-trained deep learning model for extracting text summaries; The third generating module is used to obtain summaries of the multiple texts based on the summary of the central text and the summary of the non-central text in each category.
9. An electronic device, characterized in that: The electronic device comprises: a processor, a memory, and a bus; wherein the processor and the memory communicate with each other via the bus; and the processor is used to call program instructions in the memory to execute the method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The storage medium comprises: a stored program; wherein, when the program is running, the device where the storage medium is located is controlled to execute the method as claimed in any one of claims 1 to 7.