A relation extraction method based on entity semantic fusion
By constructing a new syntax dependency tree and combining GCN and PCNN neural networks, the multi-classification and limitation of entity relationship extraction in the existing technology are solved, and high-accurate entity relationship extraction is achieved, and the semantic connections between entities are enhanced. .
Patent Information
- Application Number
- CN202210267524.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2042-03-18
AI Technical Summary
The prior art has multiple classification problems, limitations in GCN network acquisition and excessive smoothing of results in the prior art. The traditional method has strong dependence on manual labeling corpus, resulting in poor relationship extraction effect.
Using the relationship extraction method based on entity semantic fusion, a new syntax dependency tree is constructed, and the entity node is used as a global node to establish a connection between the global node and other nodes, and the preset vectors are input into the GCN neural network and the PCNN segmented convolutional neural network. Perform feature extraction and finally use the Softmax classifier for relational category prediction.
Effectively capture the semantic information of the syntactic dependency tree, reduce time consumption and excessive results smoothing problems, improve the accuracy of entity relationship extraction and the recognition of the importance of entities by the model, and enhance the semantic connection between entities.
Smart Images

Figure CN114444515B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a relationship extraction method based on entity semantic fusion. Background Art
[0002] In recent years, with the advent of the era of artificial intelligence, building knowledge networks as an important part of intelligent recommendation systems has attracted more and more attention. Entity relationship extraction can effectively extract the relationship between entities from unstructured texts to construct entity relationship triples and realize the classification of the relationship between entities. The relationship extraction task can be described as: for a given target text T, determine the entity pairs e in it. 1 and e 2 The relationship r is expressed as <e 1 ,r,e 2 >. By exploring the semantic relationships in natural language texts, we can better understand user needs and mine more accurate entity relationships between entities, thereby building a knowledge network to provide more accurate recommendation functions.
[0003] Traditional relation extraction relies on machine learning such as support vector machine (SVM), but it is difficult to solve multi-classification problems. With the development of neural networks and their powerful learning ability, scholars have gradually adopted neural networks to replace traditional machine learning for relation classification tasks, such as CNN and RNN classic models. With the emergence of GCN networks, the neighborhood information of nodes can be enriched by converting the target text sequence into a graph structure in relation extraction tasks. However, the GCN network has certain limitations when obtaining neighboring features. Each layer of the GCN network structure can only obtain first-order neighborhood features. When obtaining K-order neighborhood features, it is necessary to build a multi-layer GCN network structure, which consumes a lot of time and may cause the problem of over-smoothing of the results. At the same time, the traditional GCN network regards all nodes as equally important, ignoring the importance of entities in relation extraction, which often leads to a decrease in the accuracy of the model's relation prediction. Common supervised models need to train manually annotated corpora to achieve relation extraction tasks, but this method has a strong dependence on artificial corpora and is greatly affected by sample noise, resulting in poor relation extraction results. Summary of the invention
[0004] The present invention provides a relationship extraction method based on entity semantic fusion to solve the problem of poor entity relationship extraction effect in the prior art.
[0005] In order to achieve the above object, the present invention adopts the following technical solution.
[0006] A relation extraction method based on entity semantic fusion, comprising:
[0007] Get the target sentence of the relation to be extracted;
[0008] Construct a preset vector of the target sentence, which contains each word, its part of speech, and entity tag in the target sentence;
[0009] Construct a syntactic dependency tree of the target sentence and establish an adjacency matrix of the syntactic dependency tree; wherein the syntactic dependency tree uses entity nodes as global nodes and adds connections from global nodes to other nodes and connections from all nodes to themselves;
[0010] Input the preset vector and adjacency matrix into the GCN neural network for semantic extraction to obtain the first feature vector;
[0011] Input the first feature vector into the PCNN segmented convolutional neural network for feature extraction to obtain a second feature vector;
[0012] The second feature vector is input into the Softmax classifier for relationship category prediction to achieve entity relationship extraction.
[0013] Furthermore, the preset vector for constructing the target sentence specifically includes:
[0014] The word embedding model is used to map the words in the target sentence to a dimension of d w The vector space of
[0015] Use syntactic analysis tools to construct part-of-speech tags and entity tags for the target sentence, and map the part-of-speech and entity tags to dimensions d s The vector space of
[0016] Each word, part of speech and entity tag of the target sentence are concatenated to obtain the preset vector S = {X 1 ,X 2 ,X 3 ,......,X m},in m is the target sentence length, represents the i-th word, represents the part of speech of the i-th word, Represents the entity tag of the i-th word.
[0017] Furthermore, the step of constructing a syntactic dependency tree of the target sentence and establishing an adjacency matrix of the syntactic dependency tree specifically includes:
[0018] For the target sentence, use the syntactic analysis tool to build a grammatical dependency tree with entity nodes as global nodes;
[0019] Construct connections from the global node to other nodes and establish the first adjacency matrix;
[0020] Add connections from each node to itself to create the identity matrix;
[0021] Add the first adjacency matrix to the identity matrix to get the final adjacency matrix.
[0022] Furthermore, the formula of the GCN neural network is expressed as follows:
[0023]
[0024] in, represents the hidden layer representation of the i-th node in the l-th layer; ρ represents the ReLU activation function; represents the adjacency matrix, Indicates the connection relationship between node i and node j, and its value is the distance from node i to node j; d i represents the out-degree of node i; b (l) Indicates the offset; α i represents the weight coefficient;
[0025] The hidden layer representation of each node in the last layer of the GCN neural network constitutes the first feature vector.
[0026] Furthermore, the first feature vector is input into a PCNN segmented convolutional neural network for feature extraction to obtain a second feature vector, specifically including:
[0027] Performing a convolution operation on the first eigenvector using a plurality of filters and a weight matrix;
[0028] The feature vector obtained after each convolution operation is divided into three segments, with the entity head and entity tail as the boundary. Each segment is subjected to maximum pooling to obtain a pooling vector.
[0029] Concatenate all pooled vectors, use the nonlinear equation tanh as the hidden layer activation function, calculate the maximum pooled output in slices, and get the second eigenvector.
[0030] Furthermore, the step of inputting the second feature vector into a Softmax classifier to predict the relationship category and extract the entity relationship specifically includes:
[0031] The second feature vector is input into the Softmax classifier, and the Softmax classifier formula is as follows:
[0032] f(z|g)=softmax(W s g+b s )
[0033] Among them, z represents the relationship category to be calculated, g represents the second eigenvector, and W s and bs are weight parameters and bias parameters respectively;
[0034] Calculate the probability of each relationship category, sort them from high to low, and obtain the relationship category with the highest probability as the result of relationship extraction to achieve entity relationship extraction.
[0035] Furthermore, before performing relationship extraction, it also includes: constructing a training sample set, and training the GCN neural network, the PCNN segmented convolutional neural network and the Softmax classifier based on the training sample set.
[0036] Furthermore, during the training process, the loss function of the Softmax classifier adopts the cross entropy function.
[0037] Beneficial Effects
[0038] The present invention proposes a relationship extraction method based on entity semantic fusion, which can effectively extract the relationship between entities from unstructured text, thereby playing an auxiliary role in building a knowledge network for intelligent recommendation systems. The core significance of this method is to enrich the semantic information of the sequence through a graph structure network based on a new syntactic dependency tree, take the entity node as a global node and build connections from the global node to other nodes and all nodes to themselves, which can effectively capture the semantic information of other words in the sequence to the entity. This method can obtain the information of the entire syntactic dependency tree in one convolution, avoiding the problems of large time overhead and excessive smoothing of the results brought about by the calculation of multi-layer convolutional structures. Therefore, the fully connected convolutional network centered on the entity can effectively eliminate the noise generated during training and capture the key information of the entity. At the same time, the sequence vector enriched with structural semantic features by GCN is placed in the PCNN segmented convolutional neural network for training, which can reflect the guiding role of contextual information of different segments on entity semantic information, improve the semantic expression of entities, and then enhance the semantic connection between entities to improve the accuracy of relationship extraction. Finally, the Softmax classifier is used to predict and classify the relationship, thereby realizing entity relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 It is an extraction flow chart of a relationship extraction method based on entity semantic fusion provided by an embodiment of the present invention;
[0041] Figure 2is a structural diagram of a relationship extraction algorithm model provided by an embodiment of the present invention;
[0042] Figure 3 It is a schematic diagram of a syntactic dependency tree provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] To make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described in detail below. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other implementation methods obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0044] In view of the problem that the accuracy of the relationship extraction method in the prior art is not high, an embodiment of the present invention provides a relationship extraction method based on entity semantic fusion, which focuses on enriching the semantic features of entities by constructing a new syntactic dependency tree. In the syntactic dependency tree, the entity node is used as a global node and a connection from the entity node to all nodes is created. The semantic information of the entire syntactic parsing tree can be obtained in one convolution, reducing the time consumption caused by too many GCN neural network structures and the problem of over-smoothing of the results. Putting the GCN hidden layer output into the PCNN segmented convolutional neural network with entities as segmentation points and training the sequence segments can effectively improve the semantic guidance of different contextual information on entities, improve the semantic expression of entities, and then enhance the semantic connection between entities to improve the accuracy of relationship extraction. Finally, the Softmax classifier is used to predict and classify the relationship.
[0045] In order to achieve the above purpose, it is necessary to first train the relation extraction algorithm model including GCN neural network, PCNN segmented convolutional neural network and Softmax classifier. The structure of the relation extraction algorithm model is as follows: Figure 2 As shown, the structure and training method of the relationship extraction algorithm model are introduced in detail below.
[0046] In this embodiment, the SemEval2010 Task8 dataset is used as the training set of the model. The target sentence set is defined as T 1 ={S 1 ,S 2 ,S 3 ,......,S n}, these sentences contain pre-set entities <e 1 ,e 2 >, use the GloVe word embedding model to map the words in the target sentence to a dimension of d wThe Stanford Parser syntactic analysis tool is used to construct a syntactic analysis tree, part-of-speech tagging and entity tagging for the target sentence, and the part-of-speech and entity tags are mapped to vector spaces of dimension d. s Each word, part of speech and entity tag of the target sentence are concatenated to obtain the preset vector S of the target sentence. i ={X 1 ,X 2 ,X 3 ,......,X m},in d=d w +2×d s , m is the target sentence length, represents the i-th word, represents the part of speech of the i-th word, Represents the entity tag of the i-th word.
[0047] In the prior art, the syntactic dependency tree constructed by the target sentence is parsed into a graph structure and an adjacency matrix is created. Each tag in the adjacency matrix represents a word node. If there is a dependency relationship between words, there is an edge between the corresponding nodes. After each graph convolution operation, the information of each node can be updated by fusing the features of its neighboring nodes. The resulting sequence of context information features h = {h 1 ,h 2 ,h 3 ,......,h m}. The graph convolutional neural network GCN formula is expressed as follows:
[0048]
[0049] Among them, A represents the adjacency matrix, A ij Indicates that the i-th node is connected to the j-th node, b (l) is the offset, ρ represents the ReLU activation function, W (l) is the weight matrix, and l represents the number of layers. The feature fusion of one layer of GCN network can only obtain the feature correlation of the first-order neighboring nodes. If k-order neighboring features are needed, a K-layer GCN structure needs to be constructed to obtain its semantic information. This method is time-consuming and may cause the result to be over-smoothed.
[0050] Since the semantic information between entities and contexts needs to be paid more attention in the process of relationship extraction, this embodiment proposes a new extended syntactic dependency tree, in which entity nodes are used as global nodes, and connections from global nodes to other nodes are constructed. The semantic information of the entire syntactic dependency tree can be obtained in one convolution. However, since nodes themselves cannot construct dependency relationships in the syntactic dependency tree, information cannot be extracted from Transfer to We add edges from each node to itself, such as Figure 3 As shown. The use of a new type of syntactic dependency tree can increase the importance of entity nodes in relation extraction and improve the contribution of keywords in sentences to the semantic features of sentences. Constructing a new type of syntactic dependency tree allows the entity nodes we are concerned about to gather information from other nodes in one convolution, effectively reducing the problems of over-smoothing and long time consumption caused by multiple convolutions. Therefore, the modified graph convolution network formula is:
[0051]
[0052]
[0053] in, is the adjacency matrix of the new syntactic dependency tree, which represents the m×m matrix formed by the connections of all nodes in the new syntactic dependency tree. Indicates the connection relationship between node i and node j. Its value is the distance between node i and node j. In the syntactic dependency tree, the distance between every two connected nodes is 1. Node i to node j needs to pass through y edges, and the distance is y. i represents the out-degree of node i; I represents the identity matrix formed by all nodes connecting themselves, and A represents the adjacency matrix formed by the syntactic dependency tree after building the connection from the global node to other nodes; α i represents the weight coefficient;
[0054] After passing through L layers of GCN, the hidden layer representation of each node can be obtained The hidden layer representation of each node in the last layer of the GCN neural network constitutes the first feature vector.
[0055] Next, we use the PCNN segmented convolutional neural network to enrich the impact of contextual information of different segments on entity semantics. We mainly obtain local features through sliding windows based on the convolutional network features, and use the maxpooling layer to reduce the dimension of the sentence vector by combining the segmented sequences. We can select the most significant features of each segment. Since a single max pooling layer is not enough to capture the structural information between two entities, we divide the sentence into three segments according to the position between the two entities, obtain the max pooled values of each segment and concatenate them as the convolution output to obtain the second feature vector.
[0056] The present invention adds a PCNN segmented convolutional neural network after the GCN neural network, and uses the hidden layer representation of each node of the previous GCN neural network to form a first feature vector Q as the input of the PCNN segmented convolutional neural network, and sets Q = {q 1 ,q 2 ,q3 ,...,q m}(q i ∈R d ). In this embodiment, in order to obtain different features, we use ω (ω = 3) filters, whose weight matrix is w∈R ω*d , the i-th word vector q in the first feature vector Q i To the jth word vector q j The series connection is represented by q i:j . Using k = 3 weight matrices (W = {w 1 ,w 2 ,w 3}), each weight matrix is combined with q through convolution operation i:j Multiply to get the new sequence vector c, and the modified convolution formula is:
[0057] c ij =w i q j-ω+1:j 1≤i≤k; 1≤j≤m+ω-1
[0058] The final feature matrix calculated by the convolutional layer is:
[0059] C={c 1 ,c 2 ,c 3}∈R k×(m+ω-1)
[0060] In order to better capture the structural features between two entities in a sentence, we use the entity head and entity tail as the boundary segmentation (i.e., the first entity and the previous one are the first segment, the two entities and the two entities are the second segment, and the second entity and the following one are the third segment). i It is divided into three sections, namely c i ={c i1 ,c i2 ,c i3}, put it into the maximum pooling layer for calculation, and the main features can be extracted. The maximum pooling formula is:
[0061] p ij =max(c ij )1≤i≤k,1≤j≤3
[0062] The vector after pooling calculated for the segmented vector is p i ={p i1 ,p i2 ,p i3}. Finally, concatenate all pooled vectors p i After getting the concatenated vector p, the nonlinear equation tanh is used as the hidden layer activation function, and the maximum pooling output g is calculated in slices as the second eigenvector. The formula is:
[0063]
[0064] After passing through the maximum pooling layer of the PCNN segmented convolutional neural network, the hidden representation of each node is obtained. In order to use the hidden representation of these nodes to represent the relationship classification, the Softmax classifier is used in this embodiment to predict the relationship category. The Softmax function is used as a normalized exponential function to calculate the distribution probability of a discrete random variable with N possible values. The second eigenvector g is input into the Softmax classifier, and its mathematical formula is as follows:
[0065] f(z|g)=softmax(W s g+b s )
[0066] Among them, z represents the relationship category to be calculated, g represents the second eigenvector, and W s and b s are weight parameters and bias parameters respectively; the closer the probability value of correct classification is to 1, the better the classification effect is. If the correct result is closer to 0, the classification effect is very poor. The model is trained by back propagation and uses the cross entropy loss function to evaluate and continue to adjust the softmax classifier during training. It can further expand the gap in the calculated probabilities of different categories and significantly improve the classification effect. The cross entropy loss function formula is as follows:
[0067]
[0068] Where N represents the number of relationship categories, C r represents the true relationship category, c r Represents the predicted relationship category. Finally, the probability of each relationship category is calculated, and the highest probability relationship category is obtained from high to low sorting as the result of relationship extraction, thereby realizing entity relationship extraction.
[0069] After the training of the above network models (including GCN neural network, PCNN segmented convolutional neural network and Softmax classifier) is completed based on the SemEval2010 Task8 data set, it can be used to extract entity relationships. Based on this, this embodiment provides a relationship extraction method based on entity semantic fusion, including:
[0070] S1: Get the target sentence of the relation to be extracted;
[0071] S2: Construct a preset vector of the target sentence, which contains each word, word part of speech and entity tag in the target sentence;
[0072] S3: construct a syntactic dependency tree of the target sentence and establish an adjacency matrix of the syntactic dependency tree; wherein the syntactic dependency tree uses entity nodes as global nodes, and adds connections from global nodes to other nodes and connections from all nodes to themselves;
[0073] S4: Input the preset vector and adjacency matrix into the GCN neural network for semantic extraction to obtain the first feature vector;
[0074] S5: Input the first feature vector into the PCNN segmented convolutional neural network for feature extraction to obtain a second feature vector;
[0075] S6: Input the second feature vector into the Softmax classifier for relationship category prediction to achieve entity relationship extraction.
[0076] The present embodiment provides a method for extracting relations based on entity semantic fusion, which can effectively extract relations between entities from unstructured texts, thereby playing an auxiliary role in constructing knowledge networks for intelligent recommendation systems. The core significance of this method is to enrich the semantic information of the sequence through a graph structure network based on a new syntactic dependency tree, take the entity node as a global node and build connections from the global node to other nodes and all nodes to themselves, which can effectively capture the semantic information of other words in the sequence to the entity. This method can obtain the information of the entire syntactic dependency tree in one convolution, avoiding the problems of high time overhead and excessive smoothing of the results in the calculation of multi-layer convolutional structures. Therefore, the entity-centered fully connected convolutional network can effectively eliminate the noise generated during training and capture the key information of the entity. At the same time, the sequence vector enriched with structural semantic features by GCN is placed in the PCNN segmented convolutional neural network for training, which can reflect the guiding role of contextual information of different segments on entity semantic information, improve the semantic expression of entities, and then enhance the semantic connection between entities to improve the accuracy of relation extraction. Finally, the Softmax classifier is used to predict and classify the relationship, effectively obtaining the distribution probability of discrete random variables of possible values as the basis for relationship selection. Adding the cross entropy function to the Softmax classifier to further expand the probability gap calculated for different categories can significantly improve the classification effect and thus obtain a more accurate representation of the relationship between entities.
[0077] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0078] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A relationship extraction method based on entity semantic fusion, characterized in that: include: Get the target sentence of the relation to be extracted; Construct a preset vector of the target sentence, which contains each word, its part of speech, and entity tag in the target sentence; Construct a syntactic dependency tree of the target sentence and establish an adjacency matrix of the syntactic dependency tree; wherein the syntactic dependency tree uses entity nodes as global nodes and adds connections from global nodes to other nodes and connections from all nodes to themselves; Input the preset vector and adjacency matrix into the GCN neural network for semantic extraction to obtain the first feature vector; Input the first feature vector into the PCNN segmented convolutional neural network for feature extraction to obtain a second feature vector; The second feature vector is input into the Softmax classifier for relationship category prediction to achieve entity relationship extraction.
2. The relationship extraction method based on entity semantic fusion according to claim 1 is characterized in that: The preset vector for constructing the target sentence specifically includes: The word embedding model is used to map the words in the target sentence to a dimension of d w The vector space of Use syntactic analysis tools to construct part-of-speech tags and entity tags for the target sentence, and map the part-of-speech and entity tags to dimensions d s The vector space of Each word, part of speech and entity tag of the target sentence are concatenated to obtain the preset vector S = {X1, X2, X3, ..., X m },in m is the target sentence length, represents the i-th word, represents the part of speech of the i-th word, Represents the entity tag of the i-th word.
3. The relationship extraction method based on entity semantic fusion according to claim 1 is characterized in that: The step of constructing a syntactic dependency tree of the target sentence and establishing an adjacency matrix of the syntactic dependency tree specifically includes: For the target sentence, use the syntactic analysis tool to build a grammatical dependency tree with entity nodes as global nodes; Construct connections from the global node to other nodes and establish the first adjacency matrix; Add connections from each node to itself to create the identity matrix; Add the first adjacency matrix to the identity matrix to get the final adjacency matrix.
4. The relationship extraction method based on entity semantic fusion according to claim 2 is characterized in that: The formula of the GCN neural network is as follows: in, represents the hidden layer representation of the i-th node in the l-th layer; ρ represents the ReLU activation function; represents the adjacency matrix, Indicates the connection relationship between node i and node j, and its value is the distance from node i to node j; d i represents the out-degree of node i; b (l) Indicates the offset; α i represents the weight coefficient; The hidden layer representation of each node in the last layer of the GCN neural network constitutes the first feature vector.
5. The relationship extraction method based on entity semantic fusion according to claim 1 is characterized in that: The first feature vector is input into the PCNN segmented convolutional neural network for feature extraction to obtain the second feature vector, specifically including: Performing a convolution operation on the first eigenvector using a plurality of filters and a weight matrix; The feature vector obtained after each convolution operation is divided into three segments, with the entity head and entity tail as the boundary. Each segment is subjected to maximum pooling to obtain a pooling vector. Concatenate all pooled vectors, use the nonlinear equation tanh as the hidden layer activation function, calculate the maximum pooled output in slices, and get the second eigenvector.
6. The relationship extraction method based on entity semantic fusion according to claim 1 is characterized in that: The second feature vector is input into the Softmax classifier to predict the relationship category and extract the entity relationship, which specifically includes: The second feature vector is input into the Softmax classifier. The Softmax classifier formula is as follows: f(z|g)=softmax(W s g+b s ) Among them, z represents the relationship category to be calculated, g represents the second eigenvector, and W s and b s are weight parameters and bias parameters respectively; Calculate the probability of each relationship category, sort them from high to low, and obtain the relationship category with the highest probability as the result of relationship extraction to achieve entity relationship extraction.
7. The relationship extraction method based on entity semantic fusion according to claim 1 is characterized in that: Before performing relationship extraction, it also includes: constructing a training sample set, and training the GCN neural network, the PCNN segmented convolutional neural network and the Softmax classifier based on the training sample set.
8. The relationship extraction method based on entity semantic fusion according to claim 7 is characterized in that: During the training process, the loss function of the Softmax classifier adopts the cross entropy function.
