Relation extraction method and system based on graph neural network
Through technical means such as multi-channel encoding, position perception and heterogeneous graph convolution, the recognition accuracy and robustness of graph neural networks in complex semantic relationship extraction are improved, which solves the shortcomings of existing methods in complex semantic relationship recognition and is suitable for knowledge graph construction and information extraction systems.
Patent Information
- Application Number
- CN202511093745.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-06
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2045-08-06
AI Technical Summary
Existing relationship extraction methods based on graph neural networks have problems when dealing with complex semantic relationships, cross-sentence relationships, and multi-entity co-occurrence relationships. The graph construction strategy is imperfect, the node representation is not precise enough, and there is a lack of dynamic adjustment mechanism. As a result, the relationship recognition accuracy is low and it is difficult to meet the application requirements of large-scale information extraction systems.
By adopting technical means such as multi-channel encoding, location-aware mechanism, confidence screening, heterogeneous graph convolution, path-aware attention mechanism and semantic consistency verification, an efficient graph neural network model is constructed. Through multi-layer message passing and aggregation, the recognition accuracy and robustness of the relationship between entities are improved.
It significantly improves the recognition accuracy of multi-type semantic relationships between entities in complex natural language texts, enhances the model's global semantic modeling capabilities and scalability, and is suitable for various practical application scenarios such as knowledge graph construction and information extraction systems.
Smart Images

Figure CN120611052A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, and in particular to a relationship extraction method and system based on graph neural network. Background Art
[0002] Relation extraction is a key task in information extraction, aiming to identify and extract semantic relationships between entities from unstructured text. Current mainstream approaches include rule-based methods, statistical learning-based methods, and deep learning-based methods. Deep learning methods have gradually become the mainstream due to their powerful feature representation capabilities.
[0003] However, existing deep learning methods still have limitations when dealing with complex semantic relationships, cross-sentence relationships, and multi-entity co-occurrence relationships. This is primarily due to the difficulty traditional sequence models (such as RNNs and CNNs) in capturing global context when modeling dependencies between entities. To overcome these issues, recent research has increasingly introduced graph structures to represent entities within a sentence and the multidimensional connections between them, and then utilized graph neural networks (GNNs) for modeling and analysis.
[0004] Despite this, existing graph neural network-based relationship extraction methods remain imperfect in terms of graph construction strategies, node representation, and edge weight definitions, which can easily lead to redundant graph structure information or low relationship recognition accuracy. Furthermore, the lack of a dynamic adjustment mechanism limits the generalization of such methods in complex text scenarios. Therefore, a graph neural network-based relationship extraction method that can efficiently model complex relationships between entities and improve relationship extraction accuracy is urgently needed to meet the application requirements of large-scale information extraction systems. Summary of the Invention
[0005] The purpose of the present invention is to provide a relationship extraction method and system based on graph neural network to solve the shortcomings in the background technology.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a relationship extraction method based on a graph neural network, comprising: S100: Get the target text, perform word segmentation, part-of-speech tagging and named entity recognition on the target text, and extract the entity set ; n represents the total number of entities; S200, constructing a text graph G = (V, R) based on the entity set, where V is a node set including the entity and its context words, and R is an edge set including syntactic dependency edges, positional relationship edges, and co-occurrence relationship edges; S300, construct the initial feature vector for each node v∈V in the graph , the feature vector includes word vector, part-of-speech information and position information; S400: Input the graph G into the graph neural network model for multi-layer message passing and aggregation to obtain a high-level representation of each node , where k is the number of layers of the graph neural network; S500, for the target entity in the figure The representations are concatenated or combined and input into the relation classifier to predict its relation type r∈R′, where R′ is a predefined relation set; S600: Output the relationship triples between entity pairs according to the prediction results .
[0007] Preferably, the S100 includes: S101, perform multi-channel encoding on the target text, respectively using a pre-trained language model to extract contextual semantic vectors, combining a lexical feature encoder to extract part-of-speech embedding representations, and obtaining syntactic sequence dependency representations through BiLSTM; S102. Perform vector-level fusion on the part-of-speech embedding representation to construct an enhanced word vector representation, and introduce a position-aware mechanism to encode the position bias information of the word relative to the entity in the sentence; S103: Based on the fused representation input conditional random field sequence tagger, the named entity recognition model is combined to perform entity boundary recognition and type discrimination, and extract entity sets. ; n represents the total number of entities; S104. Use a confidence screening mechanism to perform semantic consistency checks on the preliminary recognition results, filter out low-confidence entities, and improve the accuracy and robustness of the entity set.
[0008] Preferably, the S200 includes: S201, based on the entity set E, select words within the entity window context to form a candidate node set, and introduce dependency subtree nodes based on the syntactic analysis results to form a node set V; S202: Use a dependency syntax analyzer to construct syntactic dependency edges, generate directed edges based on dependency paths between words, and add grammatical relationship types as edge weight attributes; S203, calculating the relative position distance between the word and the entity, and setting a threshold to construct a position relationship edge. The edge weight decays inversely with the relative position distance to capture the influence of local word order; S204: Count the co-occurrence frequencies of entity pairs in the training corpus, and establish co-occurrence relationship edges based on word vector similarity. The edge weights are determined by the frequency-weighted cosine similarity function.
[0009] Preferably, the S300 includes: S301: For each node v in the node set V, call the pre-trained language model to obtain the contextual semantic word vector embedding , used to capture global semantic features; S302: Perform part-of-speech tagging on node v and map its corresponding part-of-speech tag into a part-of-speech embedding vector. , and uses a convolutional encoder to model the local context of the part-of-speech sequence; S303: construct a position encoding vector hˡ(v) based on the relative position information between the node v and its entity, and use a learnable position embedding parameter table to achieve vectorized representation of continuous distance; S304, will and Splicing is performed on the vector dimension, and an initial feature vector of uniform dimension is obtained through a layer of nonlinear transformation and normalization operation. , used as input for subsequent graph neural networks.
[0010] Preferably, the S400 includes: S401. Input the text graph G = (V, R) into the graph neural network model, and use a heterogeneous graph convolution structure to define message passing functions for different types of edges R respectively; S402: In the k-th layer of the graph neural network, for each node v∈V, receive feature information weighted by edge type from its adjacent node u∈N(v) ; S403, aggregated neighbor information and its own upper layer representation Perform residual connection and nonlinear transformation to generate the current layer node representation ; S404, stacking k layers of graph neural networks to capture multi-order semantic dependencies, and finally obtaining a set of high-order node representations containing global structural semantics .
[0011] Preferably, the process of multi-layer message transmission and aggregation in the graph neural network further includes: S405: Construct all possible multi-hop connection paths in each layer, score the importance of different paths using a differentiable path scoring function, and use the path score as a weight adjustment factor for message aggregation; S406: The contextual semantics of the nodes in the high-scoring path are used as structural supplementary signals and fused into the representation of the target node through a bidirectional gating mechanism to preserve the implicit semantic dependencies across sentences or between distant entities. S407. After the final node representation is generated, the path attention distribution is used as an explicit graph structure supervision signal to construct an auxiliary loss function to optimize the graph neural network's modeling ability and generalization performance for key paths.
[0012] Preferably, the S500 includes: S501, target entity Extract the high-order representation of the corresponding nodes respectively and , and fuse the aggregate representation of all intermediate nodes in the shortest path between the two in the graph structure to construct a structure-enhanced entity pair representation ; S502: Introduce the context alignment module, use the graph attention mechanism to assign different weights to the context nodes of the entity pairs in the sentence, calculate their context semantic alignment vectors, and to integrate; S503: Input the fused entity pair representation into a multi-channel relationship classification network, where the network includes a static relationship prediction branch and a dynamic context perception branch, which are used to model static semantic associations and context-driven relationship variability, respectively.
[0013] Preferably, the S600 includes: S601, dynamically modeling the relationship probability distribution output by the classifier, combining the co-occurrence pattern of entity pairs in the context and the edge connection strength in the graph structure, and adaptively adjusting the confidence value of the predicted relationship r; S602: Set a confidence gating mechanism. When the prediction confidence exceeds the preset dynamic threshold, the entity pair triple is constructed. Otherwise, the prediction result is marked as a candidate relationship and sent to the reasoning and backtracking module for further confirmation; S603, introduce semantic consistency verification strategy in the triple generation process, and The type alignment and context semantic consistency are checked to eliminate candidate triples with semantic conflicts; S604: Construct the triples that have passed the confidence gating and consistency verification into the final output result set, and support setting output rules by field or task type to achieve customized management and automatic post-processing of triples.
[0014] The present invention also provides a relationship extraction system based on a graph neural network, comprising: The entity recognition module obtains the target text, performs word segmentation, part-of-speech tagging, and named entity recognition on the target text, and extracts the entity set; n represents the total number of entities; A graph construction module constructs a text graph G = (V, R) based on the entity set, where V is a node set including the entity and its context words, and R is an edge set including syntactic dependency edges, positional relationship edges, and co-occurrence relationship edges; The feature encoding module constructs an initial feature vector for each node v∈V in the graph, and the feature vector includes word vector, part of speech information and position information; The graph neural network representation learning module inputs the graph G into the graph neural network model for multi-layer message passing and aggregation to obtain the high-order representation of each node, where k is the number of layers of the graph neural network; The relation modeling and classification module concatenates or combines the representations of the target entity pairs in the graph and inputs them into the relation classifier to predict their relation type r∈R′, where R′ is a predefined relation set; A triplet construction module outputs a relationship triplet between entity pairs according to the prediction results.
[0015] In the above technical solution, the technical effects and advantages provided by the present invention are: 1. The present invention provides a graph neural network-based relationship extraction method that can accurately identify multi-type semantic relationships between entities in complex natural language text. By introducing a heterogeneous graph structure and integrating entities, contextual terms, and the multi-dimensional edge connections between them (including syntactic dependencies, relative positions, and semantic co-occurrence edges), it effectively overcomes the traditional sequence model's inability to model long-distance dependencies and structural ambiguity, achieving a more refined representation of text structure. Furthermore, by leveraging multi-channel semantic representation, a path-aware attention mechanism, and a contextual alignment strategy, the model possesses stronger global semantic modeling capabilities, significantly improving the accuracy and robustness of relationship recognition in complex semantic contexts.
[0016] 2. The present invention introduces structural enhancement and supervision guidance mechanisms in the three core stages of entity representation, graph modeling, and relationship classification to construct entity pair expressions with greater semantic recognition. In particular, through the confidence gating mechanism and semantic consistency verification strategy, adaptive control of prediction quality is achieved in the triple output link, which significantly reduces the probability of erroneous relationship output and improves the controllability and deployability of the system. The overall solution has significant advantages such as high accuracy, strong scalability, and excellent performance in cross-sentence and weakly supervised relationships. It is suitable for a variety of practical application scenarios such as knowledge graph construction, information extraction systems, and text structuring. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments described in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0018] Figure 1 This is a mind map of the method of the present invention.
[0019] Figure 2This is a mind map of the system modules of the present invention. DETAILED DESCRIPTION
[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0021] Example 1, please refer to Figure 1 As shown, the relationship extraction method based on graph neural network described in this embodiment includes: S100: Get the target text, perform word segmentation, part-of-speech tagging and named entity recognition on the target text, and extract the entity set ; n represents the total number of entities; S200, constructing a text graph G = (V, R) based on the entity set, where V is a node set including the entity and its context words, and R is an edge set including syntactic dependency edges, positional relationship edges, and co-occurrence relationship edges; S300, construct the initial feature vector for each node v∈V in the graph , the feature vector includes word vector, part-of-speech information and position information; S400: Input the graph G into the graph neural network model for multi-layer message passing and aggregation to obtain a high-level representation of each node , where k is the number of layers of the graph neural network; S500, for the target entity in the figure The representations are concatenated or combined and input into the relation classifier to predict its relation type r∈R′, where R′ is a predefined relation set; S600: Outputting a relationship triplet between entity pairs according to the prediction result .
[0022] In one embodiment of the present invention, step S100 aims to extract the entity set E from the target text with high precision, laying a solid foundation for subsequent graph structure construction and relationship extraction. This step introduces multi-channel representation fusion, a location-aware mechanism, a joint recognition model, and a confidence screening mechanism to address issues such as low accuracy, fuzzy boundaries, and weak entity generalization in traditional named entity recognition in complex contexts.
[0023] First, the target text is preprocessed, including standardization, symbol regularization, and sentence segmentation, to ensure that the input sequence meets the requirements of the encoding model. Then, a three-channel feature extraction strategy is used to perform multi-dimensional representation of each word: Contextual semantic vector extraction: Use pre-trained language models (such as BERT, RoBERTa, etc.) to model the context of the original text and output the context-sensitive semantic vector of each word, which is recorded as This semantic vector has bidirectional encoding capabilities and can capture the semantic evolution of entities in context, effectively overcoming the problem that fixed word vectors cannot handle ambiguity.
[0024] Lexical feature embedding representation: The lexical feature encoder is used to map the part-of-speech tag (POS) of each word into a low-dimensional dense vector This vector is processed by a convolutional encoder to mine local dependencies in the part-of-speech sequence, thereby introducing syntactic clues to help distinguish homographs or entities with fuzzy boundaries.
[0025] Syntactic dependency representation acquisition: Use BiLSTM structure to perform bidirectional modeling on the original word sequence and generate sequence dependency vectors , the representation focuses on the context order and syntactic dependency path, enhancing the distinguishability of entity boundaries while preserving word sequence.
[0026] All three types of representations are extracted based on a unified word granularity to ensure semantic dimension consistency and vector alignment, providing a structural basis for subsequent fusion.
[0027] In order to integrate multi-channel information, the above three types of representations are fused in the following way: First, the three representation vectors for each word Splicing is performed on the vector dimension to form a preliminary enhanced word vector; Secondly, we introduce the position-aware mechanism, that is, for each word Construct a position vector , represents the relative distance between the word and the center of the candidate entity in the sentence. The position vector is obtained through a learnable position embedding matrix to achieve continuous relative distance vectorization; Finally, the position vector and the fused semantic vector are input into the fusion layer together, and after nonlinear transformation (such as ReLU) and batch normalization, the final enhanced word vector is obtained. .
[0028] This fusion strategy has good semantic alignment and entity perception capabilities, and significantly enhances the discriminative ability of entity representation in complex contexts.
[0029] The enhanced word vector sequence is input into the named entity recognition module, which is completed by jointly training the CRF sequence tagger and the named entity recognition neural network (such as BiLSTM-CRF): BiLSTM further models the long-term dependencies between word sequences; The CRF module performs global optimization on the labeling results to ensure that the entity labels meet the legal transfer path; The model outputs the entity label of each word in the current context, such as B-PER, I-ORG, O, etc.
[0030] Through this joint model, not only can the entity boundaries be accurately identified, but also the entity types can be labeled to form entity sets. , where each They all contain structural information such as location, boundary, and type, and n represents the total number of entities; To further improve the quality of entity recognition, especially in the presence of ambiguous or noisy text, the system has designed a confidence filtering mechanism, which includes the following steps: Confidence calculation: Statistics are collected on the entity boundaries and label assignment probabilities predicted by the model, and the prediction confidence value of each entity is calculated, which is the average CRF edge weight score of the entity path. Semantic consistency check: Extract the semantic fragments that appear in the context of the identified entity, calculate the degree of semantic matching between them and the entity label using a similarity model (such as SimCSE), and perform weakly supervised comparison in combination with an external dictionary or knowledge base; Filtering strategy: Only entities that meet both high confidence thresholds and semantic consistency judgments are retained as valid entities , low-confidence or conflicting entities are marked as “candidates” and enter the next stage of graph construction filtering or manual review process.
[0031] Through this strategy, the accuracy and robustness of the entity set E are effectively improved, and the interference of low-quality entities in subsequent graph modeling is avoided.
[0032] In a preferred embodiment of the present invention, step S200 aims to construct a semantic graph G = (V, R) based on the entity set E identified in step S100, where V is the graph's node set and R is the graph's edge set. This graph not only expresses the explicit and implicit structural relationships between entities but also provides a foundation for multi-dimensional semantic propagation in graph neural networks.
[0033] The graph construction mechanism proposed in this paper breaks the limitations of traditional sequence modeling on linear text structures. It integrates three types of information paths: syntactic structure, word order position, and semantic co-occurrence. Through structural enhancement of node construction and multi-edge type fusion strategy, it constructs a high-level text graph structure with semantic perception capabilities. Specifically, it includes the following sub-steps: To enhance the expressive power of the graph structure, this step further introduces entity neighboring context words and their syntactic dependency substructures as candidate nodes based on the entity set E: Entity Window Selection: Each entity Taking the original text as the center, set a fixed-length window (for example, ±5 words) forward and backward, and add the words within the window range to the candidate node set to preserve the local semantic context; Dependency subtree introduction: Perform dependency syntactic analysis on the text to obtain the dependency subtree of each word (that is, the set of subordinate nodes when the word is the central node). Non-entity word nodes belonging to any entity dependency path are introduced into the candidate set to retain grammatical supplementary information. Node deduplication: After deduplicating the candidate set, we obtain a node set V, which includes named entity nodes, contextual term nodes, and grammatical structure enhancement nodes. Each node is associated with a unique identifier, position index, and type label for subsequent feature construction.
[0034] This step constructs a graph node set with strong coverage and semantic continuity through the dual supplementary mechanism of semantic neighborhood and syntactic structure, providing structural diversity support for entity relationship modeling.
[0035] The edges between nodes in the graph form the path foundation for entity relationship propagation. The first thing to be constructed is the syntactic dependency edge based on the language structure. The generation logic is as follows: Use dependency parsers (such as Stanford CoreNLP and SpaCy) to obtain the dependency structure information between words and extract the dependency relationship paths between all word pairs; If the node and If there is a dependency relationship, add a line from point to Directed edges of ; Each edge is associated with a grammatical type label (such as nsubj, dobj, acl, etc.) as the grammatical attribute of the edge; The grammatical attributes are represented by trainable embedding vectors, which constitute part of the edge weight and are used to implement type-aware propagation in subsequent GNN models.
[0036] This edge type is designed to preserve the dependency between entities in a sentence and their context, enhancing the graph structure's ability to express language organization.
[0037] To further supplement the order information between nodes, this step introduces an edge construction strategy based on relative position distance to achieve modeling of local word order: For any pair of nodes , if the distance between them in the original sentence does not exceed a preset threshold (e.g., 5 words), a positional relationship edge is established between the two; The edge is undirected, and the strength of the edge (i.e., the edge weight) is determined by its relative distance in the text. The inverse decay function is defined as follows, for example , where r is the adjustable attenuation coefficient; All position edges are uniformly labeled as "position-edge" to distinguish them from dependency edges and apply different propagation strategies in GNN.
[0038] Through this mechanism, the graph structure's ability to model sequential dependencies between short-distance neighboring nodes can be enhanced, capturing linguistic phenomena such as "modifier-modified" and "subject-verb agreement".
[0039] In order to mine the implicit semantic co-occurrence relationship in the text, we further introduce an edge construction method based on co-occurrence statistics and word vector similarity: Counting entity pairs in the training corpus Frequency of co-occurrence in the same semantic context (e.g., sentence or paragraph) , and use it to measure the degree of semantic association between entities; Calculate the cosine similarity of entity word vectors , indicating the closeness of their semantic space; The final edge weight is defined as , where λ is the weighting coefficient, which controls the fusion ratio of structural co-occurrence and semantic similarity; Only when the edge weight exceeds the dynamic threshold τ, a co-occurrence relationship edge is added to avoid introducing redundant weak associations.
[0040] This strategy breaks through the limitation of syntactic edges and positional edges being limited to intra-sentence structures, provides a semantic association enhancement path for global corpus, and effectively improves the ability to model long-term dependencies between entity pairs.
[0041] In the relationship extraction method proposed in the present invention, the nodes of the graph structure include not only the entity itself, but also its context words and grammatical dependent sub-nodes. The semantic differences between the nodes in the node set V are large, and the information granularity is different. In order to fully express the feature information of various nodes, step S300 designs a multi-source semantic feature construction mechanism, including semantic vector embedding, part-of-speech encoding, position bias modeling and feature fusion normalization strategy, and finally provides a unified and structurally aligned initial node vector for the graph neural network. The specific steps include the following: First, for each node v∈V, call the pre-trained language model (such as BERT, RoBERTa, ERNIE, etc.) to obtain its contextual semantic word vector embedding This language model is pre-trained on a large-scale corpus and is capable of disambiguating polysemous words, understanding syntactic structures, and modeling cross-sentence context. The technical process is as follows: Perform word segmentation and token alignment on the original text to ensure accurate mapping of node v in the model; Take the sentence or context fragment containing node v as input and extract the word vector through each layer of Transformer in the model; Take the output vector of the last layer or multiple layers of the model after weighted fusion as the contextual semantic representation of node v , the dimension is usually 768 or 1024; If a node corresponds to multiple words, the word vectors are fused using average pooling or maximum pooling strategies.
[0042] This semantic embedding introduces global semantic information for each node, making up for the lack of expression of the static vector of the vocabulary under context changes.
[0043] In order to enhance the discriminative ability of nodes in local syntactic structures, each node v is tagged with part-of-speech, and its corresponding part-of-speech label (such as NN, VB, JJ, etc.) is obtained, and the label is encoded into an embedding vector of fixed dimension The specific steps are as follows: Use natural language processing tools (such as SpaCy, LTP) to perform part-of-speech analysis on sentences; Constructing part-of-speech tag embedding matrix in is the size of the part-of-speech tag set, d is the dimension of the part-of-speech vector; The input is a one-dimensional convolutional encoder, which combines the adjacent part-of-speech context to extract local dependency patterns at the grammatical phrase level. The output is a structure-sensitive part-of-speech representation vector that captures the functional role of a word and its contextual combination patterns. This strategy significantly improves the discernibility of the grammatical role of a node and is an important semantic dimension for building the foundation for syntactic edge propagation in graph structures.
[0044] The relative distance between entities and context in text plays an important role in relationship judgment. To this end, this paper introduces a learnable position encoding mechanism based on entity reference position to construct a position embedding vector , specifically including: For each node v, calculate the relative distance between it and the entity or target entity pair in the sentence ; Map relative distance as index to position embedding table , where L is the maximum offset distance, is the position vector dimension, and the center position is ; Position embedding vector It can directly participate in feature propagation within graph neural networks and support updates during training. To avoid noise introduced by large distances, nodes outside the offset range are uniformly mapped to "long-range" position encodings. This position representation makes the model sensitive to entity relationships across different distance ranges, avoiding problems such as misidentification of synonyms and structural mismatches.
[0045] In order to construct a unified initial node representation vector, the above three types of vectors need to be Carry out integration and structural unification. Specifically including: In the vector dimension, the three types of vectors are spliced together to obtain the fusion vector ;enter To a layer of linear transformation network , uniformly mapped to the dimension d required by the graph neural network; nonlinear activation functions (such as ReLU) are added to enhance the expression of nonlinearity; finally, batch normalization (BatchNorm) and Dropout mechanisms are applied to improve training stability and prevent overfitting. The initial feature vector of the node after fusion is It not only combines three types of information: context, lexical and structural, but also has good normalization and training robustness, providing a consistent input format for subsequent information propagation of multi-layer graph neural networks.
[0046] In a preferred embodiment of the present invention, step S400 is intended to use the above-constructed text graph G = (V, R) as input, and use the Graph Neural Network (GNN) model to perform multi-layer information propagation and representation update on each node in the graph, thereby obtaining a high-order node representation set that expresses the global structural semantics. To enhance the model’s ability to perceive entity semantic associations, this step uses a heterogeneous graph convolutional structure, a gated aggregation mechanism, and a path attention guidance strategy to achieve multi-edge type modeling, key relationship path identification, and generalization capability improvement.
[0047] The edge types in the text graph G are diverse, including dependency syntactic edges, positional relationship edges, and semantic co-occurrence edges. Traditional GNN models are difficult to model uniformly. To this end, this step constructs a heterogeneous graph convolution module and defines an independent message passing function for each edge type r∈R , and model different types of edges separately in the node information aggregation stage. The process is as follows: Decompose the graph structure into multiple edge-type subgraphs , processed separately; Each subgraph uses an independent linear transformation weight matrix , edge type-specific encoding of neighbor node features; In the node update phase, a multi-channel attention aggregation mechanism is introduced to adaptively integrate the contributions of different edge types; Finally, the weighted sum of the information of each edge type channel is used as the aggregate representation input of the node.
[0048] This mechanism effectively solves the type interference problem in heterogeneous structure graphs and improves the modeling accuracy of different relationship paths.
[0049] In each layer of graph convolution operation, for each target node v, its previous layer is represented as , the adjacent nodes are The model is used for all adjacent nodes Features Aggregate and introduce a weighting mechanism based on edge type. Introduce a gating mechanism Implement dynamic adjustment as follows: First calculate the node pair Edge weight , the edge weight can be derived from edge attribute embedding or attention weight; For each neighbor node u, calculate the gating function value , where σ is the Sigmoid activation function; u and v represent nodes in the graph, u is the neighbor node, and v is the current target node. They represent the feature vectors of the neighbor node u and the target node v in the k-1th layer respectively. represents the concatenation operation of the feature vectors, which combines the representations of u and v into a longer vector to explicitly express their joint state. Wg is the gated weight matrix (a learnable parameter) that performs a linear transformation on the concatenated feature vectors, learning how to measure the influence of u on v. The aggregation expression is: Where, Represents the edge weight index, which indicates the structural importance of the edge (type r) from node u to node v in the propagation of this layer (which may come from the attention mechanism, preset weights, or edge attribute embedding in the graph). Represents the transformation matrix corresponding to the edge type r, which is used to represent the neighbor node u Mapped to a semantic space aligned with the representation space of node v, which can be edge-type specific (common in heterogeneous graphs). Represents the representation of neighbor node u at the k-1 layer. Through the gating mechanism, the model can automatically select neighbor nodes that have substantial contributions to the current node and suppress semantic noise.
[0050] After aggregating neighbor information, the steps to update the node representation are as follows: With the previous layer's own representation Perform residual connection to form: ; Apply the Dropout layer to randomly mask some feature channels to enhance training robustness; Layer Normalization is used to stabilize the training process and accelerate convergence.
[0051] This strategy effectively alleviates the over-smoothing problem in graph convolution and retains the discriminability of node features in multi-layer propagation.
[0052] To capture the multi-level dependency information between entities, a k-layer graph convolutional network is stacked, with each layer sharing or independently weighted, to generate high-level semantic representations in a progressive propagation manner: The first layer mainly models direct grammatical dependencies and local neighborhood semantics; The middle layer gradually introduces structural extension information, such as co-occurrence paths and semantic jump relationships; The final output of layer k is Form a global structure-aware node embedding for subsequent entity relationship discrimination tasks.
[0053] In this process, node representation has multi-granularity, cross-level, and structure-sensitive semantic embedding capabilities.
[0054] To further enhance the modeling capabilities of long-distance entity relationships and multi-hop semantic paths, step S400 also introduces a path-aware mechanism with strong structural reasoning and semantic alignment capabilities, specifically including: In each layer of propagation, for all possible slave nodes in the graph To Node Multi-hop path Enumerate (limit the number of hops ≤ L) and calculate its representation through the path representation function PathRep(P). Use the path scoring function Score(P) (such as a differentiable neural network function) to calculate the importance of each path: ,in is the representation of each node in the path; the score serves as the dynamic weight adjustment factor of the edge corresponding to the path in the current layer node aggregation, further guiding the priority of multi-hop semantic information aggregation.
[0055] For paths rated as high value, the semantic information of their internal nodes is used as a structural supplementary signal: Introducing a bidirectional gating mechanism and Control the introduction intensity and aggregation method of path semantic information respectively; According to the path score adjustment, weights are introduced. The fusion ratio is adjusted based on the state of the target node; the final fused vector participates in the target node's representation update, achieving structural completion and remote dependency perception. This mechanism improves the expressibility of cross-sentence or cross-entity relationship chains, a modeling task that existing GNNs based on first-order adjacency structures cannot accomplish.
[0056] In order to enhance the model's ability to focus on structural paths, a path attention supervision signal is introduced: Perform KL divergence matching on the path score distribution with the manually annotated key paths or statistical priors; Constructing auxiliary loss , and the main loss (e.g. relational classification cross entropy) joint optimization; The final loss function is: , where λ is the adjustment factor.
[0057] This supervision method has the ability to provide explicit structural guidance, significantly improving the model's generalization ability on texts with complex structures.
[0058] In the relationship extraction method based on graph neural network proposed in the present invention, step S500 is a key stage, which is responsible for mapping high-order node representations into semantic relationships between entity pairs. Since the relationship between entities usually depends not only on their own semantics, but also on their connection paths and contextual environment in the graph structure, the traditional "entity vector splicing + classifier" method is difficult to effectively capture relationship evolution and contextual dependency. Therefore, the present invention designs a structure-enhanced entity pair modeling and multi-channel relationship classification mechanism, including path representation fusion, context alignment modeling and multi-branch classifier optimization, which specifically includes the following sub-steps: First, the target entity pair Extract the high-order node representation obtained after propagation in the graph neural network and In order to introduce structural semantic path information, the intermediate node information on the shortest path between the two is further integrated. The processing flow is as follows: In the text graph G, the shortest path between entity pairs is calculated based on a graph traversal algorithm (such as BFS or Dijkstra) , obtain the set M of intermediate nodes in the path excluding the start and end entities; Extract the representation of all nodes v∈M in the set M , aggregated by average pooling, attention weighting or maximum pooling, and recorded as path semantic representation ; Constructing structure-enhanced entity pair representations: ; This representation combines the entity representation itself with the embedding of semantic hub nodes in the structural path, making up for the defect that only splicing entity ontology information cannot model the upstream and downstream relationship chain.
[0059] The semantic relationship between entity pairs is highly dependent on the context in which they appear. To improve the model's ability to judge context-sensitive relationships, this step designs a context alignment module to extract the contextual semantics associated with entity pairs and integrate them into the relational representation. Specifically, it includes: Entity pair The set C of context nodes in the sentence that are within a certain window (e.g., ±5 words) and extract the high-level representations of these nodes; Use the graph attention mechanism (GAT) to represent the semantics of each node v in the set C Calculating attention weights , and entity pair representation Based on the correlation of ; The contextual semantic vector is fused with the structure-enhanced entity pair representation to form the final relation representation vector for classification: ;in Represents a nonlinear mapping network that unifies the representation dimension and semantic space. This mechanism effectively aligns semantic context and improves the model's ability to judge ambiguous relationships, polysemous words, or semantic shifts.
[0060] To address the diversity of entity relationships and differences in semantic drivers, this paper adopts a multi-channel relationship classification network structure to separate and model structural semantics from contextual semantics, thereby improving expression accuracy: Static semantic branch: Use a standard fully connected network to Modeling and extracting stable relational representations related to semantic structures; Dynamic context-aware branch: This branch introduces context-varying features to model the global context of the input text (such as sentence vectors and paragraph vectors), and processes it jointly with entity pair representations. The two branches each output relationship probability distribution The final fusion method can be weighted average, maximum entropy synthesis or attention regulation fusion, and the final predicted relationship category is output .
[0061] This structure strengthens the differentiated learning of two types of semantic paths: semantically stable relations and context-driven relations, and improves the fine-grained recognition capability of relationship extraction.
[0062] Considering the challenges in practical applications such as unbalanced training samples, fuzzy relationship boundaries, and path interference, this paper designs a dual supervision mechanism to enhance the discriminative robustness of the model: Entity-level label supervision: cross-entropy loss optimization is performed on the predicted relationship r and the manually annotated labels to ensure classification accuracy; Path confidence guided supervision: The path attention distribution calculated in step S400 is measured similarly to the actual label path (such as KL divergence) to guide the model to learn a reasonable structural path attention strategy; the comprehensive loss function is as follows: ; Where L_cls is the main classification loss, L_path is the path supervision auxiliary loss, and s is the adjustment factor.
[0063] This strategy not only constrains the classification output of the model, but also introduces prior guidance at the structural modeling level to improve the model's convergence speed and generalization ability for weakly supervised samples.
[0064] After completing the classification prediction of the relationship between entity pairs, the present invention designs a complete relationship triple output mechanism to ensure the structural accuracy, semantic consistency and application adaptability of the output results. In traditional methods, the classification results are usually directly used as the final triple output, ignoring the possible incorrect decisions of the classification model in marginal samples, ambiguous contexts and low-confidence predictions. The present invention introduces a dynamic confidence control mechanism, a semantic consistency verification strategy and an inference backtracking support system to form a set of triple construction processes with intelligent screening capabilities and adaptive robustness, which specifically includes the following sub-steps: First, the confidence modeling is performed on the output results of the relation classification network. At the classifier output stage, for each pair of entities , the model outputs the probability distribution of its corresponding relationship category r ∈ R′ To achieve dynamic adjustment, this step constructs a comprehensive confidence scoring function: Define the confidence scoring function: ;in: The predicted probability output by the relation classifier; is the semantic similarity of entity pairs co-occurring in the context (such as word vector similarity within the context window); is the average edge weight of the path connecting two entities in the graph structure; α, β, and γ are weighting coefficients that control the proportion of different confidence sources fused. This confidence scoring mechanism implements bidirectional structural and semantic constraints on the model output, effectively alleviating the uncertainty in relationship classification caused by contextual bias.
[0065] To ensure the reliability of the triple output, this step introduces a confidence gating mechanism to dynamically determine whether the prediction result meets the output conditions. The processing flow is as follows: Set a dynamic confidence threshold τ (which can be adaptively adjusted based on the median or distribution characteristics of the training set); when When constructing a triple , marked as confirmed; when When , it is marked as a candidate relationship and not output temporarily; All candidate relations will be fed into the reasoning and backtracking module and further confirmed through downstream knowledge base consistency verification, rule reasoning or context re-judgment strategy.
[0066] This gating strategy effectively avoids the model's excessive output behavior under critical predictions and improves the quality stability and credibility of triplet output.
[0067] To further ensure the semantic and logical consistency of the output triples, this step designs an entity semantic consistency verification mechanism, including entity type matching and context semantic rationality detection: Entity Type Matching: Check and Whether it meets the semantic role required by the relationship r. For example, if r is "subordinate relationship", then Should be "name" Should be "organization"; Contextual semantic verification: extracting the content from the original text and The context fragment is used to determine whether the relation statement is semantically consistent with the context through a semantic consistency judgment model (such as the text entailment model, SimCSE, etc.); Triples that do not satisfy semantic logic are marked and filtered to avoid erroneous knowledge injection.
[0068] Through this mechanism, pseudo-relationship triples caused by word meaning ambiguity, sentence mismatch or mislabeling of entity types are effectively suppressed, significantly improving the semantic accuracy of triples.
[0069] For all relation triples that pass confidence gating and consistency verification The system organizes them into an output set T, supporting domain-specific management and customized output according to actual application requirements: Standardized result formats: Supports output of structured data formats such as JSON, RDF, and CSV, making it easy to integrate into information extraction systems or knowledge graph platforms; Domain rule filtering: Introducing a domain dictionary and rule set based on task configuration, which can filter valid relationship types by industry (such as medical and legal); Batch deduplication and aggregation: When there are multiple relationship prediction results for the same entity pair, the one with the highest confidence is retained or prioritized according to domain rules; Automatic post-processing mechanism: supports integration with external knowledge bases (such as Wikidata and CN-DBpedia) for completion, normalization, and error correction, improving the consistency and completeness of knowledge output.
[0070] This post-processing process implements intelligent management and adaptive optimization of structured output, and is a key supporting module for the deployment of the relationship extraction system.
[0071] Example 2: To verify the effectiveness of the "graph neural network-based relationship extraction method" described in the present invention in actual tasks, the applicant constructed an experimental platform based on a public dataset and conducted comparative experiments to evaluate the relationship extraction capability of the present invention method in complex texts and compare its performance with existing mainstream methods. The details are as follows: Experimental platform: PyTorch 1.13, Python 3.9, CUDA 11.6, GPU: NVIDIA A100.
[0072] Dataset: The public Chinese relation extraction dataset CCKS2019-Task1 is used. This dataset contains approximately 15,000 sentences annotated with triples, involving 9 types of entities and 50 types of relations, and has a certain degree of semantic complexity and structural diversity.
[0073] Data partitioning: Training set: 12,000; Validation set: 1,500 records; Test set: 1,500 records; In order to verify the performance of the method of the present invention, four comparative models were designed, and their compositions and descriptions are shown in Table 1. The experimental results are shown in Table 2.
[0074] Table 1 Comparison table of baseline models
[0075] Three evaluation indicators commonly used in the field of relationship extraction are used: Precision (P): The correct proportion of predictions in the positive class; Recall (R): The proportion of correct predictions in the actual positive class; F1-score (F1): the harmonic mean of precision and recall, .
[0076] The prediction results use a strict triple matching standard, that is, the entity boundaries, types and relationships are all consistent and considered correct.
[0077] Table 2 Comparison of experimental results
[0078] As can be seen from Table 2, the F1-score of the proposed method (M4) is significantly higher than that of other comparison models, and is 4.4 percentage points higher than that of the GCN structure, reflecting its modeling advantage in multi-category complex relationships; the improvement in precision indicates that the structure-enhanced modeling and confidence gating mechanism in this method effectively suppress the generation of low-confidence pseudo-triples; the improvement in recall is attributed to the path-aware attention mechanism's ability to mine longer distances or implicit semantic relationships between entity pairs; compared with traditional methods, the proposed method can not only model intra-sentence dependencies, but also handle complex structures across sentences, multiple hops, and multiple semantic paths, thereby enhancing the system's semantic generalization and relationship interpretation capabilities.
[0079] In summary, the relationship extraction method based on graph neural network proposed in this invention effectively solves the problems of low recognition rate and high false alarm of existing methods in complex semantic scenes through multi-source feature fusion, heterogeneous graph modeling, path supervision and classification optimization strategy, and has significant technological advancement and engineering practical value.
[0080] Example 3, please refer to Figure 2 As shown, the relationship extraction system based on graph neural network described in this embodiment includes: The entity recognition module obtains the target text, performs word segmentation, part-of-speech tagging, and named entity recognition on the target text, and extracts the entity set; n represents the total number of entities; A graph construction module constructs a text graph G = (V, R) based on the entity set, where V is a node set including the entity and its context words, and R is an edge set including syntactic dependency edges, positional relationship edges, and co-occurrence relationship edges; The feature encoding module constructs an initial feature vector for each node v∈V in the graph, and the feature vector includes word vector, part of speech information and position information; The graph neural network representation learning module inputs the graph G into the graph neural network model for multi-layer message passing and aggregation to obtain the high-order representation of each node, where k is the number of layers of the graph neural network; The relation modeling and classification module concatenates or combines the representations of the target entity pairs in the graph and inputs them into the relation classifier to predict their relation type r∈R′, where R′ is a predefined relation set; A triplet construction module outputs a relationship triplet between entity pairs according to the prediction results.
[0081] The above is only a specific implementation method of the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this application, which should be covered by the scope of protection of the present application.
Claims
1. A relationship extraction method based on graph neural network, characterized by: include: S100: Get the target text, perform word segmentation, part-of-speech tagging and named entity recognition on the target text, and extract the entity set ; n represents the total number of entities; S200, constructing a text graph G = (V, R) based on the entity set, where V is a node set including the entity and its context words, and R is an edge set including syntactic dependency edges, positional relationship edges, and co-occurrence relationship edges; S300, construct the initial feature vector for each node v∈V in the graph , the feature vector includes word vector, part-of-speech information and position information; S400: Input the graph G into the graph neural network model for multi-layer message passing and aggregation to obtain a high-level representation of each node , where k is the number of layers of the graph neural network; S500, for the target entity in the figure The representations are concatenated or combined and input into the relationship classifier to predict its relationship type ,in is a set of predefined relationships; S600: Output the relationship triples between entity pairs according to the prediction results .
2. The relationship extraction method based on graph neural network according to claim 1, characterized in that: The S100 includes: S101, perform multi-channel encoding on the target text, respectively using a pre-trained language model to extract contextual semantic vectors, combining a lexical feature encoder to extract part-of-speech embedding representations, and obtaining syntactic sequence dependency representations through BiLSTM; S102. Perform vector-level fusion on the part-of-speech embedding representation to construct an enhanced word vector representation, and introduce a position-aware mechanism to encode the position bias information of the word relative to the entity in the sentence; S103: Based on the fused representation input conditional random field sequence tagger, the named entity recognition model is combined to perform entity boundary recognition and type discrimination, and extract entity sets. ; n represents the total number of entities; S104. Use a confidence screening mechanism to perform semantic consistency checks on the preliminary recognition results, filter out low-confidence entities, and improve the accuracy and robustness of the entity set.
3. The relationship extraction method based on graph neural network according to claim 1, characterized in that: The S200 includes: S201, based on the entity set E, select words within the entity window context to form a candidate node set, and introduce dependency subtree nodes based on the syntactic analysis results to form a node set V; S202: Use a dependency syntax analyzer to construct syntactic dependency edges, generate directed edges based on dependency paths between words, and add grammatical relationship types as edge weight attributes; S203, calculating the relative position distance between the word and the entity, and setting a threshold to construct a position relationship edge. The edge weight decays inversely with the relative position distance to capture the influence of local word order; S204: Count the co-occurrence frequencies of entity pairs in the training corpus, and establish co-occurrence relationship edges based on word vector similarity. The edge weights are determined by the frequency-weighted cosine similarity function.
4. The relationship extraction method based on graph neural network according to claim 1, characterized in that: The S300 includes: S301: For each node v in the node set V, call the pre-trained language model to obtain the contextual semantic word vector embedding , used to capture global semantic features; S302: Tag the node v with a part-of-speech tag and map its corresponding part-of-speech tag into a part-of-speech embedding vector. , and uses a convolutional encoder to model the local context of the part-of-speech sequence; S303: construct a position encoding vector hˡ(v) based on the relative position information between the node v and its entity, and use a learnable position embedding parameter table to achieve vectorized representation of continuous distance; S304, will 、 and Splicing is performed on the vector dimension, and an initial feature vector of uniform dimension is obtained through a layer of nonlinear transformation and normalization operation. , used as input for subsequent graph neural networks.
5. The relationship extraction method based on graph neural network according to claim 1, characterized in that: The S400 includes: S401. Input the text graph G = (V, R) into the graph neural network model, and use a heterogeneous graph convolution structure to define message passing functions for different types of edges R respectively; S402: In the k-th layer of the graph neural network, for each node v∈V, receive feature information weighted by edge type from its adjacent node u∈N(v) ; S403, aggregated neighbor information and its own upper layer representation Perform residual connection and nonlinear transformation to generate the current layer node representation ; S404, stacking k layers of graph neural networks to capture multi-order semantic dependencies, and finally obtaining a set of high-order node representations containing global structural semantics .
6. The relationship extraction method based on graph neural network according to claim 5, characterized in that: In the process of multi-layer message passing and aggregation in graph neural networks, it further includes: S405: Construct all possible multi-hop connection paths in each layer, score the importance of different paths using a differentiable path scoring function, and use the path score as a weight adjustment factor for message aggregation; S406: The contextual semantics of the nodes in the high-scoring path are used as structural supplementary signals and fused into the representation of the target node through a bidirectional gating mechanism to preserve the implicit semantic dependencies across sentences or between distant entities. S407. After the final node representation is generated, the path attention distribution is used as an explicit graph structure supervision signal to construct an auxiliary loss function to optimize the graph neural network's modeling ability and generalization performance for key paths.
7. The relationship extraction method based on graph neural network according to claim 1, characterized in that: The S500 includes: S501, target entity Extract the high-order representation of the corresponding nodes respectively and , and fuse the aggregate representation of all intermediate nodes in the shortest path between the two in the graph structure to construct a structure-enhanced entity pair representation ; S502: Introduce the context alignment module, use the graph attention mechanism to assign different weights to the context nodes of the entity pairs in the sentence, calculate their context semantic alignment vectors, and to integrate; S503: Input the fused entity pair representation into a multi-channel relationship classification network, where the network includes a static relationship prediction branch and a dynamic context perception branch, which are used to model static semantic associations and context-driven relationship variability, respectively.
8. The relationship extraction method based on graph neural network according to claim 1, characterized in that: The S600 includes: S601, dynamically modeling the relationship probability distribution output by the classifier, combining the co-occurrence pattern of entity pairs in the context and the edge connection strength in the graph structure, and adaptively adjusting the confidence value of the predicted relationship r; S602: Set a confidence gating mechanism. When the prediction confidence exceeds the preset dynamic threshold, the entity pair triple is constructed. Otherwise, the prediction result is marked as a candidate relationship and sent to the reasoning and backtracking module for further confirmation; S603, introduce semantic consistency verification strategy in the triple generation process, and The type alignment and context semantic consistency are checked to eliminate candidate triples with semantic conflicts; S604: Construct the triples that have passed the confidence gating and consistency verification into the final output result set, and support setting output rules by field or task type to achieve customized management and automatic post-processing of triples.
9. A graph neural network-based relationship extraction system, configured to implement the graph neural network-based relationship extraction method according to any one of claims 1 to 8, characterized in that: include: The entity recognition module obtains the target text, performs word segmentation, part-of-speech tagging, and named entity recognition on the target text, and extracts the entity set; n represents the total number of entities; Graph construction module, constructing a text graph based on the entity set , where V is a node set, including the entity and its context words, and R is an edge set, including syntactic dependency edges, positional relationship edges, and co-occurrence relationship edges; The feature encoding module constructs an initial feature vector for each node v∈V in the graph, and the feature vector includes word vector, part of speech information and position information; The graph neural network representation learning module inputs the graph G into the graph neural network model for multi-layer message passing and aggregation to obtain the high-order representation of each node, where k is the number of layers of the graph neural network; The relation modeling and classification module concatenates or combines the representations of the target entity pairs in the graph and inputs them into the relation classifier to predict their relation type r∈R′, where R′ is a predefined relation set. A triplet construction module outputs a relationship triplet between entity pairs according to the prediction results.
Citation Information
Patent Citations
Domain long text classification method and system based on knowledge graph
CN116521882A
Entity relationship extraction method fusing semantic information and syntactic information
CN119128154A
Heterogeneous graph neural network-based entity relationship joint extraction model and construction method
CN119474394A
Reading type examination question generation system and method based on commonsense reasoning
WO2023225858A1
Cited By
Multi-model collaborative enterprise entity hybrid identification method and device
CN120822521A
Knowledge extraction and mining method for smart home multi-mode dialogue system
CN120850235A
Full-life-cycle management system and method for intelligent communication power supply
CN121350533A
Invoice relation extraction method and system based on natural language analysis
CN121412388A
Invoice relation extraction method and system based on natural language analysis
CN121412388B