A document-level relationship extraction method based on path reasoning graph
By constructing document graph structure and entity path inference graph, using R-GCN and feedforward neural network for relationship prediction, the problem of low accuracy in document-level relationship extraction, especially the problems of long-distance dependence and redundant information processing, Significantly improves model performance.
Patent Information
- Application Number
- CN202411286301.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-09-13
AI Technical Summary
The prior art has problems with low accuracy in document-level relationship extraction, especially the difficulty in long-distance dependence and redundant information processing, which leads to difficulties in entity and relationship extraction.
Using a path inference graph based method, the entity path inference graph structure is constructed, including mentioning nodes, entity nodes, sentence nodes and different types of edges, and using R-GCN and feedforward neural network for relationship prediction. Combined with the cross loss entropy function, the prediction process is optimized.
It improves the accuracy of document-level relationship extraction, overcomes the difficulties of long-distance dependence and redundant information processing, and improves model performance.
Smart Images

Figure CN118798369B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and in particular relates to a document-level relationship extraction method based on a path reasoning graph. Background Art
[0002] Relation extraction (RE) is the task of predicting the relationships between named entities in plain text. It is an effective way to automatically acquire structured knowledge, which is beneficial to various natural language processing (NLP) applications, especially the construction of knowledge graphs. Most of the previous RE works focused on the sentence level, that is, they only extracted relations in a sentence. In real scenarios, sentence-level RE models may ignore some inter-sentence relations, and quite a few relationship representations, in addition to a single sentence, also span multiple sentences in a long document. According to the expression habits of natural language, it is also very common for entity pairs to be located in different sentences. Therefore, it is necessary and important to study document-level relationship extraction. Compared with sentence-level relationship extraction, document-level relationship extraction is more complex and challenging, mainly in the following aspects:
[0003] (1) Multi-entity relations: Document-level relation extraction needs to consider the relations between multiple entities in a document, which increases the complexity of the task. Compared with sentence-level relation extraction, document-level relation extraction needs to identify and model cross-sentence relations between entities, and there may be multiple interweaving and complexity of entity relations in long documents.
[0004] (2) Context modeling: Document-level relationship extraction requires making full use of the contextual information of the document to understand entity relationships. The context in the document can provide important clues about entity identity, entity attributes, and relationship types. However, context modeling faces challenges such as document length, information masking, and semantic complexity, making it difficult to accurately extract relationships.
[0005] (3) Multiple mentions: An entity may be mentioned in multiple sentences, and the names of the mentions may be different.
[0006] (4) The relationship between subject and object needs to be inferred.
[0007] To obtain the relationship type between document-level entities requires more complex reasoning capabilities, including logical reasoning, co-reference reasoning, and common sense reasoning. Another type of relationship requires pattern matching to obtain. Existing methods usually convert documents into graph structures, model complex information such as sentences, entities, and mentions in the documents, and then extract multiple entities and multiple relationships in long documents. During the extraction process, it is difficult to find implicit information between entities, mentions, and sentences, and lacks certain reasoning capabilities; there is a lot of redundant information in long documents, making it difficult to extract valuable entities and relationships; the entities in long documents are far apart, making it difficult to overcome the problem of long-distance dependence, etc., resulting in low extraction accuracy in existing technologies. Summary of the invention
[0008] In view of the above problems, the present invention provides a document-level relationship extraction method based on a path reasoning graph, which overcomes the above problems or at least partially solves the above problems.
[0009] In order to solve the above technical problems, the present invention provides a document-level relationship extraction method based on path reasoning, the method comprising the steps of:
[0010] Step S1, obtaining a given document, performing data preprocessing on text data of the given document, and obtaining encoding features of the given document;
[0011] Step S2, constructing a document graph structure G according to the encoding features, including three types of nodes and four types of edges, wherein the three types of nodes include: mention nodes, entity nodes, and sentence nodes; the four types of edges include: mention-mention edges, mention-entity edges, entity-sentence edges, and sentence-sentence edges;
[0012] Step S3, constructing an entity path reasoning path based on the document graph structure G, and then constructing an entity path reasoning graph g;
[0013] Step S4, adding a new node to the entity path reasoning graph, connecting the new node to the two target entity nodes whose relationships need to be predicted, so that the added new node aggregates the information of the target entity node and its subordinate mention nodes, and at the same time, the sentence node aggregates the information of all entity nodes and mention nodes in the entity reasoning graph;
[0014] Step S5, obtain and connect the target entity node embedding information, the new node embedding information, all traversed sentence node embedding information and the relative distance information of the target entity node embedding, and input them into the feedforward neural network to realize the prediction of the relationship between the two target entity nodes.
[0015] Furthermore, the specific implementation of step S1 is as follows:
[0016] Given a document D= , which consists of N sentences and contains M entities E= , each entity It is indicated by the mention of P in the sentence;
[0017] First, concatenate word embedding and entity type embedding as word express:
[0018]
[0019] in, are words and entity types, Represent word and entity type embedding layers respectively;
[0020] Then use the pre-trained language model to encode, obtain the encoding features, and generate the vector sequence corresponding to the given document D :
[0021] =Encoder([ , ... ])
[0022] Among them, Encoder () is the BERT model, K is the total number of words, and k is the word number.
[0023] Furthermore, the mention node represents the mention in a given document D. The representation of is achieved by averaging the representations of the words that make up the mention:
[0024]
[0025] in, A representation representing a mentioned node, Contains the mentioned node The representation of all words in , Represents a word, represents the mentioned node, Avg() represents the average function, i is the node number, and k is the word number;
[0026] An entity node represents an entity in a given document D. The representation of is achieved by averaging the representations of the mentions of its constituent entities:
[0027]
[0028] in, represents the representation of the entity node, A representation representing a mentioned node, Contains entity nodes All the indications mentioned in Represents the mentioned node, Represents an entity node;
[0029] Sentence nodes represent sentences in a given document D. The representation of is achieved by averaging the representations of the contained words:
[0030]
[0031] in, represents the representation of a sentence node, Contains the sentence The representation of all words in , Represents a word, Represents a sentence node.
[0032] Furthermore, the mention-mention edge indicates that when two mentions refer to the same entity, a mention edge is added to model the co-citation interaction between the mentions;
[0033] Mention-entity edges connect a mention node to an entity node when the mention is associated with an entity, in order to model the co-reference of the mentions.
[0034] Entity-sentence edge means that when a mention is in a sentence, the mention and its sentence form an edge from the mention to the sentence.
[0035] Sentence-sentence edges mean that when two sentences contain the same entity, the two sentence nodes are connected, and edges are only added between two adjacent sentence nodes of corresponding sentences in the document to maintain the order information.
[0036] Furthermore, the entity path reasoning graph is constructed as follows:
[0037] First construct three types of paths:
[0038] Intra-sentence reasoning path: The relationship between two entities appears in the same sentence at the same time. The intra-sentence reasoning path models two types of reasoning: pattern recognition and common sense reasoning. These two reasoning paths perform reasoning within a sentence.
[0039] Inter-sentence reasoning path: For two entities that are not mentioned in the same sentence, the inter-sentence reasoning path is used to model the relationship between them. It is regarded as adding an additional bridge to the intra-sentence reasoning path. Depending on the type of bridge, logical reasoning paths and co-reference reasoning paths are introduced;
[0040] Direct reasoning path: other situations that do not conform to the intra-sentence reasoning path and inter-sentence reasoning path are represented by direct reasoning paths. For each group of entity pairs with multiple paths, at most q paths are saved, where q is a constant.
[0041] Then a closed entity path reasoning graph g is extracted around the entity pairs in the document graph structure G to integrate different paths. Specifically, the entity path reasoning graph g consists of nodes that appear at least once on the path and all edges between these nodes in G.
[0042] Furthermore, given a node Q at layer l, the R-GCN at layer L is used to pass messages to each layer in the entity path reasoning graph. The embedded information of Q is defined as:
[0043]
[0044] in, represents the embedding representation of node Q after being processed by l+1 layers of R-GCN, is an activation function, , are the representations of Q and u nodes at layer l, represents the total set of edges of different types, represents the neighbor set of node Q connected to edge t, u is the neighbor node of node Q, | | indicates The model, , is a trainable parameter.
[0045] Furthermore, the two target entity nodes whose relationships need to be predicted are set as and , m and n are the numbers of the target entity nodes, then (1) the target entity node embedding The linear combination of provides the global entity perception information of the target entity pair; Represents a connection operation, , Respectively represent the embedding information of the target entity node; (2) the newly added node embedding , providing local entity-aware information of the target entity pair; (3) all traversed sentence node embeddings ;in Represents a sentence node The embedding representation of Contains the representation of all sentences in the entity path reasoning graph g; (4) The relative distance of the target entity node embedding , Indicates the first mention from a given document arrive The relative distance embedding, is the relative distance embedding layer, and then the connection is transferred through the FFNN as:
[0046]
[0047] Among them, r is the target entity pair The relationship label vector between is the target entity pair The probability value of the relationship, It is a feed-forward neural network.
[0048] Furthermore, the cross-loss entropy function is used to optimize the prediction process. The loss function is as follows:
[0049]
[0050] in is the value of the loss function, where Represents an indicator function. When the condition in the brackets is met, the value is 1, and if not, it is 0.
[0051] The relationship extraction method based on path reasoning provided by the present invention has the following beneficial effects: the present invention aggregates the context information of the entire document by constructing a document graph, adds new nodes to aggregate the information around the target entity, and constructs an entity reasoning path graph to infer the relationship between long-distance entities, thereby improving the performance of the model in document-level relationship extraction and solving the defect of low long-distance extraction accuracy in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A flowchart of the technical solution provided for an embodiment of the present invention.
[0053] Figure 2 A schematic diagram of path reasoning provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0055] Please see attached Figure 1 , Figure 1 This is a technical solution flow chart of a document-level relationship extraction method based on path reasoning provided by the implementation use case, which specifically includes the following steps:
[0056] Step S1: Obtain a given document. Preferably, the given document is a document-level relation extraction dataset prepared in advance. The text data in the given document includes entities, relations, and supporting evidence of entity co-references and relation instances in the document.
[0057] Where, given document D= , which consists of N sentences and contains M entities E= , and the task of document-level relation extraction is to predict the relationship r between each entity pair, where r R( , ), R is a pre-established set of relations, and Refers to the head entity and the tail entity respectively. Each of the entities can be represented by a mention P in a sentence. When it (the relation) is represented by any pair of their mentions, then r has an entity between.
[0058] Step S2: Perform data preprocessing on the text data of a given document to obtain the encoding features of the given document.
[0059] First, concatenate word embeddings and entity type embeddings as word representations:
[0060]
[0061] in, are words and entity types, Represent word and entity type embedding layers respectively.
[0062] Then, the given document is encoded using a pre-trained language model to obtain encoding features. The pre-trained language model is a BERT model. Preferably, the BERT model is used to encode the entire document of the given document to generate the corresponding vector sequence. :
[0063] =Encoder([ , ... ])
[0064] Among them, Encoder () is the BERT model, and K is the total number of words.
[0065] Step S3: construct the document into a document graph structure G.
[0066] Furthermore, the document graph structure G includes: mention nodes, entity nodes, sentence nodes; mention-mention edges, mention-entity edges, entity-sentence edges, sentence-sentence edges;
[0067] The mention node represents the mention in document D. The representation of is achieved by averaging the representations of the words that make up the mention:
[0068]
[0069] Among them, represents the representation of the mentioned node, which contains the representations of all words in the mentioned node, represents a word, represents the mentioned node, Avg() represents the averaging function, i is the node number, and k is the word number. A mentioned node is composed of one, two, or more words. A mentioned node is another expression form of an entity node. For example, Shanghai is an entity node, and "Hu" is equivalent to its mentioned node.
[0070] The entity node represents an entity in document D. The representation of the entity node is achieved by averaging the representations of the mentions that make up the entity:
[0071]
[0072] Among them, represents the representation of the entity node, represents the representation of the mentioned node, which contains the representations of all mentions in the entity node, represents the mentioned node, represents the entity node.
[0073] The sentence node represents a sentence in document D. The representation of the sentence node is achieved by averaging the representations of the words it contains:
[0074]
[0075] Among them, represents the representation of the sentence node, which contains the representations of all words in the sentence, represents a word, represents the sentence node.
[0076] Furthermore, the document graph structure G contains the following four types of edges to capture the contextual relationships existing among entities, mentions, and sentences in the document. The above four types of edges include: mention-mention edge, mention-entity edge, entity-sentence edge, and sentence-sentence edge.
[0077] The specific construction method is as follows:
[0078] Mention-mention edge: When two mentions refer to the same entity, add a mention edge to model the coreference interaction between the mentions;
[0079] Mention-entity edges: When a mention is associated with an entity, connect the mention node to the entity node to model the co-reference of the mentions;
[0080] Entity-sentence edge: When a mention is in a sentence, the mention forms a sentence-to-mention edge with the sentence it is in.
[0081] Sentence-sentence edges: connect two sentence nodes if they contain the same entity; and only add edges between two sentence nodes that are adjacent to each other in the document to preserve order information.
[0082] Step S4: construct entity reasoning path;
[0083] Furthermore, the present invention predicts relations by focusing on related entities, mentions, and sentences. To this end, the present invention assumes that the path between two target entities (i.e., the two entities whose relations need to be predicted) and other nodes between the target entity paths are part of all nodes provide sufficient information to determine these relations. In order to achieve the modeling of relational paths in view of the problems of existing path construction methods, this paper introduces the following reasoning paths, which connect the two target entities and explicitly model the following entity paths. Three types of paths are included in the entity reasoning path graph:
[0084] Intra-sentence reasoning path: The relationship between two entities appears in the same sentence at the same time. The intra-sentence reasoning path models two types of reasoning: pattern recognition and common sense reasoning. These two reasoning paths usually perform reasoning within a sentence.
[0085] Inter-sentence reasoning path: For two entities that are not mentioned in the same sentence, we use the inter-sentence reasoning path to model the relationship between them. It can be thought of as adding an additional bridge to the intra-sentence reasoning path, such as Figure 2 According to different bridge types, the present invention introduces a logical reasoning path and a co-reference reasoning path.
[0086] Direct reasoning path: Since there is no entity bridge between mention pairs, the present invention designs an additional direct reasoning path to meet the situation where the mention pairs do not conform to the intra-sentence reasoning path and the inter-sentence reasoning path. Assuming that entities A and B exist in different sets, and entity A and entity B have i mentions and j mentions respectively, there are at most i×j direct reasoning paths. For the case where there are multiple paths for each set of entity pairs, we save at most 3 for each reasoning path.
[0087] Step S5: construct an entity path reasoning graph;
[0088] Furthermore, a closed entity path reasoning graph g is extracted around the entity pairs in the document graph structure G to integrate different paths. Specifically, the entity path reasoning graph g consists of nodes that appear at least once on the path and all edges between these nodes in G.
[0089] Step S6: encoding of entity path reasoning graph;
[0090] Furthermore, we add a new node Q to the entity path reasoning graph and connect it to the target entity node in the reasoning graph. Then, we use the L-layer R-GCN to perform message passing on each layer in the reasoning graph. This process considers different types of edges, including mention-mention edges, mention-entity edges, entity-sentence edges, and sentence-sentence edges. This process enables the new node Q to aggregate the information of the target entity node and its subordinate mention nodes, while enabling the sentence node to aggregate the information of all entity nodes and mention nodes in the reasoning graph. Given a node Q at the lth layer, the aggregation of Q's neighbors is defined as:
[0091]
[0092] in, represents the representation of node Q after being processed by l+1 layers of R-GCN, is an activation function, , are the representations of Q and u nodes at layer l, represents the total set of edges of different types, represents the edge t (where t ) is the neighbor set of node Q connected to it, u is the neighbor node of node Q, | | indicates The model, , is a trainable parameter.
[0093] Step S7: making final prediction in the classification module, the classification module is a FFNN feed-forward neural network;
[0094] Furthermore, in order to calculate the entity pair ( , ), we use information from the pre-trained language model FFNN feedforward neural network and entity path reasoning graph, and connect the following representations: (1) Initial target entity node embedding The linear combination of provides the global entity perception information of the target entity pair; Represents a connection operation, Represents the embedding information of the target entity node. (2) The embedding of the new node added , providing local entity-aware information of the target entity pair; (3) all traversed sentence node embeddings ;in Represents a sentence node The embedding representation of Contains the representation of all sentences in the entity path reasoning graph g; (4) Relative distance embedding of entity embedding , represents the relative distance of the first mention of the target entity pair in the document, is a relative distance embedding layer, and then the connected representation is passed through the FFNN:
[0095]
[0096] For model training, the present invention uses a cross-loss entropy function to optimize the target. The loss function is as follows:
[0097]
[0098] in is the value of the loss function, where Represents an indicator function. When the condition in the brackets is met, the value is 1, and if it is not met, the value is 0. is the target entity pair The relationship label vector between is the target entity pair The probability value of the relationship.
[0099] Above, refer to Figures 1-2 A document-level relationship extraction method based on a heterogeneous graph convolutional neural network according to an embodiment of the present invention is described, which has the following beneficial effects: the present invention extracts contextual information between entities, mentions, and sentences by constructing a document graph, and constructs an entity reasoning graph to reason about the paths between entities, thereby improving the performance of the model in document-level relationship extraction and solving the problem of excessive distance between entities in existing relationship extraction.
[0100] The effect of the present invention is illustrated below through experimental results on the DocRED dataset and biomedical datasets (CDR and GDA). Table 1 compares the results of the method of the present invention with those of the existing models, where the bold parts are the results of this experiment.
[0101] 1 is the comparison between the results of the method of the present invention and the existing model
[0102]
[0103] The following are the literature sources of each model in Table 1:
[0104] Convolutional neural network CNN comes from the literature Yuan Yao, Deming Ye, Peng Li, Xu Han, YankaiLin, Zhenghao Liu, Zhiyuan Liu, Lixin Huang, Jie Zhou, and Maosong Sun.Docred: A large-scale document-level relation extraction dataset. InProceedings of the 57th An- nual Meeting of the Association for ComputationalLinguistics, pages 764– 777, 2019.
[0105] Long Short-Term Memory Network LSTM Source Literature Yuan Yao, Deming Ye, Peng Li, Xu Han, YankaiLin, Zhenghao Liu, Zhiyuan Liu, Lixin Huang, Jie Zhou, and Maosong Sun.Docred: A large-scale document-level relation extraction dataset. InProceedings of the 57th An- nual Meeting of the Association for ComputationalLinguistics, pages 764– 777, 2019.
[0106] Bidirectional long short-term memory network BiLSTM-Glove Source literature Yuan Yao, Deming Ye, Peng Li, Xu Han, YankaiLin, Zhenghao Liu, Zhiyuan Liu, Lixin Huang, Jie Zhou, and Maosong Sun. Docre: A large-scale document-level relation extraction dataset. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 764– 777, 2019.
[0107] Hierarchical inference network HIN-Glove Source document Hengzhu Tang, Yanan Cao, Zhenyu Zhang, Jiangxia Cao, Fang Fang, Shi Wang, and Pengfei Yin. Hin: Hierarchical inference network for document- level relation extraction. Advances in Knowledge Discovery and Data Min- ing, 12084:197 – 209, 2020.
[0108] Document-level neural relation extraction with edge-oriented graphs EOG source literature Fenia Christopoulou, Makoto Miwa, and Sophia Ananiadou. Connecting the dots: Document-level neural relation extraction with edge-oriented graphs. In Conference on Empirical Methods in Natural Language Processing, 2019.
[0109] Graph enhanced dual attention network for document-level relation extension. In International Conference on Computational Linguistics, 2020.
[0110] Global context-enhanced graph convolutional networks for document-level relation extraction. InInternational Conference on Com- putational Linguistics, 2020
[0111] Latent graph structure iterative optimization reasoning model LSR-Glove Source literature Guoshun Nan, ZhijiangGuo, Ivan Sekulic, and Wei Lu. Reasoning with la- tent structure refinementfor document-level relation extraction. In Annual Meeting of the Associationfor Computational Linguistics, 2020.
[0112] Graph Aggregation and Reasoning Network GAIN-Glove Source Paper Shuang Zeng, Runxin Xu, Baobao Chang, and Lei Li. Double graph based reasoning for document-level relation extraction. ArXiv, abs / 2009.13752, 2020.
[0113] SIRE-Glove, a model for separating intra- and inter-sentential reasoning, is a novel framework for document-level relation extraction. From Shuang Zeng, Yuting Wu, and Baobao Chang. Sire: Separate intra- and inter-sentential reasoning for document-level relation extraction. ArXiv, abs / 2106.01709, 2021.
[0114] Document-level relation extraction model GLRE for heterogeneous graphs Source document Difeng Wang, Wei Hu, Ermei Cao, and Weijian Sun. Global-to-local neutral networks for document-level relation extraction. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 3711–3721, 2020.
[0115] Discriminative reasoning model DRN-Glove for document-level relation extraction Source literature Wang Xu, Kehai Chen, and Tiejun Zhao. Discriminative reasoning for document-level relation extraction. In Findings of the Association for Com- putational Linguistics: ACL-IJCNLP2021, pages 1653–1663, 2021.
[0116] Path enhanced document relation extraction model path+BiLSTM Source document Quzhe Huang, ShengqiZhu, Yansong Feng, Yuan Ye, Yuxuan Lai, and Dongyan Zhao. Three sentences are all you need: Local path enhanced document relation extraction. In Annual Meeting of the Association for Computational Linguistics, 2021.
[0117] As shown in Table 1, on the DocRED dataset, the model proposed in the present invention outperforms the graph-based model GLRE by 0.72% F1 and 0.57% Ign F1 on the test set. GLRE is more effective in extracting relationships between long-distance entities when the entity distance is ≥3. The model is more effective in extracting relationships between long-distance entities when the entity distance is ≥64, and is able to predict longer-distance entity pair relationships. In addition, on the test set, the present invention outperforms the sequence-based model HIN by 4.82% F1 and 4.82% Ign F1, respectively. For path-based models, the model also achieves significant performance. The results show that the model of the present invention combines the benefits of path-based models and graph-based models, and learns more expressive features by leveraging well-designed reasoning paths and reasoning graph structures. At the same time, the model also outperforms all baseline models in intra-sentence and inter-sentence settings, which indicates that path reasoning improves the performance of inter-sentence relationship instances, and the performance of intra-sentence relationship instances is also improved.
[0118] On the biomedical datasets CDR and GDA, the proposed model achieved 71.2% F1 and 84.9% F1 on CDR and GDA, respectively, which is also better than the previous methods. In particular, compared with the above-mentioned state-of-the-art method SIRE-Glove, the proposed model achieved 0.4 and 0.2 higher F1 scores on CDR and GDA, respectively. This shows that the proposed method is also effective in document-level relation extraction in the biomedical field.
[0119] The above is a detailed introduction to the document-level relationship extraction method based on the path reasoning graph proposed in the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A document-level relationship extraction method based on path reasoning, characterized in that: The steps include: Step S1, obtaining a given document, performing data preprocessing on text data of the given document, and obtaining encoding features of the given document; Step S2, constructing a document graph structure G according to the encoding features, including three types of nodes and four types of edges, wherein the three types of nodes include: mention nodes, entity nodes, and sentence nodes; the four types of edges include: mention-mention edges, mention-entity edges, entity-sentence edges, and sentence-sentence edges; Step S3, constructing an entity path reasoning path based on the document graph structure G, and then constructing an entity path reasoning graph g; Step S4, adding a new node to the entity path reasoning graph, connecting the new node to the two target entity nodes whose relationships need to be predicted, so that the added new node aggregates the information of the target entity node and its subordinate mention nodes, and at the same time, the sentence node aggregates the information of all entity nodes and mention nodes in the entity reasoning graph; Given a node Q at layer l, the R-GCN at layer L is used to pass messages to each layer in the entity path reasoning graph. The embedding information of Q is defined as: ; in, represents the embedding representation of node Q after being processed by l+1 layers of R-GCN, is an activation function, , are the representations of Q and u nodes at layer l, represents the total set of edges of different types, represents the neighbor set of node Q connected to edge t, u is the neighbor node of node Q, | | indicates The model, , is a trainable parameter; Step S5, obtaining and connecting the target entity node embedding information, the new node embedding information, all traversed sentence node embedding information and the relative distance information of the target entity node embedding, and inputting them into the feedforward neural network to realize the prediction of the relationship between the two target entity nodes; Set the two target entity nodes whose relationships need to be predicted as and , m and n are the numbers of the target entity nodes, then (1) the target entity node embedding The linear combination of provides the global entity perception information of the target entity pair; Represents a connection operation, , Respectively represent the embedding information of the target entity node; (2) the newly added node embedding , providing local entity-aware information of the target entity pair; (3) all traversed sentence node embeddings ;in Represents a sentence node The embedding representation of Contains the representation of all sentences in the entity path reasoning graph g; (4) The relative distance of the target entity node embedding , Indicates the first mention from a given document arrive The relative distance embedding, is the relative distance embedding layer, and then the connection is transferred through the FFNN as: ; in, is the target entity pair The relationship label vector between is the target entity pair The probability value of the relationship, It is a feed-forward neural network.
2. A document-level relationship extraction method based on path reasoning as claimed in claim 1, characterized in that: The specific implementation of step S1 is as follows; Given a document D= , which consists of N sentences and contains M entities E= , each entity It is indicated by the mention of P in the sentence; First, concatenate word embedding and entity type embedding as word express: ; in, are words and entity types, Represent word and entity type embedding layers respectively; Then use the pre-trained language model to encode, obtain the encoding features, and generate the vector sequence corresponding to the given document D : =Encoder([ , ... ]); Among them, Encoder (q) is the BERT model, K is the total number of words, and k is the word number.
3. The document-level relationship extraction method based on path reasoning as claimed in claim 1, characterized in that: Mention nodes represent mentions in a given document D. The representation of is achieved by averaging the representations of the words that make up the mention: ; in, A representation representing a mentioned node, Contains the mentioned node The representation of all words in , Represents a word, represents the mentioned node, Avg() represents the average function, i is the node number, and k is the word number; An entity node represents an entity in a given document D. The representation of is achieved by averaging the representations of the mentions of its constituent entities: ; in, represents the representation of the entity node, A representation representing a mentioned node, Contains entity nodes All the indications mentioned in Represents the mentioned node, Represents an entity node; Sentence nodes represent sentences in a given document D. The representation of is achieved by averaging the representations of the contained words: ; in, represents the representation of a sentence node, Contains the sentence The representation of all words in , Represents a word, Represents a sentence node.
4. The document-level relationship extraction method based on path reasoning as claimed in claim 1, characterized in that: Mention-mention edge means when two mentions refer to the same entity, a mention edge is added to model the co-citation interaction between mentions; Mention-entity edges connect a mention node to an entity node when the mention is associated with an entity, in order to model the co-reference of the mentions. Entity-sentence edge means that when a mention is in a sentence, the mention and its sentence form an edge from the mention to the sentence. Sentence-sentence edges mean that when two sentences contain the same entity, the two sentence nodes are connected, and edges are only added between two adjacent sentence nodes of the corresponding sentences in the document to maintain the order information.
5. The document-level relationship extraction method based on path reasoning as claimed in claim 1, characterized in that: The entity path reasoning graph is constructed as follows: First construct three types of paths: Intra-sentence reasoning path: The relationship between two entities appears in the same sentence at the same time. The intra-sentence reasoning path models two types of reasoning: pattern recognition and common sense reasoning. These two reasoning paths perform reasoning within a sentence. Inter-sentence reasoning path: For two entities that are not mentioned in the same sentence, the inter-sentence reasoning path is used to model the relationship between them. It is regarded as adding an additional bridge to the intra-sentence reasoning path. Depending on the type of bridge, logical reasoning paths and co-reference reasoning paths are introduced; Direct reasoning path: other situations that do not conform to the intra-sentence reasoning path and inter-sentence reasoning path are represented by direct reasoning paths. For each group of entity pairs with multiple paths, at most q paths are saved, where q is a constant. Then a closed entity path reasoning graph g is extracted around the entity pairs in the document graph structure G to integrate different paths. Specifically, the entity path reasoning graph g consists of nodes that appear at least once on the path and all edges between these nodes in G.
6. A document-level relationship extraction method based on path reasoning as claimed in claim 1, characterized in that: The cross loss entropy function is used to optimize the prediction process. The loss function is as follows: ; in is the value of the loss function, where Represents an indicator function. When the condition in the brackets is met, the value is 1, and if not, it is 0.