Inductive link prediction method based on subgraph and path comparative representation learning

By adopting a subgraph and path-based representation learning method, the problems of insufficient supervision of logical rules and neglect of global information in knowledge graphs are solved, and effective prediction of unseen entities is achieved, improving the accuracy and generalization ability of link prediction.

CN121745241APending Publication Date: 2026-03-27TIANJIN NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-12
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies lack comprehensive logical rule supervision of entity relationships in knowledge graphs and have difficulty effectively capturing global graph information, resulting in limited link prediction performance, especially in open-world scenarios where it is difficult to accurately predict the relationships of newly added entities.

Method used

By employing a subgraph and path-based contrastive representation learning approach, breadth-first search is used to extract topological relationship paths. Combined with node-level and subgraph-level encoding, local structure and relational semantics are modeled. Furthermore, contrastive learning is used to optimize the loss function, enabling effective reasoning for unseen entities.

Benefits of technology

It enhances the supervision of logical rules, improves the ability to predict unseen entities in the knowledge graph, effectively captures information from subgraphs and the global graph, and improves the accuracy and generalization of link prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121745241A_ABST
    Figure CN121745241A_ABST
Patent Text Reader

Abstract

An inductive link prediction method based on subgraph and path comparative representation learning is characterized in that an overall knowledge graph comprises a plurality of structured triples et = (s, rT, o), surrounding subgraphs containing target nodes are extracted, isolated nodes and a complete neighbor relation are reserved, and node features of complete semantic information between neighbor nodes are obtained. And extracting a topological relation path between the head entity s and the tail entity o from the knowledge graph. Local structures and relation semantics are obtained through node-level relation coding, sub-graph-level aggregation perception message passing and an attention mechanism. And carrying out modeling on paths of adjacent relations of the sub-graphs to obtain features in the sub-graphs. A topological structure of a target map is associated with path representation, marginal-based loss is incorporated into distance scores of a positive path sample and a negative path sample, the positive path sample and the negative path sample which need to be distinguished are compared and learned through semantic information conveyed by a relation path, and a loss function is optimized through joint training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of knowledge graphs for large models, specifically to an inductive link prediction method based on subgraph and path contrast representation learning. Background Technology

[0002] A knowledge graph (KG) is a collection of structured triples (head entity, relation, tail entity) used to represent large-scale facts, typically denoted as (s, r, o), such as (Holly, resides in, China). Knowledge graphs reveal relationships between entities and play a crucial role in various applications such as natural language processing, computer vision, and recommender systems. Although knowledge graphs contain millions of facts, they are still far from complete. For example, in the Freebase knowledge graph, 71% of individuals lack birthplace information, and 75% lack nationality information, which limits its performance in downstream applications.

[0003] However, most of the link prediction methods mentioned above assume a closed-world scenario, meaning the entity set is fixed during the training and testing phases. In reality, knowledge graphs in the real world constantly introduce new entities over time, such as newly added users in e-commerce databases or newly discovered molecules in the biomedical field. In the scenario shown in Figure 1, the entities in the training and testing sets do not overlap at all, making it difficult for traditional inductive methods to accurately predict the residence relationship between entity G and address C in the testing set without retraining the entire model. Driven by graph neural networks (GNNs), the GraIL model captures the topological structure of target triples by performing closure operations on subgraphs, thus demonstrating inductive reasoning capabilities. These methods infer unseen links in knowledge graphs by utilizing existing graph structures. However, these methods still have several limitations. First, they often lack comprehensive modeling of the logical rules in entity relationships, resulting in insufficient supervision from the logical rules; second, they often over-rely on subgraph structures while ignoring the global information encoded in the entire graph.

[0004] In recent years, researchers have explored various techniques to overcome these limitations, including inductive reasoning-based methods, logic rule-based methods, GNN methods, and subgraph-based methods. However, these methods still have shortcomings. Specifically, inductive reasoning-based methods often lack comprehensive supervision from logic rules, while logic rule-based methods struggle to capture complex patterns in knowledge graphs. GNNs tend to focus on local connections while neglecting global graph information. Summary of the Invention

[0005] The present invention aims to provide an inductive link prediction method based on subgraph and path contrast representation learning to address the shortcomings of the prior art. The technical problem to be solved by the present invention is achieved through the following technical solution.

[0006] An inductive link prediction method based on subgraph and path contrastive representation learning includes the following steps:

[0007] Step 1, Preprocessing

[0008] The overall knowledge graph G includes multiple structured triples e t =(s, r) T ,o), where s is the head entity, o is the tail entity, and r T This refers to the relationship between the head entity and the tail entity, also known as the target relationship.

[0009] Extract the surrounding subgraph containing the target node, and preserve isolated nodes and complete neighbor relationships to obtain node features with complete semantic information between neighboring nodes;

[0010] Step 2: Comparison of Relationship Paths

[0011] The breadth-first search algorithm is used to extract the topological relationship path between the head entity s and the tail entity o from the knowledge graph, and the semantic relationship with the target relation r is then established. T Consistent paths are considered positive path samples. One or more relations on each positive path in the knowledge graph are randomly replaced to form negative path samples.

[0012] Step 3, Relationship Subgraph Encoding

[0013] Local structure and relational semantics are obtained through node-level relation encoding, subgraph-level aggregation to perceive message passing, and attention mechanisms.

[0014] Step 4, Path Representation Learning

[0015] Modeling the paths of adjacency relationships in a subgraph yields features within the subgraph. Subgraph representation and path representation are then placed within a unified framework to obtain local information representation.

[0016] Step 5, Joint Training

[0017] The topological structure and path representation of the target graph are linked, and the edge-based loss is incorporated into the distance scores of positive and negative path samples. The semantic information conveyed by the relational path is used to contrast and learn the positive and negative path samples that need to be distinguished. The loss function is optimized through joint training.

[0018] Preferably, in step one, a set of nodes within the k-hop neighborhood of s and o is established, where k-hop refers to the k-hop neighbors of a node. Nodes outside the k-hop neighbors are filtered out, and isolated nodes and the complete neighbor relationships of each node are retained to form a set.

[0019] Node i is located in triple (s, r) T Within the intersection of the k-hop undirected neighborhoods s and o surrounding (i, s), labeled (d(i, s), d(i, o)), where d represents the shortest topological distance between the two entities, and its location features... Using double-radius vertex labels, d p The vector dimension is represented as follows:

[0020]

[0021] Where one-hot(·) is the one-hot encoding function. This indicates a splicing operation.

[0022] Preferably, in step one, the adjacent relationship features after message passing are obtained through the following method.

[0023]

[0024] Where, α r For attention factors, r is the relation vector corresponding to the input relation r, and r′ is the relation vector corresponding to the neighbor relation r′. T Let W1 be the feature vector of the target relation, σ(·) be the LeakyReLu activation function, W1 and W2 be the learnable weight matrices, and || denote the concatenation operation.

[0025] Will and The features e of node i are represented by concatenation. i ∈R d d represents the vector dimension, which is then projected onto a plane with respect to the vector dimension. By using node features that share the same embedding space, complete semantic relationships between neighbors can be obtained.

[0026]

[0027] in, Let W represent the initial fusion features of node i, and W0 be the learnable weight matrix.

[0028] Preferably, in step two, the positive path sample in the topological relationship path between the head entity s and the tail entity o is denoted as p. + s→oNegative path samples are represented as p - s→o .

[0029] Preferably, in step three, the node-level relation encoding aggregates relation information from neighboring nodes through a relation-aware GCN framework, thereby encoding the representation of each node. The feature update rule for node i is as follows:

[0030]

[0031] in, Let r be the feature vector of node i in layer (k+1), and let r and j represent the neighbor relationships. Let α be the set of neighbor relationships. i,r,j This is the peripheral level attention coefficient. Let f(·) be the weight matrix of the k-th layer, and f(·) be the message aggregation function. Let e ​​be the feature vector of node j, a neighbor of node i in the k-th layer. r The embedding vector representing relation r. This is a self-loop weight matrix. Let i be the feature vector of node i in the kth layer;

[0032] Obtained through the following methods:

[0033]

[0034] in, Let be the weight matrix of the k-th layer, φ denote the fusion operator, and || denote the concatenation operation;

[0035] Marginal level attention coefficient α i,r,j It is obtained in the following way:

[0036]

[0037] α i,r,j =ReLU(W4[μ i,r,j ||r T ]),

[0038] Where, μ i,r,j W3 and W4 are intermediate variables, and r is the weight matrix. T The feature vector of the target relation;

[0039] The node feature matrix E is further processed using a bidirectional GRU. K ,

[0040] E K =BiGRU(E K )

[0041] Wherein, BiGRU(·) is a bidirectional gated loop function.

[0042] Preferably, in step three, the subgraph-level aggregation is aggregated into a unified subgraph representation in the following way:

[0043]

[0044] Among them, e G It is the final average vector, V G It is a set of nodes in a subgraph, |V G | is the number of nodes in the subgraph node set.

[0045] Preferably, in step four,

[0046] Using aggregation functions to derive the representation of positive sample relation paths, the positive path sample p is obtained as follows: + s→o :

[0047]

[0048] Where n represents the number of paths in the target graph, β m,p Represents path p m and r T Pay attention to the path weights between them. Represents path p m The positive representation, It is obtained through the following method:

[0049]

[0050] Among them, L m p m The number of relationships in the middle W5 represents the j-th window of the relation sequence, and W5 is the weight matrix used to... Perform a linear transformation, b j It is a bias term;

[0051] β m,p It is obtained through the following method:

[0052]

[0053] Where W1 and W2 are weight matrices, r T For the feature vector of the target relation, W1(·) concatenates the vector p. m ||r T or The first linear transformation is performed, with σ(·) as the activation function. The second linear transformation, W2(·), is then performed on the activated vector. Indicates negative path samples. Represents path p m The negative representation of the negative path sample is obtained using the same method as described above.

[0054] Preferably, in step four, the information of the closed subgraph is... Relationship path information with adjacent nodes By splicing together, a subgraph representation is formed.

[0055]

[0056] Evaluate subgraphs and the overall graph using a mutual information estimator. G The expression,

[0057]

[0058] Where N represents the number of triples;

[0059] Then, a bilinear function is used as a discriminant for similarity determination.

[0060]

[0061] Where σ represents the activation function, W MI It is a trainable parameter matrix. It is a measure of subgraph representation and global graph representation s G A discriminant for similarity between them;

[0062] Through the damage function To construct a negative sample image

[0063]

[0064] in, Indicates the process The node features after the operation, where X represents the initial node features and A represents the adjacency matrix in G.

[0065] Preferably, in step five, the triple e t =(s, r) T The probability of scoring (o) is:

[0066]

[0067] f(e t p s→o ) = W a [s s→o ||r T ||p s→o ]

[0068] Among them, ss→o Let be the associated feature vector from the head entity s to the tail entity o. For connected subgraph embedding and path representation, For global representation, the message aggregation function f(e) t ,p s→o Output triple e t For the association p s→o The final characteristic representation of W a For the learnable weight matrix, s s→o p is the associated feature vector from the head entity s to the tail entity o. s→o Let be the path set vector from the head entity s to the tail entity o;

[0069] The marginal loss is incorporated into the distance scores of positive and negative path samples in the following manner.

[0070]

[0071] in, Let G be the loss function related to the graph, and ε be the set of triples. The scoring function for negative path samples. It is a negative triplet. Indicates negative path samples. The scoring function for positive path samples. It is a positive triplet. This represents a positive path sample, while negative path samples are obtained through random replacement.

[0072] The loss function for contrastive learning is obtained by comparing and contrasting positive path samples and negative path samples that need to be distinguished in the learning process.

[0073]

[0074] Mutual information comparison is achieved by comparing the positive and negative sub-global graphs in the following way.

[0075]

[0076] Where N and M represent the number of positive path samples and negative path samples, respectively, and P(X,A) represents the probability of a positive path sample. This represents the true subgraph extracted and encoded from the original graph. The representation vector, This represents the probability of a negative path sample. This represents the negative sample sub-image obtained after perturbing the features of the original image. The representation vector;

[0077] The total loss is the weighted sum of the losses of the three individuals, expressed as:

[0078]

[0079] Where λ1 and λ2 are trainable parameters, representing the weights of the path contrast loss and the mutual information training loss, respectively.

[0080] The inductive link prediction method based on subgraph and path contrast representation learning proposed in this application has the following beneficial effects:

[0081] 1. This application enables effective reasoning about unseen entities in a knowledge graph by jointly utilizing subgraph structure and relational paths through contrastive learning;

[0082] 2. The neighbor relationship path comparison technique in this application enhances the supervision from logical rules. By constructing positive and negative relationship paths based on a BFS strategy, implicit logical supervision can be provided, thereby guiding semantic judgment;

[0083] 3. The contrastive representation learning framework in this application is used to simultaneously capture subgraph information and global graph information. This framework integrates local subgraph features with global semantics through a relational graph attention network and mutual information maximization, thereby improving representation quality and generalization ability;

[0084] 4. Comprehensive experiments were conducted on benchmark datasets in this application, demonstrating the effectiveness and superiority of the proposed method. In particular, under the inductive setting of the FB15k-237 dataset, this inductive link prediction method achieved competitive performance on the Hit@10 metric, validating its robustness and scalability. Attached Figure Description

[0085] Figure 1 This is an example of inductive reasoning in the prior art;

[0086] Figure 2 Here is a flowchart of the inductive link prediction process in this application;

[0087] Figure 3 This is a schematic diagram of the relationship path in this application.

[0088] Figure 4 This is to compare the parameter analysis results of this application with those of other models. Detailed Implementation

[0089] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0090] An inductive link prediction method based on subgraph and path contrastive representation learning includes the following steps:

[0091] Preprocessing

[0092] The overall knowledge graph G includes multiple structured triples e t =(s, r) T ,o), where s is the head entity, o is the tail entity, and r T This refers to the relationship between the head entity and the tail entity, also known as the target relationship.

[0093] Extract the surrounding subgraph containing the target node, and preserve isolated nodes and complete neighbor relationships to obtain node features with complete semantic information between neighboring nodes.

[0094] Specifically, a set of nodes within the k-hop neighborhood of s and o is established, where k-hop represents the k-hop neighbors of a node. Nodes outside the k-hop neighbors are filtered out, and isolated nodes and the complete neighbor relationships of each node are retained to form a set.

[0095] Node i is located in triple (s, r) T Within the intersection of the k-hop undirected neighborhoods s and o surrounding (i, s), labeled (d(i, s), d(i, o)), where d represents the shortest topological distance between the two entities, and its location features... Using double-radius vertex labels, d p The vector dimension is represented as follows:

[0096]

[0097] Where one-hot(·) is the one-hot encoding function. This indicates a splicing operation.

[0098] Obtain the adjacent relationship features after message passing using the following methods.

[0099]

[0100] Where, α r For attention factors, r is the relation vector corresponding to the input relation r, and r′ is the relation vector corresponding to the neighbor relation r′. T Let W1 be the feature vector of the target relation, σ(·) be the LeakyReLu activation function, W1 and W2 be the learnable weight matrices, and || denote the concatenation operation.

[0101] Will and The features e of node i are represented by concatenation. i ∈R d d represents the vector dimension, which is then projected onto a plane with respect to the vector dimension. By using node features that share the same embedding space, complete semantic relationships between neighbors can be obtained.

[0102]

[0103] in, Let W represent the initial fusion features of node i, and W0 be the learnable weight matrix.

[0104] Comparison of Relationship Paths

[0105] The breadth-first search algorithm is used to extract the topological relationship path between the head entity s and the tail entity o from the knowledge graph, and the semantic relationship with the target relation r is then established. T Consistent paths are considered positive path samples. One or more relations on each positive path in the knowledge graph are randomly replaced to form negative path samples.

[0106] In the topological relationship path between the head entity s and the tail entity o, the positive path sample is denoted as p. + s→o Negative path samples are represented as p - s→o .

[0107] Relationship Subgraph Encoding

[0108] Local structure and relational semantics are obtained through node-level relation encoding, subgraph-level aggregation to perceive message passing, and attention mechanisms.

[0109] Specifically, node-level relation encoding aggregates relation information from neighboring nodes through a relation-aware GCN framework, thereby encoding the representation of each node. The feature update rule for node i is as follows:

[0110]

[0111] in, Let r be the feature vector of node i in layer (k+1), and let r and j represent the neighbor relationships. Let α be the set of neighbor relationships. i,r,j This is the peripheral level attention coefficient. Let f(·) be the weight matrix of the k-th layer, and f(·) be the message aggregation function. Let e ​​be the feature vector of node j, a neighbor of node i in the k-th layer. r The embedding vector representing relation r. This is a self-loop weight matrix. Let i be the feature vector of node i in the kth layer;

[0112] Obtained through the following methods:

[0113]

[0114] in, Let be the weight matrix of the k-th layer, φ denote the fusion operator, and || denote the concatenation operation;

[0115] Marginal level attention coefficient α i,r,j It is obtained in the following way:

[0116]

[0117] α i,r,j =ReLU(W4[μ i,r,j ||r T ]),

[0118] Where, μ i,r,j W3 and W4 are intermediate variables, and r is the weight matrix. T The feature vector of the target relation;

[0119] The node feature matrix E is further processed using a bidirectional GRU. K ,

[0120] E K =BiGRU(E K )

[0121] Wherein, BiGRU(·) is a bidirectional gated loop function.

[0122] Subgraph-level aggregation aggregates them into a unified subgraph representation in the following way:

[0123]

[0124] Among them, e G It is the final average vector, V G It is a set of nodes in a subgraph, |V G | is the number of nodes in the subgraph node set.

[0125] Path representation learning

[0126] By modeling the paths of adjacency relationships in a subgraph, the features within the subgraph are obtained. Subgraph representation and path representation are placed within a unified framework to obtain local information representation.

[0127] Specifically, aggregation functions are used to derive the representation of positive sample relation paths, and the positive path sample p is obtained in the following way. + s→o :

[0128]

[0129] Where n represents the number of paths in the target graph, β m,p Represents path p m and rT Pay attention to the path weights between them. Represents path p m The positive representation, It is obtained through the following method:

[0130]

[0131] Among them, L m p m The number of relationships in the middle W5 represents the j-th window of the relation sequence, and W5 is the weight matrix used to... Perform a linear transformation, b j It is a bias term;

[0132] β m,p It is obtained through the following method:

[0133]

[0134] Where W1 and W2 are weight matrices, r T For the feature vector of the target relation, W1(·) concatenates the vector p. m ||r T or The first linear transformation is performed, with σ(·) as the activation function. The second linear transformation, W2(·), is then performed on the activated vector. Indicates negative path samples. Represents path p m The negative representation of the negative path sample is obtained using the same method as described above.

[0135] Information of closed subgraphs Relationship path information with adjacent nodes By splicing together, a subgraph representation is formed.

[0136]

[0137] Evaluate subgraphs and the overall graph using a mutual information estimator. G The expression,

[0138]

[0139] Where N represents the number of triples;

[0140] Then, a bilinear function is used as a discriminant for similarity determination.

[0141]

[0142] Where σ represents the activation function, W MI It is a trainable parameter matrix. It is a measure of subgraph representation and global graph representation s G A discriminant for similarity between them;

[0143] Through the damage function To construct a negative sample image

[0144]

[0145] in, Indicates the process The node features after the operation, where X represents the initial node features and A represents the adjacency matrix in G.

[0146] Joint training

[0147] The topological structure and path representation of the target graph are linked, and the edge-based loss is incorporated into the distance scores of positive and negative path samples. The semantic information conveyed by the relational path is used to contrast and learn the positive and negative path samples that need to be distinguished. The loss function is optimized through joint training.

[0148] Specifically, the triple e t =(s, r) T The probability of scoring (o) is:

[0149]

[0150] f(e t ,p s→o ) = W a [s s→o ||r T ||p s→o ]

[0151] Among them, s s→o Let be the associated feature vector from the head entity s to the tail entity o. For connected subgraph embedding and path representation, For global representation, the message aggregation function f(e) t ,p s→o Output triple e t For the association p s→o The final characteristic representation of W a For the learnable weight matrix, s s→o p is the associated feature vector from the head entity s to the tail entity o. s→o Let be the path set vector from the head entity s to the tail entity o;

[0152] The marginal loss is incorporated into the distance scores of positive and negative path samples in the following manner.

[0153]

[0154] in, Let G be the loss function related to the graph, and ε be the set of triples. The scoring function for negative path samples. It is a negative triplet. Indicates negative path samples. The scoring function for positive path samples. It is a positive triplet. This represents a positive path sample, while negative path samples are obtained through random replacement.

[0155] The loss function for contrastive learning is obtained by comparing and contrasting positive path samples and negative path samples that need to be distinguished in the learning process.

[0156]

[0157] Mutual information comparison is achieved by comparing the positive and negative sub-global graphs in the following way.

[0158]

[0159] Where N and M represent the number of positive path samples and negative path samples, respectively, and P(X,A) represents the probability of a positive path sample. This represents the true subgraph extracted and encoded from the original graph. The representation vector, This represents the probability of a negative path sample. This represents the negative sample sub-image obtained after perturbing the features of the original image. The representation vector;

[0160] The total loss is the weighted sum of the losses of the three individuals, expressed as:

[0161]

[0162] Where λ1 and λ2 are trainable parameters, representing the weights of the path contrast loss and the mutual information training loss, respectively.

[0163] It should be noted that the above detailed descriptions are exemplary and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.

[0164] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments described in this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0165] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that the embodiments of this application described herein can be implemented in sequences other than those illustrated or described herein.

[0166] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or apparatus.

[0167] For ease of description, spatial relative terms such as "above," "on top of," "on the upper surface of," "above," etc., are used herein to describe the spatial positional relationship of a device or feature as shown in the figures to other devices or features. It should be understood that spatial relative terms are intended to encompass different orientations in use or operation beyond the orientation of the device as described in the figures. For example, if the device in the figures were inverted, a device described as "above" or "on top of" other devices or structures would subsequently be positioned as "below" or "under" other devices or structures. Thus, the exemplary term "above" can include both "above" and "below." The device may also be positioned in other different ways, such as rotated 90 degrees or in other orientations, and the spatial relative descriptions used herein will be interpreted accordingly.

[0168] In the detailed description above, reference has been made to the accompanying drawings, which form part of this document. In the drawings, similar symbols typically identify similar parts unless the context otherwise indicates otherwise. The illustrated embodiments described in the detailed specification, drawings, and claims are not intended to be limiting. Other embodiments may be used and other changes may be made without departing from the spirit or scope of the subject matter presented herein.

[0169] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An inductive link prediction method based on subgraph and path contrast representation learning, characterized in that: Includes the following steps: Step 1, Preprocessing The overall knowledge graph G includes multiple structured triples e t =(s, r) T ,o), where s is the head entity, o is the tail entity, and r T This refers to the relationship between the head entity and the tail entity, also known as the target relationship. Extract the surrounding subgraph containing the target node, and preserve isolated nodes and complete neighbor relationships to obtain node features with complete semantic information between neighboring nodes; Step 2: Comparison of Relationship Paths The breadth-first search algorithm is used to extract the topological relationship path between the head entity s and the tail entity o from the knowledge graph, and the semantic relationship with the target relation r is then established. T Consistent paths are considered positive path samples. One or more relations on each positive path in the knowledge graph are randomly replaced to form negative path samples. Step 3, Relationship Subgraph Encoding Local structure and relational semantics are obtained through node-level relation encoding, subgraph-level aggregation to perceive message passing, and attention mechanisms. Step 4, Path Representation Learning Modeling the paths of adjacency relationships in a subgraph yields features within the subgraph. Subgraph representation and path representation are then placed within a unified framework to obtain local information representation. Step 5, Joint Training The topological structure and path representation of the target graph are linked, and the edge-based loss is incorporated into the distance scores of positive and negative path samples. The semantic information conveyed by the relational path is used to contrast and learn the positive and negative path samples that need to be distinguished. The loss function is optimized through joint training.

2. The inductive link prediction method based on subgraph and path contrast representation learning according to claim 1, characterized in that: In step one, a set of nodes within the k-hop neighborhood of s and o is established, where k-hop refers to the k-hop neighbors of a node. Nodes outside the k-hop neighbors are filtered out, and isolated nodes and the complete neighbor relationships of each node are retained to form a set. Node i is located in triple (s, r) T Within the intersection of the k-hop undirected neighborhoods s and o surrounding (i, s), labeled (d(i, s), d(i, o)), where d represents the shortest topological distance between the two entities, and its location features... Using double-radius vertex labels, d p The vector dimension is represented as follows: Where one-hot(·) is the one-hot encoding function, and ⊕ represents the concatenation operation.

3. The inductive link prediction method based on subgraph and path contrast representation learning according to claim 2, characterized in that: In step one, the adjacent relationship feature e after message passing is obtained in the following way. i rel , Where, α r For attention factors, r is the relation vector corresponding to the input relation r, and r′ is the relation vector corresponding to the neighbor relation r′. T Let W1 be the feature vector of the target relation, σ(·) be the LeakyReLu activation function, W1 and W2 be the learnable weight matrices, and || denote the concatenation operation. e i pos and e i rel The features e of node i are represented by concatenation. i ∈R d d represents the vector dimension, which is then projected onto a plane with respect to the vector dimension. By using node features that share the same embedding space, complete semantic relationships between neighbors can be obtained. in, Let W represent the initial fusion features of node i, and W0 be the learnable weight matrix.

4. The inductive link prediction method based on subgraph and path contrast representation learning according to claim 1, characterized in that: In step two, the positive path sample in the topological relationship path between the head entity s and the tail entity o is denoted as p. + s→o Negative path samples are represented as p - s→o .

5. The inductive link prediction method based on subgraph and path contrast representation learning according to claim 1, characterized in that: In step three, node-level relation encoding aggregates relation information from neighboring nodes through a relation-aware GCN framework, thereby encoding the representation of each node. The feature update rule for node i is as follows: in, Let r be the feature vector of node i in layer (k+1), and let r and j represent the neighbor relationships. Let α be the set of neighbor relationships. i,r,j This is the peripheral level attention coefficient. Let f(·) be the weight matrix of the k-th layer, and f(·) be the message aggregation function. Let e ​​be the feature vector of node j, a neighbor of node i in the k-th layer. r The embedding vector representing relation r. This is a self-loop weight matrix. Let i be the feature vector of node i in the kth layer; Obtained through the following methods: in, Let be the weight matrix of the k-th layer, φ denote the fusion operator, and || denote the concatenation operation; Marginal level attention coefficient α i,r,j It is obtained in the following way: a i,r,j =ReLU(W4[μ i,r,j ||r T ]), Where, μ i,r,j W3 and W4 are intermediate variables, and r is the weight matrix. T The feature vector of the target relation is used; the node feature matrix E is further processed using a bidirectional GRU. K , AND K =BigGRU(E K ) Wherein, BiGRU(·) is a bidirectional gated loop function.

6. The inductive link prediction method based on subgraph and path contrast representation learning according to claim 5, characterized in that: Subgraph-level aggregation aggregates them into a unified subgraph representation in the following way: Among them, e G It is the final average vector, V G It is a set of nodes in a subgraph, |V G | is the number of nodes in the subgraph node set.

7. The inductive link prediction method based on subgraph and path contrast representation learning according to claim 1, characterized in that: In step four, aggregation functions are used to derive the representation of the positive sample relation path, and the positive path sample p is obtained in the following way. + s→o : Where n represents the number of paths in the target graph, β m,p Represents path p m and r T Pay attention to the path weights between them. Represents path p m The positive representation, It is obtained through the following method: Among them, L m p m The number of relationships in the middle W5 represents the j-th window of the relation sequence, and W5 is the weight matrix used to... Perform a linear transformation, b j It is a bias term; β m,p It is obtained through the following method: Where W1 and W2 are weight matrices, r T For the feature vector of the target relation, W1(·) concatenates the vector p. m ||r T or The first linear transformation is performed, with σ(·) as the activation function. The second linear transformation, W2(·), is then performed on the activated vector. Indicates negative path samples. Represents path p m The negative representation of the negative path sample is obtained using the same method as described above.

8. The inductive link prediction method based on subgraph and path contrast representation learning according to claim 7, characterized in that: Information of closed subgraphs Relationship path information with adjacent nodes By splicing together, a subgraph representation is formed. Evaluate subgraphs and the overall graph using a mutual information estimator. G The expression, Where N represents the number of triples; Then, a bilinear function is used as a discriminant for similarity determination. Where σ represents the activation function, W MI It is a trainable parameter matrix. It is a measure of subgraph representation and global graph representation s G A discriminant for similarity between them; Through the damage function To construct a negative sample image in, Indicates the process The node features after the operation, where X represents the initial node features and A represents the adjacency matrix in G.

9. The inductive link prediction method based on subgraph and path contrast representation learning according to claim 8, characterized in that: In step five, triple e t =(s, r) T The probability of scoring (o) is: f(e t ,p s→o )=W a [s s→o ||r T ||p s→o ] Among them, s s→o Let be the associated feature vector from the head entity s to the tail entity o. For connected subgraph embedding and path representation, For global representation, the message aggregation function f(e) t ,p s→o Output triple e t For the association p s→o The final characteristic representation of W a For the learnable weight matrix, s s→o p is the associated feature vector from the head entity s to the tail entity o. s→o Let be the path set vector from the head entity s to the tail entity o; The marginal loss is incorporated into the distance scores of positive and negative path samples in the following manner. in, Let G be the loss function related to the graph, and ε be the set of triples. The scoring function for negative path samples. It is a negative triplet. Indicates negative path samples. The scoring function for positive path samples. It is a positive triplet. This represents a positive path sample, while negative path samples are obtained through random replacement. The loss function for contrastive learning is obtained by comparing and contrasting positive path samples and negative path samples that need to be distinguished in the learning process. Mutual information comparison is achieved by comparing the positive and negative sub-global graphs in the following way. Where N and M represent the number of positive path samples and negative path samples, respectively, and P(X,A) represents the probability of a positive path sample. This represents the true subgraph extracted and encoded from the original graph. The representation vector, This represents the probability of a negative path sample. This represents the negative sample sub-image obtained after perturbing the features of the original image. The representation vector; The total loss is the weighted sum of the losses of the three individuals, expressed as: Where λ1 and λ2 are trainable parameters, representing the weights of the path contrast loss and the mutual information training loss, respectively.