Document-level relationship extraction method and device, electronic equipment and computer storage medium
By encoding and semantic segmentation network feature extraction of documents, the problem of inaccurate document-level relationship extraction in the prior art is solved, and more accurate entity relationship classification and more distinctive feature generation are achieved.
Patent Information
- Application Number
- CN202411610260.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-03-25
AI Technical Summary
The prior art cannot accurately extract document-level relationships, lack a global perspective, and the relationship information between entity pairs is scattered, making it difficult to capture long-range semantic dependencies.
By encoding the to-be-processed document, the context embedding representation of each entity is obtained, the relationship correlation matrix between entity pairs is calculated, and feature extraction is adopted using a semantic segmentation network to obtain global context information features, and classify them to obtain the relationship between entity pairs.
It realizes a more comprehensive integration of context information at different scales, improves the accurate classification of entity relationships, produces more distinctive features, and improves the accuracy of relation classification. Especially when dealing with documents with complex entity relationships and long-distance dependencies, the extraction of document-level relationships is more accurate.
Smart Images

Figure CN119692306A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of text processing technology, and in particular to a document-level relationship extraction method, device, electronic equipment and computer storage medium. Background Art
[0002] With the continuous development of artificial intelligence, the demand for text recognition technology is also increasing, and the extraction of document-level relationships has become a very important development direction.
[0003] The entity relationships in documents have complex dependencies. Traditional methods often lack a global perspective when dealing with these relationships, which limits the accuracy of relationship extraction. In addition, the relationship information between entity pairs is often scattered in different locations in the document, making it extremely challenging to capture long-range semantic dependencies. In order to obtain a clear semantic representation of entity pair relationships, it is also necessary to capture the degree of association between entity pairs and to make a reasonable semantic understanding and representation of this degree of association, resulting in low accuracy in document-level relationship extraction.
[0004] It can be seen that the existing technology cannot accurately extract document-level relations. Summary of the invention
[0005] In view of this, it is necessary to provide a document-level relationship extraction method, device, electronic device and computer storage medium to solve the problem that the existing technology cannot accurately extract document-level relationships.
[0006] In order to solve the above problems, the present invention provides a document-level relationship extraction method, comprising: Encode the document to be processed to obtain a contextual embedding representation of each entity in the document to be processed; Calculate the relationship correlation matrix between each entity pair based on the context embedding representation of each entity; Using a semantic segmentation network to extract features from the relationship correlation matrix to obtain global context information features between each of the entity pairs; The global context information features are classified to obtain the relationship between each of the entity pairs.
[0007] In a possible implementation manner, encoding the document to be processed to obtain a contextual embedding representation of each entity in the document to be processed includes: Use a preset encoder to insert marker symbols before and after each word in the document to be processed to obtain an embedded representation of each word; Logsumexp pooling is used to aggregate multiple embedded representations of an entity to obtain a contextual embedded representation of the entity.
[0008] In a possible implementation, the calculating the relationship correlation matrix between each entity pair based on the context embedding representation of each entity includes: The relationship correlation matrix calculation formula is used to calculate the relationship correlation matrix between each entity pair. The relationship correlation matrix calculation formula is:
[0009] in, For entity pairs The relationship correlation matrix, is the preset learnable model matrix, is the transpose of the context embedding matrix of all words in the document to be processed, and softmax is the preset activation function. L is the number of attention heads of the encoder, The encoder i Attention head for entity pair The importance score of the recognition result.
[0010] In a possible implementation, the using of a semantic segmentation network to extract features from the relationship correlation matrix to obtain global context information features between each of the entity pairs includes: The preset Unet++ semantic segmentation network is used to extract features from the relationship correlation matrix of all entity pairs, and the feature representation matrix containing deep information and shallow information of each entity pair is obtained; An entity cross-attention module is used to perform entity relationship cross-recognition on the feature representation matrix to obtain global context information between each entity pair.
[0011] In a possible implementation, the entity cross-attention module is used to perform entity relationship cross-recognition on the feature representation matrix to obtain global context information features between each entity pair, including: The feature representation matrix is calculated using a preset attention calculation formula, which is:
[0012] in, Entity pairs identified for a single criss-cross attention module The entity pair relationship matrix, In the horizontal direction k Entity pair of columns right The attention score, Indicates the vertical direction l Entity pair of rows right The attention score, are preset learnable parameters; The entity pair relationship matrices of entity pairs identified by multiple cross-attention modules are integrated to obtain global context information features between the entity pairs.
[0013] In a possible implementation, the classifying the global context information features to obtain the relationship between the entity pairs includes: A nonlinear activation function is used to map the entity pairs and the global context information features of each entity pair to obtain rich entity features of each entity pair; The rich entity features are classified using a preset classifier to obtain the relationship between each entity pair.
[0014] In a possible implementation, the nonlinear activation function is used to map the entity pairs and the global context information features of each entity pair to obtain the enriched entity features of each entity pair, including:
[0015]
[0016]
[0017] in, , For entity pairs The rich entity features, tanh is a nonlinear activation function, is the sigmoid activation function, For entity pairs The global context information features, For entity pairs Existence relationship r The probability of , , and These are all preset hyperparameters.
[0018] The present invention also provides a document-level relationship extraction device, comprising: A document encoding module, used to encode the document to be processed to obtain a contextual embedding representation of each entity in the document to be processed; A correlation matrix calculation module, used for calculating the relationship correlation matrix between each entity pair based on the context embedding representation of each entity; A feature extraction module, used to extract features from the relationship correlation matrix using a semantic segmentation network to obtain global context information features between each of the entity pairs; A classification module is used to classify the global context information features to obtain the relationship between each entity pair.
[0019] The present invention also provides an electronic device, comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the document-level relationship extraction method described in any of the above embodiments.
[0020] The present invention also provides a computer-readable storage medium for storing a computer-readable program or instruction, which, when executed by a processor, can implement the steps in the document-level relationship extraction method described in any of the above embodiments.
[0021] The beneficial effects of the present invention are as follows: the document-level relationship extraction method provided by the present invention obtains the context embedding representation of each entity in the document by encoding the document, and then calculates the relationship correlation matrix between each entity pair based on the context embedding representation of each entity pair, and then performs feature extraction on the relationship correlation matrix to obtain the global context information features between the entity pairs, and classifies the global context information features to obtain the relationship between the entity pairs. The present invention can more comprehensively integrate context information of different scales, help to more accurately classify entity relationships, can generate more discriminative features, improve the accuracy of relationship classification, and more accurately extract document-level relationships when processing documents with complex entity relationships and long-distance dependencies. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 A flowchart of a document-level relationship extraction method provided by an embodiment of the present invention; Figure 2 A flowchart of a context embedding representation acquisition method provided by an embodiment of the present invention; Figure 3 A flowchart of a method for acquiring global context information features provided by an embodiment of the present invention; Figure 4 A schematic diagram of the structure of the Doc-Unified Segmentation Module provided in an embodiment of the present invention; Figure 5A schematic diagram of the structure of a single cross-attention module provided by an embodiment of the present invention; Figure 6 A schematic diagram of a flow chart of a relationship classification method provided by an embodiment of the present invention; Figure 7 A schematic diagram of the structure of a document-level relationship extraction device provided by an embodiment of the present invention; Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of the present invention and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0025] Reference to an "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The appearance of the phrase in various places 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.
[0026] A specific embodiment of the present invention, as Figure 1 As shown, a document-level relationship extraction method is disclosed, comprising: S101, encoding the document to be processed to obtain a contextual embedding representation of each entity in the document to be processed; S102, calculating the relationship correlation matrix between each entity pair based on the context embedding representation of each entity; S103, using a semantic segmentation network to extract features from the relationship correlation matrix to obtain global context information features between each entity pair; S104, classifying the global context information features to obtain the relationship between each entity pair.
[0027] In the embodiment of the present invention, the extraction of document-level relations is essentially the classification of multi-label relations of entity pairs in the document. Given a document D, the entity set in D is defined as , each entity There may be multiple entity references in D, which can be recorded as , for entity pairs ,in, , there may be multiple relationship sets, and the present invention can extract the relationship sets.
[0028] In an embodiment of the present invention, encoding the document to be processed refers to encoding the words in the document to be processed so as to divide the words in the document to be processed. An entity in a document refers to a word or phrase with a specific meaning in the document, such as a name of a person, a place name, an organization, etc. An entity may have multiple references in a text. Therefore, it is necessary to encode the document to be processed first, divide the words, and then recognize the words to obtain a contextual embedding representation of each entity.
[0029] Furthermore, there are multiple entities in the document to be processed. When extracting the relationship between entities, it is necessary to first construct entity pairs. Specifically, all entities can be paired one by one to obtain multiple entity pairs, and then the relationship correlation matrix between each entity pair is calculated. The specific calculation method of the relationship correlation matrix will be described in detail later in the present invention.
[0030] In an embodiment of the present invention, a semantic segmentation network can be used to extract features from the calculated relationship correlation matrix of each entity pair. The relationship correlation matrix of an entity pair is taken as a pixel of an image, and the pixels of the image are segmented using a semantic segmentation network. The feature representations at different scales are fused to obtain shallow detail features and deep semantic features, thereby obtaining global context information features between each entity pair.
[0031] Finally, the global context information features of each entity pair are classified to determine whether there is a relationship between each entity pair and the category of the relationship, so as to realize the extraction of document-level relationships.
[0032] The document-level relationship extraction method provided by the present invention encodes the document to obtain the context embedding representation of each entity in the document, then calculates the relationship correlation matrix between each entity pair based on the context embedding representation of each entity pair, then performs feature extraction on the relationship correlation matrix to obtain the global context information features between the entity pairs, and classifies the global context information features to obtain the relationship between the entity pairs. The present invention can more comprehensively integrate context information of different scales, help to more accurately classify entity relationships, can generate more discriminative features, improve the accuracy of relationship classification, and more accurately extract document-level relationships when processing documents with complex entity relationships and long-distance dependencies.
[0033] As a possible implementation mode of the present invention, in this implementation mode, Figure 2 As shown, the document to be processed is encoded to obtain the contextual embedding representation of each entity in the document to be processed, including: S201, using a preset encoder to insert a marker symbol before and after each word in the document to be processed to obtain an embedded representation of each word; S202, using logsumexp pooling to aggregate multiple embedded representations of an entity to obtain a context embedded representation of an entity.
[0034] In the embodiment of the present invention, when encoding the document to be processed, a preset encoder may be used. ,in, Identify the kth word in document D. The same entity may appear multiple times in the document, and may appear in the same or different words or phrases, but all refer to the same entity. Such words or phrases are called entity references. For each entity, marker symbols are inserted before and after the entity reference. The document with symbols is encoded using a pre-trained encoder to obtain the contextual embedding representation of the entity. For an entity, it may have multiple references. Logsumexp pooling (a smoothed version of the maximum pooling process) can be used to pool all references to obtain the contextual embedded representation of a single entity:
[0035] in, Indicates The contextual embedding representation of each entity, Representing Entities The entity refers to the quantity.
[0036] The pooling method in the embodiment of the present invention aims to improve the comprehensive modeling of entity semantic information and enhance the model's representation effect on entity meaning. Different references may capture the semantic information of entities in different contexts. The use of a smooth maximum pooling strategy can comprehensively consider the contribution of each reference and avoid excessive reliance on a specific reference, thereby more comprehensively reflecting the semantic information of the entity.
[0037] As a possible implementation of the present invention, in this implementation, the relationship correlation matrix between each entity pair is calculated based on the context embedding representation of each entity, including: The relationship correlation matrix calculation formula is used to calculate the relationship correlation matrix between each entity pair. The relationship correlation matrix calculation formula is:
[0038] in, For entity pairs The relationship correlation matrix, is the preset learnable model matrix, is the transpose of the context embedding matrix of all words in the document to be processed, and softmax is the preset activation function. L is the number of attention heads of the encoder, is the i-th attention head of the encoder for the entity pair The importance score of the recognition result.
[0039] In an embodiment of the present invention, based on the multi-head attention mechanism of a preset encoder, multiple entity pairs are mapped into a relationship correlation matrix between entity pairs, thereby enhancing the contextual connection between entity pairs, so that the model can better understand the relationship between entity pairs.
[0040] As a possible implementation mode of the present invention, Figure 3 As shown in the figure, a semantic segmentation network is used to extract features from the relationship correlation matrix to obtain the global context information features between each entity pair, including: S301, using a preset Unet++ semantic segmentation network to perform feature extraction on the relationship correlation matrix of all entity pairs, and obtain a feature representation matrix containing deep information and shallow information of each entity pair; S302, using the entity cross-attention module to perform entity relationship cross-recognition on the feature representation matrix to obtain global context information between each entity pair.
[0041] In the embodiment of the present invention, after calculating the relationship correlation matrix between each entity pair, the relationship correlation matrix of each entity pair is used as a pixel of the image, and all relationship correlation matrices of all entity pairs are used as the image, such as Figure 4 As shown in the figure, the Doc-Unified Segmentation Module uses the Unet++ network structure based on Encoder-Decoder and the Unet++ semantic segmentation network for feature extraction. The Unet++ semantic segmentation network includes an encoder and a decoder. The encoder includes a series of convolution units and downsampling modules, which are responsible for extracting and capturing a wider range of contextual information and abstract features from the input features. The decoder consists of an upsampling module and a series of convolution units, which can enlarge the spatial size of the feature map so that small features and boundary information can be retained. Each convolution unit includes a 3×3 Convolution kernel, Batch Normalization, LeakyReLU, etc. The downsampling operation uses the maximum pooling operation, and the upsampling is implemented using the bilinear interpolation method. In addition, the network also introduces a large number of dense jump connections between the convolution units, connecting the same layer in the corresponding encoder and decoder, allowing information to flow between different scales, so that feature information can flow directly from the encoder (downsampling) to the decoder (upsampling), retaining more contextual information. The output of each convolution unit is represented as follows:
[0042] in, Represents the number of i Layer j The output of the convolutional unit, i , j All start from 0. Conv () includes Batch Normalization operation, ReLU function, and Convolution kernel operation. Concat () indicates the Concatenation operation, Indicates from arrive A collection of Down () represents the downsampling operation in the network, Up () indicates the UpSample operation in the network.
[0043] Getting the final output Afterwards, the feature representation containing deep information and shallow information of the entity pair relationship is captured, and the process of capturing the implicit relationship and contextual information between entity pairs is summarized as follows:
[0044] in, is the feature representation matrix containing deep information and shallow information in each entity pair, is the learnable parameter matrix, b is the bias, F It is the relationship correlation matrix of entity pairs, and DUS is Doc-Unified Segmentation Module.
[0045] The embodiment of the present invention uses the relationship correlation matrix of entity pairs as pixels in an image and uses a model to perform feature extraction, thereby obtaining a feature representation of the entity pair relationship that contains deep information and shallow information.
[0046] Furthermore, the entity cross-attention module is used to perform entity relationship cross-recognition on the feature representation matrix to obtain the global context information features between each entity pair, including: The feature representation matrix is calculated using the preset attention calculation formula, which is:
[0047] in, Entity pairs identified for a single criss-cross attention module The entity pair relationship matrix, In the horizontal direction k Entity pair of columns right The attention score, Indicates the vertical direction l Entity pair of rows right The attention score, are preset learnable parameters; The entity pair relationship matrices of entity pairs identified by multiple cross-attention modules are integrated to obtain the global context information features between each entity pair.
[0048] In the embodiment of the present invention, Figure 5 As shown, although a single Criss-Cross Attention module can capture global context information for each entity pair by dynamically constructing horizontal and vertical cross attention paths, it may have the problem of insufficient local information integration, making it difficult to fully capture long-distance dependencies, especially when dealing with complex document structures and entity relationships. Therefore, the entity cross attention module of the present invention is formed by connecting two layers of Criss-CrossAttention through a residual network. By capturing global context information layer by layer, the two layers of Criss-CrossAttention allow the model to explore the relationship in the document more deeply and improve the grasp of the relevance between entities. This progressive global context information capture mechanism helps the model better understand the semantic structure and entity relationship in the document, and improves the modeling ability of long-distance dependencies. In addition, the two layers of Criss-Cross Attention can effectively utilize global information without excessively increasing computational complexity and information redundancy. Such a design improves performance while maintaining the computational efficiency and generalization ability of the model. Too many levels may lead to increased information redundancy and computational complexity, thereby reducing the generalization ability of the model. Therefore, by introducing two layers of Criss-Cross Attention, the model improves the global information integration ability and complex relationship modeling ability while maintaining high efficiency, enabling it to more accurately and deeply understand the complex interactions and dependencies between entity pairs, thereby enhancing the feature representation of each entity pair.
[0049] Further, such as Figure 6 As shown, the global context information features are classified to obtain the relationship between each entity pair, including: S601, using a nonlinear activation function to map entity pairs and global context information features of each entity pair to obtain rich entity features of each entity pair; S602: Use a preset classifier to classify the enriched entity features to obtain the relationship between each entity pair.
[0050] In the embodiment of the present invention, for a given entity pair The context embedded representation and the features obtained after two-stage processing of the semantic segmentation network processing module and the entity cross attention module are used to obtain the nonlinear activation function tanh () mapping to obtain the rich entity features of the corresponding entity pair, and finally obtain the entity pair using the classifier The relationship category of
[0051]
[0052]
[0053] in, , For entity pairs The rich entity features of tanh is a nonlinear activation function, for sigmoid Activation function, For entity pairs The global context information features, For entity pairs Existence relationship r The probability of , , and These are all preset hyperparameters.
[0054] The document-level relationship extraction method provided by the present invention encodes the document to obtain the context embedding representation of each entity in the document, then calculates the relationship correlation matrix between each entity pair based on the context embedding representation of each entity pair, then performs feature extraction on the relationship correlation matrix to obtain the global context information features between the entity pairs, and classifies the global context information features to obtain the relationship between the entity pairs. The present invention can more comprehensively integrate context information of different scales, help to more accurately classify entity relationships, can generate more discriminative features, improve the accuracy of relationship classification, and more accurately extract document-level relationships when processing documents with complex entity relationships and long-distance dependencies.
[0055] In order to better implement the document-level relationship extraction method in the embodiment of the present invention, based on the document-level relationship extraction method, correspondingly, Figure 7 As shown, the embodiment of the present invention further provides a document-level relationship extraction device, and the document-level relationship extraction device 700 includes: The document encoding module 701 is used to encode the document to be processed and obtain the context embedding representation of each entity in the document to be processed; A correlation matrix calculation module 702 is used to calculate the relationship correlation matrix between each entity pair based on the context embedding representation of each entity; A feature extraction module 703 is used to extract features from the relationship correlation matrix using a semantic segmentation network to obtain global context information features between each entity pair; The classification module 704 is used to classify the global context information features to obtain the relationship between each entity pair.
[0056] The document-level relationship extraction device 700 provided in the above embodiment can implement the technical solution described in the above document-level relationship extraction method embodiment. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above document-level relationship extraction method embodiment, which will not be repeated here.
[0057] like Figure 8 As shown, the present invention also provides an electronic device 800. The electronic device 800 includes a processor 801, a memory 802 and a display 803. Figure 8 Only some components of the electronic device 800 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0058] In some embodiments, the processor 801 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 802, such as the document-level relationship extraction method of the present invention.
[0059] In some embodiments, the processor 801 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, the processor 801 may be local or remote. In some embodiments, the processor 801 may be implemented in a cloud platform. In some embodiments, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, a multi-cloud, etc., or any combination thereof.
[0060] In some embodiments, the memory 802 may be an internal storage unit of the electronic device 800, such as a hard disk or memory of the electronic device 800. In other embodiments, the memory 802 may also be an external storage device of the electronic device 800, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 800.
[0061] Furthermore, the memory 802 may include both an internal storage unit of the electronic device 800 and an external storage device. The memory 802 is used to store application software installed in the electronic device 800 and various data.
[0062] In some embodiments, the display 803 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 803 is used to display information of the electronic device 800 and to display a visual user interface. The components 801-803 of the electronic device 800 communicate with each other via a system bus.
[0063] In some embodiments, when the processor 801 executes the document-level relationship extraction program in the memory 802, the following steps may be implemented: Encode the document to be processed to obtain the contextual embedding representation of each entity in the document to be processed; Calculate the relationship correlation matrix between each entity pair based on the contextual embedding representation of each entity; The semantic segmentation network is used to extract features from the relationship correlation matrix to obtain the global context information features between each entity pair; The global context information features are classified to obtain the relationship between each entity pair.
[0064] It should be understood that: when the processor 801 executes the document-level relationship extraction program in the memory 802, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.
[0065] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 800 mentioned, and the electronic device 800 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 800 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0066] Correspondingly, an embodiment of the present invention also provides a computer-readable storage medium, which is used to store computer-readable programs or instructions. When the program or instructions are executed by a processor, it can implement the steps or functions of the document-level relationship extraction method provided in the above-mentioned method embodiments.
[0067] Those skilled in the art can understand that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0068] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A document-level relationship extraction method, characterized in that: include: Encode the document to be processed to obtain a contextual embedding representation of each entity in the document to be processed; Calculate the relationship correlation matrix between each entity pair based on the context embedding representation of each entity; Using a semantic segmentation network to extract features from the relationship correlation matrix to obtain global context information features between each of the entity pairs; The global context information features are classified to obtain the relationship between each of the entity pairs.
2. The document-level relationship extraction method according to claim 1, characterized in that: The step of encoding the document to be processed to obtain a contextual embedding representation of each entity in the document to be processed includes: Use a preset encoder to insert marker symbols before and after each word in the document to be processed to obtain an embedded representation of each word; Logsumexp pooling is used to aggregate multiple embedded representations of an entity to obtain a contextual embedded representation of the entity.
3. The document-level relationship extraction method according to claim 2, characterized in that: The calculating the relationship correlation matrix between each entity pair based on the context embedding representation of each entity includes: The relationship correlation matrix calculation formula is used to calculate the relationship correlation matrix between each entity pair. The relationship correlation matrix calculation formula is: in, For entity pairs The relationship correlation matrix, is the preset learnable model matrix, is the transpose of the context embedding matrix of all words in the document to be processed, and softmax is the preset activation function. L is the number of attention heads of the encoder, The encoder i Attention head for entity pair The importance score of the recognition result.
4. The document-level relationship extraction method according to claim 3 is characterized in that: The method of using a semantic segmentation network to extract features from the relationship correlation matrix to obtain global context information features between each of the entity pairs includes: The preset Unet++ semantic segmentation network is used to extract features from the relationship correlation matrix of all entity pairs, and the feature representation matrix containing deep information and shallow information of each entity pair is obtained; An entity cross-attention module is used to perform entity relationship cross-recognition on the feature representation matrix to obtain global context information between each entity pair.
5. The document-level relationship extraction method according to claim 4, characterized in that: The entity cross attention module is used to perform entity relationship cross recognition on the feature representation matrix to obtain global context information features between each entity pair, including: The feature representation matrix is calculated using a preset attention calculation formula, which is: in, Entity pairs identified for a single criss-cross attention module The entity pair relationship matrix, In the horizontal direction k Entity pair of columns right The attention score, Indicates the vertical direction l Entity pair of rows right The attention score, are preset learnable parameters; The entity pair relationship matrices of entity pairs identified by multiple cross-attention modules are integrated to obtain global context information features between the entity pairs.
6. The document-level relationship extraction method according to claim 5, characterized in that: The classifying the global context information features to obtain the relationship between the entity pairs includes: A nonlinear activation function is used to map the entity pairs and the global context information features of each entity pair to obtain rich entity features of each entity pair; The rich entity features are classified using a preset classifier to obtain the relationship between each entity pair.
7. The document-level relationship extraction method according to claim 6, characterized in that: The nonlinear activation function is used to map the entity pairs and the global context information features of each entity pair to obtain the rich entity features of each entity pair, including: in, , For entity pairs The rich entity features, tanh is a nonlinear activation function, is the sigmoid activation function, For entity pairs The global context information features, For entity pairs Existence relationship r The probability of , , and These are all preset hyperparameters.
8. A document-level relationship extraction device, characterized in that: include: A document encoding module, used to encode the document to be processed to obtain a contextual embedding representation of each entity in the document to be processed; A correlation matrix calculation module, used for calculating the relationship correlation matrix between each entity pair based on the context embedding representation of each entity; A feature extraction module, used to extract features from the relationship correlation matrix using a semantic segmentation network to obtain global context information features between each of the entity pairs; A classification module is used to classify the global context information features to obtain the relationship between each entity pair.
9. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the document-level relationship extraction method described in any one of claims 1 to 7 above.
10. A computer-readable storage medium, characterized in that: Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps in the document-level relationship extraction method described in any one of claims 1 to 7 above.