Entity relationship joint extraction method, device, computer equipment and storage medium

The problem of insufficient accuracy of entity relationship extraction in the prior art is solved by pre-training word embedding, bidirectional decoding and graph convolutional network (GCN), and the more efficient relationship extraction effect is achieved.

CN116795994BActive Publication Date: 2025-08-19NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310081316.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-30
Publication Date
2025-08-19
Estimated Expiration
2043-01-30

AI Technical Summary

Technical Problem

In the prior art, there is a mispropagation of named entity recognition in entity relationship extraction, the model cannot model the dependence between entities and relationships, and the other relationship facts in the sentence are ignored, resulting in insufficient accuracy of relationship extraction.

Method used

Pretrained word embedding is used to convert the test statement into a marker vector, and bidirectional decoding is performed through the encoder and decoder, a relationship joint graph is constructed and relationship correlation is captured using graph convolution, forward decoding errors are mitigated using bidirectional decoder, and attention mechanism and graph convolution network (GCN) capture relationship co-occurrence.

Benefits of technology

It improves the accuracy and efficiency of entity relationship extraction, reduces the negative impact of forward decoding errors, and enhances the model's ability to capture relationship co-occurrence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116795994B_ABST
    Figure CN116795994B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, computer equipment and storage medium for joint extraction of entity relationships, and belongs to the field of natural language processing technology. The method for joint extraction of entity relationships includes: using pre-trained word embedding to convert the sentence to be tested into a labeled vector; inputting the labeled vector into an encoder for encoding to obtain a labeled embedded representation; inputting the labeled embedded representation into a backward decoder to obtain a backward decoding result; inputting the labeled embedded representation and the backward decoding result into a forward decoder, and performing decoding from left to right to generate a relationship vector; constructing a relationship joint graph according to the relationship vector; inputting the relationship joint graph into a collaboration graph module, and using graph convolution to capture relationship correlation to obtain a relationship representation. This method uses a bidirectional decoder to reduce the negative impact of forward decoding errors, uses the relationship co-graph representation as an auxiliary task, and allows the model to capture relationship co-occurrence through GCN, thereby improving the efficiency of entity relationship extraction.
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 technology, and more specifically, to a method, apparatus, computer device and storage medium for jointly extracting entity relationships. Background Art

[0002] Relation extraction, also known as relational fact extraction, plays a crucial role in various natural language processing applications, particularly in the automatic construction of knowledge graphs (KGs). In recent years, much research has focused on this task, aiming to identify the relationship between a pair of entities in a sentence and construct relation triples. Traditionally, relation extraction involves two steps: named entity recognition (NER) and relation classification, performed in a pipelined fashion. First, errors in named entity recognition propagate to the downstream task of relation classification, preventing the model from receiving feedback and thus impacting relation extraction performance. Furthermore, pipeline approaches train separate models for each subtask, failing to model the underlying dependencies between the two subtasks. Finally, pipeline approaches only consider the relationship between target entities, ignoring other relational facts that may appear in the same sentence. Therefore, improving accuracy in relation extraction has become a pressing issue.

[0003] In related art, a unified model for joint entity-relation extraction (JERE) was proposed. This joint approach not only models the dependencies between entity information and relations, but also considers the interactions between relations, as it can simultaneously extract all relational facts from a sentence. In addition to the aforementioned work, another research direction, Sequence-to-Sequence (Seq2Seq), recasts this task as a sequence generation problem, treating relation extraction as the task of generating triples. This model is based on the encoder-decoder architecture, but it also suffers from some issues, namely forward decoding errors and relation co-occurrence, which are often overlooked. Summary of the Invention

[0004] The content of this application is used to briefly introduce concepts that will be described in detail in the detailed description section below. The content of this application is not intended to identify key features or essential features of the technical solution for which protection is sought, nor is it intended to limit the scope of the technical solution for which protection is sought.

[0005] Some embodiments of the present application propose entity relationship joint extraction methods, devices, electronic devices and computer storage media to solve the technical problems mentioned in the above background technology section.

[0006] As one aspect of the present application, some embodiments of the present application provide a method for extracting entity relationships, including:

[0007] S100: Use pre-trained word embeddings to convert the test sentence into a token vector;

[0008] S200: Inputting the tag vector into an encoder for encoding to obtain an embedded representation of the tag;

[0009] S300: Inputting the embedded representation of the marker into the backward decoder, decoding it from right to left, and obtaining a backward decoding result;

[0010] S400: Inputting the embedded representation of the mark and the backward decoding result into the forward decoder, and performing decoding from left to right to generate a relationship vector;

[0011] S500: Constructing a relationship joint graph according to the relationship vector;

[0012] S600: Input the relationship joint graph into the collaboration graph module, use graph convolution to capture relationship correlation, and obtain relationship representation.

[0013] Furthermore, in step S200, the encoder is a RNN encoder.

[0014] Furthermore, in step S200, the encoder includes several bidirectional LSTM modules.

[0015] Furthermore, the step S200 specifically includes:

[0016] The token vector is input into the bidirectional LSTM module in the order from left to right and from right to left, and the forward output and backward output are combined to obtain the embedding representation of each token, where the embedding representation of the i-th token of the token vector is:

[0017]

[0018] in, For the i The embedding representation of the tokens, For the i The forward output of words, For the i The backward output of words.

[0019] Furthermore, in step S300, the backward decoder is an RNN with an improved LSTM unit; the improved LSTM unit is an LSTM unit that introduces an attention mechanism.

[0020] Furthermore, the step S300 specifically includes:

[0021] The embedding representations of all tokens are combined into an embedding representation sequence, with the first element of the embedding representation sequence as the start of the target token and the last element of the embedding representation sequence as the end of the target token;

[0022] In the backward decoder, starting from the end of the target token until the beginning of the target token is encountered, the embedded representation sequence is decoded step by step from right to left to obtain the backward decoder output; the backward decoder output at time step t is:

[0023]

[0024]

[0025]

[0026]

[0027] Among them, [·;·] is vector connection, is the input of the previous step in the backward decoder, Mark The embedding representation of is the context vector obtained from the encoder using the attention mechanism, is the embedding representation of the i-th token, is the attention score of the backward decoder, is the backward decoding output at time step t and the The fused encoding representation of the embedding representation of the tags;

[0028] The decoder output is subjected to mask processing and then linear transformation to obtain a backward decoding result.

[0029] Furthermore, in step S400, the forward decoder and the backward decoder have the same structure.

[0030] Furthermore, the step S400 specifically includes:

[0031] The embedded representation of the tag and the backward decoding result are input into the forward decoder, and decoding is performed from left to right to obtain the forward decoder output. The forward decoder output at time step t is:

[0032]

[0033]

[0034]

[0035]

[0036]

[0037]

[0038]

[0039] in, and is the output of the previous forward decoder and the embedding of the token, is a mark The embedding representation of and are two context vectors obtained from the backward decoder and encoder respectively using the attention mechanism, and are the attention scores of the forward decoder and encoder, is the output of the forward decoder at time step t and the The fused encoding representation of the backward decoding results of the tags, is the forward decoding output at time step t and the The fused encoding representation of the embedding representation of the tags;

[0040] A linear transformation is used to project the forward decoder output to the token to obtain the relation vector.

[0041] Furthermore, in step S500, each node of the relationship joint graph represents a relationship.

[0042] Furthermore, in step S500, the relationship joint graph is composed of a plurality of stacked GCN layers.

[0043] Furthermore, the step S500 specifically includes initializing the nodes of the relationship joint graph as node vectors and representing the edges of the relationship joint graph with an adjacency matrix;

[0044] Initialize the adjacency matrix to the normalized correlation matrix;

[0045] According to the node vector and adjacency matrix, after being processed by multiple stacked GCN layers, the relationship representation is obtained; among them, the first ( l + 1) The calculation formula for layer nodes is:

[0046]

[0047] in, For the first l + 1) layer nodes, No. ( l+ 1) layer nodes, δ(·) represents the activation function, A is the adjacency matrix.

[0048] Furthermore, the bidirectional decoding model based on the collaboration graph is composed of a bidirectional decoding module and a collaboration graph module, the bidirectional decoding module is composed of an encoder, a backward decoder and a forward decoder, and the method includes:

[0049] Construct a loss function for the bidirectional decoding model based on the collaboration graph. The loss function expression is:

[0050]

[0051]

[0052]

[0053]

[0054] in, is the final loss of the entire model, is the target loss of the forward decoder, M is the target sequence length, is the target loss for the backward decoder, for The flip representation of are network parameters, is the conditional probability.

[0055] Furthermore, the step S100 specifically includes converting the sentence to be tested into a token vector using word2vec.

[0056] As another aspect of the present application, some embodiments of the present application provide an entity relationship joint extraction device, including:

[0057] The vector representation module of the test sentence is used to convert the test sentence into a labeled vector using pre-trained word embedding;

[0058] The encoding and decoding module is configured to input the tag vector into an encoder for encoding to obtain an embedded representation of the tag; the encoder includes an RNN encoder; the embedded representation of the tag is input into a backward decoder, and decoding is performed in a right-to-left manner to obtain a backward decoding result; the backward decoder is an RNN with an improved LSTM unit; the improved LSTM unit introduces an attention mechanism into the LSTM unit, inputs the embedded representation of the tag and the backward decoding result into a forward decoder, and decoding is performed in a left-to-right manner to generate a relation vector; the forward decoder has the same structure as the backward decoder;

[0059] A relationship representation determination module is used to construct a relationship joint graph based on the relationship vector; each node of the relationship joint graph represents a relationship; the relationship joint graph is input into the collaboration graph module, and graph convolution is used to capture the relationship correlation to obtain the relationship representation.

[0060] As another aspect of the present application, some embodiments of the present application provide a computer device, including:

[0061] One or more processors; a storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation of the first aspect above.

[0062] As another aspect of the present application, some embodiments of the present application provide a computer storage medium on which a computer program is stored, wherein when the program is executed by a processor, the method described in any implementation of the first aspect above is implemented.

[0063] The beneficial effects of this application are:

[0064] This method adopts a bidirectional decoder to alleviate the negative impact of forward decoding errors, uses relation co-graph representation as an auxiliary task, and allows the model to capture relation co-occurrence through GCN, thereby improving the efficiency of entity relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] The drawings constituting a part of this application are used to provide a further understanding of this application and make other features, purposes and advantages of this application more apparent. The drawings and descriptions of the exemplary embodiments of this application are used to explain this application and do not constitute an improper limitation on this application.

[0066] In addition, throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the elements and components are not necessarily drawn to scale.

[0067] In the attached figure:

[0068] Figure 1 It is a flowchart of a method for joint extraction of entity relationships according to an embodiment of the present application.

[0069] Figure 2 It is a structural diagram of a bidirectional decoding model based on a collaboration graph according to an embodiment of the present application.

[0070] Figure 3 It is a structural block diagram of a flow chart of a method for joint extraction of entity relationships according to an embodiment of the present application.

[0071] Figure 4An internal structure diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0072] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.

[0073] It should also be noted that, for ease of description, only the parts related to the invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other.

[0074] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0075] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".

[0076] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0077] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0078] Reference Figure 1 As shown, a method for jointly extracting entity relationships according to an embodiment of the present application includes the following steps:

[0079] Step 100: Use pre-trained word embedding to convert the sentence to be tested into a token vector.

[0080] The sentence to be tested is a sentence.

[0081] As an implementation of step S100, word2vec is used to convert the sentence to be tested into a token vector.

[0082] Specifically, the pre-trained word embedding can use but is not limited to Word2Vec.

[0083] Step 200: Input the token vector into the encoder for encoding to obtain an embedded representation of the token;

[0084] Wherein, the encoder includes an RNN encoder;

[0085] Specifically, the encoder is the same as the classic Seq2Seq model, aiming to obtain the contextual representation of each word. RNNs are commonly used to model sequential data and have been successfully applied to various NLP tasks.

[0086] In this work, sentences are treated as time series data. A bidirectional LSTM (BiLSTM) is used as the sentence encoder, which reads the input sequence in left-to-right and reverse order, generating a deep contextualized bidirectional hidden representation for each token.

[0087] Then, finally, the forward decoder generates relation triplets from left to right using two attention mechanisms that consider the information of the encoder and the backward decoder.

[0088] Step 300: Input the embedded representation of the mark into the backward decoder and decode it from right to left to obtain the backward decoding result;

[0089] Among them, the backward decoder is an RNN with an improved LSTM unit; the improved LSTM unit introduces an attention mechanism into the LSTM unit.

[0090] Specifically, the backward decoder performs relation transformation in a right-to-left manner to capture the reverse context.

[0091] The backward decoder is similar to the NMT decoder using RNN with LSTM units, but the difference is that it performs decoding in the reverse direction. Suppose the triple sequence of the sentence is , is the start of target token (SOS), is the end of target token (EOS). Given the encoded source sentence, the backward decoder starts from EOS and progressively decodes the target triple sequence from right to left until it encounters SOS.

[0092] Step 400: Input the embedded representation of the mark and the backward decoding result into the forward decoder, and perform decoding from left to right to generate a relationship vector; the structure of the forward decoder is the same as that of the backward decoder.

[0093] Specifically, the forward decoder generates relation triplets from left to right using two attention mechanisms that consider information from the encoder and the backward decoder. During inference, the decoded sequence is processed with the help of special tokens (; and |) to obtain relation triplets.

[0094] The relationship is represented as a set of vectors, which also serve as parameters for the forward decoder.

[0095] Step 500: construct a relationship joint graph based on the relationship vector;

[0096] Each node of the relationship union graph represents a relationship.

[0097] Specifically, we construct a relational joint graph on the relation vectors, where each node represents a relation and the edges model the relationship between any two events. We stack multiple graph convolution operations on the relations and map the relation vectors to a set of new relational representations.

[0098] Step 600: Input the relationship joint graph into the collaboration graph module, use graph convolution to capture the relationship correlation, and obtain the relationship representation.

[0099] Specifically, the collaboration graph module is mainly used to capture common relationships using graph convolution operations.

[0100] Graph convolution (GCN) is an extension of convolutional neural networks that can be used to encode graphs. The basic idea is to perform convolution filtering on the graph and update the node representation by propagating information between nodes. Compared with the traditional local Euclidean space convolution operation, the key of GCN is to learn a function on the graph. .

[0101] The bidirectional decoding module is composed of an encoder, a backward decoder, and a forward decryptor. The bidirectional decoding module and the collaboration graph module constitute a bidirectional decoding model based on the collaboration graph. The structure of the bidirectional decoding model based on the collaboration graph is as follows: Figure 2 shown. Figure 2 NAT / PRE / BI / LI are the abbreviations for Nationality, President of, Born in and Location in respectively.

[0102] The above-mentioned joint entity-relationship extraction method includes: using pre-trained word embeddings to convert the test sentence into a token vector; inputting the token vector into an encoder for encoding to obtain a token embedding representation; inputting the token embedding representation into a backward decoder, decoding it from right to left to obtain a backward decoding result; inputting the token embedding representation and the backward decoding result into a forward decoder, decoding it from left to right to generate a relation vector; constructing a relation joint graph based on the relation vector; each node in the relation joint graph represents a relation; inputting the relation joint graph into a collaboration graph module, using graph convolution to capture relation correlations, and obtaining a relation representation. This method uses a bidirectional decoder to mitigate the negative impact of forward decoding errors and utilizes relation co-graph representation as an auxiliary task, allowing the model to capture relation co-occurrences through GCN. This method can improve the efficiency of entity relationship extraction.

[0103] In one embodiment, the encoder includes a plurality of bidirectional LSTM modules; step 200 includes:

[0104] S201: Input the token vector into the bidirectional LSTM module in the order from left to right and from right to left, combine the forward output and backward output obtained, and obtain the embedding representation of each token, where the first i The embedding of a token is represented as:

[0105] (1)

[0106] in, For the i The embedding representation of the tokens, For the i The forward output of words, For the i The backward output of words.

[0107] S202: Given a continuous statement to be tested As a sequence of tokens, the encoder is responsible for mapping each token to a continuous embedding representation.

[0108] (2)

[0109] In one embodiment, step S300 includes:

[0110] S301: The embedded representations of all tokens are combined into an embedded representation sequence, with the first element of the embedded representation sequence as the start of the target token and the last element of the embedded representation sequence as the end of the target token; in the backward decoder, the embedded representation sequence is decoded step by step from right to left, starting from the end of the target token until the start of the target token is encountered, to obtain the backward decoder output; the backward decoder output at time step t is:

[0111] (3)

[0112] (4)

[0113] (5)

[0114] (6)

[0115] Among them, [·;·] is vector connection, is the input of the previous step in the backward decoder, Mark The embedding representation of is the context vector obtained from the encoder using the attention mechanism, For thei The embedding representation of the tokens, is the attention score of the backward decoder, is the backward decoding output at time step t and the i The fused encoded representation of the embedding representations of the tags.

[0116] S302: Masking the decoder output and then performing linear transformation to obtain a backward decoding result.

[0117] Specifically, although this method uses the Seq2Seq translation framework, relation extraction is very different from machine translation. In relation extraction, the entities in the relation facts must appear in the encoded sentences, and only the relations need to be predicted. If only the equation , the decoder will make obvious mistakes and predict words that do not appear in the source sentence as entities. To prevent this problem, we add a mask to the linear transformation, allowing only words in the source sentence, special tokens (';', '|', EOS), unknown words, and all relation types to appear in the decoded sequence. By introducing a backward decoder, our model captures the right context for further forward decoding.

[0118] In one embodiment, step S400 includes:

[0119] S401: Input the embedded representation of the mark and the backward decoding result into the forward decoder, perform decoding from left to right, and obtain the forward decoder output. The forward decoder output at time step t is:

[0120] (7)

[0121] (8)

[0122] (9)

[0123] (10)

[0124] (11)

[0125] (12)

[0126] (13)

[0127] in, and is the output of the previous forward decoder and the embedding of the token, is a mark The embedding representation of and are two context vectors obtained from the backward decoder and encoder respectively using the attention mechanism, and are the attention scores of the forward decoder and encoder, is the output of the forward decoder at time step t and the i The fused encoding representation of the backward decoding results of the tags, is the forward decoding output at time step t and the i The fused encoding representation of the embedding representation of the tags;

[0128] S402: Use linear transformation to project the forward decoder output to the token to obtain a relation vector.

[0129] Specifically, the formula for projecting the forward decoder output to the token using linear transformation is:

[0130] (14)

[0131] in, and are the parameters of the model, Confidence scores for all words in the decoding vocabulary.

[0132] In one embodiment, the relational joint graph is composed of a plurality of stacked GCN layers; step 600 includes:

[0133] S601: Initialize the nodes of the relationship joint graph as node vectors, and use the adjacency matrix to represent the edges of the relationship joint graph;

[0134] S602: Initialize the adjacency matrix to a normalized correlation matrix;

[0135] S603: According to the node vector and adjacency matrix, after being processed by multiple stacked GCN layers, a relational representation is obtained;

[0136] Among them, l + 1) The calculation formula for layer nodes is:

[0137] (15)

[0138] in, For the first l + 1) layer nodes, For the first l ) layer nodes, δ(·) represents the activation function, A is the adjacency matrix.

[0139] S604: Finally, the decoder output is projected to a token using a linear classifier.

[0140] Among them, each token in the decoding vocabulary is a class, Each row of is the parameter of the corresponding classifier.

[0141] There is a strong correlation between the relations of triplets extracted from the same sentence, but linear classifiers ignore this correlation. GCN is a powerful method for mining structural features on graphs. First, a relational co-graph is constructed. Then, GCN is used to capture the correlation for relation classifiers.

[0142] A graph consists of vertices (also called nodes) connected by edges (also called links). It is an ordered pair G = (V, E), where V is a set of vertices and E is a set of edges. We can mathematically represent a graph with n nodes using an adjacency matrix A ∈ Rn×n, where Aij = 1 if there is an edge between nodes i and j, and 0 otherwise. If the node V is represented as a d-dimensional vector V ∈ Rn×d, the GCN layer on the graph can be written as a nonlinear function f(V, A). When considering the stacking of multiple GCN layers and utilizing the convolution operation proposed in

[15] , the GCN can be expressed as Equation (15).

[0143] How to effectively capture relational correlations and explore these correlations to improve the performance of classifiers is very important for solving relation extraction. In this application, a relational Co-graph is constructed and GCN is used to model relational correlations.

[0144] Specifically, the nodes of the graph represent relationships, which are further initialized as vectors. The edges are represented by the adjacency matrix, which reflects the co-occurrence between relationships. We use graph convolution to aggregate information. The purpose is to embed information such as co-occurrence and dependency of relationships in the edges into the representation of the relationships, so as to learn good relationship representations through training. We construct a relational Co-graph and use GCN to model relationship correlations. Specifically, the nodes of the graph represent relationships, which are further initialized as vectors. The edges are represented by the adjacency matrix, which reflects the co-occurrence between relationships. We use graph convolution to aggregate information. The purpose is to embed information such as co-occurrence and dependency of relationships in the edges into the representation of the relationships, so as to learn good relationship representations through training. l The nodes of the GCN layer are aggregated by their neighbors to form the first ( l + 1) layer. For example, if label 5 has two adjacent labels 3 and 4, the equation can be expressed in another way:

[0145] (16)

[0146] in, is the adjacency matrixA No. i Rank j Elements of the column, Indicates the corresponding l Layer i In this case, GCN aggregates information from all adjacent labels with the same convolutional weights and then passes the result through an activation function to produce updated node features. In this way, adjacent labels in the graph influence each other, and the correlation between labels is learned through multiple layers of convolution operations.

[0147] The adjacency matrix plays a very important role in the model. It models the dependencies between relations. The construction of the adjacency matrix is a key issue in the model. The adjacency matrix is initialized using the correlation matrix. If two relations appear in the same sentence, they will be considered as co-occurrences of their corresponding labels. To address the label imbalance problem, the correlation matrix is normalized as follows:

[0148] (17)

[0149] Where M is the co-occurrence matrix and F is the frequency vector of each tag.

[0150] In one embodiment, a bidirectional decoding model based on a collaboration graph is composed of a bidirectional decoding module and a collaboration graph module. The bidirectional decoding module is composed of an encoder, a backward decoder, and a forward decryptor. The entity relationship joint extraction method of the present application further includes: constructing a loss function of the bidirectional decoding model based on the collaboration graph. The loss function expression is:

[0151] (18)

[0152] (19)

[0153] (20)

[0154] (twenty one)

[0155] in, L is the final loss of the entire model, L f is the target loss of the forward decoder, M is the target sequence y length, L b is the target loss for the backward decoder, for The flip representation of θ are network parameters, is the conditional probability.

[0156] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0157] In a verification example, two versions of the data set were selected for experiments to demonstrate that the model proposed in the present invention has good superiority over other models in complex event type prediction.

[0158] The first version filters out sentences with more than 100 words and sentences that do not contain positive triples. We randomly select 5,000 sentences from the training data as the test set, 5,000 sentences as the development set, and the rest as the training set. Because this dataset contains 24 relations, this example names this version NYT24.

[0159] The second version filters out relations whose relation types in the training set do not exist in the test set and excludes sentences that do not contain any relation. There are 29 relations, so this example names this version NYT29.

[0160] The statistics of these two datasets are shown in Table 1.

[0161] Table 1 Statistics of the two datasets

[0162]

[0163] In order to verify that the model proposed in the present invention has good superiority over other models in complex event type prediction, this embodiment uses precision (P), recall (R) and F1 metric (F1) to evaluate the results. The comparison results are shown in Table 2.

[0164] Table 2 Comparison results of several model tests

[0165]

[0166] Experimental Results Analysis: NovelTagging: This method treats the joint extraction task as a sequence tagging problem based on a novel tagging schema, where each tag simultaneously encodes entity mentions and relation types. This method can extract entities and relations in one step. However, it does not address the overlap issue. MHS: This method is based on table filling and uses an additional conditional random field (CRF) layer to tag entities. It also proposes a novel table scheme, multi-head selection, to achieve relation classification. HRL: This method uses a hierarchical reinforcement learning framework to enhance the interaction between entities and relations. The HRL model first detects relations and then extracts the entities corresponding to each relation. This is true when there are two or more triples with the same relation in a sentence. CopyMTL: This method uses a seq2seq framework with a copy mechanism to extract triples. It is an improved version of CopyRE, where a NER task is used to complete multiple-token entities. WDec: This method is a standard seq2seq model with dynamic masks and decodes entity tokens token by token. BDCore is the proposed method in this paper. It introduces two attention mechanisms to simultaneously consider the hidden states of the encoder and backward decoder and utilizes GCN to learn relation representations.

[0167] In one embodiment, Figure 3 As shown, a device for joint entity-relationship extraction is provided, comprising: a vector representation module for a sentence to be tested, an encoding and decoding module, and a relationship representation determination module, wherein:

[0168] The vector representation module of the sentence to be tested is used to convert the sentence to be tested into a labeled vector using pre-trained word embedding.

[0169] The encoding and decoding module is used to input the token vector into the encoder for encoding to obtain the embedded representation of the token; the encoder includes an RNN encoder; the embedded representation of the token is input into the backward decoder, and decoding is performed from right to left to obtain the backward decoding result; the backward decoder is an RNN with an improved LSTM unit; the improved LSTM unit introduces an attention mechanism into the LSTM unit, and the embedded representation of the token and the backward decoding result are input into the forward decoder, and decoding is performed from left to right to generate a relation vector; the forward decoder has the same structure as the backward decoder.

[0170] The relationship representation determination module is used to construct a relationship joint graph based on the relationship vector; each node in the relationship joint graph represents a relationship; the relationship joint graph is input into the collaboration graph module, and graph convolution is used to capture the relationship correlation to obtain the relationship representation.

[0171] In one embodiment, the encoder includes a plurality of bidirectional LSTM modules; the encoding and decoding module is further configured to input the token vector into the bidirectional LSTM module in a left-to-right and right-to-left order, combine the obtained forward output and backward output, and obtain an embedding representation of each token, wherein the embedding representation of the i-th token of the token vector is expressed as shown in Formula (1).

[0172] In one embodiment, the encoding and decoding module is further configured to form an embedded representation sequence of all tokens, wherein the first element of the embedded representation sequence is used as the start of the target token, and the last element of the embedded representation sequence is used as the end of the target token; in the backward decoder, the embedded representation sequence is decoded step by step from right to left from the start of the end of the target token until the start of the target token is encountered, to obtain the backward decoder output; the expressions of the backward decoder output at time step t are shown in Equations (3) to (6).

[0173] The decoder output is processed by masking and then linearly transformed to obtain the backward decoding result.

[0174] In one embodiment, the encoding and decoding module is further configured to input the embedded representation of the tag and the backward decoding result into the forward decoder, and perform decoding from left to right to obtain the forward decoder output. The expression of the forward decoder output at time step t is shown in equations (7) to (13).

[0175] A linear transformation is used to project the forward decoder output to the token to obtain the relation vector.

[0176] In one embodiment, the relationship joint graph is composed of a plurality of stacked GCN layers; the relationship representation determination module is further used to initialize the nodes of the relationship joint graph as node vectors and represent the edges of the relationship joint graph with an adjacency matrix; initialize the adjacency matrix as a normalized correlation matrix; and obtain the relationship representation after processing the node vectors and the adjacency matrix through the stacked plurality of GCN layers; wherein, the first ( l + 1) The calculation formula of the layer node is shown in formula (15).

[0177] In one embodiment, a bidirectional decoding model based on a collaboration graph is composed of a bidirectional decoding module and a collaboration graph module. The bidirectional decoding module is composed of an encoder, a backward decoder, and a forward decryptor. The device also includes a loss function construction module for constructing a loss function of the bidirectional decoding model based on the collaboration graph. The loss function expression is shown in Equations (18) to (21).

[0178] In one embodiment, the vector representation module of the sentence to be tested is further used to convert the sentence to be tested into a tag vector using word2vec.

[0179] For the specific definition of the entity relationship joint extraction device, please refer to the definition of the entity relationship joint extraction method above, which will not be repeated here. The various modules in the above-mentioned entity relationship joint extraction device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0180] Reference Figure 4 As shown, a computer device is provided, which can be a terminal, and its internal structure can be as shown in FIG. Figure 4 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for joint extraction of entity relationships is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0181] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0182] In particular, according to some embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer storage medium, the computer program comprising program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a read-only memory. When the computer program is executed, the above-mentioned functions defined in the methods of some embodiments of the present disclosure are performed.

[0183] It should be noted that the computer storage medium described above in some embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0184] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0185] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of the systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function.

[0186] It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures.

[0187] For example, two blocks shown in succession may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functionality involved. It should also be noted that each block in the block diagrams and / or flow charts, and combinations of blocks in the block diagrams and / or flow charts, may be implemented using a dedicated hardware-based system that performs the specified functions or operations, or may be implemented using a combination of dedicated hardware and computer instructions.

[0188] The units described in some embodiments of the present disclosure may be implemented in software or hardware. The units described may also be provided in a processor, and the names of these units do not, in some cases, limit the units themselves.

[0189] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0190] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0191] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

[0192] The above is a schematic description of the present invention and its embodiments, which is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. Therefore, if a person skilled in the art is inspired by this and, without departing from the purpose of the present invention, designs a structure and embodiment similar to this technical solution without inventiveness, they shall fall within the scope of protection of the present invention.

Claims

1. A method for joint extraction of entity relationships, characterized by: include, S100: Use pre-trained word embeddings to convert the test sentence into a token vector; S200: Inputting the tag vector into an encoder for encoding to obtain an embedded representation of the tag; S300: Input the embedded representation of the marker into the backward decoder and decode it from right to left to obtain a backward decoding result; S400: Inputting the embedded representation of the mark and the backward decoding result into the forward decoder, and performing decoding from left to right to generate a relationship vector; S500: Constructing a relationship joint graph according to the relationship vector; S600: Input the relationship joint graph into the collaboration graph module, use graph convolution to capture relationship correlation, and obtain relationship representation; In the step S500, each node of the relationship joint graph represents a relationship; In step S500, the relationship joint graph is composed of a plurality of stacked GCN layers; The step S500 specifically includes initializing the nodes of the relationship joint graph as node vectors and representing the edges of the relationship joint graph with an adjacency matrix; Initialize the adjacency matrix to the normalized correlation matrix; According to the node vector and adjacency matrix, after being processed by multiple stacked GCN layers, the relationship representation is obtained; among them, the first ( l + 1) The calculation formula for layer nodes is: in, For the first l + 1) layer nodes, For the first l ) layer nodes, δ(·) represents the activation function, A is the adjacency matrix.

2. The entity relationship joint extraction method according to claim 1, characterized in that: In step S200, the encoder is a RNN encoder.

3. The entity relationship joint extraction method according to claim 1, characterized in that: In step S200, the encoder includes several bidirectional LSTM modules.

4. The entity relationship joint extraction method according to claim 3, characterized in that: The step S200 specifically includes: The token vector is input into the bidirectional LSTM module in the order from left to right and from right to left, and the forward output and backward output are combined to obtain the embedding representation of each token, where the embedding representation of the i-th token of the token vector is: in, For the i The embedding representation of the tokens, For the i The forward output of words, For the i The backward output of words.

5. The entity relationship joint extraction method according to claim 1, characterized in that: In step S300, the backward decoder is an RNN with an improved LSTM unit; The improved LSTM unit is an LSTM unit that introduces an attention mechanism.

6. The entity relationship joint extraction method according to claim 5, characterized in that: The step S300 specifically includes: The embedding representations of all tokens are combined into an embedding representation sequence, with the first element of the embedding representation sequence as the start of the target token and the last element of the embedding representation sequence as the end of the target token; In the backward decoder, starting from the end of the target token until the beginning of the target token is encountered, the embedded representation sequence is decoded step by step from right to left to obtain the backward decoder output; the backward decoder output at time step t is: Among them, [·;·] is vector connection, is the input of the previous step in the backward decoder, Mark The embedding representation of is the context vector obtained from the encoder using the attention mechanism, is the embedding representation of the i-th token, is the attention score of the backward decoder, is the backward decoding output at time step t and the The fused encoding representation of the embedding representation of the tags; The decoder output is subjected to mask processing and then linear transformation to obtain a backward decoding result.

7. The entity relationship joint extraction method according to claim 1, characterized in that: In step S400, the forward decoder and the backward decoder have the same structure.

8. The entity relationship joint extraction method according to claim 7, characterized in that: The step S400 specifically includes: The embedded representation of the tag and the backward decoding result are input into the forward decoder, and decoding is performed from left to right to obtain the forward decoder output. The forward decoder output at time step t is: in, and is the output of the previous forward decoder and the embedding of the token, is a mark The embedding representation of and are two context vectors obtained from the backward decoder and encoder respectively using the attention mechanism, and are the attention scores of the forward decoder and encoder, is the output of the forward decoder at time step t and the The fused encoding representation of the backward decoding results of the tags, is the forward decoding output at time step t and the The fused encoding representation of the embedding representation of the tags; A linear transformation is used to project the forward decoder output to the token to obtain the relation vector.

9. The entity relationship joint extraction method according to claim 1, characterized in that: The encoder, the backward decoder, and the forward decoder constitute a bidirectional decoding module. The bidirectional decoding module and the collaboration graph module constitute a bidirectional decoding model based on the collaboration graph. The entity relationship joint extraction method further includes: Construct a loss function for the bidirectional decoding model based on the collaboration graph. The loss function expression is: in, is the final loss of the entire model, is the target loss of the forward decoder, M is the target sequence length, is the target loss for the backward decoder, for The flip representation of are network parameters, is the conditional probability.

10. The entity relationship joint extraction method according to claim 1, characterized in that: The step S100 specifically includes converting the sentence to be tested into a token vector using word2vec.

11. An entity relationship joint extraction device, characterized by: include, The vector representation module of the test sentence is used to convert the test sentence into a labeled vector using pre-trained word embedding; An encoding and decoding module, configured to input the tag vector into an encoder for encoding to obtain an embedded representation of the tag; the encoder includes an RNN encoder; input the embedded representation of the tag into a backward decoder for decoding in a right-to-left manner to obtain a backward decoding result; the backward decoder is an RNN with an improved LSTM unit; The improved LSTM unit introduces an attention mechanism into the LSTM unit, inputs the embedding representation of the tag and the backward decoding result into the forward decoder, and performs decoding from left to right to generate a relation vector; the forward decoder has the same structure as the backward decoder; A relationship representation determination module is used to construct a relationship joint graph based on the relationship vector; each node of the relationship joint graph represents a relationship; the relationship joint graph is input into the collaboration graph module, and graph convolution is used to capture the relationship correlation to obtain the relationship representation.

12. A computer device comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the processors implement the entity relationship joint extraction method as described in any one of claims 1 to 10.

13. A computer storage medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the entity relationship joint extraction method described in any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • A method for jointly extracting entity relations from sequential annotations based on attention mechanism

    CN109408812A

  • Joint event extraction method based on entity relationship and dependency Tree-LSTM

    CN111353306A