Constraint-aware heterogeneous interactive joint entity relation extraction method and system
Patent Information
- Application Number
- CN202611486627.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-23
- Publication Date
- 2026-10-30
AI Technical Summary
现有模型大多采用同质图结构或简单的异质图结构,未能充分区分和建模词节点、主语节点与关系节点之间的语义差异,导致深层语义交互不足,重叠场景下虚假三元组频发,抽取鲁棒性不足
本发明通过构建包含词节点、主语节点和关系节点的双层异质图结构,并堆叠多层图注意力网络实现多源语义信息的深度交互,有效捕获了词、主语和关系三类节点之间的复杂语义依赖;通过并行设置类型注意力层与节点注意力层,分别建模节点与类型特征之间的交互以及节点与节点之间的交互,克服了现有模型对多源信息融合不足的缺陷;通过引入约束感知模块,构建全局实体-关系对应矩阵施加逻辑约束,有效过滤冗余预测结果,减少了虚假三元组的生成,缓解了子任务间的误差传播问题。本发明能够有效处理重叠三元组抽取问题,具有抽取准确率高、鲁棒性强的优点。
Smart Images

Figure CN123014124A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of knowledge graph construction and natural language processing technology, and in particular relates to a method and system for joint entity relation extraction based on heterogeneous interaction networks for extracting overlapping triples. Background Technology
[0002] In entity relation joint extraction tasks, text often exhibits triple overlap, including both single-entity overlap and entity-pair overlap. Existing models mostly employ homogeneous graph structures or simple heterogeneous graph structures, failing to adequately distinguish and model the semantic differences between word nodes, subject nodes, and relation nodes. This results in insufficient deep semantic interaction, frequent spurious triples in overlapping scenarios, and insufficient extraction robustness. Furthermore, existing models typically use the same attention calculation method for different types of neighbor nodes during information aggregation, making it difficult to dynamically capture complex dependencies across node types and limiting the model's ability to fuse multi-source semantic information.
[0003] Meanwhile, existing models lack effective global constraint mechanisms to suppress invalid predictions, and entity labeling bias will continue to affect the accuracy of relation extraction, resulting in a large number of redundant predictions in the extracted triples.
[0004] Therefore, there is an urgent need to design a method and system for joint extraction of entity relations that can fully model the deep semantic interaction of three types of nodes: words, subjects, and relations, and introduce a global constraint mechanism to filter out invalid predictions. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention proposes a constraint-aware method and system for joint extraction of heterogeneous interactive entity relationships, comprising: In one aspect, this invention provides a constraint-aware method for joint extraction of heterogeneous interactive entity relationships, comprising the following steps: S1: Obtain the input text, generate the initial representation matrix of word nodes for each word in the text using a pre-trained language model; generate the initial representation matrix of relation nodes for each relation type according to a predefined set of relation types; predict candidate subjects in the text using a subject tagger, and generate the initial representation matrix of subject nodes for each candidate subject.
[0006] S2: Based on the initial representation matrix of three types of nodes (word, subject, and relation), a two-layer heterogeneous graph structure is constructed by updating it through a multi-layer graph attention network.
[0007] S3: The nodes in the two-layer heterogeneous graph structure are updated by stacking multi-layer graph attention networks, wherein each layer of the graph attention network contains a parallel two-layer structure that performs type attention operation and node attention operation respectively; the type attention operation is used to model the dependency relationship between a node and different node type features, and the node attention operation is used to model the interaction relationship between a node and its neighboring nodes; the outputs of the two are weighted and fused to obtain the node representation updated in the current layer.
[0008] S4: Input the updated node representation output from the last layer of the graph attention network in S3 into the constraint-aware decoder. The constraint-aware decoder includes an entity-relation tagger, a constraint-aware module, and an encoder-decoder backfeedback unit. The entity-relation tagger receives the updated node representation and predicts the subject boundary and object boundary for each word position and each predefined relation type, respectively, to obtain a candidate subject set and a candidate object set. The constraint-aware module constructs a three-dimensional parallel entity-relation constraint tensor, which includes a subject-relation matching matrix, an object-relation matching matrix, and an entity mutual exclusion constraint tensor, respectively used to represent word nodes and relation types. The system calculates the subject-object matching coefficient, object-object matching coefficient, and mutual exclusion penalty coefficient between entities and relations. Based on the three-dimensional parallel entity-relation constraint tensor, it performs hierarchical screening of candidate subject-relation pairs and candidate object-relation pairs, filtering out candidates with low confidence and logical conflicts by setting matching thresholds and mutual exclusion penalty thresholds for each channel. Simultaneously, the backfeedback unit uses the matching coefficients generated by the constraint perception module as trainable constraint bias terms, injecting them back into the type attention layer and node attention layer of the graph attention network to correct node representations in subsequent encoding processes. After a two-layer iterative closed-loop update of encoding and decoding, the decoder outputs the final valid relation triples.
[0009] In another aspect, the present invention also provides a constraint-aware heterogeneous interactive entity relationship joint extraction system, comprising the following modules: The initial representation matrix module is used to obtain the input text and generate initial representation matrices for three types of nodes: words, subjects, and relations.
[0010] The two-layer heterogeneous graph module generates initial representation matrices for three types of nodes: words, subjects, and relations. These matrices are then updated through a multi-layer graph attention network to construct a two-layer heterogeneous graph structure.
[0011] The entity relation module is used to input the two-layer heterogeneous graph structure into the constraint-aware decoder, and the decoder outputs the final valid relation triples.
[0012] The beneficial effects of this invention are: This invention constructs a two-layer heterogeneous graph structure containing word nodes, subject nodes, and relation nodes, and stacks a multi-layer graph attention network to achieve deep interaction of multi-source semantic information, effectively capturing the complex semantic dependencies between word, subject, and relation nodes. By setting up type attention layers and node attention layers in parallel, it models the interaction between nodes and type features, as well as the interaction between nodes, overcoming the shortcomings of existing models in fusion of multi-source information. By introducing a constraint-aware module, it constructs a global entity-relation correspondence matrix to apply logical constraints, effectively filtering redundant prediction results, reducing the generation of false triples, and mitigating the error propagation problem between subtasks. This invention can effectively handle the problem of overlapping triple extraction, and has the advantages of high extraction accuracy and strong robustness. Attached Figure Description
[0013] Figure 1 This is an overall flowchart of the constraint-aware heterogeneous interactive entity relationship joint extraction method of the present invention; Figure 2 This is a schematic diagram of the structure of the two-layer three-node heterogeneous network of the present invention; Figure 3 This is a schematic diagram of the processing flow of the attention layer of the present invention; Figure 4 This is a schematic diagram of the processing flow of the node attention layer of the present invention; Figure 5 This is a performance comparison chart of the present invention under different network layers. Detailed Implementation
[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. The described embodiments are merely some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0015] This invention provides a constraint-aware method for joint extraction of heterogeneous interactive entity relationships, such as... Figures 1 to 5 As shown, this method mainly includes three core stages: constructing an initial representation matrix, interaction of a two-layer three-node heterogeneous network, and constraint-aware decoding.
[0016] Step S1: Construct the initial representation matrix.
[0017] For the input sentence ,in For sequence length, Indicates the first word in the sentence The word units at each position are encoded using a pre-trained BERT language model, and the hidden layer vectors of the last layer are extracted as the initial representation matrix of the word nodes. , of which OK Corresponding to the The representation vector of each word, As an embedded dimension, in this invention The value is .
[0018] Based on a predefined set of relation types ,in This represents the total number of relation types. For the first Each relationship type has a label name. First, each All are converted to one-hot encoding, and then the one-hot encodings of each relation label are concatenated row by row to form a one-hot matrix. Finally, a linear transformation through a fully connected layer is used to generate the initial representation matrix of the relation nodes. Specifically: in and These are trainable parameters.
[0019] A subject marker is constructed, consisting of two binary classifiers that predict the probability of each word being the start and end position of the subject. The start position classifier determines whether the current lexical unit is the starting boundary of a candidate subject entity. The probability of being the starting position of a candidate subject entity is The end-position classifier is used to determine whether the current lexical unit is the end boundary of a candidate subject entity. The probability of being the starting position of a candidate subject entity is The specific formula for the subject marker is: in for function, , , , All are trainable parameters. The subject probability vector is obtained by concatenating the start and end probabilities. : Then, the initial representation matrix of the subject node is mapped through a fully connected layer. : in and These are trainable parameters. Through subject taggers, the matrix... Each word position in the sentence is assigned a corresponding subject node. In subsequent graph interactions, only the nodes corresponding to the positions that are identified by the tagger as high-confidence candidate subjects will play a dominant role in relation extraction. Subject nodes in other positions play more of a role in contextual supplementation and semantic assistance, rather than being forcibly regarded as real subjects.
[0020] Through the above encoding, the three types of nodes—word, subject, and relation—are mapped to a unified semantic space while maintaining type distinguishability, providing type-labeled node inputs for constructing the heterogeneous graph structure in step S2.
[0021] Step S2: Construct a two-layer, three-node heterogeneous network.
[0022] The nodes generated in step S1 exist independently in their respective feature spaces, lacking semantic interaction with each other and unable to capture the dependencies between subjects and words, or between relations and words. Therefore, it is necessary to construct a heterogeneous graph structure to place the three types of nodes in the same topological space, making subsequent information propagation possible.
[0023] Construct a two-layer heterogeneous graph structure, where each layer contains three types of nodes: word nodes, subject nodes, and relation nodes. The result obtained in step S1... , , This is represented as an input node in the first layer.
[0024] The nodes are updated by stacking multiple layers of Graph Attention Network (GAT). The number of stacked layers of the Graph Attention Network in this invention is... .
[0025] The establishment of the two-layer heterogeneous graph structure enables clear connections between the three types of nodes, providing a graph topology basis for the type-aware propagation of the graph attention network in steps S3 and S4.
[0026] Step S3: Construct the type attention layer.
[0027] In heterogeneous graphs, the semantic distribution of nodes of different types varies significantly. If a uniform attention calculation method is used for all nodes, the essential differences between types will be ignored. Therefore, it is necessary to explicitly model the dependencies between nodes and their types during the propagation process, so that nodes can consciously focus on semantic features related to their own type when aggregating information.
[0028] For the The layer type is an attention layer, and the input is a matrix of word nodes. Subject node matrix and relation node matrix First, the average feature of each type of node is obtained through the type feature generator: The three types of features are concatenated and linearly mapped to obtain the type feature representation. : Taking word nodes as an example, a multi-view feature fusion attention mechanism with type-guided coefficients is used to calculate the attention score between word nodes and type features. For the first... Each channel has an attention score calculated as follows: in Let be a trainable projection matrix, and be the th . Query and key projection matrix for each viewpoint feature channel. The constraint bias weight coefficient is set to a value of [value]. , The type-guided coefficient is used to adjust the first... The word node in the th _ ... The dependence strength of type features under each attention channel is as follows: in One-hot encoding for the current node's type, namely, word, subject, and relation. vector, For a two-layer fully connected network, output a scalar.
[0029] Compared to traditional multi-head attention mechanisms, the method employed in this invention can explicitly introduce node type priors, making it more adaptable to heterogeneous graph scenarios with multiple node types. By introducing type-guided coefficients to fuse current node features, global type features, and node one-hot type encoding, the intensity of attention each node pays to different type features under various perspective channels can be dynamically adjusted. For example, relationship nodes will automatically amplify the weight of global relationship type features, while word nodes will focus on fusing text context type information, thus solving the defect that homogeneous attention cannot adapt to heterogeneous nodes. At the same time, multi-view channels independently model fine-grained type dependencies, making feature decoupling capabilities stronger. After splicing multi-view outputs, multi-level type semantics can be fused, avoiding the loss of feature information caused by a single perspective.
[0030] Subsequently, conduct Normalization yields attention weights. Specifically: The type attention feature is obtained by concatenating the outputs of the feature channels from each perspective and then performing a linear transformation. Specifically: in The projection matrix is the value. This is for outputting the projection matrix.
[0031] Then, through residual linking... and The features are added together and passed through a fully connected layer to obtain the word node features. Specifically: in and These are trainable parameters.
[0032] Finally, the word node features obtained from all word nodes are concatenated to obtain the first... Layer type Attention layer output .
[0033] The attention calculation method for subject nodes and relation nodes is the same as that for word nodes.
[0034] Step S4: Construct the node attention layer.
[0035] The node attention layer calculates the attention weights between the current node and each node in the set of neighboring node types. For the ... The attention layer for word nodes also employs a multi-view feature fusion attention mechanism with type-guided coefficients to calculate the attention score between the word node and all subject nodes. For the first... The first channel, the... The word node is the first The attention scores for each subject node are as follows: in For trainable projection matrices, To constrain the bias weighting coefficients, The type-guided coefficient is used to adjust the first... The word node in the th _ ... The dependence strength of type features under each attention channel is as follows: in One-hot encoding for the current node's type, namely, word, subject, and relation. vector, For a two-layer fully connected network, output a scalar.
[0036] Subsequently, conduct Normalization yields attention weights. Specifically: The type attention feature is obtained by concatenating the outputs of the feature channels from each perspective and then performing a linear transformation. Specifically: in The projection matrix is the value. This is for outputting the projection matrix.
[0037] The word nodes are initially updated, specifically as follows: in This is a trainable weight matrix.
[0038] The same method is used to calculate the attention between the updated word nodes and all relation nodes. Specifically: After employing a multi-source, multi-view feature fusion attention mechanism, the intermediate representation of word nodes, which incorporates multiple pieces of information, is obtained. Specifically: in , and These are multi-view fusion attention features between word nodes and type features, and between subject nodes and relation nodes. , and The preset weighting coefficient has a value of [value]. , , , is a trainable weight matrix.
[0039] Finally, the residual connection will be used to... and After addition, the updated word node representation of the current layer is obtained through a fully connected layer: in and These are trainable parameters.
[0040] Finally, update the representation of all word nodes corresponding to all word nodes. splicing to obtain the first Layer node attention layer output .
[0041] The node attention calculation method for subject nodes and relation nodes is the same as that for word nodes.
[0042] Step S5: Multi-layer stacking and enhanced interaction.
[0043] Single-layer graph attention networks can only achieve one-hop neighbor information exchange, while the subject and object in a relation triple may be separated by multiple lexical units, requiring multi-hop propagation to establish long-range dependencies. Therefore, multiple graph attention layers need to be stacked to achieve deep semantic interaction.
[0044] Deep semantic interaction can be achieved by stacking multiple GAT layers with the same structure. Each layer of the graph attention network includes a type attention layer and a node attention layer, performing type attention operations and node attention operations. In this invention, the number of network layers is defined as follows: .
[0045] For word nodes, residual links are introduced between layers, where the first... The layer's output is specifically as follows: For subject nodes and relation nodes, residual links are also introduced between layers for computation. The output enhancement node of the last layer can then be represented as... , , .
[0046] After being enhanced by multi-layer stacking and residual connections, the node representation fully incorporates the semantic information of multi-hop neighbors, possessing the rich contextual representation required to support relation classification and boundary prediction in step S6.
[0047] Step S6: Establish a bidirectional coupled iterative constraint-aware decoder.
[0048] Existing constraint-aware decoders generally adopt a unidirectional serial paradigm of encoding first and then decoding constraints. The constraint logic is only used as a post-processing means, and can only filter the prediction results after encoding. It cannot suppress the occurrence of low matching degree phenomenon from the source of feature generation, and there is an upper limit to the number of false candidate entities generated in overlapping triplet scenarios. This invention proposes a bidirectional coupled iterative constraint-aware decoder, which improves the constraint-aware module from a simple post-filter into a closed-loop interactive unit that can reverse correct encoded features. Through a two-layer iterative architecture of encoding and decoding constraints, reverse correcting encoding, and secondary decoding, deep coupling of constraint information and graph encoded features is achieved.
[0049] First, construct a three-dimensional parallel entity-relation constraint tensor. ,in The length of the text sequence. To predefine the total number of relation types, the three channels of the tensor correspond to three independent constraint mappings.
[0050] The first channel of the tensor Subject-relation matching matrix Each element Characterizing the first When each word node is used as the subject, it corresponds to the first word node. The semantic matching coefficient of class relations. The higher the coefficient, the more likely the word node is to be the subject entity of the relation.
[0051] The second channel of tensor Object-relation matching matrix Each element Characterizing the first When the word node is used as an object, it is related to the first word node. The semantic matching coefficient of class relations. The higher the coefficient, the more likely the word node is to be the object entity of the relation.
[0052] The third channel of tensor For entity mutual exclusion constraint tensor Each element Characterizing the first The candidate entity and the first The mutual exclusion penalty coefficient of a class relation is determined by the semantic conflict or logical mutual exclusion between the entity pair and the relation. The higher the penalty coefficient, the easier it is for the corresponding triple to be filtered out.
[0053] The specific calculation formula for the 3D parallel entity-relation constraint tensor is as follows: in The parameters are trainable, and , The pre-defined structured prior weights are used to control the contribution strength of subject node information in the construction of the corresponding matrix. The three-dimensional parallel entity-relation constraint tensor expands the single subject-relation binary constraint into a three-dimensional parallel constraint of subject matching, object matching, and relation mutual exclusion, making the constraint dimensions richer.
[0054] Existing decoder constraint logic only applies to the decoding output, but it cannot affect the node feature generation process during the encoding stage. Even if an entity-relation pair is judged as low-confidence and filtered out during the decoding stage, its corresponding node representation has already been formed during the encoding stage and participated in subsequent information propagation, which will still indirectly interfere with the prediction accuracy of other entity-relation pairs. This invention designs a decode-encoder backfeedback embedding unit, which uses the matching coefficients obtained from constraint decoding as trainable bias terms and backfeeds them into the graph attention network to correct node representations from the encoding source. The backfeedback embedding is specifically implemented through two branches, embedding into the type attention layer and the node attention layer respectively.
[0055] In the type attention layer constraint bias embedding, for the multi-view attention scoring function of the type attention layer, the constraint bias term from the subject channel of the constraint tensor is replaced. For word nodes, for the first... For each perspective channel, the revised formula for calculating the attention scoring function is: in For the 3D parallel entity-relation constraint tensor, the first... The subject matching coefficient vector corresponding to each word node, with dimensions and the number of relation types. Consistency. By incorporating constraint bias into the type attention scoring, if a word node is determined to be highly matched with a certain type of relationship during the decoding stage, i.e. A high matching coefficient automatically increases the weight of the corresponding relation type feature in the next round of type attention calculation; conversely, a low matching coefficient suppresses attention to that type feature. This allows constraint information to guide the weight allocation of type attention.
[0056] In the constrained bias embedding of the node attention layer, a constraint bias term from the object channel of the constraint tensor is added to the multi-source information fusion formula of the node attention layer. Taking word nodes as an example, the revised node fusion formula is as follows: in The node constraint bias weight coefficient has a value of , For 3D parallel entity-relation constraint tensor The Middle Each word node corresponds to an object matching coefficient vector. By adding a constraint bias to the node attention fusion, the object matching information of the constraint tensor will directly participate in the feature update of the node. This allows word nodes that are judged as high-confidence objects in the decoding stage to obtain stronger object semantic features in the encoding stage, thereby improving the accuracy in subsequent boundary prediction.
[0057] The two branches mentioned above together constitute the decoding-encoding reverse feedback channel, which makes the constraint perception module no longer a passive post-filter, but a closed-loop interactive unit that can actively participate in the encoding process, suppressing the generation of invalid entity-relationship representations from the source of feature generation.
[0058] Based on 3D parallel entity-relation constraint tensor With the addition of a reverse feedback embedding unit, this invention constructs an encoding-decoding two-layer iterative closed-loop update process.
[0059] First, based on the three-dimensional parallel entity-relation constraint tensor The node representation of the modified graph attention network is obtained as follows: The word nodes output from the last layer are represented as... Features are obtained by aligning global average pooling with relation node representations. Specifically: The entity-relation labeler is used to perform predictions using the corrected node representations. Two binary classifiers are used to predict the subject and object respectively, resulting in the corrected predicted subject probability. and predicting object probability Specifically: Subscript It is necessary to iterate through all relation types. Features The One element, For the first A representation vector of each relation node. , and All of these are trainable parameters.
[0060] Then set the entity prediction threshold. The two probabilities are filtered by an entity prediction threshold. For the first... The word element and the first A relation type, if Then mark the lexical as the first one. Candidate subjects under each relation type; similarly, lexical units can be marked as those in the first... Candidate objects under each relation type. Therefore, a set of candidate subjects can be formally defined. and candidate object set as follows: in Indicates the first The word element in the first Under each relation type, the subject or object is predicted.
[0061] Based on the corrected node representation, the updated 3D parallel entity-relation constraint tensor is reconstructed. .
[0062] Through a two-layer iterative closed loop of initial encoding, initial decoding, back feedback, corrective encoding, and secondary decoding, constraint information can be deeply integrated into the encoding process. Node representations are optimized under constraint guidance, resulting in more accurate entity boundary predictions and constraint tensors in the next decoding round. In this invention, the number of iteration rounds is set to... wheel.
[0063] After a two-level iterative closed-loop update, based on the first... The set of candidate subjects to be updated is due. Update the set of candidate objects and updating 3D parallel entity-relation constraint tensor It performs joint decoding of multiple objectives, sequentially filters data through the three channels of the three-dimensional tensor, and outputs the final valid relation triplet.
[0064] In the first level of filtering, it is necessary to traverse the set of candidate subjects. For each candidate subject, a subject-relation pair is formed between each candidate subject and each predefined relation type. Query the 3D parallel entity-relation constraint tensor Corresponding element of the first channel Set the subject matching threshold. ,like If the threshold is not met, the subject-relation pair is filtered out from the candidate set; if the threshold is greater than or equal to the threshold, the subject-relation pair is retained and enters the next level of filtering.
[0065] In the second layer of filtering, for each subject-relation pair retained after the first layer of filtering... In the candidate object set Searching for the same relation type All candidate objects below Query the 3D parallel entity-relation constraint tensor Corresponding element of the second channel This refers to the object matching coefficient. Setting the object matching threshold... ,like Then the word node Mark it as a valid object under this relationship; if it is below the threshold, exclude the candidate object.
[0066] In the third layer of screening, for each candidate triplet obtained from the first two layers of screening... Query the 3D parallel entity-relation constraint tensor The corresponding element in the third channel: subject lexical unit With Relationship Mutual exclusion penalty coefficient and object word elements With Relationship Mutual exclusion penalty coefficient The overall conflict penalty value of the triple is calculated based on these two sets of coefficients. Mutual exclusion penalty coefficient and mutual exclusion penalty coefficient The average value. Simultaneously, a mutual exclusion penalty threshold is set. ,like If the entity has a high degree of semantic conflict or logical mutual exclusion with the relation, the triple is judged as a false triple and filtered out; otherwise, the triple is retained.
[0067] After the above three-layer tensor constraint filtering and relation mutual exclusion logic verification, the retained triples are the final valid relation triples. The output is from the decoder.
[0068] The triples output by the constraint-aware decoder have undergone secondary verification by the global correspondence matrix, effectively suppressing false triples and forming an end-to-end trainable process. Simultaneously, the constraint logic is moved from post-processing to the encoding stage, suppressing invalid entity-relation representations from the source of feature generation, rather than just filtering at the result end. Furthermore, the three-layer progressive joint decoding ensures that the output triples undergo multiple constraint checks, significantly reducing the false triple rate.
[0069] Step S7: Develop a training strategy.
[0070] The total loss function of this invention consists of three parts, expressed as follows: in and The cross-entropy loss function is used for binary classification, specifically to supervise the subject boundary predictor and the object boundary predictor. in Each word element and each relation type The true subject and object labels, The length of the text sequence. The total number of predefined relation types. The binary cross-entropy loss of the global correspondence matrix is used to supervise the 3D parallel entity-relation constraint tensor. The quality, specifically: in For 3D parallel entity-relation constraint tensor Corresponding real labels. Balancing hyperparameters. .
[0071] This embodiment is trained and validated on the WebNLG natural language generation dataset. During training, the large language model BERT-base is used as the encoder, and the initial learning rate is set to... It adopts an exponential decay strategy with a decay rate of , represented as Batch size set to The maximum sequence length is limited to The unit is Both the entity prediction threshold and the relationship prediction threshold are set to [value missing]. Corresponding threshold .train In each round, an early stopping strategy is adopted, specifically stopping the iteration for a certain number of rounds. .
[0072] In another aspect, the present invention also provides a constraint-aware heterogeneous interactive entity relationship joint extraction system for implementing the aforementioned heterogeneous interactive entity relationship joint extraction method, comprising an initial representation matrix module, a two-layer heterogeneous graph module, and an entity relationship module.
[0073] The initial representation matrix module is used to obtain the input text and generate initial representation matrices for three types of nodes: words, subjects, and relations.
[0074] The two-layer heterogeneous graph module constructs a two-layer heterogeneous graph structure based on the initial representation matrices of three types of nodes: words, subjects, and relations, through updates via a multi-layer graph attention network.
[0075] The entity relationship module is used to input the two-layer heterogeneous graph structure into the constraint-aware decoder, and the decoder outputs the final valid relationship triplet.
[0076] Simulation verification of the present invention: To verify the effectiveness of this invention, experiments were conducted on the publicly available natural language generation dataset WebNLG. This dataset was originally designed to advance the field of natural language generation. To ensure consistency between the experimental setup and existing research, the version of the WebNLG dataset released by Wei et al. was selected. This dataset is rigorously partitioned, containing 5,019 sentences for model training, 500 validation sentences for hyperparameter tuning, and 703 test sentences for final performance evaluation. The data distribution covers 246 valid relations, exhibiting rich semantic expression and high complexity.
[0077] In the experimental evaluation phase, strict matching criteria were employed to ensure the accuracy of the results. Specifically, only when the relation triples extracted by the model were completely consistent with the ground truth annotations in terms of relation type and entity pairs were they considered correctly extracted. This standard ensured the rigor of the evaluation process and avoided errors caused by partial matching. To comprehensively measure model performance, the evaluation system of mainstream baseline models was adopted, and precision, recall, and F1 score were calculated for this dataset. Among them, precision reflects the reliability of the model's prediction results, that is, the proportion of correctly predicted triples out of all prediction results; recall reflects the model's ability to cover ground truth triples, that is, the proportion of successfully predicted ground truth triples out of all ground truth triples. Through the combination of the above dataset and evaluation metrics, the model's performance in complex semantic environments can be objectively and systematically verified.
[0078] Experimental results show that the model proposed in this invention achieves a significant improvement in F1 score compared to baseline models (such as the single-stage joint extraction model TPLinker). Table 1 shows a comparison of relation extraction experimental results in some embodiments of this invention. Table 1 Comparison of Relation Extraction Experiment Results
[0079] In terms of accuracy, this invention achieves 92.4%, which is comparable to the best baseline model, the hierarchical entity relationship decoder HD-RET. base The accuracy remained flat, showing a 0.6% improvement compared to the single-stage joint extraction model TPLinker, a 2.1% improvement compared to the cascaded dual-decoder model DualDec, and a 10% improvement compared to the joint extraction model RAJE based on relational attention mechanisms. The improved accuracy is mainly attributed to two factors: First, the two-layer heterogeneous graph structure enables fine-grained modeling of word nodes, subject nodes, and relation nodes, allowing the model to more accurately capture the semantic dependencies between these three types of nodes and reduce misjudgments of subject or object boundaries. Second, the constraint-aware module effectively filters low-confidence subject-relation pairs through a global entity-relation correspondence matrix, significantly reducing the number of false positive predictions.
[0080] In terms of recall, this invention achieves 94.7%, which is higher than the best baseline hierarchical entity relationship decoder HD-RET. base The performance improvement is 2.5%, 2.7% higher than the single-stage joint extraction model TPLinker, 3.2% higher than the cascaded dual-decoder model DualDec, and 2.5% higher than the joint extraction model RAJE based on relational attention mechanisms. The significant improvement in recall is the core advantage of this invention. This is mainly due to the parallel design of type attention and node attention operations, which allows the model to simultaneously aggregate multi-source semantic information from both the type and instance levels. This effectively solves the problems of blurred subject-object boundaries and scattered relational semantics in overlapping scenarios. Furthermore, the stacking of multi-layer graph attention networks and residual connections further enhance deep semantic interaction, strengthening subject and object candidates that are not adequately represented in shallow networks, thus leading to more complete identification and recall.
[0081] In terms of F1 score, this invention achieves 93.4%, which is 1.1% higher than the best baseline hierarchical entity relation decoder HD-RET_base, 1.5% higher than the single-stage joint extraction model TPLinker, 2.5% higher than the cascaded dual decoder model DualDec, and 2.1% higher than the joint extraction model RAJE based on relation attention mechanism. The overall advantage of the F1 score indicates that this invention achieves a better balance between accuracy and recall, verifying the effectiveness of the joint optimization strategy of heterogeneous interaction network and constraint awareness in handling overlapping triplet extraction tasks.
[0082] exist Figure 5 The study further explored the impact of network layer number on model performance. Results showed that on the WebNLG dataset, the model achieved the best F1 score with 2 layers. As the number of network layers increased, the F1 score exhibited a trend of decreasing slowly followed by a sharp decline. When the number of layers exceeded 4, the model's F1 score even dropped below 40%. This indicates that the model is sensitive to network depth, and excessively high network layer counts can lead to overfitting.
[0083] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A constraint-aware method for joint extraction of heterogeneous interactive entity relationships, characterized in that, Includes the following steps: S1: Obtain the input text and generate the initial representation matrix of three types of nodes: words, subjects, and relations; S2: Based on the initial representation matrix of three types of nodes (word, subject, and relation), a two-layer heterogeneous graph structure is constructed by updating it through a multi-layer graph attention network. S3: Input the two-layer heterogeneous graph structure into the constraint-aware decoder, and the decoder outputs the final valid relation triples.
2. The constraint-aware heterogeneous interactive entity relationship joint extraction method according to claim 1, characterized in that, The initial representation matrices for the three types of nodes—generated words, subjects, and relations—are as follows: For input text ,in For sequence length, Indicates the first word in the sentence The word elements at each position are encoded using a BERT pre-trained language model, and the hidden layer vectors of the last layer are extracted as the initial representation matrix of the word nodes. , of which OK Corresponding to the The representation vector of each word; Based on a predefined set of relation types ,in The total number of relations. For the first Each relationship type has a label name; first, each... All are converted to one-hot encoding, and then the one-hot encodings of each relation label are concatenated row by row to form a one-hot matrix. Finally, a linear transformation through a fully connected layer is used to generate the initial representation matrix of the relation nodes. ; A subject marker is constructed, consisting of two binary classifiers, which predict the probability of each word being the start and end position of the subject, respectively. The start position classifier determines whether the current word is the starting boundary of a candidate subject entity. The probability of being the starting position of a candidate subject entity is The end-position classifier is used to determine whether the current lexical unit is the end boundary of a candidate subject entity. The probability of being the starting position of a candidate subject entity is The subject probability vector is obtained by concatenating the start and end probabilities. Then, the initial representation matrix of the subject node is mapped through a fully connected layer. .
3. The constraint-aware heterogeneous interactive entity relation joint extraction method according to claim 2, characterized in that, The specific implementation process of S2 is as follows: Construct a two-layer heterogeneous graph structure, with each layer containing three types of nodes: word nodes, subject nodes, and relation nodes; use the initial representation matrix obtained in S1. , , As the input node representation of the first layer; The nodes are updated by stacking multiple layers of graph attention network (GAT). Each layer of graph attention network includes a type attention layer and a node attention layer, which perform type attention operations and node attention operations. For word nodes, residual connections are introduced between layers, where the first... The layer output is: For subject nodes and relation nodes, residual connections are also introduced between layers for computation. The output enhancement node of the last layer is represented as follows. , , .
4. The constraint-aware heterogeneous interactive entity relation joint extraction method according to claim 3, characterized in that, The specific implementation process of the attention layer of this type is as follows: For the The layer type is an attention layer, and the input is a matrix of word nodes. Subject node matrix and relation node matrix First, the average feature of each type of node is obtained through a type feature generator. Then, the three types of features are concatenated and linearly mapped to obtain the type feature representation. : For word nodes, a multi-view feature fusion attention mechanism with type guidance coefficients is used to calculate the attention score between the word node and the type feature; for the th Each channel has an attention score calculated as follows: in Let be a trainable projection matrix; let be the th Query and key projection matrix for each viewpoint feature channel. To constrain the bias weighting coefficients, The type-guided coefficient is used to adjust the first... The word node in the th _ ... The strength of dependence on type features under each attention channel ,in One-hot encoding for the type of the current node, For a fully connected network, output a scalar; Subsequently, conduct Normalization yields attention weights. Type attention features are obtained through linear transformation. Specifically: ,in The projection matrix is the value. To output the projection matrix, and then through residual linking... and The features are added together and passed through a fully connected layer to obtain the word node features. The word node features obtained from all word nodes are concatenated to obtain the first word node. Layer type Attention layer output ; The attention calculation method for subject nodes and relation nodes is the same as that for word nodes.
5. The constraint-aware heterogeneous interactive entity relation joint extraction method according to claim 4, characterized in that, The specific implementation process of the node attention layer is as follows: The node attention layer calculates the attention weights between the current node and each node in the set of neighboring node types. For the The node attention layer, targeting word nodes, works similarly to the type attention layer, employing a multi-view feature fusion attention mechanism with type-guided coefficients to calculate the attention scores between word nodes and all subject nodes. Type attention features ; Initial update of word nodes ,in The weight matrix is trainable; a multi-view feature fusion attention mechanism with type-guided coefficients is used to calculate the updated attention scores between word nodes and all relation nodes. ; Weighted fusion is achieved through multi-source, multi-perspective feature fusion and attention mechanism. , and This yielded the intermediate representation of word nodes that integrates multiple pieces of information. Finally, the residual connection will be used to connect the components. and After addition, the updated word node representation of the current layer is obtained through a fully connected layer. Finally, the representation of all word nodes corresponding to all word nodes is updated. splicing to obtain the first Layer node attention layer output .
6. The constraint-aware heterogeneous interactive entity relation joint extraction method according to claim 5, characterized in that, The specific implementation process of the constraint-aware decoder is as follows: S3.1: Constructing a 3D parallel entity-relation constraint tensor based on a two-layer heterogeneous graph structure. ; S3.2: Based on the 3D parallel entity-relation constraint tensor The attention scoring function and node fusion process were modified to obtain a set of candidate subjects and a set of candidate objects. S3.3: After a two-level iterative closed-loop update, for the final 3D parallel entity-relation constraint tensor Perform hierarchical filtering to output the final valid relation triplets.
7. The constraint-aware heterogeneous interactive entity relation joint extraction method according to claim 6, characterized in that, The specific implementation of S3.1 is as follows: First, construct a three-dimensional parallel entity-relation constraint tensor. ,in The length of the text sequence. To predefine the total number of relation types, the three channels of the tensor correspond to three independent constraint mappings; The first channel of the tensor Subject-relation matching matrix Each element Characterizing the first When each word node is used as the subject, it corresponds to the first word node. Semantic matching coefficients of class relationships; The second channel of tensor Object-relation matching matrix Each element Characterizing the first When the word node is used as an object, it is related to the first word node. Semantic matching coefficients of class relationships; The third channel of tensor For entity mutual exclusion constraint tensor Each element Characterizing the first The candidate entity and the first The mutual exclusion penalty coefficient for class relationships; in For trainable parameters, , For structured prior weights.
8. The constraint-aware heterogeneous interactive entity relation joint extraction method according to claim 6, characterized in that, The specific implementation of S3.2 is as follows: In the type attention layer constraint bias embedding, for the multi-view attention scoring function of the type attention layer, the constraint bias term from the subject channel of the constraint tensor is replaced. For word nodes, for the first Each perspective channel, utilizing Replacement type guiding coefficient Calculate the corrected attention scoring function The attention scoring function is modified in the same way for both subject nodes and relation nodes. In the constraint bias embedding of the node attention layer, for the multi-source information fusion of the node attention layer, a constraint bias term from the object channel of the constraint tensor is added. The same method is used to correct node merging for both subject nodes and relation nodes. Based on the three-dimensional parallel entity-relation constraint tensor The node representation of the modified graph attention network is obtained as follows: ; Represent the word nodes of the last layer output Features are obtained by aligning global average pooling with relation node representations. Then, two binary classifiers are used to obtain the corrected predicted subject probability. and predicting object probability This yields a set of candidate subjects. and candidate object set Based on the corrected node representation, an updated 3D constraint tensor is reconstructed. ; Candidate subject set and candidate object set For: Setting the entity prediction threshold For the first The word element and the first A relation type, if Then mark the lexical as the first one. Candidate subjects under each relation type; similarly, lexical units are marked as those in the first... Candidate objects under each relation type, formally defining the set of candidate subjects. and candidate object set .
9. The constraint-aware heterogeneous interactive entity relation joint extraction method according to claim 8, characterized in that, The specific implementation of S3.3 is as follows: After a two-level iterative closed-loop update, based on the first... The set of candidate subjects to be updated is due. Update the set of candidate objects and updating 3D parallel entity-relation constraint tensor Perform multi-objective joint decoding, sequentially filter through the three channels of the three-dimensional tensor, and output the final valid relation triplet; First-level filtering, traversal Each candidate subject in the table forms a subject-relation pair with each predefined relation type. Query the 3D parallel entity-relation constraint tensor Corresponding element of the first channel ; Set subject matching threshold ,like If the condition is met, the subject-relation pair is filtered out from the candidate set; otherwise, the subject-relation pair is retained and proceeds to the next level of filtering. The second layer of filtering involves reserving each subject-relation pair after the first layer of filtering. ,exist Searching for the same relation type All candidate objects below Query the 3D parallel entity-relation constraint tensor Corresponding element of the second channel ; Set object matching threshold ,like Then the word node Mark it as a valid object under this relation; otherwise, exclude the candidate object. The third layer of filtering involves querying the 3D parallel entity-relation constraint tensor for each candidate triplet obtained from the first two layers of filtering. The corresponding element in the third channel: subject lexical unit With Relationship Mutual exclusion penalty coefficient and object word elements With Relationship Mutual exclusion penalty coefficient The overall conflict penalty value of the triple is calculated based on the two sets of coefficients. Mutual exclusion penalty coefficient and mutual exclusion penalty coefficient The mean; and simultaneously set a mutual exclusion penalty threshold. ,like If the entity has a high degree of semantic conflict or logical mutual exclusion with the relation, the triple is judged as a false triple and filtered out; otherwise, the triple is retained.
10. A constraint-aware heterogeneous interactive entity relation joint extraction system, used to implement the heterogeneous interactive entity relation joint extraction method according to any one of claims 1 to 9, characterized in that, Includes the following modules: The initial representation matrix module is used to obtain the input text and generate initial representation matrices for three types of nodes: words, subjects, and relations. The two-layer heterogeneous graph module generates initial representation matrices for three types of nodes: words, subjects, and relations. These matrices are then updated through a multi-layer graph attention network to construct a two-layer heterogeneous graph structure. The entity relation module is used to input the two-layer heterogeneous graph structure into the constraint-aware decoder, and the decoder outputs the final valid relation triples.