A method for extracting entity relations based on relation awareness

Through the entity relationship extraction method based on relationship awareness, the relationship awareness layer and entity extractor are combined with the subject-object alignment extractor to solve the problem of insufficient information interaction between entities and relationships, achieve efficient triple extraction, and improve entity relationships. Extraction performance and accuracy.

CN117971990BActive Publication Date: 2024-10-22CHONGQING UNIV OF TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410030736.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-09
Publication Date
2024-10-22
Estimated Expiration
2044-01-09

AI Technical Summary

Technical Problem

Existing entity relationship extraction technology suffers from insufficient information interaction between entities and relationships, error propagation and entity redundancy, resulting in poor extraction performance.

Method used

Adopt the entity relationship extraction method based on relationship awareness, encode the text through the encoding layer, use the relationship awareness layer to extract potential relationships, combine the entity extractor and the subject-object alignment extractor, and optimize the loss function to improve the accuracy and accuracy of triple extraction. quality.

Benefits of technology

It effectively improves the accuracy of entity relationship extraction and the quality of triples, reduces error propagation and redundant entity pairs, and improves the stability and accuracy of entity relationship extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117971990B_ABST
    Figure CN117971990B_ABST
Patent Text Reader

Abstract

The present invention proposes an entity relationship extraction method based on relationship perception, which includes: encoding the input text by using an encoding layer to obtain a vector representation of the input text; inputting the vector representation of the input text into a relationship perception layer, and obtaining a potential relationship by using the relationship perception layer; inputting the potential relationship 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 relationship extraction model, and optimizing the model through a loss function to extract triples. The present invention encodes the vocabulary in the input text and converts it into a computer-recognizable format for easy subsequent processing. The multi-head attention mechanism is used to extract the potential relationship in the text and improve the extraction accuracy of the entity relationship. The subject and the object are extracted from the potential relationship to further improve the extraction effect of the entity relationship. The redundant entity pairs are filtered to generate the final triples and improve the quality of the triples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language relationship extraction, and in particular to an entity relationship extraction method based on relationship perception. Background Art

[0002] Entity relationship extraction is the process of extracting triples from text, including subjects, relations, and objects, which is of great significance to downstream tasks such as knowledge graph construction. However, entity relationship extraction faces many challenges, such as the lack of information interaction between entities and relations, entity overlap, etc., which all affect the extraction performance. In the early days, entity relationship extraction adopted a pipeline method, which was divided into two subtasks: named entity recognition and relationship prediction. However, this method ignores the connection between entities and relations, leading to the problem of error propagation. To solve this problem, predecessors proposed a joint learning method to combine entity extraction with relationship extraction to achieve information sharing and effectively reduce error propagation. Despite the progress, the connection between entities and relations has not been fully utilized. For example, CasRel has redundant operations, PRGC generates a large amount of entity redundancy and fails to effectively utilize the information between entities and relations. Summary of the invention

[0003] The present invention aims to at least solve the technical problem of poor performance in extracting triples in the prior art, and in particular innovatively proposes an entity relationship extraction method based on relationship perception.

[0004] In order to achieve the above-mentioned object of the present invention, the present invention provides an entity relationship extraction method based on relationship perception, the method comprising:

[0005] S100, encoding the input text using the encoding layer to obtain a vector representation of the input text;

[0006] S200, inputting the vector representation of the input text into a relationship perception layer, and using the relationship perception layer to obtain potential relationships;

[0007] S300, inputting the potential relationship into an entity extractor to obtain a subject and an object;

[0008] S400, inputting the subject and the object into a subject-object alignment extractor to filter out redundant entity pairs;

[0009] S500, establishing an entity relationship extraction model, and optimizing the model through a loss function to extract triples.

[0010] As an optional embodiment of the present invention, optionally, the acquiring potential relationship by using the relationship perception layer includes:

[0011] S201, inputting the vector representation of the input text into a multi-head attention module, using the multi-head attention module to assign different weights to different words in the input text, and obtaining word embedding in the input text;

[0012] The multi-head attention module is expressed by the formula:

[0013]

[0014] Among them, Attention(,,) represents the multi-head attention mechanism, Q represents the query vector, K represents the key vector, V represents the value vector, softmax() represents the activation function, T represents the transposition, d k Represents the dimension information of the key;

[0015] S202, performing average pooling on the word embedding;

[0016] Its formula is expressed as:

[0017] h avg =Avgpool(h att )∈R D×1

[0018] Among them, h avg Represents the vector representation of the word embedding after average pooling, Avgpool() represents the average pooling operation, h att represents word embedding, R D×1 represents a vocabulary vector set;

[0019] S203, using the sigmoid function to obtain potential relationships;

[0020] Its formula is expressed as:

[0021] P rel =σ(W r h avg +b r )

[0022] Among them, P rel represents the probability of extracting potential relationships, σ() represents the sigmoid function, and W r and b r Represents trainable weights.

[0023] As an optional embodiment of the present invention, optionally, inputting the potential relationship into an entity extractor to obtain a subject and an object includes:

[0024] S301, using a subject decoder to obtain a subject, and using a pointer network to mark the start position and the end position of the subject, and combining the subject with the potential relationship;

[0025] The formula is:

[0026]

[0027]

[0028]

[0029] in, represents the predicted probability of the starting position of the head entity, σ represents the sigmoid function, and All represent trainable parameters, Indicates the starting position of the head entity. represents the predicted probability of the end position of the head entity, Indicates the end position of the head entity, p sub (h|r,S) represents the probability value of extraction as the subject, h represents the head entity, r represents the relationship, S represents the input text, n represents the total number of words in the text, Π() represents the summation operation, Indicates whether the i-th word in the text is the start position tag of the subject, Indicates whether the i-th word in the text is the end position tag of the subject;

[0030] S302, obtaining an object through an object decoder;

[0031] Its formula is expressed as:

[0032]

[0033]

[0034]

[0035] in, represents the predicted probability of the starting position of the tail entity, and t represents the tail entity; and All represent trainable parameters, Indicates the start position of the tail entity. represents the predicted probability of the end position of the tail entity, Indicates the end position of the tail entity, p obj (t|r,h,S) represents the probability of extracting the object. Indicates whether the i-th word in the text is the start position tag of the object, The end position tag indicating whether the i-th word in the text is an object.

[0036] As an optional embodiment of the present invention, optionally, the method further includes:

[0037] When the When it is greater than or equal to the threshold, it means that word i is the head of the subject;

[0038] When the When it is greater than or equal to the threshold, it means that word i is the tail of the subject;

[0039] When the or / and When it is less than the threshold, it indicates that word i is an entity between the head and the tail.

[0040] As an optional embodiment of the present invention, optionally, inputting the subject and the object into a subject-object alignment extractor to filter out redundant entity pairs includes:

[0041] S401, establishing an entity pair matrix and setting a threshold λ2, wherein the threshold λ2 is used to distinguish correct entity pairs from incorrect entity pairs;

[0042] S402, when the probability value of the subject and the object is greater than the threshold λ2, the entity pair is a correct entity pair; otherwise, when the probability value of the subject and the object is less than the threshold λ2, the entity pair is an incorrect entity pair, and the incorrect entity pair is filtered out;

[0043] Its formula is expressed as:

[0044] p matrix =σ(W[h i sub ;h j obj ]+b)

[0045] Among them, p matrix represents the probability value of obtaining the true entity pair through the subject-object alignment extractor, σ() represents the sigmoid function, W and b both represent trainable parameters, and h i sub represents the i-th label in the input text as the main body, h j obj Represents the encoded representation of the jth label as an object in the input text.

[0046] As an optional embodiment of the present invention, optionally, the formula of the loss function is expressed as:

[0047]

[0048]

[0049]

[0050]

[0051] in, represents the loss of extracting potential relations, n r Represents the number of relations in the relation set, y i represents the probability of the ith potential relationship, P rel represents the probability of extracting potential relationships, represents the loss of entity extraction, E represents the expected value, and p sub (h|r,S) represents the probability value of extraction as the subject, p obj (t|r,h,S) represents the probability value of being extracted as an object, represents the loss of subject-object alignment extraction, n represents the total number of words in the input text, and y i,j represents the probability that the i-th word vector and the j-th word vector are entities, P matrix It represents the probability value of obtaining the true entity pair through the subject-object alignment extractor. Represents the overall loss of the entity relationship extraction model.

[0052] The present invention has the following advantages: First, by encoding the vocabulary in the input text through the encoding layer, the text information can be effectively converted into a computer-recognizable format, which is convenient for subsequent processing. Secondly, by utilizing the multi-head attention mechanism of the relationship perception layer, the potential relationship in the text can be effectively extracted, thereby improving the extraction accuracy of the entity relationship. In addition, through the entity extractor, the corresponding subject and object can be extracted from the extracted potential relationship, further improving the extraction effect of the entity relationship. Finally, the subject-object alignment extractor is used to effectively filter out redundant entity pairs and generate the final triples, thereby improving the quality of the triples.

[0053] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0055] Figure 1 It is a flowchart of an entity relationship extraction method based on relationship perception of the present invention;

[0056] Figure 2 It is a structural schematic diagram of an entity relationship extraction model of an entity relationship extraction method based on relationship perception of the present invention;

[0057] Figure 3It is a schematic diagram of the structure of a multi-head attention mechanism of an entity relationship extraction method based on relationship perception of the present invention;

[0058] Figure 4 It is a structural schematic diagram of a subject-object alignment extractor of a relationship-aware entity relationship extraction method of the present invention. DETAILED DESCRIPTION

[0059] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.

[0060] like Figure 1 and 2 As shown, a method for extracting entity relations based on relation perception includes:

[0061] S100, encoding the input text using the encoding layer to obtain a vector representation of the input text;

[0062] It should be noted that the encoding layer in this embodiment uses a pre-trained Bert model for text encoding. Bert can obtain a deep representation of the contextual semantics of words and has been widely used in entity relationship extraction tasks. In this embodiment, the output of the Bert encoder is H(S) = {h1,...,h i ,...,h n}, where S represents the sentence input to the encoder, h i represents the vector corresponding to each token in S, and n is the number of words in the sentence.

[0063] S200, inputting the vector representation of the input text into a relationship perception layer, and using the relationship perception layer to obtain potential relationships;

[0064] It should be noted that the main purpose of the relation perception layer is to extract the potential relation set R = {r1,...,r m}, where r j represents the specific type of relation extracted, and m represents the number of potential relations in R. Before extracting the relation, this embodiment first inputs the obtained vector into the multi-head attention module, such as Figure 3 As shown in Figure 2, the multi-head attention mechanism models each word in the sentence and assigns different weights to the vectors of each word in the sentence to provide it with more critical information. att Represents the word embeddings in a sentence obtained by weighted summation of the multi-head attention mechanism, which is then input into the relation-aware layer for relation extraction.

[0065] S300, inputting the potential relationship into an entity extractor to obtain a subject and an object;

[0066] It should be noted that the entity extraction layer takes the potential relationship set obtained from the relationship perception layer as input and generates triples containing redundant entity pairs as output. The entity extraction layer consists of a subject decoder and an object decoder module. The subject decoder is responsible for extracting the subject and then combining it with the potential relationship. The object decoder is then used to extract the object and generate triples. In the extraction of entities, this embodiment uses a pointer network as a decoding method to identify the entire entity by marking the start and end positions of the entity, and realizes the connection between the entity and the relationship by combining it with the potential relationship in the relationship perception layer. The ability of the pointer network to accurately mark the entire entity effectively solves the entity overlap problem relative to other decoding methods.

[0067] S400, inputting the subject and the object into a subject-object alignment extractor to filter out redundant entity pairs;

[0068] It should be noted that the triples generated by the entity extractor contain redundant triples. To solve this problem, this embodiment uses a subject-object alignment extractor to filter out redundant triples and output all valid triples. The structure of the subject-object alignment extractor is as follows: Figure 4 As shown. The subject-object alignment extractor is mainly composed of a matrix, which is used to identify valid entity pairs in a sentence. Due to the symmetry of the matrix, this embodiment only stores its upper triangular area to save storage space and reduce the time complexity of the algorithm.

[0069] S500, establishing an entity relationship extraction model, and optimizing the model through a loss function to extract triples.

[0070] It should be noted that the loss of the entity relationship extraction model consists of three parts, including the loss of the potential relationship extraction part, the entity extraction part loss and the subject-object alignment extraction part loss. The loss of the potential relationship extraction part is used to optimize the accuracy of the model in extracting potential relationships, the entity extraction part loss is used to optimize the accuracy of the model in extracting entities, and the subject-object alignment extraction part loss is used to optimize the accuracy of the model in filtering redundant entity pairs. The performance of the model is improved by minimizing the difference between the predicted subject-object alignment results and the true subject-object alignment results.

[0071] like Figure 2As shown in the figure, the entity relationship extraction model consists of an encoding layer, a relationship perception layer, an entity extractor, and a subject-object alignment extractor. The encoding layer is mainly responsible for encoding the input text and obtaining its vector representation. The relationship perception layer uses a multi-head attention mechanism to extract the potential relations therein. The extracted potential relations are then sent to the entity extractor to extract the corresponding subject and object. Since the triples extracted at this stage may still contain redundant information, the subject-object alignment extractor is used to filter out redundant entity pairs and generate the final triples.

[0072] In summary, this embodiment firstly encodes the vocabulary in the input text through the encoding layer, which can effectively convert the text information into a computer-recognizable format for subsequent processing. Secondly, by utilizing the multi-head attention mechanism of the relationship perception layer, the potential relations in the text can be effectively extracted, thereby improving the extraction accuracy of entity relations. In addition, through the entity extractor, the corresponding subject and object can be extracted from the extracted potential relations, further improving the extraction effect of entity relations. Finally, the subject-object alignment extractor is used to effectively filter out redundant entity pairs and generate the final triples, thereby improving the quality of the triples.

[0073] As an optional embodiment of the present invention, optionally, the acquiring potential relationship by using the relationship perception layer includes:

[0074] S201, inputting the vector representation of the input text into a multi-head attention module, using the multi-head attention module to assign different weights to different words in the input text, and obtaining word embedding in the input text;

[0075] The multi-head attention module is expressed by the formula:

[0076]

[0077] Among them, Attention(,,) represents the multi-head attention mechanism;

[0078] Q represents the query vector;

[0079] K represents the key vector;

[0080] V represents the value vector;

[0081] softmax() represents the activation function;

[0082] T stands for transpose;

[0083] d k Represents the dimension information of the key;

[0084] It should be noted that in this embodiment, the vector representation of the input text is sent to the multi-head attention module. The multiple parallel sub-networks inside the multi-head attention module will perform weight calculations on each word in the input text to ensure that each word receives personalized attention. Through the multi-head attention mechanism, each sub-network processes the input tag and connects their respective results in series to form the final output. This method helps the multi-head attention mechanism to extract key information from the input text more effectively. This embodiment further utilizes the weighted vocabulary embedding and inputs it into the relationship perception layer for deep processing. This not only improves the accuracy of entity relationship extraction, but also enhances the stability of entity relationship extraction.

[0085] S202, performing average pooling on the word embedding;

[0086] Its formula is expressed as:

[0087] h avg =Avgpool(h att )∈R D×1

[0088] Among them, h avg Represents the vector representation after average pooling of word embeddings;

[0089] Avgpool() represents the average pooling operation;

[0090] h att Represents word embedding;

[0091] R D×1 represents a vocabulary vector set;

[0092] It should be noted that average pooling can reduce the dimensionality of word embeddings, which reduces the computational burden of the model and reduces the complexity of the model. In addition, the introduction of trainable weights makes the average pooling operation more flexible, and weights can be allocated according to the importance of word embeddings, thereby further improving the processing effect of the relationship perception layer.

[0093] S203, using the sigmoid function to obtain potential relationships;

[0094] Its formula is expressed as:

[0095] P rel =σ(W r h avg +b r )

[0096] Among them, P rel Represents the probability of extracting potential relationships;

[0097] σ() represents the sigmoid function;

[0098] W r and b r Represents trainable weights.

[0099] It should be noted that this embodiment regards the relationship extraction task as a multi-label classification task, and therefore uses the sigmoid function to obtain the probability distribution of each relationship. If the probability value of a specific relationship exceeds the threshold λ1 (λ1 is equal to 0.5 in this embodiment), it is regarded as a potential relationship to be extracted, and its label is marked as 1. In the subsequent entity extraction layer, the present invention only extracts entities corresponding to potential relationships.

[0100] As an optional embodiment of the present invention, optionally, inputting the potential relationship into an entity extractor to obtain a subject and an object includes:

[0101] S301, using a subject decoder to obtain a subject, and using a pointer network to mark the start position and the end position of the subject, and combining the subject with the potential relationship;

[0102] The formula is:

[0103]

[0104]

[0105]

[0106] in, Indicates the predicted probability of the start position of the head entity

[0107] σ() represents the sigmoid function;

[0108] and All represent trainable parameters;

[0109] Indicates the starting position of the head entity;

[0110] Represents the predicted probability of the end position of the head entity;

[0111] Indicates the end position of the head entity;

[0112] p sub (h|r,S) represents the probability value of being extracted as the subject;

[0113] h represents the head entity;

[0114] r indicates relationship;

[0115] S represents input text;

[0116] n represents the total number of words in the text;

[0117] ∏() represents the sum operation;

[0118] Indicates whether the i-th word in the text is the start position tag of the subject;

[0119] Indicates whether the i-th word in the text is the end position tag of the subject;

[0120] It should be noted that this embodiment uses the object decoder to achieve the function of accurately extracting object entities from text. The application of the pointer network further improves the annotation accuracy of the object entity and ensures the integrity and accuracy of the object entity. By combining the object with the potential relationship, the extracted object entity is more in line with the actual semantic requirements, which improves the performance of the model in practical applications.

[0121] In the extraction of entities, the present invention uses a pointer network as a decoding method to identify the entire entity by marking the start and end positions of the entity, and realizes the connection between the entity and the relationship by combining it with the potential relationship in the relationship perception layer. The ability of the pointer network to accurately mark the entire entity effectively solves the entity overlap problem relative to other decoding methods.

[0122] S302, obtaining an object through an object decoder;

[0123] Its formula is expressed as:

[0124]

[0125]

[0126]

[0127] in, represents the predicted probability of the start position of the tail entity;

[0128] t represents the tail entity;

[0129] and All represent trainable parameters;

[0130] Indicates the starting position of the tail entity;

[0131] Represents the predicted probability of the end position of the tail entity;

[0132] Indicates the end position of the tail entity;

[0133] p obj (t|r,h,S) represents the probability of extracting the object;

[0134] n represents the total number of words in the text;

[0135] Indicates the start position tag of whether the i-th word in the text is an object;

[0136] The end position tag indicating whether the i-th word in the text is an object.

[0137] It should be noted that the object mentioned above refers to the tail entity, and extracting the tail entity refers to the extracted potential relationship and the extracted head entity. The corresponding tail entity is identified by the extracted head entity and relationship. When the starting position of the tail entity is marked, the three formulas in the above step S302 will be executed in sequence for each token (lexicon vector).

[0138] As an optional embodiment of the present invention, optionally, the method further includes:

[0139] When the When it is greater than or equal to the threshold, it means that word i is the head of the subject;

[0140] When the When it is greater than or equal to the threshold, it means that word i is the tail of the subject;

[0141] When the or / and When it is less than the threshold, it indicates that word i is an entity between the head and the tail.

[0142] It should be noted that, in terms of determining the subject head and tail, the present invention introduces the concept of a threshold, where the threshold is a certain probability value. Specifically, when the predicted probability of the start position and the end position of the head entity determined by the entity decoder exceeds a preset threshold, the position is considered to be the head or tail of the subject entity. Similarly, in terms of determining the object head and tail, when the predicted probability of the start position and the end position of the tail entity determined by the object decoder exceeds a preset threshold, the position is considered to be the head or tail of the object entity. This threshold determination method can effectively exclude some low-probability entity positions and improve the accuracy and reliability of entity extraction. The threshold in this embodiment is 1, and it can be set according to actual conditions when using the present invention.

[0143] As an optional embodiment of the present invention, optionally, inputting the subject and the object into a subject-object alignment extractor to filter out redundant entity pairs includes:

[0144] S401, establishing an entity pair matrix and setting a threshold λ2, wherein the threshold λ2 is used to distinguish correct entity pairs from incorrect entity pairs;

[0145] It should be noted that the threshold λ2 in this embodiment is equal to 2, and the threshold λ2 can be adjusted according to actual conditions to ensure that correct entity pairs and incorrect entity pairs can be distinguished.

[0146] S402, when the probability value of the subject and the object is greater than the threshold λ2, the entity pair is a correct entity pair; otherwise, when the probability value of the subject and the object is less than the threshold λ2, the entity pair is an incorrect entity pair, and the incorrect entity pair is filtered out;

[0147] Its formula is expressed as:

[0148] p matrix =σ(W[h i sub ;h j obj ]+b)

[0149] Among them, p matrix represents the probability value of obtaining a true entity pair through the subject-object alignment extractor;

[0150] σ() represents the sigmoid function;

[0151] W and b both represent trainable parameters;

[0152] h i sub Represents the i-th label as the subject in the input text;

[0153] h j obj Represents the encoded representation of the jth label as an object in the input text.

[0154] It should be noted that in Figure 4There are two real entity pairs in the sentence: (Tim, fruits) and (Jack, apple), while the remaining entity pairs marked as 0 are irrelevant entity pairs in the sentence. Due to the redundancy in the entity pairs extracted in the entity extractor, this embodiment first sets a threshold λ to distinguish between correct and incorrect entity pairs. For a sentence with n tags, it corresponds to an n×n matrix. This embodiment uses each element of the matrix to represent the starting position of each tag in the sentence. For entities with multiple tags, this embodiment selects their starting positions to represent the entire entity. For entities with multiple tokens, this embodiment selects their starting positions to represent the entire entity. For each token pair in the matrix, the sigmoid function is used to obtain the probability between each token pair. If the probability corresponding to a token pair is higher than the set threshold λ, 1 will be marked at the corresponding position in the upper triangular matrix, and it is considered to be the correct entity pair in the sentence; otherwise, it will be marked as 0 and the entity pair will be filtered out. However, since the matrix is ​​a symmetric matrix, this embodiment only takes the upper triangular part. In Figure 4 The sentences marked with “1” in the subject-object alignment extractor in are true entity pairs, and the redundant entity pairs with “0”. Since the matrix is ​​a symmetric matrix, only the upper triangular part is taken.

[0155] As an optional embodiment of the present invention, optionally, the formula of the loss function is expressed as:

[0156]

[0157]

[0158]

[0159]

[0160] in, represents the loss of extracting latent relations;

[0161] n r Represents the number of relations in a relation set;

[0162] y i represents the probability of the ith potential relationship;

[0163] P rel Represents the probability of extracting potential relationships;

[0164] Represents the loss of the entity's extraction;

[0165] E represents expected value;

[0166] p sub(h|r,S) represents the probability value of extraction as the subject;

[0167] p obj (t|r,h,S) represents the probability value of being extracted as an object;

[0168] represents the loss of subject-object alignment extraction;

[0169] n represents the total number of words in the input text;

[0170] y i,j Represents the probability that the i-th word vector and the j-th word vector are entities;

[0171] P matrix Represents the probability value of obtaining the true entity pair through the subject-object alignment extractor;

[0172] Represents the overall loss of the entity relationship extraction model.

[0173] It should be noted that the above formula is only an optional loss function formula, and the specific loss function should be designed and selected according to actual needs and model characteristics. In the present invention, the loss function is used to optimize the model parameters so that the model can better learn and predict entity relationships. By continuously optimizing the loss function, the accuracy and generalization ability of the model can be improved. In addition, the various parameters and probability values ​​in the above formula should be set and calculated according to the specific training data and tasks. In practical applications, the performance and performance of the model can be adjusted by adjusting these parameters and probability values.

[0174] Experimental study of the present invention

[0175] The experiments are conducted on two widely used public datasets for entity relationship extraction, namely WebNLG and NYT, where each dataset has two versions. The WebNLG and NYT datasets are labeled at the full entity level, while the WebNLG* and NYT* datasets are labeled at the last token of each entity. The relevant statistics of the datasets are shown in Table 1.

[0176]

[0177]

[0178] Table 1: Experimental related data statistics

[0179] This experiment compares the model proposed in this paper with previous strong baselines and state-of-the-art relation extraction models. The following lists the relevant comparison models:

[0180] GraphRel: Use GCN to build a linear correlation structure model, extract sequence features and region features from text, and use graphs to extract features of unseen word pairs in text.

[0181] OrderCopyRE: proposes the idea of ​​using reinforcement learning and considers that the extraction order in triples is important.

[0182] ETL-span: It is decomposed into two interrelated subtasks, head entity extraction and tail entity and relationship extraction. The former subtask extracts the head entity involved in the target relationship, and the latter subtask identifies the relationship between the tail entity and the head entity.

[0183] WDec: Two entity relation extraction methods are designed, the first one generates variable-length entity names and relations on the decoder side; the second one generates tuples of entities with variable entity length but only one relation.

[0184] RSAN: A Relation-Specific Attention Network for Joint Entity and Relation Extraction, which divides the model into a relation-specific sentence encoder and a relation-specific entity decoder.

[0185] CasRel: A cascaded binary tagging framework for relation triplet extraction is proposed, which can extract multiple triples simultaneously and solve the entity overlap problem.

[0186] TPLinker: A token pair linker is proposed for single-stage joint extraction of entities and relations, which solves the problem of exposure bias in joint extraction.

[0187] PRGC: It can effectively solve the problem of entity overlap. Compared with the CasRel model, the model calculation efficiency and model training and testing efficiency have been greatly improved.

[0188] Evaluation indicators and parameter settings

[0189] In order to make a fair and comprehensive comparison, this experiment uses precision, recall and F1 score as evaluation indicators. Only when all three components are accurately predicted, this experiment considers the predicted triple (subject, relation, object) to be correct.

[0190] In order to compare with the baseline model, this experiment uses the pre-trained BERT as the encoder of the model. The model of this experiment uses the AdamW optimizer with a batch size of 6 and is trained for 100 rounds. The learning rate is set to 1e-4, and the threshold of the relation extraction layer and the threshold of the subject-object aligner are set to λ=0.5.

[0191]

[0192] Table 2: Comparison of RPnet method with previous works. Bold indicates the highest score.

[0193] Overall experimental results

[0194] Table 2 shows the results of the model in this experiment on different versions of the two datasets. It can be observed that the model in this experiment outperforms the baseline model in almost all aspects. On the NYT* and NYT datasets, this experiment improved by 0.7 points and 0.8 points respectively over the best baseline model. On the WebNLG and WebNLG* datasets, this experiment obtained improvements of 0.6 points and 0.6 points respectively, proving that RPnet can effectively improve the performance of triple extraction. This experiment believes that this is mainly because extracting latent relations can significantly filter out irrelevant relations in the sentence. In addition, extracting subjects and objects based on a set of extracted latent relations greatly enhances the connection between relations and entities and effectively avoids entity redundancy.

[0195] Ablation studies

[0196] In order to further evaluate the contribution of the main components of the model, this experiment conducted an ablation experiment. In each experiment, this experiment deleted a key component of the model to evaluate its impact on the experimental results. The experimental results are shown in Table 3.

[0197] Relation-aware layer: The relation-aware layer is removed from the model, and all predefined relations in the sentence are used for entity extraction instead of latent relations. Experiments show that the performance of triple extraction is significantly reduced. This experiment attributes it to the excessive number of predefined relations (e.g., 171 relations in WebNLG), which leads to relation redundancy and thus reduces the performance of extracting triples. In addition, too many relations also increase the inference time of the model.

[0198] Entity Extractor: This experiment removed the entity extractor from the model and used a span-based method instead of a pointer network method to extract the subject and object. The experiments showed that the effectiveness of this method dropped significantly. The main reason is that the span-based method extracts more redundant entities, and the method ignores the relationship between the subject and the object when extracting long entities and identifying the subject and object. In this paper, by adopting the pointer network method on the entity extraction order and combining it with the relationship-aware scenario, it promotes a better connection between relations and entities. The experimental results prove that the pointer network method of this experiment is better.

[0199] Subject-Object Alignment Extractor: This experiment removed the subject-object alignment extractor from the model and used the output of the entity extractor as the final result. The experimental results show that the performance is significantly degraded. This can be attributed to the fact that the entity extractor extracts all entities related to the potential relation, thus creating redundancy in the extracted triples.

[0200]

[0201] Table 3: Ablation experiments

[0202]

[0203] Table 4: Scores under different entity overlap methods

[0204] Performance under different overlapping modes

[0205] In order to study the performance of our model in the case of entity overlap, this experiment is conducted on two different overlapping scenarios, namely EPO and SEO. The experiments are conducted on the WebNLG* and NYT* datasets, and the results are shown in Table 4. It can be observed that RPnet outperforms most baseline methods in both overlapping scenarios, which shows that it is effective in handling the task of triple extraction in complex contexts.

[0206] Experimental Conclusion

[0207] In this paper, this experiment proposes a relation-aware entity relation extraction method (RPnet). It is a joint extraction framework that first extracts latent relations from text, then extracts subjects and objects based on latent relations, and finally introduces a subject-object aligner to remove redundant entity pairs. RPnet achieves excellent entity relation extraction performance on public datasets and effectively solves the challenges of entity nesting and entity overlap.

[0208] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.

Claims

1. A method for extracting entity relations based on relation perception, characterized in that: The method comprises: S100, encoding the input text using the encoding layer to obtain a vector representation of the input text; S200, inputting the vector representation of the input text into a relationship perception layer, and using the relationship perception layer to obtain potential relationships; using the relationship perception layer to obtain potential relationships includes: S201, inputting the vector representation of the input text into a multi-head attention module, using the multi-head attention module to assign different weights to different words in the input text, and obtaining word embedding in the input text; The multi-head attention module is expressed by the formula: Among them, Attention(,,) represents the multi-head attention mechanism, Q represents the query vector, K represents the key vector, V represents the value vector, softmax() represents the activation function, T represents the transposition, d k Represents the dimension information of the key; S202, performing average pooling on the word embedding; Its formula is expressed as: h avg =Avgpool(h att )∈R D×1 Among them, h avg Represents the vector representation of the word embedding after average pooling, Avgpool() represents the average pooling operation, h att represents word embedding, R D×1 Represents a vocabulary vector set; S203, using the sigmoid function to obtain potential relationships; Its formula is expressed as: P rel =σ(W r h avg +b r ) Among them, P rel represents the probability of extracting potential relationships, σ() represents the sigmoid function, and W r and b r represents trainable weights; S300, inputting the potential relationship into an entity extractor to obtain a subject and an object; S400, inputting the subject and the object into a subject-object alignment extractor to filter out redundant entity pairs; S500, establishing an entity relationship extraction model, and optimizing the model through a loss function to extract triples.

2. The entity relationship extraction method based on relationship perception as claimed in claim 1, characterized in that: Inputting the potential relationship into an entity extractor to obtain a subject and an object includes: S301, using a subject decoder to obtain a subject, and using a pointer network to mark the start position and the end position of the subject, and combining the subject with the potential relationship; The formula is: in, represents the predicted probability of the starting position of the head entity, σ represents the sigmoid function, and All represent trainable parameters, Indicates the starting position of the head entity. represents the predicted probability of the end position of the head entity, Indicates the end position of the head entity, p sub (h|r,S) represents the probability value of extraction as the subject, h represents the head entity, r represents the relationship, S represents the input text, n represents the total number of words in the text, ∏() represents the sum operation, Indicates whether the i-th word in the text is the start position tag of the subject, Indicates whether the i-th word in the text is the end position tag of the subject; S302, obtaining an object through an object decoder; Its formula is expressed as: in, represents the predicted probability of the start position of the tail entity, t represents the tail entity, and All represent trainable parameters, Indicates the start position of the tail entity. represents the predicted probability of the end position of the tail entity, Indicates the end position of the tail entity, p obj (t|r,h,S) represents the probability of extracting the object. Indicates whether the i-th word in the text is the start position tag of the object, The end position tag indicating whether the i-th word in the text is an object.

3. The entity relationship extraction method based on relationship perception as claimed in claim 2, characterized in that: The method further comprises: When the When it is greater than or equal to the threshold, it means that word i is the head of the subject; When the When it is greater than or equal to the threshold, it means that word i is the tail of the subject; When the or / and When it is less than the threshold, it indicates that word i is an entity between the head and the tail.

4. The entity relationship extraction method based on relationship perception as claimed in claim 1, characterized in that: The step of inputting the subject and the object into a subject-object alignment extractor and filtering out redundant entity pairs comprises: S401, establishing an entity pair matrix and setting a threshold λ2, wherein the threshold λ2 is used to distinguish correct entity pairs from incorrect entity pairs; S402, when the probability value of the subject and the object is greater than the threshold λ2, the entity pair is a correct entity pair; otherwise, when the probability value of the subject and the object is less than the threshold λ2, the entity pair is an incorrect entity pair, and the incorrect entity pair is filtered out; Its formula is expressed as: Among them, p matrix represents the probability value of obtaining the true entity pair through the subject-object alignment extractor, σ represents the sigmoid function, W and b both represent trainable parameters, and h i sub represents the i-th label in the input text as the main body, h j obj Represents the encoded representation of the jth label as an object in the input text.

5. The entity relationship extraction method based on relationship perception as claimed in claim 4, characterized in that: The formula of the loss function is expressed as: in, represents the loss of extracting potential relations, n r Represents the number of relations in the relation set, y i represents the probability of the ith potential relationship, P rel represents the probability of extracting potential relationships, represents the loss of entity extraction, E represents the expected value, and p sub (h|r,S) represents the probability value of extraction as the subject, p obj (t|r,h,S) represents the probability value of being extracted as an object, represents the loss of subject-object alignment extraction, n represents the total number of words in the input text, and y i,j represents the probability that the i-th word vector and the j-th word vector are entities, P matrix It represents the probability value of obtaining the true entity pair through the subject-object alignment extractor. Represents the overall loss of the entity relationship extraction model.

Citation Information

Cited By

  • Relation triple joint extraction method based on information enhancement and bidirectional modeling

    CN120764530A