A text summary generation method, device, computer equipment and storage medium
By using a 12-layer Transformers Encoder module and a word-entity cross-attention layer in the text summarization generation method, the problem of entity information loss in traditional methods is solved, and more accurate text summarization generation is achieved.
Patent Information
- Application Number
- CN202210489164.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-06
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2042-05-06
AI Technical Summary
Traditional text summarization methods suffer from low accuracy, especially due to the loss of entity information during the encoding process, resulting in decoded summaries that fail to reflect the central content of the original text.
A stacked structure of 12 Transformers Encoder modules is adopted, combined with a word-entity cross-attention layer. Entity information is mapped to vectors of the same dimension through entity mapping layer and entity type mapping layer. A word-entity cross-attention layer is added between the multi-head attention layer and the feedforward neural network layer to enhance the model's ability to express entities.
It improves the accuracy of text summarization, ensuring that the decoder can accurately extract important information and enhances the model's ability to fuse and express entity information.
Smart Images

Figure CN114881033B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to a method, device, computer equipment and storage medium for generating a text summary integrating entity information. Background Art
[0002] With the advent of the big data era, text data on the Internet has exploded, causing people to spend a lot of time browsing and understanding the corresponding texts, and inevitably miss some important information. Therefore, how to quickly and efficiently obtain important information from a large amount of text has become increasingly important. Automatic summarization technology is an effective way to alleviate this problem.
[0003] There is a method for generating text summaries, which uses a deep learning encoder-decoder model. Specifically, the encoder is responsible for vector encoding the original text and extracting semantic information; the decoder decodes the compressed information and generates a summary of the original text.
[0004] However, the applicant found that the traditional text summary generation method uses a word-based dictionary or pre-trained model, and the encoding process will inevitably lose entity information, resulting in the decoded summary being insufficient to reflect the core content of the original text. It can be seen that the traditional text summary generation method has the problem of low accuracy. Summary of the invention
[0005] The purpose of the embodiments of the present application is to propose a text summary generation method, apparatus, computer equipment and storage medium that integrate entity information to solve the problem of low accuracy in traditional text summary generation methods.
[0006] In order to solve the above technical problems, the embodiment of the present application provides a text summary generation method integrating entity information, which adopts the following technical solution:
[0007] Get the raw text data to be processed;
[0008] Performing entity extraction operation on the original text data to obtain entity text data and entity type data;
[0009] Performing a first fusion operation on the entity text data and the entity type data to obtain entity fusion data;
[0010] Performing a vector conversion operation on the original text data to obtain text vector data;
[0011] The text vector data and the entity fusion data are respectively input into a language representation model for summary encoding operation to obtain summary encoded data, wherein the language representation model is composed of 12 layers of Transformers Encoder modules stacked together, and a word-entity cross attention layer is provided between the multi-head attention layer and the feedforward neural network layer of the Encoder module;
[0012] The summary encoded data is decoded to obtain a target text summary.
[0013] In order to solve the above technical problems, the embodiment of the present application also provides a text summary generation device integrating entity information, which adopts the following technical solution:
[0014] A data acquisition module, used to acquire the original text data to be processed;
[0015] An entity extraction module is used to perform entity extraction operation on the original text data to obtain entity text data and entity type data;
[0016] A first fusion module, used for performing a first fusion operation on the entity text data and the entity type data to obtain entity fusion data;
[0017] A vector conversion module, used for performing a vector conversion operation on the original text data to obtain text vector data;
[0018] A summary encoding module, used for inputting the text vector data and the entity fusion data into a language representation model for summary encoding operation to obtain summary encoding data, wherein the language representation model is composed of 12 layers of Transformers Encoder modules, and a word-entity cross attention layer is provided between the multi-head attention layer and the feedforward neural network layer of the Encoder module;
[0019] The summary decoding module is used to perform a decoding operation on the summary encoding data to obtain a target text summary.
[0020] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0021] The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the text summary generation method integrating entity information as described above are implemented.
[0022] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0023] The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the text summary generation method integrating entity information as described above are implemented.
[0024] The present application provides a method for generating a text summary by integrating entity information, comprising: obtaining original text data to be processed; performing an entity extraction operation on the original text data to obtain entity text data and entity type data; performing a first fusion operation on the entity text data and the entity type data to obtain entity fusion data; performing a vector conversion operation on the original text data to obtain text vector data; respectively inputting the text vector data and the entity fusion data into a language representation model for summary encoding operation to obtain summary encoding data, wherein the language representation model is formed by superimposing an Encoder module of 12 layers of Transformers, and a word-entity cross attention layer is provided between the multi-head attention layer and the feedforward neural network layer of the Encoder module; performing a decoding operation on the summary encoding data to obtain a target text summary. Compared with the prior art, the present application adds an entity mapping layer (hereinafter referred to as Entity Embedding) and an entity type mapping layer (hereinafter referred to as TypeEmbedding) on the basis of the original network, and maps the entity information of the input text to two vectors of the same dimensions respectively, thereby enhancing the amount of information received by the model; at the same time, a word-entity cross-attention layer is added between the multi-head attention layer and the feedforward neural network layer of each sub-module to enhance the model's ability to express entities, so that the decoder can accurately extract important information. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0026] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0027] Figure 2 It is a flowchart of the implementation of the text summary generation method of integrating entity information provided in the first embodiment of the present application;
[0028] Figure 3 This is a structural diagram of a specific implementation of the Encoder module provided in Example 1 of the present application;
[0029] Figure 4 yes Figure 2A flowchart of a specific implementation of step S203;
[0030] Figure 5 yes Figure 2 A flowchart of a specific implementation of step S205;
[0031] Figure 6 yes Figure 5 A flowchart of a specific implementation of step S502;
[0032] Figure 7 This is a schematic diagram of the structure of a text summary generation device integrating entity information provided in Example 2 of the present application;
[0033] Figure 8 It is a structural diagram of a specific implementation of the first fusion module 230 provided in Example 2 of the present application;
[0034] Fig. 9 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0035] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0036] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0037] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0038] like Figure 1As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0039] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0040] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.
[0041] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0042] It should be noted that the text summary generation method for fused entity information provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the text summary generation device for fused entity information is generally set in the server / terminal device.
[0043] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0044] Embodiment 1
[0045] Continue to refer Figure 2 , shows an implementation flow chart of the text summary generation method that integrates entity information provided in Example 1 of the present application. For the sake of convenience, only the parts related to the present application are shown.
[0046] The above-mentioned text summary generation method integrating entity information comprises the following steps:
[0047] Step S201: Acquire original text data to be processed.
[0048] Step S202: performing entity extraction operation on the original text data to obtain entity text data and entity type data.
[0049] Step S203: performing a first fusion operation on the entity text data and the entity type data to obtain entity fusion data.
[0050] In the embodiments of this application, see Figure 3 , shows a schematic diagram of the structure of the Encoder module provided in the embodiment of the present application, assuming that the original text to be extracted is D = [x1, x2, ..., x n ], where x i is the i-th word in the document, and n is the length of the document. First, use text tools (such as Hanlp, etc.) to extract entities in the original text (called entity extraction), and each entity has an entity type (name, place name, etc.), thus forming an entity sequence E = [e1, e2, ..., e m ] and entity type sequence E′=[e′1,e′2,…,e′ m ]. Where e i represents the i-th entity in the sequence, e′ i Similarly, the EntityEmbedding and TypeEmbedding layers are used to map the two to fixed vectors of the same dimension, generating vector sequences T = [t1, t2, …, t m ] and K=[k1,k2,…,k m ]. Considering the importance of the entity and the impact of the entity length, this application needs to merge T and K.
[0051] Step S204: performing a vector conversion operation on the original text data to obtain text vector data.
[0052] In the embodiment of the present application, the original text data D is mapped to a vector of the same dimension through the WordEmbedding layer to obtain a matrix H = [h1, h2, ..., h n ].
[0053] Step S205: respectively input the text vector data and the entity fusion data into the language representation model for summary encoding operation to obtain summary encoded data, wherein the language representation model is composed of 12 layers of Transformers' Encoder modules stacked together, and a word-entity cross-attention layer is set between the multi-head attention layer and the feedforward neural network layer of the Encoder module.
[0054] Step S206: Decode the summary encoded data to obtain a target text summary.
[0055] In an embodiment of the present application, a method for generating a text summary by integrating entity information is provided, including: obtaining original text data to be processed; performing an entity extraction operation on the original text data to obtain entity text data and entity type data; performing a first fusion operation on the entity text data and the entity type data to obtain entity fusion data; performing a vector conversion operation on the original text data to obtain text vector data; respectively inputting the text vector data and the entity fusion data into a language representation model for summary encoding operation to obtain summary encoding data, wherein the language representation model is composed of an Encoder module of 12 layers of Transformers superimposed, and a word-entity cross-attention layer is provided between the multi-head attention layer and the feedforward neural network layer of the Encoder module; performing a decoding operation on the summary encoding data to obtain a target text summary. Compared with the prior art, the present application adds an entity mapping layer (hereinafter referred to as Entity Embedding) and an entity type mapping layer (hereinafter referred to as TypeEmbedding) on the basis of the original network, and maps the entity information of the input text to two vectors of the same dimensions respectively, thereby enhancing the amount of information received by the model; at the same time, a word-entity cross-attention layer is added between the multi-head attention layer and the feedforward neural network layer of each sub-module to enhance the model's ability to express entities, so that the decoder can accurately extract important information.
[0056] Continue reading Figure 4 , showing Figure 2 A flowchart of a specific implementation of step S203 is shown in FIG. 1 . For ease of explanation, only the part related to the present application is shown.
[0057] In some optional implementations of this embodiment, step S203 specifically includes:
[0058] Step S401: fusion calculation is performed on entity text data and entity type data according to an entity fusion algorithm to obtain entity fusion data, wherein the entity fusion algorithm is expressed as:
[0059]
[0060] Among them, g i represents the entity fusion data of the i-th entity; w i Represents the i-th entity text data; tfidf(w i ) represents the term frequency-inverse document frequency index of the i-th entity text data; max(tfidf(w i ), i∈[1,m]) represents the maximum term frequency-inverse document frequency index of all entities in the original text data; |w i | represents the length of the i-th entity; max(|w i|,i∈[1,m]) represents the length of the longest entity in the original text data.
[0061] Continue reading Figure 5 , showing Figure 2 A flowchart of a specific implementation of step S205 is shown in FIG. 1 . For ease of explanation, only the part related to the present application is shown.
[0062] In some optional implementations of this embodiment, step S205 specifically includes:
[0063] Step S501: Perform self-attention layer calculation and splicing operations in the multi-head attention layer according to the text vector data to obtain the multi-head attention layer result.
[0064] Step S502: Perform a second fusion operation in the word-entity cross-attention layer based on the multi-head attention layer results and the entity fusion data to obtain the cross-attention layer results.
[0065] Step S503: Input the cross attention layer result into the residual neural network and the feedforward neural network to obtain summary coded data.
[0066] In an embodiment of the present application, the input matrix H is first calculated by the self-attention layer, and then the calculation results of multiple self-attention layers are spliced, and finally passed through the residual and feedforward neural network layers.
[0067] In some optional implementations of this embodiment, the multi-head attention layer result Z L It is expressed as:
[0068]
[0069] in, H L Represents the text vector data of the L-th layer Transformers.
[0070] Continue reading Figure 6 , showing Figure 5 A flowchart of a specific implementation of step S502 is shown in FIG. 1 . For ease of explanation, only the part related to the present application is shown.
[0071] In some optional implementations of this embodiment, step S502 specifically includes:
[0072] Step S601: Perform softmax operation on the multi-head attention layer results and entity fusion data according to the softmax algorithm to obtain the first weight distribution result a g′ And the second weight distribution result a z′ , where the softmax algorithm is expressed as:
[0073] A=Z L *G
[0074] a g =softmax-line(A)
[0075] a z =softmax-row(A)
[0076] Among them, softmax-row means to perform softmax operation on the column direction of A, and the same is true for softmax-line;
[0077] Step S602: respectively distribute the first weighted result a g′ And entity type data, second weight distribution result a z′ And the multi-head attention layer result Z L Performing weighted summation to obtain a first weighted summation result and a second weighted summation result;
[0078] Step S603: performing a second fusion operation on the first weighted summation result and the second weighted summation result according to a second fusion algorithm to obtain a second fusion matrix;
[0079] Step S604: Input the second fusion matrix into the fully connected layer for dimensional compression operation to obtain the cross attention layer result.
[0080] In the embodiment of the present application, the output of the multi-head attention layer of the Lth layer is assumed to be Z L In order to enable the model to fuse the semantic information of text sequence and entity sequence, in the cross attention layer, the entity fusion data G and Z L Calculate the following formula:
[0081] A=Z L *G
[0082] a g =softmax-line(A)
[0083] a z =softmax-row(A)
[0084] Among them, softmax-row means to perform softmax operation on the column direction of A, and the same is true for softmax-line. After the softmax operation, the weight distribution a is obtained g′ and a z′ . Among them a g′ represents the attention weight distribution of a word to all entities, a z′ vice versa.
[0085] For a gand G,a z and Z L Perform weighted summation, the formula is as follows:
[0086]
[0087]
[0088] In the embodiment of the present application, in order to further integrate the distributed expression of text and entity sequence, two fusion methods are proposed based on the above vectors, and the results are concatenated to obtain vector z″. This process is repeated to generate the output matrix Z L″ The formula is as follows:
[0089]
[0090] in, The two expressions are subtracted element by element, It means element-wise multiplication of the two.
[0091] In the embodiment of the present application, since the output matrix has a different dimension from the weight matrix of the lower network, it is sent to the fully connected layer for dimension compression to obtain the final output of the WEA layer. The calculation formula is as follows:
[0092]
[0093] In the embodiment of the present application, the output of the WEA layer is sent to the residual and feedforward neural network layer for operation to obtain the output of the encoder. Finally, 12 encoders perform the above operation, and the input of the WEA layer of each encoder shares the information of the same EntityEmbedding layer.
[0094] In some optional implementations of this embodiment, the output of the top model is sent to the decoder for decoding, and the text summary model is trained by autoregression and the parameters in the text summary model are optimized by the Adam optimization method. The training target formula is as follows:
[0095]
[0096] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0097] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0098] Embodiment 2
[0099] Further references Figure 7 , as a response to the above Figure 2 The present application provides an embodiment of a text summary generation device integrating entity information. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0100] like Figure 7 As shown, the text summary generation device 200 integrating entity information of this embodiment includes: a data acquisition module 210, an entity extraction module 220, a first fusion module 230, a vector conversion module 240, a summary encoding module 250 and a summary decoding module 260. Among them:
[0101] The data acquisition module 210 is used to acquire the original text data to be processed;
[0102] The entity extraction module 220 is used to perform entity extraction operations on the original text data to obtain entity text data and entity type data;
[0103] A first fusion module 230, configured to perform a first fusion operation on the entity text data and the entity type data to obtain entity fusion data;
[0104] A vector conversion module 240 is used to perform a vector conversion operation on the original text data to obtain text vector data;
[0105] A summary encoding module 250 is used to input the text vector data and the entity fusion data into a language representation model for summary encoding operation to obtain summary encoding data, wherein the language representation model is composed of 12 layers of Transformers Encoder modules, and a word-entity cross attention layer is set between the multi-head attention layer and the feedforward neural network layer of the Encoder module;
[0106] The summary decoding module 260 is used to perform a decoding operation on the summary encoding data to obtain a target text summary.
[0107] In the embodiments of this application, see Figure 3 , shows a schematic diagram of the structure of the Encoder module provided in the embodiment of the present application, assuming that the original text to be extracted is D = [x1, x2, ..., x n ], where x i is the i-th word in the document, and n is the length of the document. First, use text tools (such as Hanlp, etc.) to extract entities in the original text (called entity extraction), and each entity has an entity type (name, place name, etc.), thus forming an entity sequence E = [e1, e2, ..., e m ] and entity type sequence E′=[e′1,e′2,…,e′ m ]. Where e i represents the i-th entity in the sequence, e′ i Similarly, the EntityEmbedding and TypeEmbedding layers are used to map the two to fixed vectors of the same dimension, generating vector sequences T = [t1, t2, …, t m ] and K=[k1,k2,…,k m ]. Considering the importance of the entity and the impact of the entity length, this application needs to merge T and K.
[0108] In the embodiment of the present application, the original text data D is mapped to a vector of the same dimension through the WordEmbedding layer to obtain a matrix H = [h1, h2, ..., h n ].
[0109] In an embodiment of the present application, a text summary generation device 200 for integrating entity information is provided, including: a data acquisition module 210, used to acquire original text data to be processed; an entity extraction module 220, used to perform entity extraction operation on the original text data to obtain entity text data and entity type data; a first fusion module 230, used to perform a first fusion operation on the entity text data and the entity type data to obtain entity fusion data; a vector conversion module 240, used to perform a vector conversion operation on the original text data to obtain text vector data; a summary encoding module 250, used to input the text vector data and the entity fusion data into a language representation model for summary encoding operation to obtain summary encoding data, wherein the language representation model is composed of 12 layers of Transformers Encoder modules superimposed, and a word-entity cross attention layer is provided between the multi-head attention layer and the feedforward neural network layer of the Encoder module; a summary decoding module 260, used to perform a decoding operation on the summary encoding data to obtain a target text summary. Compared with the prior art, the present application adds an entity mapping layer (hereinafter referred to as Entity Embedding) and an entity type mapping layer (hereinafter referred to as TypeEmbedding) on the basis of the original network, and maps the entity information of the input text to two vectors of the same dimensions respectively, thereby enhancing the amount of information received by the model; at the same time, a word-entity cross-attention layer is added between the multi-head attention layer and the feedforward neural network layer of each sub-module to enhance the model's ability to express entities, so that the decoder can accurately extract important information.
[0110] Continue reading Figure 8 , shows a structural schematic diagram of a specific implementation of the first fusion module 230 provided in Example 2 of the present application. For the sake of ease of explanation, only the part related to the present application is shown.
[0111] In some optional implementations of this embodiment, the first fusion module 230 includes: a first fusion submodule 231, wherein:
[0112] The first fusion submodule 231 is used to perform fusion calculation on the entity text data and the entity type data according to the entity fusion algorithm to obtain entity fusion data, wherein the entity fusion algorithm is expressed as:
[0113]
[0114] Among them, g i represents the entity fusion data of the i-th entity; w i Represents the i-th entity text data; tfidf(w i ) represents the term frequency-inverse document frequency index of the i-th entity text data; max(tfidf(w i), i∈[1,m]) represents the maximum term frequency-inverse document frequency index of all entities in the original text data; |w i | represents the length of the i-th entity; max(|w i |,i∈[1,m]) represents the length of the longest entity in the original text data.
[0115] In some optional implementations of this embodiment, the summary encoding module 250 includes: a calculation splicing submodule, a second fusion submodule and a summary encoding submodule, wherein:
[0116] The calculation and splicing submodule is used to perform self-attention layer calculation and splicing operations according to the text vector data in the multi-head attention layer to obtain the multi-head attention layer result;
[0117] The second fusion submodule is used to perform a second fusion operation in the word-entity cross attention layer according to the multi-head attention layer results and the entity fusion data to obtain the cross attention layer results;
[0118] The summary encoding submodule is used to input the results of the cross attention layer into the residual neural network and the feedforward neural network to obtain summary encoding data.
[0119] In some optional implementations of this embodiment, the multi-head attention layer result Z L It is expressed as:
[0120]
[0121] in, H L Represents the text vector data of the L-th layer Transformers.
[0122] In some optional implementations of this embodiment, the second fusion submodule includes: a softmax operation unit, a weighted summation unit, a second fusion unit, and a dimension compression unit, wherein:
[0123] The softmax operation unit is used to perform softmax operation on the multi-head attention layer results and entity fusion data according to the softmax algorithm to obtain the first weight distribution result a g′ And the second weight distribution result a z′ , where the softmax algorithm is expressed as:
[0124] A=Z L *G
[0125] a g =softmax-line(A)
[0126] a z=softmax-row(A)
[0127] Among them, softmax-row means to perform softmax operation on the column direction of A, and the same is true for softmax-line;
[0128] A weighted summation unit is used to respectively distribute the first weighted result a g′ And entity type data, second weight distribution result a z′ And the multi-head attention layer result Z L Performing weighted summation to obtain a first weighted summation result and a second weighted summation result;
[0129] A second fusion unit, configured to perform a second fusion operation on the first weighted sum result and the second weighted sum result according to a second fusion algorithm to obtain a second fusion matrix;
[0130] The dimension compression unit is used to input the second fusion matrix into the fully connected layer for dimension compression operation to obtain the cross attention layer result.
[0131] In the embodiment of the present application, the output of the multi-head attention layer of the Lth layer is assumed to be Z L In order to enable the model to fuse the semantic information of text sequence and entity sequence, in the cross attention layer, the entity fusion data G and Z L Calculate the following formula:
[0132] A=Z L *G
[0133] a g =softmax-line(A)
[0134] a z =softmax-row(A)
[0135] Among them, softmax-row means to perform softmax operation on the column direction of A, and the same is true for softmax-line. After the softmax operation, the weight distribution a is obtained g′ and a z′ . Among them a g′ represents the attention weight distribution of a word to all entities, a z′ vice versa.
[0136] For a g and G,a z and Z L Perform weighted summation, the formula is as follows:
[0137]
[0138]
[0139] In the embodiment of the present application, in order to further integrate the distributed expression of text and entity sequence, two fusion methods are proposed based on the above vectors, and the results are concatenated to obtain vector z″. This process is repeated to generate the output matrix Z L″ The formula is as follows:
[0140]
[0141] in, The two expressions are subtracted element by element, It means element-wise multiplication of the two.
[0142] In the embodiment of the present application, since the output matrix has a different dimension from the weight matrix of the lower network, it is sent to the fully connected layer for dimension compression to obtain the final output of the WEA layer. The calculation formula is as follows:
[0143]
[0144] In the embodiment of the present application, the output of the WEA layer is sent to the residual and feedforward neural network layer for operation to obtain the output of the encoder. Finally, 12 encoders perform the above operation, and the input of the WEA layer of each encoder shares the information of the same EntityEmbedding layer.
[0145] In some optional implementations of this embodiment, the output of the top model is sent to the decoder for decoding, and the text summary model is trained by autoregression and the parameters in the text summary model are optimized by the Adam optimization method. The training target formula is as follows:
[0146]
[0147] To solve the above technical problems, the present application also provides a computer device. Fig. 9 , Fig. 9 This is a basic structural block diagram of the computer device in this embodiment.
[0148] The computer device 300 includes a memory 310, a processor 320, and a network interface 330 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 300 having components 310-330, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0149] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0150] The memory 310 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 310 can be an internal storage unit of the computer device 300, such as a hard disk or memory of the computer device 300. In other embodiments, the memory 310 can also be an external storage device of the computer device 300, such as a plug-in hard disk equipped on the computer device 300, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Of course, the memory 310 can also include both the internal storage unit of the computer device 300 and its external storage device. In this embodiment, the memory 310 is generally used to store an operating system and various application software installed on the computer device 300, such as computer-readable instructions of a text summary generation method integrating entity information, etc. In addition, the memory 310 can also be used to temporarily store various data that have been output or are to be output.
[0151] The processor 320 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 320 is generally used to control the overall operation of the computer device 300. In this embodiment, the processor 320 is used to run the computer-readable instructions stored in the memory 310 or process data, such as computer-readable instructions for running the text summary generation method of the fused entity information.
[0152] The network interface 330 may include a wireless network interface or a wired network interface. The network interface 330 is generally used to establish a communication connection between the computer device 300 and other electronic devices.
[0153] The computer device provided in the present application adds an entity mapping layer (hereinafter referred to as Entity Embedding) and an entity type mapping layer (hereinafter referred to as TypeEmbedding) on the basis of the original network, and maps the entity information of the input text to two vectors of the same dimensions respectively, thereby enhancing the amount of information received by the model; at the same time, a word-entity cross-attention layer is added between the multi-head attention layer and the feedforward neural network layer of each sub-module to enhance the model's ability to express entities and enable the decoder to accurately extract important information.
[0154] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the text summary generation method that integrates entity information as described above.
[0155] The computer-readable storage medium provided by the present application adds an entity mapping layer (hereinafter referred to as Entity Embedding) and an entity type mapping layer (hereinafter referred to as TypeEmbedding) on the basis of the original network, and maps the entity information of the input text to two vectors of the same dimensions respectively, thereby enhancing the amount of information received by the model; at the same time, a word-entity cross-attention layer is added between the multi-head attention layer and the feedforward neural network layer of each sub-module to enhance the model's ability to express entities, so that the decoder can accurately extract important information.
[0156] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0157] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A text summary generation method integrating entity information, characterized in that: The steps include: Get the raw text data to be processed; Performing entity extraction operation on the original text data to obtain entity text data and entity type data; Performing a first fusion operation on the entity text data and the entity type data to obtain entity fusion data; Performing a vector conversion operation on the original text data to obtain text vector data; The text vector data and the entity fusion data are respectively input into a language representation model for summary encoding operation to obtain summary encoded data, wherein the language representation model is composed of 12 layers of Transformers Encoder modules stacked together, and a word-entity cross attention layer is provided between the multi-head attention layer and the feedforward neural network layer of the Encoder module; Decoding the summary encoded data to obtain a target text summary; The step of performing a first fusion operation on the entity text data and the entity type data to obtain entity fusion data specifically includes the following steps: The entity text data and the entity type data are fused and calculated according to an entity fusion algorithm to obtain the entity fusion data, wherein the entity fusion algorithm is expressed as: ; in, Represents the entity fusion data of the i-th entity; Represents the i-th entity text data; Represents the term frequency-inverse document frequency index of the i-th entity text data; Represents the maximum term frequency-inverse document frequency index of all entities in the original text data; Indicates the length of the i-th entity; Indicates the length of the longest entity in the original text data; The step of respectively inputting the text vector data and the entity fusion data into the trained language representation model for summary encoding operation to obtain summary encoding data specifically includes the following steps: In the multi-head attention layer, self-attention layer calculation and splicing operation are performed according to the text vector data to obtain a multi-head attention layer result; In the word-entity cross attention layer, a second fusion operation is performed according to the multi-head attention layer result and the entity fusion data to obtain a cross attention layer result; Inputting the cross attention layer result into the residual neural network and the feedforward neural network to obtain the summary coded data; The step of performing a second fusion operation in the word-entity cross attention layer according to the multi-head attention layer result and the entity fusion data to obtain the cross attention layer result specifically includes the following steps: according to The algorithm performs the multi-head attention layer results and the entity fusion data Operation, get the first weight distribution result And the second weight distribution result Among them, the The algorithm is expressed as: ; in, Indicates that the column direction of A is Operations, Similarly; The first weight distribution results are respectively As well as entity type data, the second weight distribution result And the results of multi-head attention layer Performing weighted summation to obtain a first weighted summation result and a second weighted summation result; Performing a second fusion operation on the first weighted sum result and the second weighted sum result according to a second fusion algorithm to obtain a second fusion matrix; The second fusion matrix is input into the fully connected layer for dimension compression operation to obtain the cross attention layer knot.
2. The text summary generation method of integrating entity information according to claim 1 is characterized in that: The multi-head attention layer results It is expressed as: ; in, ; ; ; Represents the text vector data of the L-th layer Transformers.
3. The text summary generation method of integrating entity information according to claim 1 is characterized in that: After the step of decoding the summary coded data to obtain the target text summary, the following steps are also included: The language representation model is trained according to an autoregressive method, and the parameters of the language representation model are optimized according to an Adam optimization method, wherein the training objective of the autoregressive method is expressed as: .
4. A text summary generation device integrating entity information, characterized in that: include: A data acquisition module, used to acquire the original text data to be processed; An entity extraction module is used to perform entity extraction operation on the original text data to obtain entity text data and entity type data; A first fusion module, used for performing a first fusion operation on the entity text data and the entity type data to obtain entity fusion data; A vector conversion module, used for performing a vector conversion operation on the original text data to obtain text vector data; A summary encoding module, used for inputting the text vector data and the entity fusion data into a language representation model for summary encoding operation to obtain summary encoding data, wherein the language representation model is composed of 12 layers of Transformers Encoder modules, and a word-entity cross attention layer is provided between the multi-head attention layer and the feedforward neural network layer of the Encoder module; A summary decoding module, used for decoding the summary encoded data to obtain a target text summary; The first fusion module includes: The first fusion submodule is used to perform fusion calculation on the entity text data and the entity type data according to an entity fusion algorithm to obtain the entity fusion data, wherein the entity fusion algorithm is expressed as: ; in, Represents the entity fusion data of the i-th entity; Represents the i-th entity text data; Represents the term frequency-inverse document frequency index of the i-th entity text data; Represents the maximum term frequency-inverse document frequency index of all entities in the original text data; Indicates the length of the i-th entity; Indicates the length of the longest entity in the original text data; The summary encoding module specifically includes: a calculation splicing submodule, a second fusion submodule and a summary encoding submodule, wherein: The calculation and splicing submodule is used to perform self-attention layer calculation and splicing operations in the multi-head attention layer according to the text vector data to obtain a multi-head attention layer result; The second fusion submodule is used to perform a second fusion operation in the word-entity cross attention layer according to the multi-head attention layer result and the entity fusion data to obtain a cross attention layer result; The summary encoding submodule is used to input the cross attention layer result into the residual neural network and the feedforward neural network to obtain the summary encoding data; The second fusion submodule specifically includes: A computing unit, a weighted summing unit, a second fusion unit, and a dimension compression unit, wherein: Said The calculation unit is used to The algorithm performs the multi-head attention layer results and the entity fusion data Operation, get the first weight distribution result And the second weight distribution result Among them, the The algorithm is expressed as: ; in, Indicates that the column direction of A is Operations, Similarly; The weighted summation unit is used to respectively calculate the first weight distribution result As well as entity type data, the second weight distribution result And the multi-head attention layer results Performing weighted summation to obtain a first weighted summation result and a second weighted summation result; The second fusion unit is used to perform a second fusion operation on the first weighted sum result and the second weighted sum result according to a second fusion algorithm to obtain a second fusion matrix; The dimension compression unit is used to input the second fusion matrix into the fully connected layer for dimension compression operation to obtain the cross attention layer knot.
5. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the method for generating a text summary of fused entity information as claimed in any one of claims 1 to 3 when executing the computer-readable instructions.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the method for generating a text summary of fused entity information according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Text event abstract generation method and device, electronic equipment and storage medium
CN111324728A
Word weight determination method and device, server and computer readable storage medium
CN112507724A