A translation-based entity and relationship joint extraction system and usage method

Through the joint extraction system of entities and relationships based on the translation mechanism, combined with the encoding and annotation modules, the problems of redundant prediction, overlap and relationship correlation in the joint extraction of entities and relationships are solved, achieving more accurate triple extraction and improving The effect of knowledge graph construction.

CN114065781BActive Publication Date: 2024-09-03BEIJING INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111303044.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-05
Publication Date
2024-09-03
Estimated Expiration
2041-11-05

AI Technical Summary

Technical Problem

Existing technologies have problems such as redundant prediction, overlapping problems, and difficulty in capturing relationship correlations in joint extraction of entities and relationships. Especially when dealing with redundant triples, overlapping entity pairs, and single-entity overlapping scenarios, traditional methods are difficult to be effective. solve.

Method used

A joint extraction system for entities and relationships based on the translation mechanism is adopted. By combining the encoding module, entity annotation module and relationship prediction module, the byte pair encoding, BERT model and translation mechanism ideas are used to calculate the relationship representation between entities, and through the loss Functional optimization trains models to address redundant predictions, overlaps, and relational correlations.

Benefits of technology

It effectively solves the problems of redundant prediction, overlapping triples and relationship correlation, improves the accuracy of joint extraction of entities and relationships, and can handle multiple relationships in a unified system, especially the ability to process symmetric relationships and no relationships. Improved the accuracy of knowledge graph construction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114065781B
    Figure CN114065781B
Patent Text Reader

Abstract

The present invention proposes a joint extraction system of entities and relations based on a translation mechanism and a method for using the same. The system utilizes the idea of ​​a translation mechanism and avoids the problem of traditional translation mechanisms in handling symmetric relations. It proposes to use NA (no relation) relations as a dynamic threshold to demarcate correct and incorrect results of relation prediction. The entity annotation part uses four 0 / 1 annotators to independently annotate the head entity and the tail entity, which can solve the problem of single entity overlap. For each group of head and tail entities, the idea of ​​a translation mechanism is used to use h+r≈t, and the vector representation of the relationship is obtained by subtracting the head entity from the tail entity, and then the similarity is calculated with the vectors of all relations in the relation set, and the "similarity with the NA relationship" is used as a dynamic threshold, and all relations with a similarity greater than the relationship are taken as prediction results, thus solving the problem of entity pair overlap. Experiments on public data sets show that the method of the system can achieve a good level.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing and deep learning technology, and in particular to a translation-based entity and relationship joint extraction system and a use method. Background Art

[0002] Joint extraction of entities and relations is defined as a task to extract structured knowledge in the form of triples (head, relation, tail) from unstructured text, which is very important in natural language processing and automatic construction of knowledge graphs. For example, the sentence "The Summer Palace is in Beijing, the capital of China" can form triples such as (Summer Palace, located in Beijing), (Beijing, located in China), (Beijing, is the capital of..., China), (Summer Palace, located in China).

[0003] Traditional pipeline methods treat entity recognition and relation extraction as two independent tasks, ignoring the relationship between them, and thus suffer from the problem of error propagation. In recent years, many researchers have focused on building joint models. Although great success has been achieved, no work has yet been able to address three key issues in a unified system:

[0004] The first problem is redundant prediction. Many joint extraction methods adopt an extraction-before-classification approach to extract triples: first detect all possible entities in the sentence, and then classify the type of relationship between each entity pair. This logically separated paradigm makes the task easy to handle and makes each component more flexible, but the relationship classifier may be misled by some unrelated entity pairs, because N entities will produce nearly N 2 entity pairs, but most of them do not have any relationship.

[0005] The second problem is the overlap problem. A sentence may contain entity pair overlap (EPO) and single entity overlap (SEO). Entity pair overlap means that an entity pair has multiple relations, while single entity overlap means that two triples share an overlapping entity. This problem directly affects some classic methods, which usually assume that each entity holds at most one relation. Existing research methods to solve this problem usually convert the task into sequence labeling or text clustering. Although they have achieved good results, considering each relation separately will inevitably ignore the connection between them, making it difficult to discover implicit triples.

[0006] The third issue is relational association. The correlation between relations is very important for entity pair overlap and single entity overlap scenarios. For example, in the sentence "The Summer Palace is located in Beijing, the capital of China", the triple (Beijing, located in, China) can be derived from the triple (Beijing, is the capital of, China). Although such a situation is common for knowledge graph tasks, it is difficult to capture the correlation between relations for joint extraction tasks that do not contain entities in the input.

[0007] Therefore, we design and implement a unified entity and relation joint extraction system to address three important challenges: redundant prediction, overlapping triples, and relation connections. Summary of the invention

[0008] In order to solve the three important challenges of redundant prediction, overlapping triples, and relation association in a unified system, the present invention provides an entity and relation joint extraction system based on a translation mechanism, and names it TransRel, the system comprising:

[0009] An encoding module, used for encoding the received sentence into a vector sequence, and transmitting the vector sequence to the entity labeling module;

[0010] An entity labeling module is used to label the vector sequence to obtain all head entity vector sets and tail entity vector sets contained in the sentence; and then transmit the head entity vector set and the tail entity vector set to the relationship prediction module;

[0011] The relationship prediction module predicts the relationship between the head entity vector and the tail entity vector, thereby obtaining the relationship between each pair of head and tail entities.

[0012] Furthermore, in the encoding module, the encoding method includes:

[0013] S11. Use byte pair encoding (BPE) to segment the input sentence into a sequence of characters contained in the vocabulary. The purpose of this step is to convert low-frequency words into simple word segmentation representations so that the word segmentation results can exist in the vocabulary of the BERT model to prevent the OOV (out-of-vocabulary) phenomenon.

[0014] For example, a word "playing" will be converted into two parts ['play', '##ing'] after the BPE algorithm, both of which exist in the vocabulary of the BERT model;

[0015] S12, perform symbol embedding and position embedding on the character sequence generated in step S11, and add them together as the overall embedding of the word:

[0016] t i =wi +p i

[0017] Among them, w i and p i They represent the symbol embedding and position embedding of the word respectively, and the embedding matrices are all randomly initialized.

[0018] The final sentence embedding is represented as: [t1, t2, t3, …, t l ], l represents the sentence length.

[0019] S13. Input the sentence embedding into the pre-trained BERT model to obtain the sentence representation (vector sequence):

[0020] s=(e1,e2,e3,…,e l )

[0021] Where l represents the length of the sentence.

[0022] Furthermore, in the entity annotation module, the annotation method includes:

[0023] S21, using a tagger to mark the word as belonging to the beginning or end of the head entity or the tail entity;

[0024] For example, using 4 0 / 1 taggers, we can tag each word vector with 0 / 1 and get a 4-bit 0 / 1 sequence. Each bit of the 4-bit 0 / 1 sequence represents:

[0025] The first position: is not / is the beginning of the header entity,

[0026] The second position: is not / is the end of the header entity,

[0027] The third position: is not / is the beginning of the tail entity,

[0028] Position 4: is not / is the end of the tail entity;

[0029] S22. According to the 0 / 1 labeling result obtained in S11, a vector sequence corresponding to each head entity and tail entity is obtained, that is, a vector sequence between the beginning and the end (including both ends) is taken. If the beginning and the end of the head entity or the tail entity are in the same position, it means that the entity contains only one word, and the vector is directly used as the final representation of the entity;

[0030] S23. For entities with more than one vector (multi-word entity), average pooling is used to compress the vector sequence between the beginning and the end (including the beginning and the end) into a single vector as the vector representation of the entity.

[0031] Furthermore, the 0 / 1 tagger in step S21 includes two fully connected networks, which takes context-dependent representations (in this system, e i ) as input and output a 0 / 1 sequence, where the result of the i-th symbol labeling is calculated as:

[0032]

[0033]

[0034] Among them and Respectively represent the probability that the position of the i-th symbol in the input sequence belongs to the beginning and the end, W (·) and b (·) represents the trainable weights and bias values, and σ() represents the sigmoid activation function. For the final calculation result, we set a threshold θ and assume that if p ≥ θ, then p = 1.

[0035] Furthermore, in the relationship prediction module, the prediction method includes:

[0036] S31, each head entity h in the head entity set obtained in the entity annotation module i , respectively with each tail entity t in the tail entity set j , using the idea of ​​the translation mechanism, do vector subtraction to get their relationship vector r, that is:

[0037]

[0038] Among them, W t and W h The purpose of adding these two matrices is to prevent the relationship r from being symmetrical when the direct subtraction will make it tend to The mapping matrix is ​​a parameter matrix that is randomly initialized and gradually trained in the training module.

[0039] S32, the relationship vector obtained in step S31 The similarity is calculated with the relation representation vectors of all relations in the relation set, and a hierarchical sequence of similarities is obtained.

[0040] Rank=[x1,x2,x3,...,x N , x NA ]

[0041]

[0042]

[0043] Among them, ri The relation representation vector of the i-th relation in the set of all relations, r NA The relationship representation vector of "NA" is the vector representation of "no relationship", and N represents the number of relationships in the relationship set. Here, all relationship representation vectors are obtained by training through the training module after random initialization, including NA relationships. i Represents the similarity with the i-th relationship, x NA Indicates the similarity with no relation.

[0044] S33, calculated Sort the similarity sequence of the representation vectors of all relations in the relation set in descending order, and take the relation with higher similarity than the NA relation as the relation prediction result. If there are multiple relations, it means that there are multiple relations between the head and tail entity pairs, and all of these relations are taken as the prediction results. In particular, if the similarity with the NA relation is the largest, then take the NA relation as the prediction result, which means that there is "no relation" between the two entities.

[0045] In step S31, the reason for adding the weight matrix is ​​that the traditional translation mechanism directly calculates the relationship vector without introducing additional parameters, but the traditional translation mechanism cannot handle symmetric relationships, that is, if the triple (h, r, t) satisfies h+r≈t and t+r≈h, it will lead to In order to solve this problem, the weight matrix W is introduced into the model. t and W h .

[0046] Furthermore, in the relationship prediction module, the entity labeling module is trained and the relationship prediction module is trained, and the final training goal is to minimize the sum of the loss functions of the entity labeling module and the relationship prediction module.

[0047] Furthermore, the loss function of the entity annotation module includes the head entity prediction loss and tail entity prediction loss The calculation formulas for both are as follows:

[0048]

[0049]

[0050] Among them, s j represents the jth sentence, |D| represents the size of the training set, and H j and T j They represent the set of head entities and tail entities marked in the jth sentence. The likelihood function p(h|s j ) is calculated as:

[0051]

[0052] Here l represents the length of the sentence. and is the true 0 / 1 label of the i-th character in the sentence. The I(x) function is defined as follows:

[0053]

[0054] Likelihood function p(t|s j ) is defined in the same way.

[0055] Furthermore, the loss function of the relation prediction module includes the prediction loss of the correct relation triple and NA relationship prediction loss

[0056] Among them, the correct relation triple prediction loss function is defined as:

[0057]

[0058] Among them, C j represents the set of correct relation triples in the jth sentence, and r represents C j The vector representation of a certain relation in . The correct relation triple is the triple whose head entity and tail entity have relation r, i.e. (head entity, correct relation, tail entity). |D| represents the size of the training set; v t and v h For the formula t in j and h i ;

[0059] The definition is similar to the above formula. Just replace C j Replace with N j , N j It represents the set of negative examples obtained by replacing the head entity or tail entity of each correct relation triple in sentence j with an incorrect head entity or tail entity, and replacing the relation with an NA relation. Adding data to the NA relation is to enable the system to better learn the characteristics of the NA relation, so as to generate the correct NA relation vector as the threshold for relation prediction.

[0060] The loss function of the final relationship prediction part The definition is as follows:

[0061]

[0062] Where λ is the reconciliation factor, which satisfies λ<<1. The purpose is to reduce the importance of NA relationship relative to other correct relationships, so that it can become the lowest level of "correct relationship" in relationship prediction and serve as a dynamic threshold as the boundary between predicted results and non-predicted results.

[0063] Furthermore, the final total loss function of the extraction system is for:

[0064]

[0065] Training is performed based on this loss function. During the training process, the Adam algorithm is used to optimize the parameters in the entire system.

[0066] Furthermore, negative samples are generated as follows:

[0067] For example, for the correct triple (h, r, t), two NA relation samples are generated accordingly:

[0068] (h′, NA, t)

[0069] (h, NA, t′)

[0070] Among them, h' and t' are the original h and t, which are randomly replaced by other incorrect head and tail entities. If there are multiple head / tail entities in the sentence, h and t will be randomly replaced by other head / tail entities in the sentence; if there are no other head / tail entities in the sentence, h and t will be randomly replaced by head / tail entities in other sentences.

[0071] According to another aspect of the present invention, a method for using a translation-based entity and relationship joint extraction system is proposed, comprising:

[0072] 1. Training the extraction system;

[0073] 2. Input a sentence to the extraction system, and the extraction system outputs a correct relation triple;

[0074] The training steps include:

[0075] S1, input the sentence into the training module;

[0076] S2, the training module inputs the sentences in the data set into the encoding module to obtain the vector representation of each sentence;

[0077] S3, the encoding module inputs the vector representation of the sentence into the entity labeling module, and the entity labeling module labels the head entity and the tail entity with 0 and 1, thereby obtaining the head entity set and the tail entity set of each sentence;

[0078] S4, transmitting the head entity set and the tail entity set to a relationship prediction module, and predicting and outputting the relationship between the head and tail entities in the relationship prediction module;

[0079] S5. Calculate the loss function of the entity labeling module and the loss function of the relationship prediction module in the training module, and add them together to obtain a total loss function;

[0080] S6. Apply the total loss function to all training parameters, including the weight parameters of the fully connected network in the entity annotation module, W t and W h , and the representation vectors of all relationships are derived, and these parameters are updated and optimized using back propagation;

[0081] S7. Iterate according to steps S1-S6 until the value of the total loss function is less than the set threshold, or the number of training rounds reaches a maximum.

[0082] Compared with the existing entity-relationship joint extraction system, the entity-relationship joint extraction system based on the translation mechanism described in the present invention has the following beneficial effects:

[0083] (1) The entity and relationship joint extraction system described in the present invention utilizes the idea of ​​translation mechanism for the first time to calculate the relationship representation between head and tail entities, and avoids the limitations of translation mechanism for symmetric relationships, so that the idea of ​​translation mechanism can better serve data with symmetric relationships.

[0084] (2) The entity and relationship joint extraction system described in the present invention defines and trains the vector representation of NA relationships, so that the NA vector can have the standard of "identifying" unrelated entities and can serve as a dynamic threshold, becoming the "dividing line" between correct and incorrect relationships in the relationship prediction stage.

[0085] (3) The entity and relationship joint extraction system described in the present invention trains and optimizes non-NA relationships so that the relationship vectors with related relationships are close in distance. Therefore, the dynamic threshold of the NA relationship can be used to predict multiple relationships between the head and tail entities at one time, effectively solving the problem of entity pair overlap.

[0086] (4) The entity and relationship joint extraction system described in the present invention can extract all possible head and tail entities by independently marking the head entity and the tail entity. That is, the same entity can be included in both the head entity set and the tail entity set. In this way, the problem of single entity overlap can be solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0087] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0088] Figure 1 A schematic diagram of the use of an extraction system according to an embodiment of the present invention;

[0089] Figure 2 A schematic diagram of a coding process of an extraction system according to an embodiment of the present invention;

[0090] Figure 3 A schematic diagram of a flow chart of an entity annotation module of an extraction system according to an embodiment of the present invention;

[0091] Figure 4 A schematic diagram of a flow chart of a relationship prediction module of an extraction system according to an embodiment of the present invention;

[0092] Figure 5 A schematic diagram of a flow chart of a training method for an extraction system according to an embodiment of the present invention;

[0093] Figure 6 This is a statistical diagram showing the impact of different λ values ​​of the extraction system on experimental results according to one embodiment of the present invention. DETAILED DESCRIPTION

[0094] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0095] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0096] In order to make the technical solutions and advantages in the examples of this application more clear, the following further describes the exemplary embodiments of this application in detail in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this application, rather than an exhaustive list of all the embodiments. It should be noted that the examples in this application can be combined with each other in the absence of conflict.

[0097] The present invention provides a translation-based entity and relationship joint extraction system. Figure 1As shown in the figure, when the user inputs the sentence "Yiheyuan is located in Beijing, the capital of China", the system will output the triple (Yiheyuan, located_in, Beijing), (Beijing, capital_of, China). The triple is a standard relational triple in the format of (h, r, t). If h and t have a relation r, then it becomes a correct relational triple. Generally speaking, the relation r is a non-bidirectional relation.

[0098] The present invention proposes a joint extraction system of entities and relations based on translation mechanism, such as Figure 1 As shown, it includes an encoding module, an entity annotation module and a relationship prediction module.

[0099] An encoding module, used for encoding the received sentence into a vector sequence, and transmitting the vector sequence to the entity labeling module;

[0100] An entity labeling module is used to label the vector sequence to obtain all head entity vector sets and tail entity vector sets contained in the sentence; and then transmit the head entity vector set and the tail entity vector set to the relationship prediction module;

[0101] The relationship prediction module predicts the relationship between the head entity vector and the tail entity vector, thereby obtaining the relationship between each pair of head and tail entities.

[0102] In the encoding module, the encoding workflow is as follows Figure 2 As shown, the specific steps are:

[0103] S11. Use byte pair encoding (BPE) to segment the input sentence into a sequence of characters contained in the vocabulary. The purpose of this step is to convert low-frequency words into simple word segmentation representations so that the word segmentation results can exist in the vocabulary of the BERT model to prevent the OOV (out-of-vocabulary) phenomenon (for example, a word "playing" will be converted into two parts ['play', '##ing'] after the BPE algorithm, and both parts exist in the BERT vocabulary).

[0104] S12, perform symbol embedding and position embedding on the character sequence generated in step S11, and add them together as the overall embedding of the word:

[0105] t i =w i +p i

[0106] Among them, w i and p iThey represent the symbol embedding and position embedding of the word respectively, and the embedding matrices are randomly initialized. The final sentence embedding is expressed as: [t1, t2, t3, …, t l ], l represents the sentence length.

[0107] S13. Input the sentence embedding into the pre-trained BERT to obtain the sentence representation (vector sequence):

[0108] s=(e1,e2,e3,…,e l )

[0109] Where l represents the length of the sentence.

[0110] In step S2, the workflow of the entity annotation module is as follows: Figure 3 As shown, the specific steps are as follows:

[0111] S21. First, use 4 0 / 1 taggers to perform 0 / 1 tagging on each word vector to obtain a 4-bit 0 / 1 sequence. Each bit of the 4-bit 0 / 1 sequence represents:

[0112] The first position: is not / is the beginning of the header entity,

[0113] The second position: is not / is the end of the header entity,

[0114] The third position: is not / is the beginning of the tail entity,

[0115] Position 4: is not / is the end of the tail entity;

[0116] The 0 / 1 tagger here is composed of two fully connected networks at its core. The classifier takes the context-dependent representation (in this system, e i ) as input and output a 0 / 1 sequence, where the head / tail entity labeling result of the i-th symbol is calculated as:

[0117]

[0118]

[0119] Among them and Represents the probability that the position of the i-th symbol in the input sequence belongs to the start position of the head / tail entity and the end position, respectively, and W (·) and b (·) represents the trainable weights and bias values, and σ() represents the sigmoid activation function. For the final calculation result, we set a threshold θ and assume that if p ≥ θ, then p = 1.

[0120] S22. Based on the 0 / 1 labeling results obtained in S11, the vector sequence corresponding to each head / tail entity is obtained. That is, the vector sequence between the beginning and the end (including both ends) is taken. If the beginning and the end are in the same position, it means that the entity contains only one word, and the vector is directly used as the final representation of the entity;

[0121] S23. For entities with more than one vector (multi-word entity), average pooling is used to compress the vector sequence into a single vector as the vector representation of the entity.

[0122] The relationship prediction step in step S3 is as follows Figure 4 As shown, the specific steps are as follows:

[0123] S31, each head entity h in the head entity set obtained in step S2 i , respectively with each tail entity t in the tail entity set j , using the idea of ​​the translation mechanism, do vector subtraction to get their relationship vector r, that is:

[0124]

[0125] Among them, W t and W h The purpose of adding these two matrices is to prevent the relationship r from being symmetrical when the direct subtraction will make it tend to The traditional translation mechanism directly calculates the relationship vector without introducing additional parameters. However, the traditional translation mechanism cannot handle symmetric relationships. Therefore, if the triple (h, r, t) satisfies h+r≈t and t+r≈h, it will cause In order to solve this problem, the weight matrix W is introduced into the model. t and W h The mapping matrix is ​​a randomly initialized parameter matrix that can be gradually trained during training.

[0126] S32, the relationship vector obtained in step S31 The similarity is calculated with the relation representation vectors of all relations in the relation set, and a hierarchical sequence of similarities is obtained.

[0127] Rank=[x1,x2,x3,...,x N , x NA ]

[0128]

[0129]

[0130] Among them, ri Represents the relation representation of the i-th relation in the set of all relations, r NA The vector representation of "NA" relations, i.e. "no relations", is represented by N, where N represents the number of relations in the dataset. Here, all relation representation vectors are randomly initialized and then trained in the training step, including NA relations.

[0131] S33, for the calculated Sort the similarity sequence of the representation vectors of all relations in the relation set in descending order, and take the relation with a higher similarity than the NA relation as the relation prediction result. If there are multiple relations, it means that there are multiple relations between the head and tail entity pairs, and all of these relations are taken as the prediction results. In particular, if the similarity with the NA relation is the largest, then take the NA relation as the prediction result, which means that there is "no relation" between the two entities.

[0132] Here, after being sorted in descending order, the NA relationship serves as a dynamic threshold, that is, the "dividing line" between the correct relationship set and the incorrect relationship set. The relationship with a similarity higher than the similarity with NA is the correct relationship, and the relationship with a similarity lower than NA is the wrong relationship.

[0133] The system also includes a training module for training the entire system, including the training of the entity labeling module and the relationship prediction module. The final training goal is to minimize the sum of the loss functions of the entity labeling module and the relationship prediction module. The BERT representation model and the corresponding byte pair (BPE) encoder used in the encoding module are pre-trained, so we don’t need to train them again. We can use them directly. For example, the BERT model can be directly called by introducing the BERT library function and downloading the corresponding pre-trained weights. The word sequence segmented by BPE can be directly generated into a word vector sequence with context information.

[0134] The loss function of the entity annotation module includes the head entity prediction loss and tail entity prediction loss The calculation formulas for both are as follows:

[0135]

[0136]

[0137] Among them, s j represents the jth sentence, |D| represents the size of the training set, and H j and T j They represent the set of head entities and tail entities marked in the jth sentence respectively. The likelihood function p(h|s j ) is calculated as:

[0138]

[0139] Here l represents the length of the sentence. and is the 0 / 1 label of the i-th character in the sentence. The I(x) function is defined as follows:

[0140]

[0141] Likelihood function p(t|s j ) is defined similarly, as follows:

[0142]

[0143] and is the true 0 / 1 label of the i-th word in the sentence, It means that the position of the i-th word in the sentence is start; It means that the position of the i-th word in the sentence is end. Represents the probability that the position of the i-th word in the sequence tagging result is start; Represents the probability that the position of the i-th word in the sequence tagging result is end. q∈{start, end} means that q is taken as start and end respectively.

[0144] The loss function of the relation prediction part includes the prediction loss of the correct relation triple and NA relationship prediction loss

[0145] Among them, the correct relation triple prediction loss function is defined as:

[0146]

[0147] Among them, C j represents the set of correct relation triples in the jth sentence, and r represents C j The vector representation of a certain relationship in . |D| represents the size of the training set; v t and v h That is the formula t in j and h i .

[0148] The definition is similar to the above formula. Just replace C j Replace with N j , N jrepresents a set of negative examples, that is, the head entity or tail entity of each correct relation triple in sentence j is replaced with an incorrect head entity or tail entity, and the relation is replaced with a NA relation. Adding data to the NA relation is to enable the system to better learn the characteristics of the NA relation, so as to generate the correct NA relation vector as the threshold for relation prediction.

[0149] For example, for the correct triple (h, r, t), two negative examples are generated accordingly:

[0150] (h′, NA, t)

[0151] (h, NA, t′)

[0152] Among them, h' and t' are the original h and t, which are randomly replaced by other incorrect head and tail entities. If there are multiple head / tail entities in the sentence, h and t will be randomly replaced by other head / tail entities in the sentence; if there are no other head / tail entities in the sentence, h and t will be randomly replaced by head / tail entities in other sentences.

[0153] The loss function of the final relationship prediction part The definition is as follows:

[0154]

[0155] Where λ is the reconciliation factor, which satisfies λ<<1. The purpose is to reduce the importance of NA relationship relative to other correct relationships, so that it can become the lowest level of "correct relationship" in relationship prediction and serve as a dynamic threshold as the boundary between predicted results and non-predicted results.

[0156] The final total loss function of the system for:

[0157]

[0158] In the training module, the entity labeling module and the relationship prediction module are trained according to the final total loss function, which specifically includes: calculating the loss function of the entity labeling module, the loss function of the relationship prediction module, and the final total loss function; applying the total loss function to all training parameters (including the weight parameters of the fully connected network in the entity labeling module, W t and W h , and the representation vectors of all relationships, etc.), and use back propagation to update and optimize these parameters. Iterate in this way until the final loss function value is less than the set threshold, or the number of training rounds reaches the maximum. During the training process, the Adam algorithm is used to optimize the parameters in the entire system.

[0159] According to another aspect of the present invention, a method for using a translation-based entity and relationship joint extraction system is proposed, comprising:

[0160] 1. Training the extraction system;

[0161] 2. Input a sentence to the extraction system, and the extraction system outputs a correct relation triple;

[0162] Among them, the training steps are as follows: Figure 5 As shown, including:

[0163] S1, input the sentences in the data set into the training module;

[0164] S2, the training module inputs the sentences in the data set into the encoding module to obtain the vector representation of each sentence;

[0165] S3, the encoding module inputs the vector representation of the sentence into the entity labeling module, and the entity labeling module labels the head entity and the tail entity with 0 and 1, thereby obtaining the head entity set and the tail entity set of each sentence;

[0166] S4, transmitting the head entity set and the tail entity set to a relationship prediction module, and predicting and outputting the relationship between the head and tail entities in the relationship prediction module;

[0167] S5. Calculate the loss function of the entity labeling module and the loss function of the relationship prediction module in the training module, and add them together to obtain a total loss function;

[0168] S6. Apply the loss function to all training parameters including the weight parameters of the fully connected network in the entity annotation module, W t and W h , and the representation vectors of all relationships are derived, and these parameters are updated and optimized using back propagation;

[0169] S7. Iterate according to steps S1-S6 until the value of the total loss function is less than the set threshold, or the number of training rounds reaches a maximum.

[0170] The effectiveness of the present invention is illustrated in the following experimental part.

[0171] The data sets used in the experimental part of the present invention are the NYT data set and the WebNLG data set, both of which are public data sets from Google. The data information in the two data sets is shown in Table 1:

[0172] Table 1 Dataset composition

[0173]

[0174] Specifically, the NYT dataset is a dataset built using a remote supervision method, which contains 24 kinds of relations and 5,000 sentences as a validation set. WebNLG was originally a dataset created for natural language generation tasks, but was later modified by researchers to be used for relation extraction. The dataset contains 171 kinds of relations and 500 sentences as a validation set.

[0175] In addition, for the comparison model, we selected CasRel, TPLinker, RSAN, CGT, CopyRE, GraphRel and RIFRE models as baselines; for the evaluation indicators of the results, we selected accuracy, recall and F1 value as the basis for judgment. The experimental results of each baseline model and the method proposed in this invention are shown in Table 2:

[0176] Table 2 Comparison of experimental results of various models (unit: %)

[0177]

[0178] In addition, for the problem of single entity overlap and entity pair overlap, we also counted the detailed information of the above experiments. For the sake of simplicity, only the F1 value is shown, as shown in Table 3 and Table 4. EPO and SEO represent sentences with entity pair overlap and single entity overlap, respectively. The N value represents that the sentence contains N triples, and the corresponding columns correspond to the effects on these sentences.

[0179] Table 3 F1 value of each type of relation extraction effect in NYT dataset (unit: %)

[0180]

[0181] Table 4 F1 value of relation extraction effect of each type in WebNLG dataset (unit: %)

[0182]

[0183] It is not difficult to see from the results that the method we used can achieve good results. In addition, for the harmonic factor λ in the method used, we also conducted some experiments to analyze the impact of different λ values ​​on the results. The experimental results are as follows Figure 6 shown.

[0184] Those skilled in the art will appreciate that the foregoing embodiments are merely intended to illustrate the technical solutions of the present invention rather than to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will appreciate that the technical solutions described in the foregoing embodiments may be modified or some or all of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope defined by the claims of the present invention.

Claims

1. A translation-based entity and relationship joint extraction system, characterized in that: The system comprises: An encoding module, used for encoding the received sentence into a vector sequence, and transmitting the vector sequence to the entity labeling module; An entity labeling module is used to label the vector sequence to obtain all head entity vector sets and tail entity vector sets contained in the sentence; and then transmit the head entity vector set and the tail entity vector set to the relationship prediction module; The relationship prediction module predicts the relationship between the head entity vector and the tail entity vector, thereby obtaining the relationship between each pair of head and tail entities; In the encoding module, the encoding method includes: S11, using byte pair encoding, segmenting the input sentence into word sequences contained in the vocabulary; S12, perform symbol embedding and position embedding on the word sequence, and add them together as the overall embedding of the word sequence: t i =w i +p i Among them, w i and p i Represent the symbol embedding and position embedding of the i-th word respectively, The final sentence embedding is represented as: [t1, t2, t3, …, t l ], l represents the sentence length, S13. Embed the sentence into the pre-trained BERT model to obtain a vector sequence of the sentence: s=[e1,e2,e3,…,e l ] Where l represents the length of the sentence; In the relationship prediction module, the prediction method includes: S31, each head entity h in the head entity set i , respectively with each tail entity t in the tail entity set j , do vector subtraction to get their relationship vector r, that is: Among them, W t and W h is the mapping matrix; S32, for the relationship vector Calculate the similarity with the relation representation vectors of all relations in the relation set and obtain a hierarchical sequence of similarities. Rank=[x1,x2,x3,…,x N ,x NA ] Among them, r i The relation representation vector of the i-th relation in the set of all relations, r NA is the vector representation of no relationship, N is the number of relationships in the relationship set; all relationship representation vectors are obtained through the training module after random initialization, including NA relationships; x i Represents the similarity with the i-th relationship, x NA Indicates similarity with no relation; S33. Take the relationship with a higher similarity than the unrelated relationship as the relationship prediction result; if the similarity with the unrelated relationship is the largest, then take the unrelated relationship as the prediction result.

2. The extraction system according to claim 1, characterized in that In the entity annotation module, the annotation method includes: S21, use the 0 / 1 tagger to mark the beginning or end of the head entity or tail entity for the word vector sequence; S22. Obtain the vectors corresponding to the head entity and the tail entity according to the annotation; S23. For entities with more than one vector, average pooling is used to compress the vector sequence into a single vector as the vector representation of the entity.

3. The extraction system according to claim 2, characterized in that The system also includes a training module, which uses a back-propagation algorithm to train the entity labeling module and the relationship prediction module, with the goal of minimizing the sum of the loss functions of the entity labeling module and the relationship prediction module.

4. The extraction system according to claim 3, characterized in that: The tagger includes two fully connected networks, and the loss function of the entity tagging module includes the head entity prediction loss and tail entity prediction loss The calculation formula is as follows: Among them, s j represents the jth sentence, |D| represents the size of the training set, and H j and T j Respectively represent the set of head entities and tail entities marked in the jth sentence, where p(h|s j )、p(t|s j ) is the likelihood function.

5. The extraction system according to claim 4, characterized in that The calculation method of the likelihood function is: Here l represents the length of the sentence. and is the true 0 / 1 label of the i-th word in the sentence, It means that the position of the i-th word in the sentence is start; It means that the position of the i-th word in the sentence is end; Represents the probability that the position of the i-th word in the sequence tagging result is start; Represents the probability that the position of the i-th word in the sequence tagging result is end; q∈{start,end} represents taking q as start and end respectively, and the I(x) function is defined as follows:

6. The extraction system according to claim 3, characterized in that: The loss function of the relation prediction module includes the correct relation triple prediction loss function And no relationship prediction loss function Among them, the correct relation triple prediction loss function is defined as: Among them, C j represents the set of correct relation triples in the jth sentence, and r represents C j The vector representation of a certain relationship in ; |D| represents the size of the training set; v t and v h For the formula t in j and h i ; The definition is similar to the above formula, Nj is a set of negative samples; the negative samples are the head entity or tail entity of the correct relation triple replaced by the incorrect head entity or tail entity, and the relation replaced by the NA relation: The loss function of the final relationship prediction part The definition is as follows: Where λ is the reconciliation factor, satisfying λ<<1, the purpose is to reduce the importance of irrelevant relationships.

7. The extraction system according to claim 3, characterized in that In the training module, the parameters of the extraction system are optimized using the Adam algorithm.

8. A method for using the extraction system according to any one of claims 3 to 7, comprising: training the extraction system; Input a sentence into the extraction system, and the extraction system outputs a correct relation triple; The training steps include: S1, input the sentence into the training module; S2, the training module inputs the sentences in the data set into the encoding module to obtain the vector representation of each sentence; S3, the encoding module inputs the vector representation of the sentence into the entity labeling module, and the entity labeling module labels the head entity and the tail entity with 0 and 1, thereby obtaining the head entity set and the tail entity set of each sentence; S4, transmitting the head entity set and the tail entity set to a relationship prediction module, and predicting and outputting the relationship between the head and tail entities in the relationship prediction module; S5. Calculate the loss function of the entity labeling module and the loss function of the relationship prediction module in the training module, and add them together to obtain a total loss function; S6. Deriving the total loss function with respect to all training parameters, and updating and optimizing the training parameters by back propagation; S7. Iterate according to steps S1-S6 until the value of the total loss function is less than the set threshold, or the number of training rounds reaches a maximum.