Text summary generation method, device, equipment and medium based on large language model
Through the text summary generation method based on the large language model, the related text is used to generate more comprehensive news summary, which solves the one-sided problem caused by the news presentation method and achieves an accurate summary of news events.
Patent Information
- Application Number
- CN202410103103.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-24
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-01-24
AI Technical Summary
Due to the fragmentation of the way news presentation, there are differences in reports of the same news. A single news summary cannot fully display the main content of the news incident, and there is one-sidedness and inaccuracy.
Using a text summary generation method based on a large language model, by obtaining the target text, determining its keywords, finding associated text that is consistent with the description object but inconsistent with the text content, determining the summary generation strategy based on the number of associated texts, and generating a more comprehensive summary text.
It realizes the rapid and accurate generation of more comprehensive abstract text, avoids the one-sidedness and inaccuracy of a single news summary, and can more accurately display the main content of news events.
Smart Images

Figure CN118069830B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a method, device, equipment and medium for generating a text summary based on a large language model. Background Art
[0002] With the development of Internet technology, most news is no longer presented in paper documents, but is presented by different network platforms or online media reports. In order to improve user experience, it is necessary to determine the summary text corresponding to the news so that users can easily understand the news topic.
[0003] In the related art, the document summary is generally formed by counting the words that appear most frequently in a single piece of news, and then reintegrating these words according to their parts of speech, order of appearance, etc.
[0004] However, in the related art, due to the fragmented nature of presenting news on the Internet, each different online media has certain differences in reporting the same news. Therefore, the news summary extracted from a single online news article is one-sided and cannot fully present the main content of the news event. Summary of the invention
[0005] The present application provides a method, device, equipment and medium for generating a text summary based on a large language model, so as to solve the technical problem in the related art that, due to the fragmentation of the way of presenting news, there may be differences in reporting the same news, that is, the news summary extracted from a single news article is one-sided and cannot fully present the main content of the news event.
[0006] The first aspect of the present application provides a method for generating a text summary based on a large language model, comprising the following steps: obtaining a target text for which a summary text is to be generated; inputting the target text into a pre-trained language model to determine keywords of the target text; determining associated texts of the target text based on the keywords, wherein the associated texts are texts that are consistent with the description object of the target text but inconsistent with the text content; determining a target number of associated texts, and determining a summary generation strategy corresponding to the target text based on the target number; and generating a summary text corresponding to the target text according to the summary generation strategy.
[0007] The second aspect of the present application provides a text summary generation device based on a large language model, including: an acquisition module, used to acquire a target text to be generated as a summary text; a first determination module, used to input the target text into a pre-trained language model to determine the keywords of the target text; a second determination module, used to determine the associated text of the target text based on the keywords, wherein the associated text is a text that is consistent with the description object of the target text but inconsistent with the text content; a third determination module, used to determine a target number of the associated texts, and determine a summary generation strategy corresponding to the target text based on the target number; and a generation module, used to generate a summary text corresponding to the target text according to the summary generation strategy.
[0008] The third aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the text summary generation method based on a large language model as described in the above embodiment.
[0009] The fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program. When the program is executed by a processor, it implements the above-mentioned text summary generation method based on a large language model.
[0010] The fifth aspect of the present application provides a computer program, which, when executed, is used to implement the above-mentioned text summary generation method based on a large language model.
[0011] The embodiment of the present application can obtain the target text to be generated summary text, use the pre-trained language model, determine the keywords of the target text, determine the associated text of the target text according to the keywords, and then determine the target number of associated texts, and determine the summary generation strategy corresponding to the target text according to the target number, and generate the summary text corresponding to the target text according to the summary generation strategy. The embodiment of the present application can generate the summary text of the target text based on the language model and the associated text of the target text, and the summary text of the target text can be determined more accurately and quickly through the language model. The summary text of the target text generated by the associated text of the comprehensive target text is more accurate and comprehensive than the summary text generated for a single target text, avoiding the one-sidedness and inaccuracy of the summary text generated only for a single target text, and realizing the rapid and accurate generation of a more comprehensive summary text. Thus, the technical problem that the fragmentation of the way of presenting news in the related technology may lead to differences in reporting the same news, that is, the news summary extracted from a single news article is one-sided and cannot fully present the main content of the news event is solved.
[0012] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0014] Figure 1 A flowchart of a method for generating a text summary based on a large language model according to an embodiment of the present application;
[0015] Figure 2 A flowchart of a text summary generation strategy based on a large language model provided for a specific embodiment of the present application;
[0016] Figure 3 A flowchart of a text vector integration process to be processed provided by an embodiment of the present application;
[0017] Figure 4 A flowchart of another text summary generation strategy based on a large language model provided for a specific embodiment of the present application;
[0018] Figure 5 A schematic diagram of the structure of a text node graph of a text to be processed provided by one embodiment of the present application;
[0019] Figure 6 A block diagram of a text summary generation device based on a large language model provided according to an embodiment of the present application;
[0020] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0022] The following describes the text summary generation method, device, equipment and medium based on a large language model of the embodiment of the present application with reference to the accompanying drawings. In view of the technical problem mentioned in the above background technology that due to the fragmentation of the way of presenting news, there may be differences in reporting the same news, that is, the news summary extracted from a single news article is one-sided and cannot fully present the main content of the news event, the present application provides a text summary generation method based on a large language model. In this method, by obtaining the target text to be generated, using a pre-trained language model, the keywords of the target text can be determined, and the associated text of the target text can be determined based on the keywords, and then the target number of associated texts can be determined, and the summary generation strategy corresponding to the target text can be determined based on the target number, and the summary text corresponding to the target text can be generated according to the summary generation strategy. The embodiment of the present application can generate a summary text of the target text based on the language model and the associated text of the target text, and the summary text of the target text can be determined more accurately and quickly through the language model. The summary text of the target text generated by integrating the associated text of the target text is more accurate and comprehensive than the summary text generated for a single target text, avoiding the one-sidedness and inaccuracy of the summary text generated only for a single target text, and achieving the rapid and accurate generation of a more comprehensive summary text. Thus, the technical problem in the related art that due to the fragmentation of the way of presenting news, there may be differences in reporting the same news, that is, the news summary extracted from a single news article is one-sided and cannot fully present the main content of the news event is solved.
[0023] Specifically, Figure 1 A flowchart of a method for generating a text summary based on a large language model provided according to an embodiment of the present application.
[0024] like Figure 1 As shown, the text summary generation method based on the large language model includes the following steps:
[0025] In step S101, a target text for generating a summary text is obtained.
[0026] It is understood that the summary text may be, but is not limited to, a text that includes a summary of the main points of the target text description, wherein the main points of the target text description may be, but are not limited to, the objects, methods, conclusions, etc. described in the target text, and this application does not make specific restrictions. In addition, the embodiments of the present application may summarize the main points of the target text description through brief text content.
[0027] Furthermore, the target text of the embodiment of the present application may be, but is not limited to, the text for which a summary is to be generated, and may be in the form of a news text or any paragraph text, and the present application does not impose any specific limitation thereto.
[0028] As a possible implementation method, the embodiment of the present application can obtain the target text from a preset website, or use OCR (Optical Character Recognition) technology to scan a paper version of the text (for example, a newspaper or a journal, etc.) to obtain the scanned electronic text, and determine the electronic text as the target text. The target text can also be obtained from a preset database, where the database can be used to store multiple texts to be summarised, and the present application does not make specific restrictions. The specific method of obtaining the target text can be set by a person skilled in the art according to the actual situation, and the present application does not make specific restrictions.
[0029] In step S102, the target text is input into a pre-trained language model to determine the keywords of the target text.
[0030] It can be understood that the language model can be, but is not limited to, a pre-trained language model for processing the target text, such as a ChatGPT (Chat Generative Pre-trained Transformer) model. In an embodiment of the present application, the language model can generate keywords for the target text, can also generate a summary text for the target text, and can also generate both keywords for the target text and a summary text for the target text. This application does not impose any specific limitations.
[0031] In addition, in the embodiments of the present application, keywords can be words used to represent the main content of the target text, or words that appear multiple times in the target text, or words with specific entity meanings, such as time entities, place entities, relationship entities, etc., and the present application does not impose specific restrictions.
[0032] Specifically, in some embodiments, a language model may be used to generate keywords for a target text. In this case, the embodiments of the present application may input the target text into the language model to obtain the keywords for the target text output by the language model.
[0033] In other embodiments, the language model can be used to generate both keywords and summary text of the target text. Then, the input of the language model can be the target text, so that the language model can generate and output keywords or summary text corresponding to the target text based on the target text.
[0034] Optionally, in one embodiment of the present application, a target text is input into a pre-trained language model to determine keywords of the target text, including: generating a first prompt text according to the target text and a preset first prompt template, wherein the first prompt text is used to prompt the generation of an initial summary text corresponding to the target text; inputting the first prompt text into the language model to obtain the initial summary text output by the language model; obtaining a preset sample text and sample keywords corresponding to the sample text; generating a second prompt text according to the sample text, the sample keywords, the initial summary text and a preset second prompt template, wherein the second prompt text is used to prompt the sample keywords generated with reference to the sample text and the initial keywords corresponding to the generation of the initial summary text; inputting the second prompt text into the language model to obtain the initial keywords of the initial summary text output by the language model, and determining the initial keywords as keywords of the target text.
[0035] As a possible implementation method, the embodiment of the present application can generate a first prompt text for prompting the generation of keywords of the target text based on the target text and the preset first prompt template, and then input the first prompt text into the language model, and then use the language model to output the initial summary text and obtain the keywords of the target text. Further, in the embodiment of the present application, in order to more accurately determine the keywords of the target text, the language model can be used to first generate the initial summary text corresponding to the target text, and the initial keywords can be further extracted from the initial summary text, and the initial keywords are determined as the keywords of the target text.
[0036] Specifically, the embodiment of the present application can first generate a first prompt text based on the target text and a preset first prompt template, wherein, in the embodiment of the present application, the first prompt text can be used to prompt the generation of an initial summary text of the target text, then, the first prompt text is input into the language model, and the initial summary text is output using the language model, then, a preset sample text and sample keywords corresponding to the sample text are obtained, and a second prompt text is generated based on the sample text, the sample keywords, the above-mentioned initial summary text, and a preset second prompt template, wherein the second prompt text can be used to prompt the sample keywords generated with reference to the sample text and the initial keywords corresponding to the generation of the initial summary text, finally, the second prompt text is input into the language model, the language model is used to output the initial keywords of the initial summary text, and the initial keywords are determined as the keywords of the target text.
[0037] In addition, the preset first prompt template, the preset second prompt template, the sample text, and the sample keywords can be set by technicians in this field according to actual conditions, and this application does not impose any specific restrictions.
[0038] For example, in general, the target text in the embodiments of the present application is a news text and is relatively long, containing a large number of words. After generating a summary text of the target text through a language model, the number of words can be reduced and the keywords corresponding to the target text can be extracted more quickly.
[0039] In an embodiment of the present application, it can be assumed that the first prompt template is "Please generate a summary text within xxx words for xxx", and it can be assumed that the target text is a news text, and the number of words in the summary text generated by the news text is 300 words; in this way, the text content of the news text and the required number of words can be filled into the first prompt template, and the first prompt text can be obtained as "Please generate a summary text within 300 words for the following news text (the text content of the news text can be inserted here)".
[0040] Furthermore, in an embodiment of the present application, the first prompt text may be input into a language model to obtain an initial summary text output by the language model. Then, a preset sample text and sample keywords corresponding to the sample text are obtained, and a second prompt text is generated based on the sample text, the sample keywords, the initial summary text, and a preset second prompt template, such as "Please refer to the sample keyword xxx of the sample text xxx to generate keywords for the target text." Finally, in an embodiment of the present application, the second prompt text may be input into a language model to obtain the initial keywords of the initial summary text output by the language model, and the initial keywords are determined as keywords for the target text.
[0041] In step S103, the associated text of the target text is determined according to the keyword, wherein the associated text is a text that has the same description object as the target text but different text content.
[0042] It is understandable that the associated text may be, but is not limited to, a text that describes the same object as the target text but has inconsistent text content. For example, if the target text is a news text, the associated text of the target text may be another news text that describes the same news event as the news text but has different text content. The restriction that the text content of the associated text and the target text is inconsistent is used to eliminate redundant text, because the final summary text obtained between two texts with completely or substantially completely identical text content is the same and does not have general applicability.
[0043] As a possible implementation method, after determining the keywords of the target text, the embodiment of the present application can determine the associated text of the target text according to the keywords.
[0044] Specifically, the embodiment of the present application can input keywords into a preset search model to obtain multiple query texts output by the search model, wherein the query text is consistent with the target text description object, but the query text can be a text consistent with the text content of the target text, or it can be a text inconsistent with the text content of the target text. Therefore, in order to reduce the cost of repeated calculations, the query text of the same content has no positive impact on the generation of subsequent summary texts, so that after the search model queries multiple query texts, the text similarity between each associated text and the target text can be determined, and the associated text with a text similarity less than a preset similarity threshold is determined as the associated text of the target text. Wherein, the preset similarity threshold can be set by a person skilled in the art according to actual conditions, and this application is not specifically limited. Wherein, the search model can obtain the associated text of the target text from a database or a web page through a preset interface, or it can obtain the associated text in other ways, and this application is not specifically limited.
[0045] In step S104, a target number of associated texts is determined, and a summary generation strategy corresponding to the target text is determined according to the target number.
[0046] In step S105, a summary text corresponding to the target text is generated according to the summary generation strategy.
[0047] Step S104 and step S105 are described in detail below. The specific contents are as follows.
[0048] It can be understood that the summary generation strategy may be, but is not limited to, a strategy of performing text processing on the target text, or the target text and the associated text, to generate a summary text of the target text.
[0049] During the actual execution process, in order to more accurately determine the summary text of the target text by referring to the associated text, the embodiment of the present application can determine different summary generation strategies according to the target number of associated texts. That is to say, the embodiment of the present application can adopt different summary generation strategies according to the target number of associated texts of different numbers, and then generate summary text corresponding to the target text according to different summary generation strategies.
[0050] Furthermore, in the embodiment of the present application, after determining the associated texts of the target text, the target number of associated texts may be determined first, and a summary generation strategy corresponding to the target text may be determined according to the target number, so as to generate summary texts corresponding to the target text according to different summary generation strategies.
[0051] Optionally, in one embodiment of the present application, a summary generation strategy corresponding to the target text is determined based on the target quantity, including: determining whether the target quantity is zero; if the target quantity is zero, determining that the summary generation strategy is to generate summary text through a language model; if the target quantity is not zero, comparing the target quantity with a preset quantity threshold to obtain a comparison result, and determining the summary generation strategy based on the comparison result.
[0052] In some embodiments, it can be determined whether the target number of associated texts is zero. When the target number is zero, it can be explained that there is no associated text for the target text. At this time, the embodiment of the present application can directly determine that the summary generation strategy corresponding to the target text is a strategy for generating summary text through a language model. The language model can be the language model mentioned in step S102, or it can be a model obtained by pre-training for generating summary text of the target text, which is not limited by the present application.
[0053] For example, the embodiment of the present application can generate a first prompt text of the target according to the target text and the preset first prompt template, wherein the present application can assume that the first prompt template is "please generate a summary text within xxx words for xxx", and assume that the target text is a news text, and the number of words of the summary text generated by the news text is 300 words, and then fill the text content of the news text and the required number of words into the first prompt template, and then obtain the first prompt text as "please generate a summary text within 300 words for the following news text (the text content of the news text can be inserted here)". After that, the first prompt text is input into the language model to obtain the summary text corresponding to the target text output by the language model.
[0054] In other embodiments, if the target number of associated texts is not zero, it may indicate that the target text includes one or more associated texts. In this case, the embodiment of the present application may further compare the target number of associated texts with a preset number threshold, and determine the corresponding summary generation strategy based on the calculation result. The specific process of generating the summary generation strategy is as follows.
[0055] Optionally, in one embodiment of the present application, a summary generation strategy is determined based on the comparison result, including: when the comparison result represents that the target quantity is less than or equal to a preset quantity threshold, determining the target text and the associated text as the text to be processed; determining the vector coding sequence corresponding to each text to be processed, and determining the text topic vector corresponding to the vector coding sequence; determining the central topic vector based on the text topic vector corresponding to each text to be processed; adjusting the vector coding sequence of each text to be processed based on the central topic vector to obtain the text vector to be processed; integrating all the text vectors to be processed to determine the summary text corresponding to the target text.
[0056] Among them, according to the text topic vector corresponding to each text to be processed, the central topic vector is determined, including: summing up all text topic vectors to determine the total text topic vector; splicing each text topic vector with the total text topic vector to determine the splicing vector corresponding to each text topic vector; summing up the splicing vectors corresponding to all text topic vectors to determine the total splicing vector; for each text topic vector, according to the splicing vector corresponding to the text topic vector and the total splicing vector, determining the weight value corresponding to the text topic vector; according to the weight value corresponding to each text topic vector, weighted summing up the text topic vectors to obtain the central topic vector.
[0057] All the text vectors to be processed are integrated and processed to determine the summary text corresponding to the target text, including: for each text vector to be processed, the text vector to be processed is screened according to the text theme vector corresponding to the text vector to be processed to obtain a first vector coding sequence; the correlation between the text vector to be processed and each other text vector to be processed is determined; according to the correlation corresponding to each other text vector to be processed, the other texts to be processed are weighted summed to obtain a second vector coding sequence corresponding to the text vector to be processed; according to the first vector coding sequence and the second vector coding sequence corresponding to each text vector to be processed, the text vectors to be processed are integrated and processed to obtain the summary text corresponding to the target text.
[0058] It can be understood that, in the embodiment of the present application, if the target quantity is less than or equal to the preset quantity threshold, the target text and the associated text can be determined as the text to be processed, and then the summary generation strategy corresponding to the target text is determined, specifically, Figure 2 As shown, Figure 2 The process shown is in Figure 1 Based on the process shown, it is specifically described how to generate a summary text of the target text from the text to be processed. The process includes the following steps:
[0059] Step S201: when the comparison result indicates that the target quantity is less than or equal to a preset quantity threshold, the target text and the associated text are determined as texts to be processed.
[0060] Step S202: Determine the vector encoding sequence corresponding to each text to be processed.
[0061] The following is a detailed description of step S201 and step S202, the specific contents are as follows.
[0062] It can be understood that the vector code sequence can be, but is not limited to, a sequence consisting of vector codes of each word included in the text to be processed.
[0063] In an embodiment of the present application, in order to facilitate the processing of the target text and the associated text, the target text and the associated text can be first determined as the text to be processed, and then for each word included in the text to be processed, the vector encoding of the word and the position information of the word in the text to be processed can be determined. Finally, the embodiment of the present application can generate a vector encoding sequence of the text to be processed based on the vector encoding and position information of each word.
[0064] For example, assuming that the target text is a news text, and the news text includes 20 words. In the embodiment of the present application, the vector code of each word and the position information of the word in the news text can be determined, and the 20 words can be sorted in sequence according to the position information, and then the vector code of each word can be sequenced according to the word order to obtain a vector code sequence.
[0065] Step S203: Determine the text topic vector corresponding to the vector encoding sequence.
[0066] Step S204: Determine a central topic vector according to the text topic vector corresponding to each text to be processed.
[0067] Step S203 and step S204 are described in detail below. The specific contents are as follows.
[0068] It is understandable that the text topic vector may be, but is not limited to, the vector corresponding to the text topic of the text to be processed, wherein the text topic may cover the main information of the text to be processed, and this application does not make specific restrictions. In addition, the central topic vector may be, but is not limited to, the vector corresponding to the central topic expressed by all the texts to be processed, wherein the central topic may cover the common main information of all the texts to be processed.
[0069] In some embodiments, in order to determine the central theme to be expressed by all the texts to be processed, the present application may process the vector coding sequence of each text to be processed to obtain the text theme vector of each text to be processed, and determine the central theme vector of all the texts to be processed based on the text theme vector of each text to be processed, thereby determining the central theme to be expressed by all the texts to be processed based on the central theme vector.
[0070] Specifically, when determining the central theme vector based on the text theme vector corresponding to each text to be processed, the embodiment of the present application can first determine the contribution of the text theme of each text to be processed to the central theme, that is, determine the weight value of each text theme, and then perform weighted summation on all text themes to obtain the central theme vector corresponding to all texts to be processed.
[0071] Furthermore, in an embodiment of the present application, when determining the weight value corresponding to each text topic vector, all text topic vectors can be summed up first to determine the total text topic vector, and then each text topic vector can be spliced with the total text topic vector to determine the splicing vector corresponding to each text topic vector, and then, the splicing vectors corresponding to all text topic vectors are summed up to determine the total splicing vector, and finally, for each text topic vector, the splicing vector corresponding to the text topic vector is divided by the total splicing vector to obtain the weight value corresponding to the text topic vector.
[0072] In addition, in the embodiment of the present application, for ease of understanding, each text topic vector can be calculated using a first preset formula to obtain a weight value of each text topic vector, wherein the expression of the first preset formula can be:
[0073]
[0074] Among them, w i is the weight value corresponding to the i-th text topic vector, S i is the i-th text topic vector, S 1~N is the sum of all text topic vectors, S i ,S 1~N is the concatenation vector of the i-th text topic vector and the sum of all text topic vectors, S 1~N is the sum of the concatenated vectors.
[0075] Furthermore, the embodiment of the present application can perform weighted summation of the text topic vectors according to the weight value corresponding to each text topic vector to obtain the central topic vector. Specifically, the embodiment of the present application can calculate each text topic vector and the weight value through the second preset formula to obtain the central topic vector, wherein the expression of the second preset formula can be:
[0076]
[0077] Among them, T is the central topic vector.
[0078] In other embodiments, the present application can determine the same vector of all text topic vectors, and for each text topic vector, divide the same vector by the text topic vector to obtain a weight value corresponding to the text topic vector, and then, based on the weight value corresponding to each text topic vector, perform weighted summation on all text topic vectors to obtain a central topic vector.
[0079] Step S205: According to the central theme vector, the vector coding sequence of each text to be processed is adjusted to obtain the vector of the text to be processed.
[0080] It can be understood that in the embodiment of the present application, since the central theme covers the most central idea of all the texts to be processed, some words related to the central idea can be determined through the central theme, so that the final generated text vector to be processed is more topic-relevant and comprehensive. Therefore, after determining the central theme, the embodiment of the present application can adjust the vector encoding sequence corresponding to each text to be processed through the central theme vector, and then generate a text vector to be processed corresponding to each text to be processed.
[0081] Specifically, the embodiment of the present application can perform pooling processing on the vector coding sequence of each text to be processed according to the central theme vector to obtain the processing result corresponding to each text to be processed, and then for each text to be processed, according to the processing result of the text to be processed, perform weighted processing on the non-redundant information in the vector coding sequence to obtain the text vector to be processed. It should be noted that the embodiment of the present application refers to performing attention weighting on the vector coding corresponding to each word in the corresponding vector coding sequence based on the result after pooling processing to obtain the text vector to be processed, wherein the attention weighting is to capture the word information related to the central theme, that is, to strengthen the related words and reduce the irrelevant words, so that the text vector to be processed of each text to be processed can be more in line with the content covered by the central theme. Other weighting methods can also be used, and this application does not make specific restrictions.
[0082] In addition, the embodiments of the present application can also reduce the redundant information in the vector encoding sequence of each text to be processed through pooling processing, and can also reduce the redundant information in the vector encoding sequence of the text to be processed through other processing methods, and the present application does not make specific limitations.
[0083] Step S206: Integrate all the text vectors to be processed to determine the summary text corresponding to the target text.
[0084] It can be understood that, in the embodiment of the present application, after determining the to-be-processed text vector corresponding to each to-be-processed text, all to-be-processed text vectors can be integrated to obtain a summary text corresponding to the target text, wherein the summary text can be, but is not limited to, a fusion of word information in the target text and the associated text of the target text, and the present application does not make specific restrictions. In other words, the embodiment of the present application can make the obtained summary text more comprehensive through integration processing.
[0085] As a possible implementation method, the embodiment of the present application integrates all the text vectors to be processed to obtain a summary text of the target text. The specific implementation method can be as follows: Figure 3 As shown, the process may include the following steps:
[0086] Step S301: for each text vector to be processed, the text vector to be processed is screened according to the text topic vector corresponding to the text vector to obtain a first vector encoding sequence.
[0087] It can be understood that the text topic vector can be understood as the text topic vector corresponding to each to-be-processed text determined in step S203.
[0088] That is to say, in the embodiment of the present application, since the obtained text vector to be processed is determined based on the central theme through pooled attention, etc., the text vector to be processed conforms to the representation of the central theme, but cannot deviate too much from the meaning covered by the original text to be processed, so that it still has a certain degree of personalization. Therefore, the embodiment of the present application can screen the text vector to be processed according to the text theme vector corresponding to the text vector to be processed for each text vector to be processed, and then obtain the first vector encoding sequence corresponding to the text to be processed.
[0089] Specifically, the embodiment of the present application can first determine the similarity value between the text topic vector and the word vector corresponding to each word in the text vector to be processed, and judge the relationship between each similarity value and the preset similarity threshold. If the similarity value is less than the preset similarity threshold, the word vector corresponding to the similarity value can be deleted; if the similarity value is greater than or equal to the preset similarity threshold, the word vector corresponding to the similarity value can be retained. The relationship between the similarity value corresponding to each word vector in the text vector to be processed and the preset similarity threshold is judged in turn, and corresponding operations are performed according to the judgment results to obtain the first vector encoding sequence. Among them, the preset similarity threshold can be set by a technician in this field according to actual conditions, and this application does not make specific restrictions.
[0090] For example, in the embodiment of the present application, assuming that the preset similarity threshold is 0.5, if the similarity value is greater than or equal to the similarity threshold 0.5, the corresponding word vector is output as 1; if the similarity value is less than the similarity threshold 0.5, the corresponding word vector is output as 0. Among them, 1 indicates that the word vector is related to the text topic vector, and 0 indicates that the word vector is not related to the text topic vector.
[0091] Based on this, the embodiment of the present application can filter the words in the text according to the similarity value comparison results, that is, eliminate the words with a comparison result of 0 and retain the words with a comparison result of 1, and then filter out the words related to the text theme of the text to be processed from the vocabulary of the text to be processed, and output a new vector coding sequence, namely the first vector coding sequence.
[0092] Step S302: Determine the correlation between the text vector to be processed and each other text vector to be processed.
[0093] Step S303: performing weighted summation on other texts to be processed according to the relevance corresponding to each other text vector to be processed, and obtaining a second vector encoding sequence corresponding to the text vector to be processed.
[0094] Step S302 and step S303 are described in detail below. The specific contents are as follows.
[0095] It is understandable that the correlation degree may be but is not limited to the correlation degree between the texts to be processed, which may characterize the correlation relationship between the texts to be processed, and the present application does not impose any specific limitation thereto.
[0096] That is to say, in an embodiment of the present application, in order to obtain the correlation between the summary texts of the texts to be processed, the embodiment of the present application can first determine the correlation between each text to be processed and other texts to be processed, and process the corresponding texts to be processed according to the correlation, and then obtain the correlation between the texts to be processed, so that the generated summary text is more accurate and comprehensive.
[0097] Specifically, the embodiment of the present application can determine the keywords of each text to be processed, calculate the similarity values between the keywords of the text to be processed and the keywords of other texts to be processed, and use each keyword similarity value as the correlation between the text to be processed and each other text to be processed.
[0098] Furthermore, when adjusting the corresponding text to be processed by the correlation degree, the embodiment of the present application can perform weighted summation on other texts to be processed according to the correlation degree corresponding to each other text vector to be processed, thereby obtaining a second vector encoding sequence corresponding to the text vector to be processed.
[0099] Step S304: integrating the text vectors to be processed according to the first vector coding sequence and the second vector coding sequence corresponding to each text vector to be processed, to obtain a summary text corresponding to the target text.
[0100] From the above, it can be seen that in the embodiment of the present application, the first vector coding sequence can ensure that the individual content in each text to be processed is applied, and the second vector coding sequence can obtain the correlation between the summary texts of the texts to be processed. That is to say, the embodiment of the present application can integrate all the text vectors to be processed according to the first vector coding sequence and the second vector coding sequence of each text to be processed, so as to obtain the summary text corresponding to the target text. The summary text generated in this way can preserve the individual content of each text to be processed, and retain the correlation between the texts to be processed, which is more comprehensive.
[0101] For example, the embodiment of the present application integrates all the text vectors to be processed to obtain a summary text corresponding to the target text, and the process may be:
[0102] First, decode each text vector to be processed to obtain a decoded vector corresponding to each text vector to be processed, and determine a weight value corresponding to each decoded vector. In the embodiment of the present application, each decoded vector can be calculated according to a third preset formula to obtain a weight value of each decoded vector, wherein the expression of the third preset formula can be:
[0103]
[0104] Among them, a i is the weight value corresponding to the i-th decoding vector, b 1~N is the sum of all decoded vectors, b i ,b 1~N is the concatenation vector of the i-th decoded vector and the sum of all decoded vectors, b 1~N is the sum of all concatenated vectors.
[0105] Then, a weighted sum is performed on the first vector encoding sequence and the weight value corresponding to each text vector to be processed, thereby obtaining a first decoding vector. In the embodiment of the present application, a weighted sum is performed on the first vector encoding sequence and the weight value according to a fourth preset formula, thereby obtaining a first decoding vector, wherein the expression of the fourth preset formula can be:
[0106]
[0107] Among them, A is the first decoding vector, a i is the weight value corresponding to the i-th decoding vector, t i is the first vector encoding sequence corresponding to the i-th text vector to be processed.
[0108] Next, a weighted sum is performed on the second vector encoding sequence and the weight value corresponding to each text vector to be processed to obtain a second decoding vector. In the embodiment of the present application, a weighted sum is performed on the second vector encoding sequence and the weight value according to the fifth preset formula to obtain a second decoding vector, wherein the expression of the fifth preset formula can be:
[0109]
[0110] Among them, B is the second decoding vector, a i is the weight value corresponding to the i-th decoding vector, c i is the second vector encoding sequence corresponding to the i-th text vector to be processed.
[0111] Finally, the first decoding vector and the second decoding vector are concatenated and linearly mapped to obtain the target decoding vector, and the target decoding vector is normalized and fully connected layer processed to obtain the summary text corresponding to the target text.
[0112] The embodiment of the present application can determine the target text and the associated text as the text to be processed, determine the vector coding sequence corresponding to each text to be processed, and determine the text theme vector corresponding to the vector coding sequence, determine the central theme vector according to the text theme vector corresponding to each text to be processed, and adjust the vector coding sequence of each text to be processed according to the central theme vector to obtain the text vector to be processed, and then integrate all the text vectors to be processed to obtain the summary text corresponding to the target text. Since the central theme of all target texts and associated texts can be determined by the text theme of the associated text and the target text, and the summary text of the target text is generated by integrating all the associated texts and the target text on the basis of the central theme, the generated summary text integrates the text theme of the target text and the text theme of all associated texts, and is more accurate and comprehensive than the summary text generated for a single target text, and achieves a more comprehensive and accurate generation of the summary text of the target text.
[0113] Optionally, in one embodiment of the present application, a summary text corresponding to the target text is generated according to a summary generation strategy, including: when the comparison result indicates that the target quantity is greater than a preset quantity threshold, the target text and the associated text are determined as texts to be processed; using a preset topic feature encoder and a key feature encoder, the topic vector and the paragraph vector corresponding to each text to be processed are determined; according to the topic vector and the paragraph vector, the target similarity between each two texts to be processed is determined; one text to be processed is taken as a text node, and a text node graph is constructed according to the target similarity and all text nodes, wherein the text node graph includes at least one connecting edge connecting two text nodes; the connectivity of each connecting edge is detected, and the text node graph is decomposed according to the connectivity to obtain at least one text node subgraph; according to the text to be processed corresponding to all text nodes in each text node subgraph, a summary vector is determined, wherein one text node subgraph corresponds to one summary vector; and summary text is generated according to all summary vectors.
[0114] It can be understood that, in the embodiment of the present application, if the target quantity is greater than the preset quantity threshold, the target text and the associated text can be determined as the text to be processed, and then the summary generation strategy corresponding to the target text is determined. Specifically, Figure 4 As shown, Figure 4 The process shown is in Figure 1 Based on the process shown, it is specifically described how to generate a summary text of the target text from the text to be processed. The process may include the following steps:
[0115] Step S401: when the comparison result indicates that the target quantity is greater than a preset quantity threshold, the target text and the associated text are determined as texts to be processed.
[0116] Step S402: using a preset topic feature encoder and a key feature encoder, determine a topic vector and a paragraph vector corresponding to each text to be processed.
[0117] Step S401 and step S402 are described in detail below. The specific contents are as follows.
[0118] It is understandable that the topic vector may be, but is not limited to, a vector corresponding to the topic to be expressed by the text to be processed. The paragraph vector may be, but is not limited to, a vector corresponding to a sentence or paragraph included in the text to be processed. Further, in an embodiment of the present application, the paragraph vector may be expressed as a vector corresponding to a sentence of the topic of the text to be processed.
[0119] In addition, in an embodiment of the present application, a topic feature encoder can be used to determine the topic distribution of the text to be processed and obtain a topic vector. Among them, the topic feature encoder can adopt an LDA (local-density approximation) model, or other models, which are not specifically limited in this application. The key feature encoder can be used to convert sentence paragraphs in the text to be processed into paragraph vectors, which are not specifically limited in this application.
[0120] That is to say, in order to facilitate the processing of the target text and related text, the embodiment of the present application can determine the target text and related text as the text to be processed, and use the preset topic feature encoder and key feature encoder to determine the topic vector and paragraph vector corresponding to each text to be processed.
[0121] Specifically, in the embodiment of the present application, for each text to be processed, the text to be processed can be input into a preset topic feature encoder to obtain a topic vector corresponding to the text to be processed output by the topic feature encoder.
[0122] In addition, since the target text may contain too many sentences, some sentences contain redundant information, that is, information that is not helpful for generating summary text. Therefore, the embodiment of the present application can filter the target text according to the determined text theme, and then filter out the sentences that meet the meaning of the text theme, and eliminate the sentences that do not meet the meaning of the text theme.
[0123] That is, the embodiment of the present application can determine the text theme corresponding to the text to be processed based on the theme vector, and determine multiple first target paragraph texts that meet the text theme from the text to be processed based on the text theme.
[0124] In some embodiments, the present application can compare the keywords of each paragraph sentence in the text to be processed with the text theme. If the keywords are found to have the same meaning as the text theme, the corresponding paragraph sentence is determined as the first target paragraph text.
[0125] In other embodiments, the present application can input the text to be processed and the text theme into a pre-trained screening model to obtain the first target paragraph text output by the screening model. Among them, the screening model can be set by those skilled in the art according to the actual situation, and the present application does not make specific limitations.
[0126] Further, the embodiments of the present application can eliminate the pronouns in the obtained first target paragraph text to obtain the second target paragraph text with accurate expression. Among them, the second target paragraph text can be one or multiple, and the present application does not make limitations in this regard. For example, eliminate some words without actual meaning, such as "de", "di", "a", etc., and eliminate the ambiguity of some demonstrative pronouns, such as "he", "she", "it", etc. In addition, the embodiments of the present application can determine the specific meaning according to the context information and restore the specific content of the reference. For example, if "it" refers to xxx enterprise, the embodiments of the present application can replace "it" in the text with xxx enterprise to obtain the second target paragraph text.
[0127] Further, in the embodiments of the present application, the second target paragraph text can also be judged. If the second target paragraph text is one, it is directly input into the key feature encoder to obtain the initial paragraph vector corresponding to the second target paragraph text, and the initial paragraph vector is determined as the paragraph vector corresponding to the text to be processed. If the second target paragraph text is multiple, each second target paragraph text is respectively input into the key feature encoder to obtain the initial paragraph vector corresponding to each second target paragraph text, and then the multiple initial paragraph vectors are weighted and summed and averaged to finally obtain the paragraph vector corresponding to the text to be processed.
[0128] Step S403: Determine the target similarity between every two texts to be processed according to the theme vector and the paragraph vector.
[0129] That is to say, in order to more comprehensively and comprehensively consider the target text and its associated text and determine the summary text of the target text, the embodiments of the present application can first determine the target similarity between every two texts to be processed, and based on the target similarity of every two texts to be processed, determine the summary text of the target text.
[0130] Specifically, the embodiment of the present application can determine the topic similarity between each two to-be-processed texts according to the topic vector, determine the paragraph similarity between each two to-be-processed texts according to the paragraph vector, and then determine the target similarity between each two to-be-processed texts according to the sum of the topic similarity and the paragraph similarity.
[0131] Step S404: taking a text to be processed as a text node, and constructing a text node graph according to the target similarity and all text nodes, wherein the text node graph includes at least one connection edge connecting two text nodes.
[0132] Step S405: Detect the connectivity of each connecting edge, and decompose the text node graph according to the connectivity to obtain at least one text node subgraph.
[0133] Step S404 and step S405 are described in detail below. The specific contents are as follows.
[0134] It is understandable that the node graph of the text to be processed may be, but is not limited to, a node graph with the text to be processed as nodes, wherein there may or may not be a connecting edge between any two nodes in the node graph, and this application does not impose any specific restrictions. Further, in an embodiment of this application, connectivity may be, but is not limited to, the frequency with which each connecting edge is used, the number of times the connecting edge appears in different paths in the path connecting each two text nodes, which may be the number of times used, or the percentage of each connecting edge to all connecting edges, and this application does not impose any specific restrictions.
[0135] That is to say, the embodiment of the present application can construct the connecting line between two to-be-processed texts according to the target similarity between every two to-be-processed texts. Wherein, the associated text may exceed the preset threshold value, that is, there are many associated texts, if the connecting edge is constructed between the nodes corresponding to each associated text, it may cause the to-be-processed text node graph to be too complicated. Therefore, the embodiment of the present application can set a preset similarity threshold value, that is, when the similarity between two to-be-processed texts is greater than the preset similarity threshold value, the connecting edge can be constructed between two nodes, thereby obtaining the text node graph of the to-be-processed text. In addition, the preset threshold value and the preset similarity threshold value can be set by those skilled in the art according to actual conditions, and the present application is not specifically limited.
[0136] It can also be understood that in order to more accurately refer to the associated text to generate the summary text of the target text, the embodiment of the present application can determine the text to be processed that is most suitable for generating the summary text by constructing a text node graph between the texts to be processed.
[0137] For example, the embodiment of the present application assumes that there are 6 texts to be processed: text 1, text 2, text 3, text 4, text 5 and text 6, and the preset similarity threshold is 55%.
[0138] Among them: the target similarity between text 1 and text 2 is 60%, the target similarity between text 1 and text 3 is 50%, the target similarity between text 1 and text 4 is 70%, the target similarity between text 1 and text 5 is 40%, the target similarity between text 1 and text 6 is 60%, the target similarity between text 2 and text 3 is 65%, the target similarity between text 2 and text 4 is 55%, the target similarity between text 2 and text 5 is 70%, the target similarity between text 2 and text 6 is 80%, the target similarity between text 3 and text 4 is 70%, the target similarity between text 3 and text 5 is 90%, the target similarity between text 3 and text 6 is 75%, the target similarity between text 4 and text 5 is 85%, the target similarity between text 4 and text 6 is 80%, and the target similarity between text 5 and text 6 is 77%.
[0139] Then, the connecting edges constructed in the embodiments of the present application can be: text 1 and text 2, text 1 and text 4, text 1 and text 6, text 2 and text 3, text 2 and text 5, text 2 and text 6, text 3 and text 4, text 3 and text 5, text 3 and text 6, text 4 and text 5, text 4 and text 6, and text 5 and text 6.
[0140] Finally, the embodiment of the present application can construct the following Figure 5 The text node graph of the text to be processed is shown.
[0141] Furthermore, the embodiment of the present application can decompose the text node graph of the text to be processed according to the connectivity of each connecting edge from the constructed text node graph to obtain at least one most representative text node subgraph. The text node subgraph can be, but is not limited to, the minimum node graph in the text node graph of the text to be processed, and the present application does not make any specific restrictions.
[0142] Specifically, in the embodiment of the present application, the target connection method with the least number of connection edges can be determined from the text node graph of the text to be processed. For example, there are two connection methods between node A and node B, one of which requires four connection edges and the other requires only three connection edges. Then the connection between node A and node B is the connection with three connection edges. Figure 5 Taking the text node graph of the text to be processed shown as an example, the connection methods of text 1 and text 5 include: 1-4-5, 1-2-5, 1-6-5, 1-2-3-5, 1-2-6-5, 1-4-6-5, 1-2-3-6-5, and 1-2-3-4-5. According to the target connection method with the least connected edges, the target connection methods of text 1 and text 5 are: 1-4-5, 1-2-5, and 1-6-5.
[0143] Furthermore, on the basis of determining the target connection mode, if there are multiple target connection modes between two text nodes, corresponding weights are added to several target connection modes, where the weight can be understood as the target similarity between the two text nodes connected by the connection edge. For example, 1-4-5 can add the target similarity between text node 1 and text node 4 as the weight between the connection edge 1-4; then the path with the smallest sum of all weight values is determined as the target connection mode. For example, the weight of the connection mode 1-4-5 is 0.7+0.85=1.55, the weight of the connection mode 1-2-5 is 0.6+0.7=1.3, and the weight of the connection mode 1-6-5 is 0.6+0.77=1.37; finally, 1-2-5 is selected as the target connection mode from text node 1 to text node 5.
[0144] Furthermore, the embodiment of the present application can determine the connectivity of each connection edge in the text node graph, such as the number of times it is used, from all the target connection modes, and delete the connection edges whose connectivity is greater than the preset connectivity threshold, to obtain at least one text node subgraph. In addition, if the number of times the most connection edges are used is higher than the set number threshold, it means that the versatility of this edge is too high, and the result of too high versatility is that the summary text output with the text in the current text node graph has no personalized expression. For example, only a summary in the form of person + place + time can be output. Among them, the preset connectivity threshold and number threshold can be set by a technician in this field according to actual conditions, and this application does not make specific restrictions.
[0145] Step S406: Determine a summary vector according to the to-be-processed texts corresponding to all text nodes in each text node subgraph, wherein one text node subgraph corresponds to one summary vector.
[0146] Step S407: Generate summary text according to all summary vectors.
[0147] Step S406 and step S407 are described in detail below. The specific contents are as follows.
[0148] It can be understood that the summary vector may be, but is not limited to, the corresponding vector generated by each text node subgraph.
[0149] From the above, it can be seen that in an embodiment of the present application, the connectivity of all connecting edges in the text node subgraph is lower than the set connectivity threshold. At this time, the text nodes in each text node subgraph have the highest correlation, not through some specially owned text nodes (for example, two text node subgraphs can be connected through one text node), so that a summary vector can be generated according to the topic vector and paragraph vector corresponding to the text node of the text to be processed in the text node subgraph.
[0150] Furthermore, the embodiment of the present application can judge the number of text node subgraphs. If the number is one, a summary vector can be generated based on the text node subgraph including the topic vector and paragraph vector corresponding to the node. If the number is multiple, a summary vector can be generated based on each text node subgraph, including the topic vector and paragraph vector corresponding to the node, and the multiple summary vectors can be weighted averaged to obtain the summary vector corresponding to the summary text. Finally, the embodiment of the present application normalizes the summary vector and performs full connection layer processing to generate a summary text corresponding to the target text.
[0151] The embodiment of the present application can determine the target text and the associated text as the text to be processed, use the preset main feature encoder and the key feature encoder to determine the topic vector and paragraph vector corresponding to each text to be processed, determine the target similarity between each two texts to be processed according to the topic vector and the paragraph vector, take one text to be processed as a text node, and construct a text node graph according to the target similarity and all text nodes, wherein the text node graph includes at least one connecting edge connecting two text nodes, and then detect the connectivity of each connecting edge, and decompose the text node graph according to the connectivity to obtain at least one text node subgraph, and then determine the summary vector according to the text to be processed corresponding to all text nodes in each text node subgraph, wherein one text node subgraph corresponds to one summary vector, and generate summary text according to all summary vectors. That is to say, the embodiment of the present application can achieve more comprehensive and accurate generation of the summary text of the target text by constructing a node graph of the target text and the associated text, and determining the text node subgraph involved in the generated summary text through the connectivity of each edge in the node graph, and then generating the summary text of the target text according to the text node subgraph.
[0152] In addition, after generating a summary text of the target text according to the summary generation method, the embodiment of the present application can input the target text and the summary text into a pre-trained scoring model to obtain a matching value between the target text and the corresponding summary text. The scoring model can be set by a person skilled in the art according to actual conditions, and this application does not make any specific restrictions.
[0153] In addition, the scoring model can be implemented in but is not limited to one method, and this application does not impose any specific limitations.
[0154] Specifically, if the matching value is greater than the preset matching value threshold, it means that the generated summary text is relatively accurate, and the summary text can be directly output at this time. If the matching value is less than or equal to the preset matching value threshold, it means that the generated summary text is inaccurate, or the pre-trained scoring model needs further training. At this time, the step of generating the summary text corresponding to the target text can be returned to regenerate the summary text of the target text, and the target text and the generated new summary text are input into the pre-trained scoring model to obtain the matching value of the target text and the corresponding summary text. In addition, the embodiment of the present application can also perform negative feedback training on the scoring model to obtain a more accurate scoring model. Among them, the preset matching value threshold can be set by a technician in this field according to the actual situation, and this application does not make specific restrictions.
[0155] According to the text summary generation method based on the large language model proposed in the embodiment of the present application, the target text to be generated can be obtained, the pre-trained language model is used to determine the keywords of the target text, the associated text of the target text is determined according to the keywords, and then the target number of associated texts is determined, and the summary generation strategy corresponding to the target text is determined according to the target number, and the summary text corresponding to the target text is generated according to the summary generation strategy. In addition, the embodiment of the present application can obtain the matching value of the target text and the corresponding summary text based on the scoring model. The embodiment of the present application can generate the summary text of the target text based on the language model and the associated text of the target text, and the summary text of the target text can be determined more accurately and quickly through the language model. The summary text of the target text generated by the associated text of the comprehensive target text is more accurate and comprehensive than the summary text generated for a single target text, avoiding the one-sidedness and inaccuracy of the summary text generated only for a single target text, and realizing the rapid and accurate generation of a more comprehensive summary text. Thus, the technical problem that the fragmentation of the way of presenting news in the related technology may lead to differences in reporting the same news, that is, the news summary extracted from a single news article is one-sided and cannot fully present the main content of the news event is solved.
[0156] Next, a text summary generation device based on a large language model proposed in an embodiment of the present application is described with reference to the accompanying drawings.
[0157] Figure 6 A block diagram of a text summary generation device based on a large language model provided in an embodiment of the present application.
[0158] like Figure 6 As shown, the text summary generation device 10 based on the large language model includes: an acquisition module 100, a first determination module 200, a second determination module 300, a third determination module 400 and a generation module 500.
[0159] Specifically, the acquisition module 100 is used to acquire a target text for generating a summary text.
[0160] The first determination module 200 is used to input the target text into a pre-trained language model to determine keywords of the target text.
[0161] The second determination module 300 is used to determine the associated text of the target text according to the keyword, wherein the associated text is a text that has the same description object as the target text but has different text content.
[0162] The third determination module 400 is used to determine a target number of associated texts, and determine a summary generation strategy corresponding to the target text according to the target number.
[0163] The generation module 500 is used to generate a summary text corresponding to the target text according to the summary generation strategy.
[0164] Optionally, in one embodiment of the present application, the first determination module 200 includes: a first generation unit, a first input unit, an acquisition unit, a second generation unit and a second input unit.
[0165] The first generating unit is used to generate a first prompt text according to the target text and a preset first prompt template, wherein the first prompt text is used to prompt the generation of an initial summary text corresponding to the target text.
[0166] The first input unit is used to input the first prompt text into the language model to obtain an initial summary text output by the language model.
[0167] The acquisition unit is used to acquire a preset sample text and sample keywords corresponding to the sample text.
[0168] The second generating unit is used to generate a second prompt text according to the sample text, the sample keywords, the initial summary text and a preset second prompt template, wherein the second prompt text is used to prompt the sample keywords generated with reference to the sample text and the initial keywords corresponding to the generated initial summary text.
[0169] The second input unit is used to input the second prompt text into the language model, obtain the initial keywords of the initial summary text output by the language model, and determine the initial keywords as keywords of the target text.
[0170] Optionally, in an embodiment of the present application, the third determination module 400 includes: a judgment unit, a first determination unit and a second determination unit.
[0171] The judging unit is used to judge whether the target quantity is zero.
[0172] The first determining unit is used to determine, when the target quantity is zero, that the summary generation strategy is to generate a summary text through a language model.
[0173] The second determining unit is used to compare the target quantity with a preset quantity threshold when the target quantity is not zero, obtain a comparison result, and determine a summary generation strategy according to the comparison result.
[0174] Optionally, in one embodiment of the present application, the second determining unit includes: a first determining subunit, a second determining subunit, a third determining subunit, an adjusting subunit and a fourth determining subunit.
[0175] The first determination subunit is used to determine the target text and the associated text as the text to be processed when the comparison result indicates that the target quantity is less than or equal to a preset quantity threshold.
[0176] The second determination subunit is used to determine the vector coding sequence corresponding to each text to be processed, and determine the text topic vector corresponding to the vector coding sequence.
[0177] The third determining subunit is used to determine the central topic vector according to the text topic vector corresponding to each text to be processed.
[0178] The adjustment subunit is used to adjust the vector encoding sequence of each text to be processed according to the central theme vector to obtain the text vector to be processed.
[0179] The fourth determination subunit is used to integrate all the text vectors to be processed and determine the summary text corresponding to the target text.
[0180] Optionally, in one embodiment of the present application, the third determination subunit includes: a first determination subcomponent, a second determination subcomponent, a third determination subcomponent, a fourth determination subcomponent and a weighting subcomponent.
[0181] The first determining component is used to sum up all text topic vectors to determine the total text topic vector.
[0182] The second determining component is used to concatenate each text topic vector with the total text topic vector to determine the concatenated vector corresponding to each text topic vector.
[0183] The third determining component is used to sum the concatenated vectors corresponding to all the text topic vectors to determine the total concatenated vector.
[0184] The fourth determining component is used to determine, for each text topic vector, a weight value corresponding to the text topic vector according to the concatenation vector corresponding to the text topic vector and the total concatenation vector.
[0185] The weighted subcomponent is used to perform weighted summation on the text topic vectors according to the weight value corresponding to each text topic vector to obtain the central topic vector.
[0186] Optionally, in one embodiment of the present application, the fourth determination subunit includes: a first obtaining subcomponent, a fifth determining subcomponent, a second obtaining subcomponent and a third obtaining subcomponent.
[0187] The first obtaining component is used to screen each text vector to be processed according to the text subject vector corresponding to the text vector to be processed, so as to obtain a first vector encoding sequence.
[0188] The fifth determining component is used to determine the correlation between the text vector to be processed and each other text vector to be processed.
[0189] The second obtaining sub-component is used to perform weighted summation on other texts to be processed according to the correlation degree corresponding to each other text vector to be processed, so as to obtain a second vector encoding sequence corresponding to the text vector to be processed.
[0190] The third obtaining component is used to integrate the text vectors to be processed according to the first vector encoding sequence and the second vector encoding sequence corresponding to each text vector to be processed, so as to obtain the summary text corresponding to the target text.
[0191] Optionally, in one embodiment of the present application, the generating module 500 includes: a third determining unit, a fourth determining unit, a fifth determining unit, a constructing unit, a detecting unit, a sixth determining unit and a third generating unit.
[0192] The third determining unit is configured to determine the target text and the associated text as texts to be processed when the comparison result indicates that the target quantity is greater than a preset quantity threshold.
[0193] The fourth determining unit is used to determine the topic vector and paragraph vector corresponding to each to-be-processed text by using a preset topic feature encoder and a key feature encoder.
[0194] The fifth determining unit is used to determine the target similarity between every two to-be-processed texts according to the topic vector and the paragraph vector.
[0195] The construction unit is used to take a text to be processed as a text node and construct a text node graph according to the target similarity and all text nodes, wherein the text node graph includes at least one connection edge connecting two text nodes.
[0196] The detection unit is used to detect the connectivity of each connection edge and decompose the text node graph according to the connectivity to obtain at least one text node subgraph.
[0197] The sixth determining unit is used to determine a summary vector according to the to-be-processed texts corresponding to all the text nodes in each text node subgraph, wherein one text node subgraph corresponds to one summary vector.
[0198] The third generating unit is used to generate summary text according to all summary vectors.
[0199] It should be noted that the aforementioned explanation of the embodiment of the text summary generation method based on a large language model is also applicable to the text summary generation device based on a large language model in this embodiment, and will not be repeated here.
[0200] According to the text summary generation device based on the large language model proposed in the embodiment of the present application, the target text to be generated can be obtained, the keywords of the target text can be determined by using the pre-trained language model, the associated text of the target text can be determined according to the keywords, and the target number of associated texts can be determined, and the summary generation strategy corresponding to the target text can be determined according to the target number, and the summary text corresponding to the target text can be generated according to the summary generation strategy. In addition, the embodiment of the present application can obtain the matching value of the target text and the corresponding summary text based on the scoring model. The embodiment of the present application can generate the summary text of the target text based on the language model and the associated text of the target text, and the summary text of the target text can be determined more accurately and quickly through the language model. The summary text of the target text generated by the associated text of the comprehensive target text is more accurate and comprehensive than the summary text generated for a single target text, avoiding the one-sidedness and inaccuracy of the summary text generated only for a single target text, and realizing the rapid and accurate generation of a more comprehensive summary text. Thus, the technical problem that the fragmentation of the way of presenting news in the related technology may lead to differences in reporting the same news, that is, the news summary extracted from a single news article is one-sided and cannot fully present the main content of the news event is solved.
[0201] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:
[0202] A memory 701 , a processor 702 , and a computer program stored in the memory 701 and executable on the processor 702 .
[0203] When the processor 702 executes the program, the text summary generation method based on the large language model provided in the above embodiment is implemented.
[0204] Furthermore, the electronic device further comprises:
[0205] The communication interface 703 is used for communication between the memory 701 and the processor 702 .
[0206] The memory 701 is used to store computer programs that can be executed on the processor 702 .
[0207] The memory 701 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0208] If the memory 701, the processor 702 and the communication interface 703 are implemented independently, the communication interface 703, the memory 701 and the processor 702 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0209] Optionally, in a specific implementation, if the memory 701, the processor 702 and the communication interface 703 are integrated on a chip, the memory 701, the processor 702 and the communication interface 703 can communicate with each other through an internal interface.
[0210] The processor 702 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0211] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned method for generating a text summary based on a large language model.
[0212] The embodiment of the present application also provides a computer program, which can run computer instructions. When the computer instructions are executed by a processor, the text summary generation method based on a large language model provided in the embodiment of the present application is implemented.
[0213] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0214] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0215] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0216] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or N wirings (electronic devices), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways as necessary and then storing it in a computer memory.
[0217] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0218] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0219] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0220] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A text summary generation method based on a large language model, characterized in that: The following steps are involved: Obtain the target text to be generated as summary text; Inputting the target text into a pre-trained language model to determine keywords of the target text; Determining the associated text of the target text according to the keyword, wherein the associated text is a text having the same description object as the target text but different text content; Determining a target number of the associated texts, and determining a summary generation strategy corresponding to the target text according to the target number; Generate a summary text corresponding to the target text according to the summary generation strategy; Wherein, determining the summary generation strategy corresponding to the target text according to the target number includes: judging whether the target number is zero; if the target number is zero, determining that the summary generation strategy is to generate the summary text through the language model; if the target number is not zero, comparing the target number with a preset number threshold to obtain a comparison result, and determining the summary generation strategy according to the comparison result; Wherein, the determining of the summary generation strategy according to the comparison result includes: when the comparison result indicates that the target quantity is less than or equal to the preset quantity threshold, determining the target text and the associated text as the text to be processed; determining the vector coding sequence corresponding to each of the texts to be processed, and determining the text theme vector corresponding to the vector coding sequence; determining the central theme vector according to the text theme vector corresponding to each of the texts to be processed; adjusting the vector coding sequence of each of the texts to be processed according to the central theme vector to obtain the text vector to be processed; integrating all the text vectors to be processed to determine the summary text corresponding to the target text; Wherein, generating the summary text corresponding to the target text according to the summary generation strategy includes: when the comparison result indicates that the target quantity is greater than the preset quantity threshold, determining the target text and the associated text as the text to be processed; using a preset topic feature encoder and a key feature encoder to determine the topic vector and paragraph vector corresponding to each text to be processed; determining the target similarity between each two texts to be processed according to the topic vector and the paragraph vector; taking one of the texts to be processed as a text node, and constructing a text node graph according to the target similarity and all the text nodes, wherein the text node graph includes at least one connecting edge connecting two text nodes; detecting the connectivity of each of the connecting edges, and decomposing the text node graph according to the connectivity to obtain at least one text node subgraph; determining the summary vector according to the text to be processed corresponding to all the text nodes in each of the text node subgraphs, wherein one text node subgraph corresponds to one summary vector; generating the summary text according to all the summary vectors.
2. The method according to claim 1, characterized in that The step of inputting the target text into a pre-trained language model to determine keywords of the target text includes: Generate a first prompt text according to the target text and a preset first prompt template, wherein the first prompt text is used to prompt the generation of an initial summary text corresponding to the target text; Inputting the first prompt text into the language model to obtain an initial summary text output by the language model; Obtaining a preset sample text and sample keywords corresponding to the sample text; Generate a second prompt text according to the sample text, the sample keywords, the initial summary text and a preset second prompt template, wherein the second prompt text is used to prompt the sample keywords generated with reference to the sample text and the initial keywords corresponding to the initial summary text; The second prompt text is input into the language model to obtain initial keywords of the initial summary text output by the language model, and the initial keywords are determined as keywords of the target text.
3. The method according to claim 1, characterized in that: Determining the central topic vector according to the text topic vector corresponding to each of the to-be-processed texts includes: Summing all the text topic vectors to determine a total text topic vector; Splicing each of the text topic vectors with the total text topic vector to determine a splicing vector corresponding to each of the text topic vectors; Summing the concatenated vectors corresponding to all the text topic vectors to determine a total concatenated vector; For each of the text topic vectors, determining a weight value corresponding to the text topic vector according to a concatenation vector corresponding to the text topic vector and the total concatenation vector; According to the weight value corresponding to each of the text topic vectors, the text topic vectors are weighted summed to obtain the central topic vector.
4. The method according to claim 1, characterized in that The step of integrating all the text vectors to be processed to determine the summary text corresponding to the target text includes: For each text vector to be processed, the text vector to be processed is screened according to the text topic vector corresponding to the text vector to be processed to obtain a first vector encoding sequence; Determining a correlation between the to-be-processed text vector and each other to-be-processed text vector; According to the correlation degree corresponding to each of the other text vectors to be processed, weighted summation is performed on the other texts to be processed to obtain a second vector encoding sequence corresponding to the text vector to be processed; According to the first vector encoding sequence and the second vector encoding sequence corresponding to each of the text vectors to be processed, the text vectors to be processed are integrated to obtain a summary text corresponding to the target text.
5. A text summary generation device based on a large language model, characterized in that: include: An acquisition module is used to acquire a target text to be generated as a summary text; A first determination module, configured to input the target text into a pre-trained language model to determine keywords of the target text; A second determination module is used to determine the associated text of the target text according to the keyword, wherein the associated text is a text that has the same description object as the target text but different text content; A third determination module is used to determine a target number of the associated texts, and determine a summary generation strategy corresponding to the target text according to the target number; and A generation module, used to generate a summary text corresponding to the target text according to the summary generation strategy; The third determination module includes: a judgment unit, configured to judge whether the target number is zero; a first determination unit, configured to determine that the summary generation strategy is to generate the summary text by using the language model when the target number is zero; and a second determination unit, configured to compare the target number with a preset number threshold to obtain a comparison result when the target number is not zero, and determine the summary generation strategy according to the comparison result. Wherein, the second determination unit includes: a first determination subunit, used to determine the target text and the associated text as the text to be processed when the comparison result indicates that the target quantity is less than or equal to the preset quantity threshold; a second determination subunit, used to determine the vector coding sequence corresponding to each of the texts to be processed, and determine the text theme vector corresponding to the vector coding sequence; a third determination subunit, used to determine the central theme vector according to the text theme vector corresponding to each of the texts to be processed; an adjustment subunit, used to adjust the vector coding sequence of each of the texts to be processed according to the central theme vector to obtain the text vector to be processed; a fourth determination subunit, used to integrate all the text vectors to be processed to determine the summary text corresponding to the target text; Wherein, the generating module comprises: a third determining unit, which is used to determine the target text and the associated text as the text to be processed when the comparison result indicates that the target quantity is greater than the preset quantity threshold; a fourth determining unit, which is used to determine the topic vector and paragraph vector corresponding to each text to be processed by using a preset topic feature encoder and a key feature encoder; a fifth determining unit, which is used to determine the target similarity between each two texts to be processed according to the topic vector and the paragraph vector; a constructing unit, which is used to take one of the texts to be processed as a text node, and construct a text node graph according to the target similarity and all the text nodes, wherein the text node graph includes at least one connecting edge connecting two text nodes; a detecting unit, which is used to detect the connectivity of each of the connecting edges, and decompose the text node graph according to the connectivity to obtain at least one text node subgraph; a sixth determining unit, which is used to determine the summary vector according to the text to be processed corresponding to all the text nodes in each of the text node subgraphs, wherein one text node subgraph corresponds to one summary vector; and a third generating unit, which is used to generate the summary text according to all the summary vectors.
6. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method for generating a text summary based on a large language model as described in any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the text summary generation method based on a large language model as described in any one of claims 1 to 4.
