Relation extraction method and device based on semantic enhanced graph convolutional network
Patent Information
- Application Number
- CN202311062089.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-22
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2043-08-22
AI Technical Summary
[0008]然而,上述研究仅关注依存关系,而忽略了词本身的重要性
[0076]1、本发明提出了一种基于关键词权重增强的关联密度策略。首先从现成的工具包中获取输入句子的依存关系树,然后在依存关系树的基础上构建邻接矩阵,并根据每个词和其他词的关联密度给每个词分配权重。
Smart Images

Figure CN117057341B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of relation extraction technology, and in particular to a relation extraction method and apparatus based on semantically enhanced graph convolutional networks. Background Technology
[0002] Relation extraction, as a crucial task in information extraction, plays a vital role in natural language processing fields such as automatic summarization and chatbots. The purpose of relation extraction is to establish semantic connections between entities within sentences, paragraphs, or chapters. For example, the following contains a causal relationship:
[0003] Financial <e1>problems< / e1> is one of the reasons for <e2> divorce< / e2> ". <e1>< / e1> and <e2>< / e2> Mark the positions of entity 1 (problems) and entity 2 (divorce) in the sentence.
[0004] With the development of deep learning, deep neural networks have been successfully applied to many fields of artificial intelligence, such as image processing, speech recognition, and video signal processing. Using deep neural networks to handle relation extraction tasks has also become a hot topic in the field of information extraction. Specifically, convolutional neural networks can share local features, while recurrent neural networks can process sequential features. Deep neural networks can reduce the accumulated errors in the manual feature design and selection process, and also reduce the accumulated errors in the feature extraction process.
[0005] Deep neural networks have been widely used in relation extraction. Existing methods can be divided into two categories: sequence-based methods and dependency-based methods.
[0006] Sequence-based methods extract features using only word sequences. Common methods include convolutional neural networks (CNNs), recurrent neural networks (RNNs), and long short-term memory (LSTM) networks. Zeng et al. used CNNs for relation extraction. Santos et al. improved the CNN model, proposing a CR-CNN method. Zhang et al. used recurrent neural networks (RNNs) for relation extraction. Zhou et al. proposed an attention-based recurrent neural network model, ATT-RNN, for relation extraction. Zhang et al. proposed a bidirectional long short-term memory network, Bi-LSTM, which models sentences using the complete sequence information of all words. Wang et al. proposed an attention-based bidirectional long short-term memory network, Bi-LSTM-ATT, for relation extraction.
[0007] Dependency-based methods, in addition to utilizing word sequences, integrate dependency trees into the model. These methods have been shown to improve performance by capturing long-distance relationships. Tao et al. combined syntactic metrics and sentence context enhancement for relation extraction. Zhang et al. constructed a graph convolutional network (GCN) for relation extraction using dependency trees. Guo et al. transformed the dependency tree into a fully connected weighted graph using a self-attention mechanism, and further proposed attention-guided graph convolutional networks (AGGCNs) to model relationships between entities. Tian et al., building on dependency trees, proposed a dependency-driven method to extract attention-based graph convolutional networks for relation extraction.
[0008] However, the aforementioned studies only focus on dependency relationships, neglecting the importance of the words themselves. They also overlook the importance of the head sentence in the relationship extraction process. Summary of the Invention
[0009] To address the aforementioned problems, this invention proposes a relation extraction method and apparatus based on semantically enhanced graph convolutional networks. By using semantically enhanced graph convolutional networks, the entire sentence can be better understood, thereby enabling better relation extraction.
[0010] To achieve the above objectives, the present invention adopts the following technical solution:
[0011] A relation extraction method based on semantically enhanced graph convolutional networks includes:
[0012] Step 1 involves preprocessing the publicly available labeled text dataset, including: extracting the central sentence from each sentence and concatenating the central sentence into the original sentence to obtain the final input sentence;
[0013] Step 2: Input the preprocessed text dataset into the encoder for encoding to obtain the vector code x for each word in the text. i And the semantic understanding vector encoding (CLS) for each sentence;
[0014] Step 3: Use a semantically enhanced graph convolutional network to extract features from the vector encoding output in Step 2, obtaining the features of the two entities. and
[0015] Step 4, and The input is fed into the maxpooling layer for max pooling.
[0016] Step 5: Encode the vector CLS obtained in Step 2 and perform the max pooling operation. The input is fed into the softmax function to obtain the corresponding relationships between entities.
[0017] Furthermore, the central sentence is extracted from the sentence in the following manner:
[0018] First, extract the sentence between the two entities, then perform part-of-speech tagging on the extracted sentence, and finally delete the parallel words.
[0019] Furthermore, the preprocessing of the publicly available labeled text dataset also includes:
[0020] The final input sentence X is subjected to dependency analysis using CoreNLP to generate a dependency tree T. X .
[0021] Furthermore, the encoder employs a pre-trained language model, BERT.
[0022] Further, step 3 includes:
[0023] Step 3.1, based on the dependency tree T X We used the NLTK tool to annotate the relationships between words and construct an adjacency matrix.
[0024] Step 3.2, based on the dependency tree T X Construct the correlation density matrix;
[0025] Step 3.3: Combine the adjacency matrix from Step 3.1 and the correlation density matrix from Step 3.2 to obtain the final enhancement matrix:
[0026]
[0027] in It is x corresponding to the l-th layer network. i and x j The enhancement matrix, These are the adjacency matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. These are the association density matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. 1 represents the first sentence, 2 represents the center sentence (the second sentence), s and g represent the indices (x-axis and y-axis) of the adjacency matrix and association density matrix of the first sentence, respectively, and h and k represent the indices (x-axis and y-axis) of the adjacency matrix and association density matrix of the second sentence, respectively. The symbol indicates that the matrices are joined along the diagonal, and the plus sign indicates that the corresponding elements of the two matrices are added together.
[0028] Step 3.4: Input the enhancement matrix together with the vector obtained by the encoder in step 2 into the semantic enhancement graph convolutional network;
[0029] Step 3.5: In the semantically enhanced graph convolutional network, the outputs h1 and h2 after the L-layer iteration are subjected to ReLU activation, and the final output is... and
[0030]
[0031] in It is the x of the l-th layer. i Output, w (l) and b (l) Here, σ represents the trainable matrix and bias values of the l-th layer, and σ is the activation function. x represents the (l-1)th layer after enhancement by the correlation density matrix. j Output, enhanced formula:
[0032]
[0033] in x represents the (l-1)th layer j Output, X j It is x j The corresponding correlation density matrix.
[0034] Further, step 5 includes:
[0035] Step 5.1: Combine the vector encoding CLS obtained in Step 2 with the vector after max pooling. Combine them in the following ways:
[0036]
[0037] Where O is an R-dimensional vector, and each value in O points to a relation type in the relation type set R; W R It is a trainable matrix; h x It is the vector code CLS obtained in step 2; Indicates the concatenation of vectors;
[0038] Step 5.2: Finally, the softmax function is used to predict the relationship between entities E1 and E2 represented by O.
[0039]
[0040] Among them o u The dimension representing O is u.
[0041] Further, step 3.2 includes:
[0042] Through the dependency tree T XThe number of words with dependencies is obtained, and this number is used as the word association density. Each word is then assigned a weight based on its association density with other words, thus obtaining the sentence association density matrix.
[0043] Another aspect of the present invention proposes a relation extraction device based on a semantically enhanced graph convolutional network, comprising:
[0044] The preprocessing module is used to preprocess the publicly available labeled text dataset, including: extracting the central sentence from the sentences and concatenating the central sentence into the original sentences to obtain the final input sentence;
[0045] The encoding module takes the preprocessed text dataset and inputs it into the encoder for encoding, obtaining the vector code x for each word in the text. i And the semantic understanding vector encoding (CLS) for each sentence;
[0046] The feature enhancement and extraction module is used to extract features from the vector encoding output from the encoding module using a semantically enhanced graph convolutional network, thereby obtaining the features of the two entities. and
[0047] The max pooling module is used to... and The input is fed into the maxpooling layer for max pooling.
[0048] The relation extraction module is used to encode the vectors obtained from the encoding module into CLS and the vectors after max pooling. The input is fed into the softmax function to obtain the corresponding relationships between entities.
[0049] Furthermore, the central sentence is extracted from the sentence in the following manner:
[0050] First, extract the sentence between the two entities, then perform part-of-speech tagging on the extracted sentence, and finally delete the parallel words.
[0051] Furthermore, the preprocessing of the publicly available labeled text dataset also includes:
[0052] The final input sentence X is subjected to dependency analysis using CoreNLP to generate a dependency tree T. X .
[0053] Furthermore, the encoder employs a pre-trained language model, BERT.
[0054] Furthermore, the feature enhancement and extraction module is specifically used to perform the following steps:
[0055] Step 3.1, based on the dependency tree T X We used the NLTK tool to annotate the relationships between words and construct an adjacency matrix.
[0056] Step 3.2, based on the dependency tree T X Construct the correlation density matrix;
[0057] Step 3.3: Combine the adjacency matrix from Step 3.1 and the correlation density matrix from Step 3.2 to obtain the final enhancement matrix:
[0058]
[0059] in It is x corresponding to the l-th layer network. i and x j The enhancement matrix, These are the adjacency matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. These are the association density matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. 1 represents the first sentence, 2 represents the center sentence (the second sentence), s and g represent the indices of the adjacency matrix and association density matrix of the first sentence, respectively, and h and k represent the indices of the adjacency matrix and association density matrix of the second sentence, respectively. The symbol indicates that the matrices are joined along the diagonal, and the plus sign indicates that the corresponding elements of the two matrices are added together.
[0060] Step 3.4: Input the enhancement matrix together with the vector obtained by the encoder in the encoding module into the semantic enhancement graph convolutional network;
[0061] Step 3.5: In the semantically enhanced graph convolutional network, the outputs h1 and h2 after the L-layer iteration are subjected to ReLU activation, and the final output is... and
[0062]
[0063] in It is the x of the l-th layer. i Output, w (l) and b (l) Here, σ represents the trainable matrix and bias values of the l-th layer, and σ is the activation function. x represents the (l-1)th layer after enhancement by the correlation density matrix. j Output, enhanced formula:
[0064]
[0065] in x represents the (l-1)th layer j Output, Xj It is x j The corresponding correlation density matrix.
[0066] Furthermore, the relation extraction module is specifically used to perform the following steps:
[0067] Step 5.1: Encode the vector obtained by the encoding module into CLS and perform max pooling operation. Combine them in the following ways:
[0068]
[0069] Where O is an R-dimensional vector, and each value in O points to a relation type in the relation type set R; W R It is a trainable matrix; h x It is the vector encoding CLS obtained in the encoding module; Indicates the concatenation of vectors;
[0070] Step 5.2: Finally, the softmax function is used to predict the relationship between entities E1 and E2 represented by O.
[0071]
[0072] Among them o u The dimension representing O is u.
[0073] Further, step 3.2 includes:
[0074] Through the dependency tree T X The number of words with dependencies is obtained, and this number is used as the word association density. Each word is then assigned a weight based on its association density with other words, thus obtaining the sentence association density matrix.
[0075] Compared with the prior art, the present invention has the following beneficial effects:
[0076] 1. This invention proposes a keyword weight-enhanced association density strategy. First, the dependency tree of the input sentence is obtained from an existing toolkit. Then, an adjacency matrix is constructed based on the dependency tree, and weights are assigned to each word according to the association density between each word and other words.
[0077] 2. This invention proposes a central sentence strategy based on semantic enhancement. It extracts the sentence between two entities from a sentence and removes unimportant words. The extracted central sentence is then concatenated into the original sentence.
[0078] 3. This invention proposes a semantically enhanced graph convolutional network relation extraction model by combining the central sentence, the association density matrix and the graph convolutional network to construct a new convolutional network model. Attached Figure Description
[0079] Figure 1 A flowchart of a relation extraction method based on semantically enhanced graph convolutional network (SE-GCN) provided for embodiments of the present invention;
[0080] Figure 2 This is a diagram illustrating the overall architecture of the SE-GCN model provided in this embodiment of the invention.
[0081] Figure 3 A dependency relationship and adjacency matrix comparison diagram provided for embodiments of the present invention;
[0082] Figure 4 Sentence entity annotation diagram provided in the embodiments of the present invention;
[0083] Figure 5 The learning rate comparison test results provided in the embodiments of the present invention;
[0084] Figure 6 Comparison of Warmup Rate parameters provided in embodiments of the present invention;
[0085] Figure 7 This is a schematic diagram of a relation extraction device based on a semantically enhanced graph convolutional network, provided in an embodiment of the present invention. Detailed Implementation
[0086] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments:
[0087] like Figure 1 As shown, a relation extraction method based on semantically enhanced graph convolutional networks includes:
[0088] Step 1 involves preprocessing the publicly available labeled text dataset, including: extracting the central sentence from each sentence and concatenating the central sentence into the original sentence to obtain the final input sentence;
[0089] Step 2: Input the preprocessed text dataset into the encoder for encoding to obtain the vector code x for each word in the text. i And the semantic understanding vector encoding (CLS) for each sentence;
[0090] Step 3: Use a semantically augmented graph convolutional network to extract features from the vector encoding output in Step 2, obtaining the features of the two entities. and
[0091] Step 4, and The input is fed into the maxpooling layer for max pooling.
[0092] Step 5: Encode the vector CLS obtained in Step 2 and perform the max pooling operation. The input is fed into the softmax function to obtain the corresponding relationship.
[0093] Furthermore, the central sentence is extracted from the sentence in the following manner:
[0094] First, extract the sentence between the two entities, then perform part-of-speech tagging on the extracted sentence, and finally delete the parallel words.
[0095] Furthermore, the preprocessing of the publicly available labeled text dataset also includes:
[0096] The final input sentence X is subjected to dependency analysis using CoreNLP to generate a dependency tree T. X .
[0097] Furthermore, the encoder employs a pre-trained language model, BERT.
[0098] Further, step 3 includes:
[0099] Step 3.1, based on the dependency tree T X We used the NLTK tool to annotate the relationships between words and construct an adjacency matrix.
[0100] Step 3.2, based on the dependency tree T X Construct the correlation density matrix;
[0101] Step 3.3: Combine the adjacency matrix from Step 3.1 and the correlation density matrix from Step 3.2 to obtain the final enhancement matrix:
[0102]
[0103] in It is x corresponding to the l-th layer network. i and x j The enhancement matrix, These are the adjacency matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. These are the association density matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. 1 represents the first sentence, 2 represents the center sentence (the second sentence), s and g represent the indices of the adjacency matrix and association density matrix of the first sentence, respectively, and h and k represent the indices of the adjacency matrix and association density matrix of the second sentence, respectively. The symbol indicates that the matrices are joined along the diagonal, and the plus sign indicates that the corresponding elements of the two matrices are added together.
[0104] Step 3.4: Input the enhancement matrix together with the vector obtained by the encoder in step 2 into the semantic enhancement graph convolutional network;
[0105] Step 3.5: In the semantically enhanced graph convolutional network, the outputs h1 and h2 after the L-layer iteration are subjected to ReLU activation, and the final output is... and
[0106]
[0107] in It is the x of the l-th layer. i Output, w (l) and b (l) Here, σ represents the trainable matrix and bias values of the l-th layer, and σ is the activation function. x represents the (l-1)th layer after enhancement by the correlation density matrix. j Output, enhanced formula:
[0108]
[0109] in x represents the (l-1)th layer j Output, X j It is x j The corresponding correlation density matrix.
[0110] Further, step 5 includes:
[0111] Step 5.1: Combine the vector encoding CLS obtained in Step 2 with the vector after max pooling. Combine them in the following ways:
[0112]
[0113] Where O is an R-dimensional vector, and each value in O points to a relation type in the relation type set R; W R It is a trainable matrix; h x It is the vector code CLS obtained in step 2; Indicates the concatenation of vectors;
[0114] Step 5.2: Finally, the softmax function is used to predict the relationship between entities E1 and E2 represented by O.
[0115]
[0116] Among them o uThe dimension representing O is u.
[0117] Further, step 3.2 includes:
[0118] Through the dependency tree T X The number of words with dependencies is obtained, and this number is used as the word association density. Each word is then assigned a weight based on its association density with other words, thus obtaining the sentence association density matrix.
[0119] Specifically, relation extraction (RE) is typically treated as a classification task. Given a sentence *s* containing N words, relation extraction refers to extracting the relationship between entities E1 and E2. The semantic enhancement method proposed in this invention analyzes the problem from two perspectives. First, it analyzes the words themselves, assigning weights to each word by determining its dependency density with other words. This dependency density is obtained through a dependency tree, constructed using the Stanford CoreNLP tool. Second, it assumes that the words between two entities are more important than the words on either side. The words between the two entities are extracted separately, and the extracted sentences undergo simple pruning, such as removing parallel words. Finally, the extracted central sentence is concatenated to the original sentence. Part-of-speech tagging is implemented using the NLTK tool. Our overall architecture is as follows: Figure 2 As shown. Specifically, given an unstructured input sentence X = x1, x2, ..., x... n Given a string of n words, let E1 and E2 represent two entities in X. Our method predicts the relationship between E1 and E2 using Equation 1.
[0120]
[0121] Where T X It is a dependency tree of X obtained from an off-the-shelf toolkit, where R is a set of relation types. X and T X As input, p calculates the probability of output through SE-GCN given two entities and a specific relation r. The following sections first introduce the standard GCN model, then elaborate on our proposed SE-GCN model with semantic enhancement, and finally explain the process of applying SE-GCN to RE tasks.
[0122] 1. Standard Graph Convolutional Network
[0123] Graph Convolutional Networks (GCNs) are used to encode information in graphs. In each GCN layer, information within each node is communicated with its neighbors through connections between them. Typically, a standard GCN model is as follows: Figure 3As shown, the graph is constructed from word dependencies and consists of an n*n adjacency matrix A = (a i,j ) represents. When i = j, a i,j =1, indicating that the word x in the dependency tree i And the word x j There exists a dependency connection between them, otherwise a i,j =0. The i-th element x of the l-th layer GCN. i The information carried can be represented as shown in Formula 2.
[0124]
[0125] in x represents the (l-1)th layer GCN j Output. w (l) and b (l) σ represents the trainable matrix and bias values of the l-th layer GCN. σ is the activation function.
[0126] 2. Semantic Enhancement SE-GCN
[0127] In standard GCNs, word-to-word relationships are categorized into two types: relationships represented by 1 and no relationships represented by 0. For related words, both the relationship with itself and its relationships with other words are represented by 1, ignoring the importance of the word itself. Therefore, this invention proposes the SE-GCN model, which differentiates each word based on the different dependency densities between them (e.g., if a word has dependencies on x other words, then its association density is x). Specifically, this is achieved using two adjacency matrices. (Dimension is n*n) (m*m) represent the sentence and the central sentence, respectively, and the two correlation density matrices. (Dimension is n*n) (m*m dimension) represent sentences and head sentences respectively, indicating the importance of different words. Then, this is combined with the adjacency matrix to obtain a new matrix. (The dimension is (n+m)*(n+m)), as shown in Formula 3.
[0128]
[0129] in This indicates that matrices are concatenated along the diagonal, and the plus sign indicates that corresponding elements of the preceding and following matrices are added together. Then, the weights are... Applied to x i and x j The associated dependencies are shown in Equation 4.
[0130]
[0131] Where σ, w (l) and b (l) It has the same meaning as the standard GCN. It is enhanced through the density matrix, which can be represented by Equation 5.
[0132]
[0133] X j This is the density matrix, which, combined with the hidden layers, yields the enhanced hidden layers. Compared to standard GCNs, our model uses numerical weighting (e.g., p...). i,j It uses [0,1] instead of binary selection to distinguish different dependencies and the importance of dependency density.
[0134] In graph convolutional networks, sentence encoding is performed on a per-sentence basis, while the crucial core sentence becomes less important. Therefore, the semantics of the overall sentence can be enhanced by extracting the core sentence separately. Specifically, the sentence between the two entities is first extracted, then part-of-speech tagging is performed on the extracted sentence, and finally, parallel words are removed.
[0135] 3. SE-GCN Relation Extraction
[0136] Before applying SE-GCN to RE, it first encodes the input sequence X into a latent vector x using BERT. i The output x i become The input sequence begins with [CLS], sentences are separated by [SEP], and the second sentence ends with [SEP]. Next, [the sequence will be...] The input is fed into an SE-GCN model with L layers, and the corresponding output is obtained. Then, the max pooling mechanism is applied to the vector output by the entity. Then, the overall representation of the sentence h x and two entities Connect them together and combine them into a trainable matrix W. R This is applied to the calculated vector, thereby mapping it to the output space, as shown in Equation 6.
[0137]
[0138] Where O is an R-dimensional vector, where each value points to a relation type in the set of relation types R. This represents the concatenation of vectors. Finally, the softmax function is used to predict the relationship between E1 and E2 represented by O, as shown in Equation 7.
[0139]
[0140] o u The dimension representing O is u.
[0141] 4. Example
[0142] Insert the special character "" into the input sentence. <e1> 、< / e1> , <e2> and< / e2> Furthermore, based on this idea, special characters "#" and "$" are also inserted into the second sentence to mark the two entities respectively, such as... Figure 4 As shown.
[0143] This allows the encoder to distinguish entity locations during the encoding process, thereby improving model performance. BERT is used for the encoder because it is a powerful pre-trained language model. Specifically, BERT-base is used, following its default configuration: 12 multi-layer attention with 768-dimensional hidden vectors. For model evaluation, following previous research, both SemEval-2010 Task 8 and KBP37 use standard F1 scoring. In the experiments, different hyperparameter combinations were tried and tuned on the validation set. The model that achieved the highest F1 score on the validation set was then evaluated on the test set.
[0144] 5. Experiment
[0145] This section presents RE tests on the SemEval-2010 Task 8 and KBP37 datasets. Through a series of experiments, the effectiveness of SE-GCN is demonstrated. This experiment consists of three parts.
[0146] 1. Introduction to the dataset
[0147] 2. Hardware environment and parameter settings
[0148] 3. Comparative Experiment and Result Analysis
[0149] 5.1 Dataset and Evaluation Criteria
[0150] Table 1 shows the number of instances in the training, validation, and test sets of SemEval-2010 Task 8 and KBP37. Experiments were conducted simultaneously on both SemEval-2010 Task 8 and KBP37. For the SemEval-2010 Task 8 dataset, there was no validation set, only training and test sets. The KBP37 dataset was divided into training, validation, and test sets, both based on previous research [Yinmiao Wang, Zhimin Han, Keyou You, Zhiyun Lin. 2022. A Two-channel model for relation extraction using multiple trainedword embeddings.]. Sentences in KBP37 containing spaces and special characters (such as "?" and ")") underwent preprocessing.
[0151] Table 1. Dataset Description
[0152]
[0153] The SemEval-2010 Task 8 dataset is described in detail in Table 2.
[0154] Table 2. Distribution of the number of relations in the Semeval-2010 Task 8 dataset.
[0155]
[0156]
[0157] The KBP37 dataset is described in detail in Table 3.
[0158] Table 3. Distribution of the number of relations in the KBP37 dataset.
[0159]
[0160]
[0161] 5.2 Hardware Environment and Parameter Settings
[0162] Table 4 shows the hyperparameters tested during model training, with combinations tested for each model and dataset. The best combinations are displayed in the table. All experiments were coded using BERT-based methods, and all models were tested on an NVIDIA Tesla V100 GPU.
[0163] Table 4 Hyperparameter Settings
[0164]
[0165] 5.3 Comparative Experiment and Result Analysis
[0166] We tried 1e-5, 3e-5, and 5e-5 learning rates on both datasets, and the best results were achieved with a learning rate of 3e-5. The experimental results are as follows... Figure 5 As shown.
[0167] In addition, we experimented with different warmup rates on two datasets, using values of 0.02, 0.03, 0.04, and 0.05. On the SemEval-2010 Task 8 dataset, a warmup rate of 0.02 yielded the best results, while on the KBP37 dataset, a warmup rate of 0.05 showed the best performance. The experimental results are as follows... Figure 6 As shown.
[0168] In the experiments, the SE-GCN model used a BERT-based encoder. First, the effect of using the GCN model alone was observed. Then, ablation experiments were conducted using the association density matrix and the center sentence. Table 5 shows a comparison between the GCN combined with the association density matrix, the GCN combined with the center sentence, and the GCN model alone.
[0169] Table 5. Results of the model ablation experiment
[0170]
[0171]
[0172] In the SE-GCN model, the extracted central sentence is concatenated with the original sentence and then input into BERT. The output word vectors are combined with the enhanced adjacency matrix and input into the graph convolution. Table 6 shows whether the combined central sentence and the enhanced matrix should be input into the graph convolution and the impact on the experimental results. The experimental results show that inputting the extracted central sentence and the original sentence together into the graph convolutional network yields better results.
[0173] Table 6 Comparison of experimental results regarding whether the central sentence was input into GCN.
[0174]
[0175] RE-GCN achieved excellent results on both datasets, as shown in Table 7. Specifically, compared to a graph-based method used by Guo et al. [1: Zhijiang Guo, Yan Zhang, Wei Lu. 2019. Attention Guided Graph Convolutional Networks for Relation Extraction.], the method of this invention improves performance by approximately 4 percentage points. Compared to a method proposed by Mandya et al. [2: Anglosh Mandya, Danushka Bollegala, Frans Coenen. 2020. Graph Convolution over Multiple Dependency Sub-graphs for Relation Extraction.] that utilizes dependency connections and dependency types through attention, the method of this invention improves performance by approximately 4 percentage points. Compared to a dependency pruning method proposed by Yugoslav et al. [3: Bowen Yu, Mengge Xue, Zhenyu Zhang1, Tingwen Liu, Yubin Wang, Bin Wang. 2020. Learning to Prune Dependency Trees with Rethinking for Neural Relation Extraction.], the method of this invention improves performance by approximately 3 percentage points. Compared with Wang et al. [4: Zihan Wang. Bo Yang. 2020. Attention-based Bidirectional Long Short-Term Memory Networks for Relation Classification Using Knowledge Distillation from BERT.], which proposed an attention-based long short-term memory neural network model to obtain the most important information in a sentence, the method of this invention utilizes the idea of word-word association density and extracting the central sentence to better extract semantic information. The results were improved by 3.92% and 4.21% on the two datasets, respectively.
[0176] Table 7 Model Comparison Experiment
[0177]
[0178]
[0179] In summary, the SE-GCN model proposed in this invention utilizes dependency information for relation extraction. It enhances dependency connections using an association density matrix and further enhances sentence context by extracting the central sentence, thus improving the overall semantic understanding of the sentence. In the model implementation, NLTK is used to annotate word relationships, and an adjacency matrix is constructed based on this. The adjacency matrix and sentence semantics are optimized using the innovative features proposed in this invention. Finally, relation extraction is achieved through a graph convolutional network. Fine-tuning was first performed on the SemEval-2010 Task 8 and KBP37 English benchmark datasets to find the optimal hyperparameters. Then, ablation analysis was performed, comparing the standard GCN, GCN with only the association density matrix, GCN with only the central sentence, and GCN with both. Experimental results show that adding both results yields the best performance. Finally, comparisons with previous experiments validate the efficiency of the SE-GCN model.
[0180] Based on the above embodiments, such as Figure 7 As shown, the present invention also proposes a relation extraction device based on a semantically enhanced graph convolutional network, comprising:
[0181] The preprocessing module is used to preprocess the publicly available labeled text dataset, including: extracting the central sentence from the sentences and concatenating the central sentence into the original sentences to obtain the final input sentence;
[0182] The encoding module takes the preprocessed text dataset and inputs it into the encoder for encoding, obtaining the vector code x for each word in the text. i And the semantic understanding vector encoding (CLS) for each sentence;
[0183] The feature enhancement and extraction module is used to extract features from the vector encoding output from the encoding module using a semantically enhanced graph convolutional network, thereby obtaining the features of the two entities. and
[0184] The max pooling module is used to... and The input is fed into the maxpooling layer for max pooling.
[0185] The relation extraction module is used to encode the vectors obtained from the encoding module into CLS and the vectors after max pooling. The input is fed into the softmax function to obtain the corresponding relationships between entities.
[0186] Furthermore, the central sentence is extracted from the sentence in the following manner:
[0187] First, extract the sentence between the two entities, then perform part-of-speech tagging on the extracted sentence, and finally delete the parallel words.
[0188] Furthermore, the preprocessing of the publicly available labeled text dataset also includes:
[0189] The final input sentence X is subjected to dependency analysis using CoreNLP to generate a dependency tree T. X .
[0190] Furthermore, the encoder employs a pre-trained language model, BERT.
[0191] Furthermore, the feature enhancement and extraction module is specifically used to perform the following steps:
[0192] Step 3.1, based on the dependency tree T X We used the NLTK tool to annotate the relationships between words and construct an adjacency matrix.
[0193] Step 3.2, based on the dependency tree T X Construct the correlation density matrix;
[0194] Step 3.3: Combine the adjacency matrix from Step 3.1 and the correlation density matrix from Step 3.2 to obtain the final enhancement matrix:
[0195]
[0196] in It is x corresponding to the l-th layer network. i and x j The enhancement matrix, These are the adjacency matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. These are the association density matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. 1 represents the first sentence, 2 represents the center sentence (the second sentence), s and g represent the indices of the adjacency matrix and association density matrix of the first sentence, respectively, and h and k represent the indices of the adjacency matrix and association density matrix of the second sentence, respectively. The symbol indicates that the matrices are joined along the diagonal, and the plus sign indicates that the corresponding elements of the two matrices are added together.
[0197] Step 3.4: Input the enhancement matrix together with the vector obtained by the encoder in the encoding module into the semantic enhancement graph convolutional network;
[0198] Step 3.5: In the semantically enhanced graph convolutional network, the outputs h1 and h2 after the L-layer iteration are subjected to ReLU activation, and the final output is... and
[0199]
[0200] in It is the x of the l-th layer. i Output, w (l) and b (l) Here, σ represents the trainable matrix and bias values of the l-th layer, and σ is the activation function. x represents the (l-1)th layer after enhancement by the correlation density matrix. j Output, enhancement formula:
[0201]
[0202] in x represents the (l-1)th layer j Output, X j It is x j The corresponding correlation density matrix.
[0203] Furthermore, the relation extraction module is specifically used to perform the following steps:
[0204] Step 5.1: Encode the vector obtained by the encoding module into CLS and perform max pooling operation. Combine them in the following ways:
[0205]
[0206] Where O is an R-dimensional vector, and each value in O points to a relation type in the relation type set R; W R It is a trainable matrix; h x It is the vector encoding CLS obtained in the encoding module; Indicates the concatenation of vectors;
[0207] Step 5.2: Finally, the softmax function is used to predict the relationship between entities E1 and E2 represented by O.
[0208]
[0209] Among them o u The dimension representing O is u.
[0210] Further, step 3.2 includes:
[0211] Through the dependency tree T X The number of words with dependencies is obtained, and this number is used as the word association density. Each word is then assigned a weight based on its association density with other words, thus obtaining the sentence association density matrix.
[0212] In summary:
[0213] 1. This invention proposes a keyword weight-enhanced association density strategy. First, the dependency tree of the input sentence is obtained from an existing toolkit. Then, an adjacency matrix is constructed based on the dependency tree, and weights are assigned to each word according to the association density between each word and other words.
[0214] 2. This invention proposes a central sentence strategy based on semantic enhancement. It extracts the sentence between two entities from a sentence and removes unimportant words. The extracted central sentence is then concatenated into the original sentence.
[0215] 3. This invention proposes a semantically enhanced graph convolutional network relation extraction model by combining graph convolutional networks. It combines the central sentence, the association density matrix and the graph convolutional network to construct a new convolutional network model.
[0216] The above description is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A relation extraction method based on semantically enhanced graph convolutional networks, characterized in that, include: Step 1 involves preprocessing the publicly available labeled text dataset, including: extracting the central sentence from each sentence and concatenating the central sentence into the original sentence to obtain the final input sentence; the central sentence is extracted in the following way: first, extract the sentence between two entities, then perform part-of-speech tagging on the extracted sentence, and after tagging, delete parallel words; Step 2: Input the preprocessed text dataset into the encoder for encoding to obtain the vector code for each word in the text. And the semantic understanding vector encoding (CLS) for each sentence; Step 3: Use a semantically enhanced graph convolutional network to extract features from the vector encoding output in Step 2, obtaining the features of the two entities. and ; Step 4, and The input is fed into the maxpooling layer for max pooling. Step 5: Encode the vector CLS obtained in Step 2 and perform the max pooling operation. , The input is fed into the softmax function to obtain the corresponding relationships between entities; Step 3 includes: Step 3.1, based on the dependency tree We used the NLTK tool to annotate the relationships between words and construct an adjacency matrix. Step 3.2, based on the dependency tree Construct the correlation density matrix; Step 3.3: Combine the adjacency matrix from Step 3.1 and the correlation density matrix from Step 3.2 to obtain the final enhancement matrix: in It corresponds to the l-th layer network. and The enhancement matrix, , These are the adjacency matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. , These are the association density matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. 1 represents the first sentence, 2 represents the center sentence (the second sentence), s and g represent the indices of the adjacency matrix and association density matrix of the first sentence, respectively, and h and k represent the indices of the adjacency matrix and association density matrix of the second sentence, respectively. The symbol indicates that the matrices are joined along the diagonal, and the plus sign indicates that the corresponding elements of the two matrices are added together. Step 3.4: Input the enhancement matrix together with the vector obtained by the encoder in step 2 into the semantic enhancement graph convolutional network; Step 3.5, in the semantically enhanced graph convolutional network, the output after L layers of iteration is... and Perform ReLU activation function operation, and finally output and : in It is the lth layer Output, and These are the trainable matrix and bias values of the l-th layer. For activation function, Represents the (l-1)th layer after enhancement by the correlation density matrix. Output, enhancement formula: in Represents the (l-1)th layer Output, yes The corresponding correlation density matrix.
2. The relation extraction method based on semantically enhanced graph convolutional networks according to claim 1, characterized in that, The preprocessing of the publicly available labeled text dataset also includes: The final input sentence X is subjected to dependency analysis using CoreNLP to generate a dependency tree. .
3. The relation extraction method based on semantically enhanced graph convolutional networks according to claim 1, characterized in that, The encoder uses a pre-trained BERT language model.
4. The relation extraction method based on semantically enhanced graph convolutional networks according to claim 1, characterized in that, Step 5 includes: Step 5.1: Combine the vector encoding CLS obtained in Step 2 with the vector after max pooling. , Combine them in the following ways: Where O is an R-dimensional vector, and each value in O points to a relation type in the relation type set R; It is a trainable matrix; It is the vector code CLS obtained in step 2; Indicates the concatenation of vectors; Step 5.2: Finally, the softmax function is used to predict the entity represented by O. and The relationship between them: in The dimension representing O is u.
5. The relation extraction method based on semantically enhanced graph convolutional networks according to claim 1, characterized in that, Step 3.2 includes: Through dependency tree The number of words with dependencies is obtained, and this number is used as the word association density. Each word is then assigned a weight based on its association density with other words, thus obtaining the sentence association density matrix.
6. A relation extraction device based on a semantically enhanced graph convolutional network, characterized in that, include: The preprocessing module is used to preprocess the publicly available labeled text dataset, including: extracting the central sentence of each sentence and concatenating the central sentence into the original sentence to obtain the final input sentence; the central sentence is extracted in the following way: first, the sentence between two entities is extracted, then the extracted sentence is tagged with parts of speech, and after tagging, parallel words are deleted; The encoding module takes the preprocessed text dataset and inputs it into the encoder for encoding, obtaining the vector code for each word in the text. And the semantic understanding vector encoding (CLS) for each sentence; The feature enhancement and extraction module is used to extract features from the vector encoding output from the encoding module using a semantically enhanced graph convolutional network, thereby obtaining the features of the two entities. and ; The max pooling module is used to... and The input is fed into the maxpooling layer for max pooling. The relation extraction module is used to encode the vectors obtained from the encoding module into CLS and the vectors after max pooling. , The input is fed into the softmax function to obtain the corresponding relationships between entities; The feature enhancement and extraction module is specifically used for: Based on dependency tree We used the NLTK tool to annotate the relationships between words and construct an adjacency matrix. Based on dependency tree Construct the correlation density matrix; Combining the adjacency matrix and the correlation density matrix yields the final enhancement matrix: in It corresponds to the l-th layer network. and The enhancement matrix, , These are the adjacency matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. , These are the association density matrices of the sentence and the center sentence corresponding to the l-th layer of the network, respectively. 1 represents the first sentence, 2 represents the center sentence (the second sentence), s and g represent the indices of the adjacency matrix and association density matrix of the first sentence, respectively, and h and k represent the indices of the adjacency matrix and association density matrix of the second sentence, respectively. The symbol indicates that the matrices are joined along the diagonal, and the plus sign indicates that the corresponding elements of the two matrices are added together. The enhancement matrix, along with the vectors obtained by the encoder in the encoding module, is input into the semantic enhancement graph convolutional network. In semantically enhanced graph convolutional networks, the output after L layers of iteration is and Perform ReLU activation function operation, and finally output and : in It is the lth layer Output, and These are the trainable matrix and bias values of the l-th layer. For activation function, Represents the (l-1)th layer after enhancement by the correlation density matrix. Output, enhancement formula: in Represents the (l-1)th layer Output, yes The corresponding correlation density matrix.
Citation Information
Patent Citations
Relation extraction method based on graph neural network
CN113297838A
Relation classification method and system based on BERT model fused with multivariate entity information
CN113360582A