Relation triple joint extraction method based on information enhancement and bidirectional modeling
By constructing a bidirectional extraction model enhanced with entity-relationship information, the problems of semantic association separation and boundary fuzziness in relation triple extraction in complex contexts are solved, more efficient relation triple extraction is achieved, and the accuracy and robustness of the extraction are improved.
Patent Information
- Application Number
- CN202510764638.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-10-10
AI Technical Summary
Existing technologies have problems in extracting relation triples in complex contexts, such as semantic association separation, blurred entity boundaries, insufficient capture of long-distance dependencies, and omission of cross-sentence triples. In addition, they do not fully utilize entity and relation information, resulting in insufficient extraction accuracy and completeness.
A joint extraction method of relation triples based on information enhancement and bidirectional modeling is adopted. By constructing a bidirectional extraction model with entity-relation information enhancement, which includes a sentence tagging layer, a context feature extraction layer, an entity-to-relation branch, a relationship-to-entity branch and a relationship triplet clipping module, and combining self-attention and residual structure to optimize context features, dynamic coupling of entities and relationships and accurate capture of boundary information are achieved.
The accuracy and robustness of relation triple extraction are improved. Through bidirectional complementary reasoning and boundary mask enhancement technology, the completeness of semantic parsing and the accuracy of extraction results are enhanced, and the computational complexity is reduced.
Smart Images

Figure CN120764530A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of named entity relation extraction, and particularly relates to a relation triple joint extraction method based on information enhancement and bidirectional modeling. BACKGROUND
[0002] With the wide application of natural language processing technology in the fields of knowledge graph construction and intelligent question answering, the accuracy and completeness of relation triple extraction, as a core task of structured semantic parsing, directly affect the performance of downstream applications. Current mainstream joint extraction methods mostly adopt a one-way modeling process, i.e., a fixed-order entity-relation or relation-entity extraction framework, which can reduce the complexity of the task, but is prone to be restricted by problems such as semantic association fragmentation and entity boundary ambiguity when dealing with complex contexts, resulting in insufficient capture of long-distance dependencies or omission of cross-sentence triples. Moreover, existing relation triple extraction methods do not fully utilize entity and relation information, and most methods simply represent entities or relations through class labels. In addition, the existing multi-step extraction framework has a high dependence on the initial extraction results.
[0003] A relation perception-based entity relation extraction method is disclosed in Chinese patent CN117971990B, which comprises: encoding the input text using an encoding layer to obtain a vector representation of the input text; inputting the vector representation of the input text into a relation perception layer to obtain a latent relation using the relation perception layer; inputting the latent relation into an entity extractor to obtain a subject and an object; inputting the subject and the object into a subject-object alignment extractor to filter out redundant entity pairs; establishing an entity relation extraction model and optimizing the model through a loss function to extract triples.
[0004] As application scenarios expand to complex contexts, the present application focuses on bidirectional modeling and entity boundary information collaboration, and proposes a dual-branch joint extraction framework based on entity-to-relation and relation-to-entity, aiming to realize dynamic coupling of entity recognition and relation determination through bidirectional complementary reasoning and boundary mask enhancement technology, thereby enhancing the performance of triple extraction in complex contexts. SUMMARY
[0005] The present application aims to solve the problems in the background art and proposes a relation triple joint extraction method based on information enhancement and bidirectional modeling.
[0006] The technical solution of the present application is a relation triple joint extraction method based on information enhancement and bidirectional modeling, which comprises the following specific implementation steps:
[0007] A bidirectional extraction model based on entity-relation information enhancement is constructed, which includes a sentence tagging layer, a context feature extraction layer, a relation-to-entity branch, an entity-to-relation branch, a relation triple pruning module, and a decoding layer reasoning framework.
[0008] The sentence tokenization layer performs word segmentation and padding processing on the input sentence, generates a fixed-length word sequence and a corresponding mask, and generates an entity label sequence through BIO encoding;
[0009] The context feature extraction layer uses the pre-trained model BERT to extract the context feature vector of the sentence, and generates the context representation of the entity-to-relation branch and the relation-to-entity branch;
[0010] The entity-to-relation branch extracts the subject and object through BIO label multi-classification, generates entity pairs through bipartite graph matching, optimizes the context representation by combining the entity boundary mask and enhancing self-attention method, and further combines the potential relationship information extracted in the relation-to-entity branch to predict the relationship of the generated entity pair;
[0011] The relation-to-entity branch extracts potential relationships through a multi-label classification method, combines the entity boundary mask matrix obtained in the relation-to-entity branch and uses a self-attention method to enhance the context information, optimizes the context features using a residual structure, and predicts the subject and object corresponding to each potential relationship, generates an entity label sequence, and extracts the boundary sequence of each subject and object according to the entity boundary decoding method;
[0012] The relationship triple pruning module verifies the relevance of the entity pair and the relationship through a multi-label classification method, thereby filtering the redundant candidate triple sets output by the bidirectional modeling branch and retaining the effective relationship triples;
[0013] The decoding layer decodes the set of relationship triples from the relation-to-entity branch using a relationship triple decoding method, and decodes the set of relationship triples from the entity-to-relation branch based on the relationship triple decoding method of the entity-to-relation branch, and merges and outputs the complete set of relationship triples.
[0014] A joint training strategy is adopted to balance the loss functions of the bidirectional branch and the pruning module for end-to-end model optimization.
[0015] Preferably, the implementation process of combining the entity boundary mask matrix obtained in the relation-to-entity branch and using a self-attention method to enhance the context information is as follows:
[0016] Generate a mask matrix according to the boundary positions of the subject and object entity pair, where the mask value of the entity coverage area is 1 and the non-coverage area is 0;
[0017] Linearly weight and fuse the mask matrix and the self-attention score matrix to dynamically adjust the attention weight of the entity area;
[0018] Add the weighted attention features and the original context features through a residual connection to generate an enhanced context representation.
[0019] Preferably, the implementation process of the entity boundary decoding method is as follows:
[0020] traversing the potential entity sequence tags to dynamically identify the entity start position and end position;
[0021] generating the entity boundary set according to the start position and length, and constructing the subject-object pair.
[0022] Preferably, the implementation process of the relationship triple decoding method is as follows:
[0023] inputting the sequence tags of the subject and object, the potential relationship identifier, and the pruning matrix;
[0024] extracting the boundary set of the subject and object by the entity boundary decoding method;
[0025] constructing the subject-object set and traversing the boundary tuple of each subject-object;
[0026] double traversing the subject-object set and verifying the relevance by the pruning matrix;
[0027] if the verification is passed, generating the triple and adding it to the result set;
[0028] returning the triple list.
[0029] Preferably, the implementation of the relationship triple pruning module includes:
[0030] verifying whether there is a relationship between the subject and object by multi-label classification; filtering the redundant triples by the pruning matrix, and calculating each position of the pruning matrix by the following formula:
[0031]
[0032] wherein, represents the predicted value of the (i, j)th position of the pruning matrix; [H gi ; H gj ] represents the context encoding H gi at the i-th position and the context encoding H gj at the j-th position; W g represents the trainable matrix; b g represents the bias; and ReLU(·) represents the ReLU activation function.
[0033] Preferably, the loss function of the joint training strategy includes:
[0034] the loss L RtoEThe loss of potential relations and the loss of entity extraction are composed, wherein the loss of potential relations is the average error between the predicted value and the true value of each relation, and the loss of entity extraction is composed of the loss of subject extraction and object extraction, which is respectively averaged by the loss between the predicted value and the true value of each position for three labels B, I and O;
[0035]
[0036] L RtoE = L rel + L Ee ;
[0037] Wherein, nr represents the number of potential relations; nR represents the number of predefined relations; P r and y r respectively represent the predicted value and the true value of the rth predefined relation; and respectively represent the predicted value and the true value of the subject or object of the ith potential relation in the jth position; t represents the prediction of the subject or object; l represents the maximum length of the sentence; L rel represents the loss function of relation extraction; L Ee represents the loss function of entity extraction;
[0038] The loss function L EtoR of the entity-to-relation branch is composed of the loss of potential entity extraction and the loss of relation classification, wherein the loss of potential entity extraction is the average loss between the predicted value and the true value of each position for three labels B, I and O in the subject and object prediction sequence, and the loss of relation classification is the average loss between the predicted value and the true value of each position in the extracted relation prediction sequence for each pair of entities:
[0039]
[0040] L EtoR = L e + L rc ;
[0041] Wherein, nep represents the number of potential entity pairs; L e represents the potential entity loss; L rc represents the relation classification loss; represents the probability that the model predicts that the ith pair of entities has the jth relation; represents the true label of whether the ith pair of entities has the jth relation; represents the true label of the ith position of the subject or object; P i t represents the probability that the model predicts the ith position of the subject or object;
[0042] Loss of the relationship triple pruning part Tc The prediction value and the true value of each position of the pruning matrix are composed of:
[0043]
[0044] Wherein, y i,j represents the true value of the (i, j) position of the relationship triple pruning matrix; represents the prediction value of the (i, j) position of the pruning matrix;
[0045] The total loss of the total loss model is composed of the loss L RtoE of the entity to relationship branch, EtoR the loss L Tc of the relationship triple pruning matrix:
[0046] Loss=L RtoE +L EtoR +L Tc ;
[0047] Wherein, Loss represents the total loss function.
[0048] Preferably, the implementation process of the entity to relationship branch relationship triple decoding method is as follows: by inputting the subject and object markers, the relationship classification markers and the pruning matrix, positioning the subject and object boundary, constructing the candidate entity pair set through double traversal, removing duplicates based on the pruning matrix for relationship existence verification between the subject and the object, and finally merging the extraction results of the double branch, outputting the triple set with clear identification of the subject and object boundary.
[0049] Preferably, the entity to relationship branch includes a latent entity extraction module and a relationship classification module:
[0050] The latent entity extraction module generates a subject and object prediction sequence by performing a BIO marker multi-classification task on each position of the entity sequence, combining trainable matrix and bias matrix operations, and completing latent entity recognition based on context feature vectors;
[0051] The relationship classification module generates a subject and object entity pair through bipartite graph matching, optimizes the context representation based on entity boundary mask enhanced self-attention mechanism, and predicts the relationship between the entity pair by combining residual structure and latent relationship encoding extracted by the relationship to entity branch.
[0052] Preferably, the relationship to entity branch includes a latent relationship extraction module and an entity extraction module:
[0053] The latent relationship extraction module performs existence determination on the pre-defined relationship through a multi-label classification task, generates a prediction sequence based on activation function, matrix operation and average pooling, and outputs a latent relationship set after argmax decoding.
[0054] The entity extraction module generates a cross-region mask matrix through potential entity boundary information extracted by entity-to-relation extraction, optimizes context features by combining a self-attention method and a residual structure, and splices the coding results of potential relations and the context feature vectors to predict corresponding subject and object entity sequences, and obtains the start, internal or end positions of the entities corresponding to each position of the sequence through an argmax function.
[0055] Compared with the prior art, the above technical scheme of the present application has the following beneficial technical effects:
[0056] The present application effectively improves the accuracy and robustness of relation triple extraction in natural language processing by introducing a collaborative method of entity boundary information and bidirectional modeling.
[0057] (1) The dual-branch interactive modeling of entity-to-relation and relation-to-entity is adopted, and through the bidirectional complementary reasoning of the potential entity extraction module and the potential relation extraction module, the dynamic coupling of entities and relations is realized, and the integrity of semantic analysis is enhanced.
[0058] (2) The attention distribution is strengthened through the entity boundary mask method, and the weight of the entity related area is amplified in the self-attention calculation to accurately capture the entity boundary information and alleviate the semantic dispersion problem caused by the fuzzy boundary in the traditional method.
[0059] (3) The entity pairs and multi-label classification are generated by combining the bipartite graph matching to verify the relevance, and the redundant candidates are filtered by combining the relation triple pruning module to effectively improve the accuracy and efficiency of the extraction results.
[0060] (4) The loss function of the bidirectional branch and the pruning module is balanced through the joint training strategy to ensure the end-to-end optimization of the model, reduce the computational complexity, and enhance the generalization ability. BRIEF DESCRIPTION OF DRAWINGS
[0061] Figure 1 A network architecture diagram of a bidirectional extraction model based on entity-relation information enhancement is provided for the present application.
[0062] Figure 2 A principle block diagram of a bipartite graph matching method is provided for the present application. DETAILED DESCRIPTION
[0063] In embodiment one, a relation triple joint extraction method based on information enhancement and bidirectional modeling is provided, which constructs a bidirectional extraction model (ER-IEBE) based on entity-relation information enhancement, as shown in Figure 1As shown in the figure (taking the sentence "Happiness is an emotion that can affect people's behavior" as an example), relation triplets are extracted from two branches: "entity to relation" and "relationship to entity". The relation triplets extracted from the two branches complement each other to ensure the integrity of the extraction results. In addition, the model also uses the potential relations and potential entities extracted from the two branches to enhance contextual information, effectively improving the performance of relation triple extraction.
[0064] The ER-IEBE model architecture consists of six parts: the sentence tagging layer, the context feature extraction layer, the relationship-to-entity branch, the entity-to-relationship branch, the relationship triplet clipping module, and the decoding layer. The specific structure is as follows:
[0065] Level 1: Sentence tagging layer: For a given sentence consisting of n words S = {w1,w2,...,w i ,w j ,...,w n}, firstly, the sentence is segmented and padded or truncated into a fixed length l word sequence T = {t1, t2, ..., t i ,t j ,...,t n}, a corresponding mask is generated to shield the filler; for the padded word sequence T, the BIO encoding strategy is used to generate a tag sequence of length l, which is used as data labels for model training.
[0066] Level 2: Contextual feature extraction layer: The sentences in the dataset are passed through the pre-trained BERT model to obtain the corresponding contextual feature vector representation, which is used to extract the contextual feature information in the sentences. Different contextual representations are generated based on the relationship-to-entity branch, entity-to-relationship branch, and relationship triplet clipping modules.
[0067] Level 3, or branch 1: Entity-to-Relationship Branch: First, potential subjects and potential objects are extracted. Then, entity pairs are generated through a binary matching method. Finally, relationships are classified for each entity pair. This branch includes a potential entity extraction module and a relationship classification module. The potential entity extraction module extracts possible subjects and objects from the context, while the relationship classification module extracts the corresponding relationship for each entity pair formed by the subject and object. Specifically:
[0068] (1) Latent entity extraction module: The extraction of potential subjects and potential objects is regarded as a multi-classification task for each position of the entity sequence LPE on the three labels B, I, and O. The prediction sequence P of potential subjects and potential objects is sub and P obj The calculation process is as follows:
[0069] P sub =softmax(Wsub *H e +b sub );
[0070] P obj =softmax(W obj *H e +b obj );
[0071] Among them, W sub 、W obj represents the trainable matrix; b sub 、b obj Indicates bias; * indicates matrix multiplication; H e Represents the context feature vector generated by the context feature extraction layer for the entity-to-relation branch;
[0072] (2) Relationship classification module: For each pair of entities consisting of a subject and an object, the corresponding relationship is extracted. For the subject {S1, S2, ..., S i ,…,S n} and objects {O1, O2, ..., O j ,…,O m Generate entity pairs and use bipartite graph matching method to generate entity pairs, such as Figure 2 As shown in the figure, after obtaining the probability sequence of potential subjects and potential objects, the argmax function is used to convert the probability sequence into the corresponding subject-object sequence labels LPS and LPO, and then the boundary sequence of each subject and object is extracted according to the entity boundary decoding method;
[0073] Among them, S i represents the i-th subject, i = 1, 2, ..., n, where n is the number of subjects; O j represents the j-th object, j = 1, 2, ..., m, where m is the number of objects;
[0074] Before classifying the relationship for each pair of entities, the boundary information of the entity pair is used to enhance the context's attention to the subject and object. The specific process is as follows:
[0075] The context is enhanced by using the entity pair boundary information. First, the subject and object boundary information of the entity pair are generated into corresponding entity masks S_M and O_M, and then the corresponding mask matrix EP is generated according to the subject and object masks of the entity pair. MASK , the calculation process of obtaining the mask matrix is as follows:
[0076]
[0077] in, Represents the value corresponding to the i-th row and j-th column of the mask matrix; ai 1 if and only if the position belongs to the subject or object of the entity pair;
[0078] After obtaining the mask matrix of the entity pair, the query (Q) and the key (K) are generated through linear transformation. The attention score matrix A is generated through Q and K. Then, the mask matrix is combined with the trainable parameter β to enhance the score of the entity region. Finally, the last attention weight Attention is obtained through softmax normalization. The calculation process is as shown below:
[0079]
[0080] A' = A + β · Ep mask ; Attention = softmax(A');
[0081] Wherein, Q represents the query matrix; K represents the key matrix; A represents the attention score matrix; Attention represents the attention weight; H e represents the original context information of the entity to the relationship branch; β represents the attention enhancement multiple, which is a trainable parameter; W q,k represents the projection matrix; h represents the hidden layer size; * represents matrix multiplication; A' represents the updated attention score matrix; softmax(·) represents the softmax activation function;
[0082] The finally weighted context information is added to the original context information again to form the new context information H ent_new of the ith entity pair, so as to avoid the problems of gradient disappearance and gradient explosion:
[0083] H ent_new = H e + Attention*H e ;
[0084] After obtaining the new context information of each entity pair, the extracted potential relationship information is used to extract the corresponding relationship of each entity pair. The relationship prediction sequence P i rel of the ith entity pair is calculated as shown below:
[0085] P i rel = ReLU(W ent_new *[H ent_i ; Avg(Rel_emb)] + b ent_i );
[0086] Wherein, Avg(Rel_emb) represents the average operation on all potential relationship encodings; [;] represents the splicing operation; Went_i represents a trainable matrix; b ent_i Represents bias; * represents matrix multiplication; Rel_emb represents the potential relationship set.
[0087] Level 4, or Branch 2: Relationship to Entity Branch: This branch first extracts potential relationships and then predicts the subject and object for each potential relationship. It includes a potential relationship extraction module and an entity extraction module. The potential relationship module extracts possible relationships in the sentence from the context, while the entity extraction module extracts the corresponding subject and object for each potential relationship. Specifically:
[0088] (1) Latent Relationship Extraction Module: The extraction of latent relationships is considered as a multi-label classification task. Each predefined relationship is classified into a label 0 (i.e., the relationship does not exist) and a label 1 (i.e., the relationship exists). The calculation process is as follows:
[0089] P rel =ReLU(W rel *Avgpool(H rel )+b rel );
[0090] Among them, P rel represents the predicted sequence of potential relationships; ReLU(·) represents the activation function; H rel Represents the original context information related to the entity branch; W rel represents a trainable matrix; b rel represents bias; * represents matrix multiplication; Avgpool(·) represents average pooling operation;
[0091] According to the prediction sequence LPR of the potential relationship, the label sequence of the potential relationship is obtained, and then the potential relationship set PR={r1,r2,…,r i ,…,r nr}:
[0092] LPR=argmax(P rel );
[0093] Where nr represents the number of potential relationships; r i represents any potential relationship; argmax(·) represents the argmax function;
[0094] (2) Entity extraction module: Extracts the corresponding subject and object for each potential relationship. The subject and object information extracted by the latent entity extraction module of the entity-to-relationship branch is used to enhance the context's attention to the entity information. The boundary information of the entity and object is used to enhance the entity information at the corresponding position in the context. Specifically:
[0095] The probability sequence P of the potential subject and the potential object obtained sub , obj Transformed into a label sequence LPS, LPO:
[0096] LPS = argmax(P sub );
[0097] LPO = argmax(P obj );
[0098] The boundary information of the subject and the object is extracted by the entity boundary decoding method, and the corresponding mask sequence M is generated for each sentence according to the boundary information of all the potential entities obtained, and then the cross-region mask matrix E MASK is constructed according to the entity mask sequence of the sentence, the positions covered by the entity in the mask matrix are 1, and the positions not covered by the entity are 0, and the attention score of these positions is amplified to improve the attention of the model to the entity information, and the calculation process is as follows:
[0099]
[0100] Wherein, denotes the value corresponding to the i-th row and the j-th column of the mask matrix;
[0101] With the help of self-attention method, the attention score of the corresponding context is generated through the mask matrix, and a residual structure is used to avoid the problem of gradient disappearance and gradient explosion when obtaining new context. The new context information H rel_new The calculation process is as follows:
[0102] Q, K = H rel * W q,k ;
[0103]
[0104] A' = A + a E mask ;
[0105] Attention = softmax(A');
[0106] H rel_new = H rel + Attention * H rel ;
[0107] Wherein, Q represents the query matrix; K represents the key matrix; A represents the attention score matrix; Attention represents the attention weight; H rel represents the original context information related to the entity branch; a represents the attention enhancement multiple, which is a trainable parameter; W q,kdenotes a projection matrix; h denotes a hidden layer size; * denotes matrix multiplication; A' denotes an updated attention score matrix; softmax(·) denotes a softmax activation function;
[0108] After obtaining the new context, the subject and object sequences corresponding to each potential relationship are extracted, and the specific operations are as follows:
[0109]
[0110] wherein, P i sub , P i obj denote the prediction probability of the subject and object for i potential relationships respectively; [H rel_new ; r i ] denotes the concatenation operation on the encoding of the context information H rel_new and the i-th potential relationship r i ; W i sub , W i obj denote trainable matrices; denote bias; * denotes matrix multiplication;
[0111] Then, the predicted sequences of the subject and object are processed by the argmax function to obtain the predicted label sequences LSUB and LOBJ of the subject and object.
[0112] Level five: relationship triple pruning module: by predicting whether a relationship exists between the subject and the object, the relationship triple is pruned, the relationship triple pruning task is defined as a multi-label classification, and is regarded as a multi-label classification task on label 0 (i.e., the relationship does not exist) and 1 (i.e., the relationship exists) to avoid the use of threshold, the prediction process of the (i, j) position of the pruning matrix is as follows:
[0113]
[0114] wherein, denotes the predicted value of the (i, j) position of the pruning matrix; [H gi ; H gj ] denotes the concatenation operation of the encoding H gi of the i-th position and the encoding H gj of the j-th position; W g denotes a trainable matrix; b g denotes a bias;
[0115] Then, the predicted sequence of the pruned sentence is processed by the argmax function to obtain the label sequence LTC.
[0116] Level six: decoding layer: decoding relationship triplets from two branches respectively, and taking the union of the two to obtain the final relationship triplets;
[0117] For the entity-to-relation branch, the set of relationship triplets RE_Triples is decoded by the relationship triplet decoding method;
[0118] For the entity-to-relation branch, the corresponding decoding is based on the entity-to-relation branch relationship triplet decoding method: first, during the extraction of potential entities, the sequence of generated potential entities is decoded according to the entity boundary decoding method to generate the entity pair set EP; then the entity pairs in the set are traversed, and the corresponding relationship of the entity pair is obtained according to the label, and it is judged whether there is a relationship between the entity pairs according to the pruning matrix of the relationship triplet module, if there is, the relationship triplet composed of the entity pair and the relationship is added to ER_Triples; finally, the union operation is performed on the relationship triplets of the entity-to-relation and the relation-to-entity two branches to obtain the final relationship triplet set T;
[0119] Loss function: ER-IEBE combines several modules to train the model, and the total loss of the total loss model is composed of the loss L RtoE of the entity-to-relation branch, the loss L EtoR of the entity-to-relation branch, and the loss L Tc of the relationship triplet pruning matrix; the loss of the entity-to-relation branch is composed of the loss of potential relationship extraction and entity extraction, wherein the loss of potential relationship is the average error between the predicted value and the true value of each relationship, and the loss of entity extraction task is composed of the loss of subject extraction and object extraction, which is respectively averaged by the loss between the predicted value and the true value at each position; the loss of the entity-to-relation branch is composed of the loss of potential entity extraction and the loss of relationship classification, wherein the loss of potential entity is the average loss between the predicted value and the true value at each position of the predicted sequence of subject and object, and the loss of relationship classification is the average loss between the predicted value and the true value at each position of the predicted sequence of the relationship extracted by each pair of entity pairs; the loss of the relationship triplet pruning part is composed of the predicted value and the true value at each position of the pruning matrix;
[0120] Specifically:
[0121]
[0122] Wherein, nr represents the number of potential relationships; nR represents the number of predefined relationships; P r and y r represent the predicted value and the true value of the rth predefined relationship, respectively; and respectively represent the predicted value and the true value of the entity t in the i-th potential relationship at the j-th position; t represents the predicted subject or object sequence, and takes the value of the subject sub or the object obj; l represents the maximum length of the entity name; L rel represents the relationship extraction loss function; L Ee represents the entity extraction loss function; nep represents the number of potential entity pairs; L e represents the potential entity loss; L rc represents the relationship classification loss; represents the probability that the model predicts that the i-th pair of entities has the j-th relationship; represents the true label of whether the i-th pair of entities has the j-th relationship; represents the true label of the i-th position of the subject or object; P i t represents the probability that the model predicts the i-th position of the subject or object; y i,j represents the true value of the relationship triple pruning matrix at the (i, j) position; represents the predicted value of the pruning matrix at the (i, j) position; Loss represents the total loss function.
[0123] In the second embodiment, the information enhancement and bidirectional modeling-based relationship triple joint extraction method proposed by the application further comprises an entity boundary decoding method, which specifically comprises:
[0124] A1, initialize parameters: set the entity start position identifier start=-1, and create an empty set EB for storing entity boundary information;
[0125] Wherein, start represents the start position of the entity.
[0126] A2, sequence traversal processing: sequentially scan each position i (1≤i≤l) of the potential entity sequence label LPE:
[0127] Wherein, l represents the length of the entity sequence;
[0128] Entity start determination: when LPE[i]=1 and start=-1, mark the position as the entity start point: start=i;
[0129] Entity termination determination:
[0130] Case one, i.e. non-entity label: if LPE[i]=0 and start≠-1, add the current entity boundary (start, i-start) to EB, and reset start=-1;
[0131] Case 2, new entity marking: if LPE[i] = 1 and start ≠ -1, add the existing entity boundary (start, i-start) to EB, and update start = i.
[0132] A3, sequence end processing: if start is still valid after the traversal (i.e., start ≠ -1), add the remaining entity segment (start, l-start) to EB, where l is the total length of the sentence.
[0133] A4, result output and expansion: return the entity boundary set EB = [(start1, len1), …, (startn, lenn)]. i i n n ];
[0134] where any tuple (start i , len i ) represents the entity start position and length; n represents the total number of entities.
[0135] In example three, the relationship triple joint extraction method based on information enhancement and bidirectional modeling proposed by the application further includes a relationship triple decoding method, which is specifically:
[0136] B1, input parameter initialization: input the subject sequence label LSUB, the object sequence label LOBJ, the potential relationship identifier rel, and the pruning matrix LTC, and extract the subject boundary set and the object boundary set by an entity boundary decoding method, respectively.
[0137] The subject boundary set is:
[0138] The object boundary set is:
[0139] where m1 represents the total number of subjects; m2 represents the total number of objects.
[0140] B2, construction of subject and object sets:
[0141] Generate the subject set Heads: traverse each boundary tuple in SubB, and encapsulate it as a subject entity with an identifier;
[0142] Generate the object set Tails: traverse each boundary tuple in ObjB, and encapsulate it as an object entity with an identifier.
[0143] B3, screening of subject and object entity pairs and binding of relationships, double-traverse Heads and Tails, and verify the relevance of the entity pairs using the pruning matrix LTC.
[0144] For each subject h∈Heads and object t∈Tails, traverse the subject set and object set;
[0145] Crop matrix verification: extract the subject start position h[start] and the object start position t[start], check whether the corresponding position of the LTC matrix is a valid association;
[0146] Triple generation: if the verification passes, add (h, t, rel) as a relationship triple to the result set T.
[0147] B4, output relationship triple set: return the complete relationship triple list T.
[0148] Embodiment four, the present application proposes a relationship triple joint extraction method based on information enhancement and bidirectional modeling, which further includes an entity to relationship branch relationship triple decoding method, which is specifically:
[0149] C1, input parameters and initialization:
[0150] (1) input definition:
[0151] Subject sequence label (LSUB): label the start and boundary information of the subject entity in the sentence;
[0152] Object sequence label (LOBJ): label the start and boundary information of the object entity in the sentence;
[0153] Relationship classification label (LREL): multi-label sequence, label the relationship categories that may be involved at each position;
[0154] Crop matrix (LTC): binary matrix, indicating whether the association between the subject and the object is allowed;
[0155] Entity sequence length (L): the total length of the input sentence;
[0156] (2) Initialize storage structure: create an empty set EP to temporarily store candidate subject and object entity pairs.
[0157] C2, extract relationship-oriented triples, call relationship-driven branch: use a predefined relationship triple decoding method to generate a set of triples RE_Triples based on explicit relationship signals, which directly associates the activated relationship categories with the corresponding entities.
[0158] C3, locate the subject and object boundaries:
[0159] (1) Subject boundary extraction: call an entity boundary decoding method on the LSUB sequence to obtain the subject boundary set SubB in the form of [(start position, length),...];
[0160] (2) Object boundary extraction: the same operation is performed on the LOBJ sequence to obtain a set of object boundaries ObjB.
[0161] C4, Constructing a set of candidate entity pairs:
[0162] (1) Generating candidate pairs by double traversal: outer layer traversal of subject boundaries: the starting position and length of each subject are selected in turn, and are encapsulated into a tuple with identifier H (such as (H, starting position, length));
[0163] (2) Inner layer traversal of object boundaries: for each subject, all object boundaries are traversed, and are encapsulated into a tuple with identifier T (such as (T, starting position, length));
[0164] (3) All subject-object combinations are added to the candidate set EP to form a list of potential entity pairs.
[0165] C5, Verify the relationship of the entity pair:
[0166] (1) Double condition screening method:
[0167] Relationship existence check: traverse all predefined relationship categories, if a category in the relationship label LREL is activated (marked as 1), it is considered that the relationship is established;
[0168] Crop matrix check: check whether the starting positions of the subject and object are allowed to be associated (marked as 1) in the LTC matrix, filter semantic conflicts or invalid combinations across sentences;
[0169] (2) Dynamically generating triples: if the subject-object pair passes both types of checks, it is bound to the corresponding relationship to generate triples and added to the set ER_Triples.
[0170] C6, Merge double-branch results:
[0171] (1) Union integration: combine RE_Triples of the relationship-driven branch and ER_Triples of the entity-driven branch, remove duplicates, and obtain the final triple set T;
[0172] (2) Output form: the result form is [(subject, relationship, object),...], where the subject and object are explicitly identified by symbols H, T and boundary information.
[0173] The embodiments of the application are described in detail above in combination with the drawings, but the application is not limited thereto, and various changes can be made within the scope of knowledge possessed by those skilled in the art without departing from the purpose of the application.
Claims
1. A method for joint extraction of relation triples based on information enhancement and bidirectional modeling, characterized in that: The specific implementation steps include the following: Build a bidirectional extraction model based on entity-relation information enhancement, which includes a sentence tagging layer, a context feature extraction layer, a relation-to-entity branch, an entity-to-relation branch, a relation triplet clipping module, and a decoding layer reasoning framework; The sentence tagging layer performs word segmentation and padding on the input sentence to generate a fixed-length word sequence and corresponding mask, and generates an entity tag sequence through BIO encoding; The context feature extraction layer uses the pre-trained BERT model to extract the context feature vector of the sentence and generate context representations of the entity-to-relationship branch and the relationship-to-entity branch; The entity-to-relationship branch extracts the subject and object through BIO tag multi-classification, generates entity pairs through bipartite graph matching, and optimizes the context representation by combining the entity boundary mask to enhance the self-attention method. It further combines the potential relationship information extracted from the relationship-to-entity branch to predict the relationship classification of the generated entity pairs. The relationship-to-entity branch extracts potential relationships through a multi-label classification method, combines the entity boundary mask matrix obtained by the relationship-to-entity branch with the self-attention method to enhance contextual information, uses the residual structure to optimize contextual features and predict the subject and object corresponding to each potential relationship, generates an entity tag sequence, and extracts the boundary sequence of each subject and object based on the entity boundary decoding method; The relation triple pruning module verifies the association between entity pairs and relations through a multi-label classification method, thereby performing redundant filtering on the candidate triple sets output by the bidirectional modeling branch and retaining valid relation triples. The decoding layer decodes the set of relationship-to-entity branch relationship triplets using the relationship triple decoding method, and decodes the set of entity-to-relationship branch relationship triplets based on the entity-to-relationship branch relationship triple decoding method, and merges and outputs the complete set of relationship triples; A joint training strategy is adopted to perform end-to-end model optimization by balancing the loss functions of the bidirectional branches and the pruning module.
2. The method for jointly extracting relationship triples based on information enhancement and bidirectional modeling according to claim 1, characterized in that: The implementation process of combining the entity boundary mask matrix obtained from the entity branch and using the self-attention method to enhance the context information is as follows: Generate a mask matrix based on the boundary position of the subject-object entity pair, where the mask value of the entity coverage area is 1 and the uncovered area is 0; Linearly weighted fusion of the mask matrix and the self-attention score matrix to dynamically adjust the attention weight of the entity area; The weighted attention features are superimposed with the original context features through residual connections to generate enhanced context representations.
3. The method for jointly extracting relationship triples based on information enhancement and bidirectional modeling according to claim 1, characterized in that: The implementation process of the entity boundary decoding method is: Traverse the potential entity sequence tags and dynamically identify the entity start and end positions; Generate entity boundary sets based on starting positions and lengths, and construct subject-object pairings.
4. The method for jointly extracting relationship triples based on information enhancement and bidirectional modeling according to claim 1, characterized in that: The implementation process of the relation triple decoding method is: Input subject and object sequence labels, potential relationship identifiers and trimming matrix; Extract the boundary set of subject and object through entity boundary decoding method; Construct a subject-object set and traverse the boundary tuples of each subject-object; Double traverse the subject and object sets and use the clipping matrix to verify the association; If the verification passes, a triple is generated and added to the result set; Returns a list of triplets.
5. The method for jointly extracting relationship triples based on information enhancement and bidirectional modeling according to claim 1, characterized in that: The implementation of the relation triple pruning module includes: Verify whether there is a relationship between the subject and the object through multi-label classification; use the clipping matrix to filter redundant triplets, and each position of the clipping matrix is calculated by the following formula: in, Represents the predicted value of the (i, j)th position of the cropping matrix; [H gi ;H gj ] represents the context code H of the i-th position gi and the context code H at position j gj The splicing operation performed; W g represents the trainable matrix; b g represents the bias; ReLU(·) represents the ReLU activation function.
6. The method for jointly extracting relationship triples based on information enhancement and bidirectional modeling according to claim 1, characterized in that: The loss function of the joint training strategy includes: The loss L related to the entity branch RtoE It is composed of the loss of potential relationship extraction and the loss of entity extraction. The loss of potential relationship is the average of the errors between the predicted value and the true value of each relationship. The loss of entity extraction task is composed of the loss of subject extraction and object extraction. The loss is the average of the losses between the predicted value and the true value of the three labels B, I, and O at each position. L RtoE =L rel +L Ee ; Where nr represents the number of potential relationships; nR represents the number of predefined relationships; P r and y r Represent the predicted value and true value of the r-th predefined relationship respectively; and Represents the predicted value and true value of the subject or object of the i-th potential relationship at the j-th position; t represents the prediction of the subject or object; l represents the maximum length of the sentence; L rel represents the relation extraction loss function; L Ee represents the entity extraction loss function; The loss function L for the entity-to-relation branch EtoR , which is composed of the loss of potential entity extraction and the loss of relationship classification. The loss of potential entity extraction is the average of the loss between the predicted value and the true value of the three labels B, I, and O at each position in the subject and object prediction sequence. The loss of relationship classification is the average of the loss between the predicted value and the true value at each position in the prediction sequence of each pair of entity pairs extracted: L EtoR =L e +L rc ; Among them, nep represents the number of potential entity pairs; L e Indicates potential physical loss; L rc represents the relation classification loss; It represents the probability that the model predicts that the i-th pair of entities has the j-th relationship; The true label indicating whether the i-th pair of entities has the j-th relationship; represents the true label of the i-th position of the subject or object; P i t represents the probability of the model predicting the i-th position of the subject or object; The loss L of the pruned part of the relation triples Tc It consists of the predicted value and the true value at each position of the clipping matrix: Among them, y i,j Represents the true value of the relation triplet clipping matrix at position (i, j); Represents the predicted value of the (i, j)th position of the cropping matrix; The total loss of the total loss model is composed of the loss L related to the entity branch RtoE , the loss L of the entity-to-relation branch EtoR And the relation triplet clipping matrix L Tc constitute: Loss=L RtoE +L EtoR +L Tc ; Among them, Loss represents the total loss function.
7. The method for jointly extracting relationship triples based on information enhancement and bidirectional modeling according to claim 1, characterized in that: The implementation process of the entity-to-relationship branch relationship triplet decoding method is as follows: by inputting the subject-object label, relationship classification label and clipping matrix, the subject-object boundary is located and then a double traversal is performed to construct a set of candidate entity pairs. Based on the clipping matrix, the existence of the relationship between the subject and the object is verified to remove duplicates. Finally, the extraction results of the two branches are merged to output a set of triples that clearly identify the subject-object boundary.
8. The method for jointly extracting relationship triples based on information enhancement and bidirectional modeling according to claim 1, characterized in that: The entity-to-relation branch includes a potential entity extraction module and a relation classification module: The potential entity extraction module performs BIO labeling multi-classification tasks on each position of the entity sequence, combines trainable matrix and bias matrix operations to generate subject-object prediction sequences, and completes potential entity recognition based on context feature vectors; The relation classification module generates subject-object entity pairs through bipartite graph matching, enhances the self-attention mechanism and optimizes the context representation based on the entity boundary mask, and combines the residual structure and the latent relation encoding extracted from the entity branch to predict the relationship between entity pairs.
9. The method for jointly extracting relationship triples based on information enhancement and bidirectional modeling according to claim 1, characterized in that: The relation-to-entity branch includes the potential relation extraction module and the entity extraction module: The potential relationship extraction module determines the existence of predefined relationships through multi-label classification tasks, generates prediction sequences based on activation functions, matrix operations, and average pooling, and outputs a potential relationship set after argmax decoding; The entity extraction module generates a cross-region mask matrix through the potential entity boundary information extracted from the entity-to-relationship, combines the self-attention method and residual structure to optimize the context features, and splices the encoding results based on the potential relationship with the context feature vector to predict the corresponding subject-object entity sequence. The argmax function is used to obtain the start, internal or end position of the entity corresponding to each position in the sequence.
Citation Information
Patent Citations
A method for extracting entity relations based on relation awareness
CN117971990B
Cited By
Entity relation joint extraction method and system
CN121980014A
A method for generating a drilling pump knowledge chain based on component topology and fault propagation
CN122491439A
