Efficient negative sampling and retrieval fusion context path inductive relation prediction method

By employing semantic-aware negative sampling and context path extraction, efficient negative triples are generated and sentence embedding scores are applied. This addresses the efficiency and accuracy issues of knowledge graphs under dynamic changes, and improves the model's generalization ability and prediction performance of complex relationships.

CN119782551BActive Publication Date: 2025-11-04SHANDONG JIAOTONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411933293.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-11-04
Estimated Expiration
2044-12-26

AI Technical Summary

Technical Problem

Existing knowledge graphs are inefficient and difficult to adapt to dynamic changes when new entities are added. Random negative sampling generates a lot of noise, and the understanding of path sparsity and complex relationships is insufficient, which affects the model's generalization ability and prediction accuracy.

Method used

We employ semantically aware negative sampling to generate negative triples, combine breadth-first search and recursive multi-hop context search to extract paths, generate detailed entity descriptions through a large language model and convert them into natural language sentences, and use the Sentence Transformer model for embedding and cosine similarity scoring.

Benefits of technology

It improves the prediction efficiency and accuracy of knowledge graphs, enhances the model's adaptability to dynamic changes, and improves the understanding and prediction performance of complex relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782551B_ABST
    Figure CN119782551B_ABST
Patent Text Reader

Abstract

The application relates to an inductive relation prediction method of high-efficiency negative sampling and retrieval fusion context path, and belongs to the field of knowledge graph link prediction. The method comprises the following steps: semantic perception negative sampling; path extraction and filtering; context extraction and filtering; detailed information retrieval based on a large language model; sentence generation; embedding generation; and generation of a prediction result and training. The application generates more effective negative triples by introducing a semantic perception negative sampling technology, overcomes the limitations of traditional random negative sampling, extracts and filters paths and multi-hop contexts from query triples, combines long and short entities and relation descriptions into sentences, innovatively samples the multi-hop contexts of head entities and tail entities, and filters out irrelevant contents based on similarity, so that the problem of path scarcity or loss is effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of knowledge graph link prediction, and particularly relates to an inductive relation prediction method of efficient negative sampling and retrieval fusion context path. BACKGROUND

[0002] Knowledge Graphs (KGs) are directed graphs that take entities as nodes and relationships as edges, and are widely used in many fields. However, with the exponential growth of real-world data, current knowledge graphs gradually reveal limitations, for example, in the face of new entities constantly joining, existing methods are usually limited to transductive frameworks, and can only predict the entities and relationships that already exist in the training data, thus requiring frequent retraining of the entire graph, which is inefficient and difficult to adapt to dynamic changing scenarios. Therefore, researchers have proposed inductive link prediction, which can better cope with dynamic and open knowledge graph environments by predicting the relationships of unseen entities using known relationship structures.

[0003] The related method KRST proposed by us first extracts and filters unreliable paths, and converts the paths and triples into sentences using entity and relationship descriptions. These sentences generate embeddings through a sentence converter, and relationship prediction is performed through cosine similarity scores. However, the KRST method still has the following shortcomings: (1) random negative sampling may generate negative samples that lack practical significance, increasing training noise and limiting the generalization ability and prediction accuracy of the model; (2) existing text descriptions are difficult to fully cover the diversity of entities and relationships, resulting in poor performance of the model in understanding and predicting complex relationships; (3) relying solely on closed paths to connect query head entities and tail entities is susceptible to path loss or sparsity problems, which adversely affects the performance of the model. Therefore, it is of great theoretical value and practical significance to research an inductive relation prediction method of efficient negative sampling and retrieval fusion context path. SUMMARY

[0004] The application provides an inductive relation prediction method of efficient negative sampling and retrieval fusion context path to solve the above problems.

[0005] To achieve the above purpose, the following technical solutions are implemented:

[0006] An inductive relation prediction method of efficient negative sampling and retrieval fusion context path, comprising the following steps:

[0007] S1. Semantic-aware negative sampling: perform negative sampling through semantic awareness to generate negative sampling triples that are least similar to the query triples;

[0008] S2. Path extraction and filtering: the path information of the query triple and the negative sampling triple generated in step S1 is extracted using a breadth-first search algorithm, and the paths are filtered according to the relationship confidence, to obtain the path set of the query triple and its negative sampling triple;

[0009] S3. Context extraction and filtering: the context triple of the query triple and the negative sampling triple generated in step S1 is explored respectively by a recursive multi-hop context search algorithm, and filtered according to the cosine similarity, to obtain the context triple of the query triple and its negative sampling triple;

[0010] S4. Detailed information retrieval based on large language model: input the short description of the entity into the large language model to generate the corresponding long description of the entity;

[0011] S5. Sentence generation: combine the short description of the entity, the relationship description, the long description of the entity generated in step S4, and convert the query triple and its negative sampling triple, the path set of the query triple and its negative sampling triple extracted in step S2, and the context triple of the query triple and its negative sampling triple generated in step S3 into natural language sentences, to obtain the query triple and its negative sampling triple sentence, the path sentence and the context sentence;

[0012] S6. Embedding generation: input the natural language sentence generated in step S5 into the Sentence Transformer model to generate the query triple and its negative sampling triple sentence embedding vector, the path sentence embedding vector and the context sentence embedding vector;

[0013] S7. Generate prediction results and training: calculate the cosine similarity score between the path sentence embedding vector and the context sentence embedding vector generated in step S6 and the query triple and its negative sampling triple sentence embedding vector to obtain the final result of the inductive relationship prediction; and optimize the model using a loss function.

[0014] Further, step S1 specifically includes:

[0015] S11. Input each entity in the knowledge graph into the BERT model to generate an entity embedding ;

[0016] S12. In the head entity mode, select negative sampling tail entities of the query tail entity from the entity set of the knowledge graph , and arrange them in ascending order according to the similarity score , and the query tail entity ​​The least similar entities are ranked first, from the lowest similarity tail entities The negative sampling triple set in the head entity mode is generated Similarly, the negative sampling triple set in the tail entity mode is generated in the tail entity mode The formula is as follows:

[0017] ,

[0018] ,

[0019] wherein, represents the negative sampling triple set in the head entity mode, represents the negative sampling tail entity of the negative sampling triple set in the head entity mode, represents the top k values, represents the entity set, represents the entity embedding of the query tail entity represents the entity embedding of negative sampling tail entity, represents the number of entities, represents the negative sampling triple set in the tail entity mode, represents the negative sampling head entity of the negative sampling triple set in the tail entity mode, represents the entity embedding of the query head entity represents the entity embedding of negative sampling head entity.

[0020] Further, in step S2, the path information of the query triple and the negative sampling triple generated in step S1 is extracted using the breadth-first search algorithm, and the path is filtered according to the relationship confidence, the path extraction and filtering process of the query triple is as follows:

[0021] S21. Path extraction: in the head entity mode, the relationship and the entity are alternately traced from the head entity to the tail entity , the path from the head entity to the tail entity of the query triple is searched in the knowledge graph by using the breadth-first search algorithm, the path is represented as , and the relationship path from the head entity to the tail entity is extracted from the path​​​​ Relationship path Represented as Similarly, in the tail entity mode, the tail entity is obtained. End Entity Relationship path ;

[0022] S22. Path Filtering: Calculate the confidence score of a relational path using a relational path confidence function, specifically the relational path confidence score under the head entity schema. The formula is expressed as follows:

[0023] ,

[0024] in, Indicates a relational path The number of triplets, This indicates that there is a relational path. The number of triples in the head entity End-to-end entity Relationship path Relationship paths with a confidence level greater than or equal to a preset relationship path confidence threshold are selected from the head entity pattern to obtain valid paths in the head entity pattern; the preset relationship path confidence threshold is set to 5 × 10. -3 Similarly, the effective path in the tail entity mode is obtained.

[0025] Similarly, based on the query triples The path extraction and filtering process involves extracting and filtering the path from the negative sampled triples generated in step S1 to obtain the corresponding valid path.

[0026] Further, in step S3, the context triplet of the query triplet and the negative sampled triplet generated in step S1 is obtained through a recursive multi-hop context search algorithm, and then filtered based on cosine similarity; the context triplet search process for the query triplet is as follows:

[0027] S31. Context Extraction: Recursively apply a multi-hop context search algorithm to explore query triples. The neighborhood context of the head and tail entities is defined by the following steps:

[0028] According to the query triplet Initialize the head entity node set Set of tail entity nodes Head entity node set For the entity containing the head The set, Tail entity node set For including tail entities a set of head entity context triplets, ; and an empty set of tail entity context triplets , for storing neighborhood context triplets of head entities and tail entities;

[0029] In the construction of single-hop context triplets, starting from the query head entity and the query tail entity, the nodes and relations directly connected to them are extracted respectively. For the head entity node set , the predecessor nodes and relations connected to them are extracted from the knowledge graph to form triplets ; at the same time, the successor nodes and relations connected to them are extracted to generate triplets ; these triplets are added to the head entity context triplet set , and the extracted predecessor nodes and successor nodes are added to the new head entity node set ; similarly, for the tail entity node set , the predecessor nodes and successor nodes of each node and their relations are extracted to generate triplets and add them to the tail entity context triplet set , while updating the new tail entity node set ; through this process, the direct neighborhood relation expansion of the query head entity and the query tail entity is completed in the single-hop stage, forming the initial context triplet set.

[0030] In the construction process of multi-hop context triplets, based on the head entity node set and the tail entity node set generated in the single-hop stage, they are assigned to the current head entity node set and the tail entity node set , and and are set to empty sets. In the first hop, for the current head entity node set and the tail entity node set , the predecessor nodes and successor nodes and their relations are extracted to generate corresponding triplets and add them to the head entity context triplet set and the tail entity context triplet set respectively, while adding new nodes to the updated head entity node set and the tail entity node set ; through multiple recursive neighborhood relation expansions, the multi-hop context triplet set containing deep semantic information is finally constructed​ and . The final head entity context set and the tail entity's context triple set are merged into a new context triple set ; if the query triple has existed in , it is removed;

[0031] S32. Context filtering: using a pre-trained BERT model to encode each context triple in the new context triple set and the entities and relationships in the query triple , generate an embedding vector for each entity and relationship, and store it in the dictionary, which is represented by the formula as follows:

[0032] ,

[0033] ,

[0034] wherein, , , represents the embedding vector of the head entity, relationship, and tail entity in the context triple , , , represents the embedding vector of the head entity, relationship, and tail entity in the query triple , calculate the embedding vectors of the context triple and the query triple , which is represented by the formula as follows:

[0035] ,

[0036] wherein, represents the context triple embedding vector, represents the query triple embedding vector; calculate the cosine similarity of the context triple embedding vector and the query triple embedding vector , which is represented by the formula as follows:

[0037] ,

[0038] When the cosine similarity is greater than or equal to the preset threshold value 0.9, the context triple corresponding to the context triple embedding vector and the similarity score are added to the similarity context triple set ; according to the similarity score, the context triples in are sorted in descending order, and the first a set of final context triplets ;

[0039] Similarly, according to steps S31 and S32, a set of final context triplets of the negative sampling triplets generated under the head entity pattern and the tail entity pattern of step S1 is obtained.

[0040] Further, in step S4, the Gemini large language model is used to generate long descriptions of each entity in the knowledge graph based on the short descriptions of the entities .

[0041] Further, in step S5, the query triplets and their negative sampling triplets, the path set of the query triplets and their negative sampling triplets extracted in step S2, and the context triplets of the query triplets and their negative sampling triplets generated in step S3 are all converted into natural language sentences based on the short descriptions of the entities, the relationship descriptions, and the long descriptions generated in step S4; converting the query triplets, the path set of the query triplets, and the context triplets of the query triplets into natural language sentences includes four scenarios, and the specific methods are as follows:

[0042] S51. Query triplet sentence generation: the sentence starts with a [CLS] mark, followed by the short description and the long description of the head entity of the query triplet; then the relationship description of the query triplet is added; finally, the short description and the long description of the tail entity of the query triplet are added; the head entity and its short and long descriptions, the relationship and its description, and the tail entity and its short and long descriptions are separated by a [SEP] mark; similarly, the negative sampling triplets are obtained; the sentence is generated.

[0043] S52. Path sentence generation: in the head entity pattern from the query head entity to the query tail entity, the sentence starts with a [CLS] mark, followed by the short description and the long description of the head entity of the query triplet; then the first relationship in the valid path in the obtained head entity pattern and its relationship description are added; then the short description and the long description of the intermediate entity corresponding to the first relationship are added; for each subsequent relationship and entity, the above steps are repeated until the short description and the long description of the tail entity are added.; head entity and its short description and long description, first relation and relation description, first intermediate entity and its short description and long description, second relation and relation description, second intermediate entity and its short description and long description,..., nth relation and relation description, tail entity and its short description and long description, each part is separated by [SEP] mark; similarly, the path sentence in the tail entity mode from the tail entity to the head entity is obtained;

[0044] S53. Context sentence generation: the context information of the query triplets extracted in step S3 is represented in the form of triplets, which is specifically divided into the following five types, including single-hop triplets composed of the predecessor nodes of the query head entity, single-hop triplets composed of the successor nodes of the query head entity, single-hop triplets composed of the predecessor nodes of the query tail entity, single-hop triplets composed of the successor nodes of the query tail entity, and triplets not containing the query head entity and tail entity generated by multi-hop expansion; the single-hop triplets composed of the predecessor nodes of the query head entity The sentence generation format is: the sequence starts with [CLS], followed by the short description and long description of the head entity , the relation and the relation description , and the short description and long description of the tail entity , each part is separated by a [SEP] mark; similarly, the sentences of the single-hop triplets composed of the successor nodes of the query head entity, the single-hop triplets composed of the predecessor nodes of the query tail entity, and the single-hop triplets composed of the successor nodes of the query tail entity are generated; the single-hop triplets of the successor nodes of the tail entity in the query single-hop triplets and the query tail entity , the sentence generation format is: the sequence starts with [CLS], followed by the short description and long description of the head entity , the relation and the relation description , and the short description and long description of the successor entity

[0045] , each part is separated by a [SEP] mark;

[0046] S54. No context sentence generation: when the path and context of the query triplets do not exist, the sentence only contains [CLS] and [SEP] marks;

[0047] Further, in step S7, cosine similarity is used to measure the similarity between the query triple and its negative sampling triple sentence embedding vectors obtained in step S6 and the path sentence embedding vectors, which is expressed as follows:

[0048]

[0049] wherein, is the query triple and its negative sampling triple sentence embedding vector, represents the path sentence embedding vector; similarly, the similarity between the query triple and its negative sampling triple sentence embedding vector and the context sentence embedding vector is obtained; the highest similarity score is taken as the final score of the query triple , which is expressed as follows:

[0050] ,

[0051] wherein, represents the embedding vector of the sentence generated by the path or context triple of the query triple , represents the index of the path or context triple of the query triple , represents the final score of the query triple, L represents the number of all path or context triples, represents the maximum value selected from all similarity scores; similarly, the final scores of the negative sampling triples generated under the head entity mode and the tail entity mode are obtained, and the average value of the final scores of the negative sampling triples generated under the head entity mode and the tail entity mode is taken as the final result of the inductive relation prediction; the training process is optimized by the cosine embedding loss function, which is expressed as follows:

[0052]

[0053] wherein, represents the minimum interval between positive and negative samples, represents the label of the sample, wherein 1 represents a positive sample and -1 represents a negative sample.

[0054] The advantages of the present application are:

[0055] The method of the present application solves the limitations of random negative sampling by introducing semantic-aware negative sampling to generate more effective negative triples. Then, the path and multi-hop context are extracted and filtered from the query triple, and the long and short entity and relationship descriptions are combined and converted into sentences. These sentences are embedded through a sentence converter and aggregated into triple scores through cosine similarity. We innovatively sample the multi-hop context of the head entity and tail entity and filter irrelevant content based on similarity, solving the problem of path scarcity or absence. Experimental results show that the method of the present application is superior to other models on all datasets. BRIEF DESCRIPTION OF DRAWINGS

[0056] The accompanying drawings are included to provide a further understanding of the present application, and constitute a part of the specification, illustrate the present application and explain the technical solutions of the present application, and do not constitute a limitation on the present application.

[0057] Figure 1 Flow chart of the steps of the method of the present application. DETAILED DESCRIPTION

[0058] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0059] Embodiment 1

[0060] In this embodiment, as shown in the following table, the present application provides an efficient negative sampling and retrieval fusion context path inductive relation prediction method, and the specific steps include: Figure 1

[0061] S1. Semantic-aware negative sampling: negative sampling is performed through semantic awareness to generate negative sampling triples that are least similar to the query triples;

[0062] Specifically, S11. For each entity in the knowledge graph, the corresponding short description is input into the BERT model to generate entity embedding. The corresponding short description is input into the BERT model to generate entity embedding .

[0063] S12. In the head entity mode, select K negative sampling tail entities of the query tail entity from the entity set of the knowledge graph , and arrange them in ascending order according to the similarity score , and the query tail entity . ​​​The least similar entities are ranked first, from the lowest similarity tail entities The negative sampling triple set in the head entity mode is generated Similarly, the negative sampling triple set in the tail entity mode is generated in the tail entity mode The formula is as follows:

[0064] ,

[0065] ,

[0066] wherein, represents the negative sampling triple set in the head entity mode, represents the negative sampling tail entity of the negative sampling triple set in the head entity mode, represents the top k values, represents the entity set, represents the entity embedding of the query tail entity , represents the entity embedding of negative sampling tail entities, represents the number of entities, represents the negative sampling triple set in the tail entity mode, represents the negative sampling head entity of the negative sampling triple set in the tail entity mode, represents the entity embedding of the query head entity , represents the entity embedding of negative sampling head entities.

[0067] S2. Path extraction and filtering: the path information of the query triple and the negative sampling triple generated in step S1 is extracted using the breadth-first search algorithm, and the path is filtered according to the relationship confidence, to obtain the path set of the query triple and its negative sampling triple;

[0068] Specifically, the path information of the query triple and the negative sampling triple generated in step S1 is extracted using the breadth-first search algorithm, and the path is filtered according to the relationship confidence, the path extraction and filtering process of the query triple is as follows:

[0069] S21. Path extraction: in the head entity mode, the tail entity is gradually tracked from the head entity by alternately passing through the relationship and the entity, and the query triple is searched in the knowledge graph from the head entity to the tail entity​​ path ,path Represented as From the path Extracting entities from the beginning End-to-end entity Relationship path Relationship path Represented as Similarly, in the tail entity mode, the tail entity is obtained. End Entity Relationship path ;

[0070] S22. Path Filtering: Calculate the confidence score of a relational path using a relational path confidence function, specifically the relational path confidence score under the head entity schema. The formula is expressed as follows:

[0071] ,

[0072] in, Indicates a relational path The number of triplets, This indicates that there is a relational path. The number of triples in the head entity End-to-end entity Relationship path Relationship paths with a confidence level greater than or equal to a preset relationship path confidence threshold are selected from the head entity pattern to obtain valid paths in the head entity pattern; the preset relationship path confidence threshold is set to 5 × 10. -3 Similarly, the effective path in the tail entity mode is obtained.

[0073] Similarly, based on the query triples The path extraction and filtering process involves extracting and filtering the path from the negative sampled triples generated in step S1 to obtain the corresponding valid path.

[0074] S3. Context Extraction and Filtering: Using a recursive multi-hop context search algorithm, explore the context triplets of the query triplet and the negative sample triplet generated in step S1 respectively, and filter them according to cosine similarity to obtain the context triplets of the query triplet and its negative sample triplet.

[0075] Specifically, a recursive multi-hop context search algorithm is used to obtain the context triplets of the query triplet and the negative sampled triplet generated in step s1, and then filtering is performed based on cosine similarity; the context triplet search process for the query triplet is as follows:

[0076] S31. Context extraction: recursively apply the multi-hop context search algorithm to explore the query triplets The neighborhood context of the head entity and the tail entity, the specific operation steps are as follows:

[0077] According to the query triplet , initialize the head entity node set and the tail entity node set ; the head entity node set is a set containing the head entity , , the tail entity node set is a set containing the tail entity , ; at the same time, create empty head entity context triplet set and empty tail entity context triplet set for storing the neighborhood context triplets of the head entity and the tail entity;

[0078] In the construction of single-hop context triplets, starting from the query head entity and the query tail entity, the nodes and relationships directly connected to them are extracted; for the head entity node set , the predecessor nodes and relationships connected to it are extracted from the knowledge graph to form triplets ; at the same time, the successor nodes and relationships connected to it are extracted to generate triplets ; these triplets are added to the head entity context triplet set , and the extracted predecessor nodes and successor nodes are added to the new head entity node set ; similarly, for the tail entity node set , the predecessor nodes and successor nodes of each node and their relationships are extracted to generate triplets and add them to the tail entity context triplet set , while updating the new tail entity node set ; through this process, the direct neighborhood relationship expansion of the query head entity and the tail entity is completed in the single-hop stage, forming the initial context triplet set.

[0079] In the construction process of multi-hop context triplets, based on the head entity node set and the tail entity node set generated in the single-hop stage, assign them to the current head entity node set and the tail entity node set , and and is set to empty set, in the first hop, for the current head entity node set and tail entity node set , the predecessor node and successor node and relationship are extracted, the corresponding triplets are generated and added to the head entity context triplet set and tail entity context triplet set respectively, and the new node is added to the updated head entity node set and tail entity node set respectively; through multiple hop recursive expansion of neighborhood relationship, the multi-hop context triplet set containing deep semantic information is finally constructed and . The final head entity context set and tail entity context triplet set are merged into a new context triplet set ; if the query triplet already exists in , it is removed;

[0080] S32. Context filtering: using the pre-trained BERT model to encode each context triplet in the new context triplet set and the entity and relationship in the query triplet , generate the embedding vector of each entity and relationship, and store it in the dictionary, the formula is as follows:

[0081] ,

[0082] ,

[0083] wherein, , , represents the embedding vector of the head entity, relationship, tail entity in the context triplet , , , represents the embedding vector of the head entity, relationship, tail entity in the query triplet , the embedding vector of the context triplet and the query triplet is calculated, the formula is as follows:

[0084] ,

[0085] wherein, represents the context triplet embedding vector, denote query triple embedding vectors; calculate context triple embedding vectors and cosine similarity of query triple embedding vectors , which is expressed as follows:

[0086] ,

[0087] When the cosine similarity is greater than or equal to a preset threshold value 0.9, the context triple corresponding to the context triple embedding vector and the similarity score are added to the similarity context triple set ; the context triples in are sorted in descending order according to the similarity scores, and the top triples are selected as the final context triple set ;

[0088] Similarly, according to steps S31 and S32, the final context triple set of the negative sampling triple generated under the head entity pattern and the tail entity pattern in step S1 is obtained.

[0089] S4. Detailed information retrieval based on large language model: input the short description of the entity into the large language model to generate the corresponding long description of the entity to enrich the entity information;

[0090] Specifically, the short description of each entity in the knowledge graph is input into the Gemini large language model to generate a long description . .

[0091] S5. Sentence generation: combine the short description of the entity, the relationship description, the long description of the entity generated in step S4, and convert the query triple and its negative sampling triple, the path set of the query triple and its negative sampling triple extracted in step S2, and the context triple of the query triple and its negative sampling triple generated in step S3 into natural language sentences to obtain the query triple and its negative sampling triple sentence, the path sentence, and the context sentence, which are used to construct the positive sample and the negative sampling sample required for training;

[0092] Specifically, by the short description of the entity, the relationship description, and the long description generated in step S4, the query triple and its negative sampling triple, the path set of the query triple and its negative sampling triple extracted in step S2, and the context triple of the query triple and its negative sampling triple generated in step S3 are all converted into natural language sentences; converting the query triple, the path set of the query triple, and the context triple of the query triple into natural language sentences includes four scenarios, and the specific manner is as follows:

[0093] S51. Query triple sentence generation: the sentence starts with [CLS] token, followed by the short description of the query triple head entity and long description ; followed by the query triple relation description ; and finally the short description of the query triple tail entity and long description ; the head entity and its short and long descriptions, the relation and its description, and the tail entity and its short and long descriptions are separated by [SEP] tokens; similarly, the negative sampling triple is obtained; sentence generation;

[0094] For example, for the query triple , “Schleswig-Holstein” short description as “A state in northern Germany.”, long description as “Schleswig-Holstein is the northernmost state of Germany, bordered by Denmark to the north and known for its coastline and cultural heritage.”; “capital of” description as “Indicates the capital city of a state.”; tail entity “Kiel” short description as “The capital of Schleswig-Holstein.”, long description as “Kiel is a port city in northern Germany, known for its maritime culture, universities, and sailing events.”, the generated sentence is “[CLS] Schleswig-Holstein: A state in northern Germany. Schleswig-Holstein is the northernmost state of Germany, known for its coastline and culture. [SEP] Capital of: Indicates the capital city of a state. [SEP] Kiel: The capital of Schleswig-Holstein. Kiel is a port city in northern Germany, known for its maritime culture, universities, and sailing events.”

[0095] S52. Path sentence generation: In the head entity pattern from the query head entity to the query tail entity, the sentence starts with the [CLS] tag, followed by the short description of the query triple head entity and the long description ; then the first relationship in the valid path in the derived head entity pattern and its relationship description ; followed by the short description and long description of the intermediate entity corresponding to the first relationship , for each subsequent relation and entity, until the short description of the tail entity is reached and the long description ; the head entity and its short and long descriptions, the first relation and the relation description, the first intermediate entity and its short and long descriptions, the second relation and the relation description, the second intermediate entity and its short and long descriptions,..., the n-th relation and the relation description, the tail entity and its short and long descriptions, separated by the [SEP] token between each part; similarly, the path sentence in the tail-to-head entity mode is obtained from the tail entity to the head entity;

[0096] For example, for the query triple . The short description for the head entity "Schleswig-Holstein" is "A state in northern Germany." The long description is "Schleswig-Holstein is the northernmost state of Germany, bordered by Denmark to the north and known for its coastline and cultural heritage." The description for the first relation "is_part_of" is "Indicates that an entity is part of another entity." The short description for the middle entity "Germany" is "A country in central Europe." The long description is "Germany is a federal republic in central Europe, known for its rich history and economic influence." The description for the second relation "has_capital" is "Indicates the capital city of a state." The short description for the tail entity "Kiel" is "The capital of Schleswig-Holstein." The long description is "Kiel is a port city in northern Germany, known for its maritime culture, universities, and sailing events." The generated path sentence is "[CLS] Schleswig-Holstein: A federal state in northern Germany. Schleswig-Holstein is the northernmost state of Germany, bordered by Denmark to the north and known for its coastline and cultural heritage. [SEP] is_part_of: Indicates that an entity is part of another entity. [SEP] Germany: A country in central Europe."Germany is a federal republic in central Europe, known for its rich history and economic influence. [SEP] has_capital: Indicates the capital city of a state. [SEP] Kiel: The capital of Schleswig-Holstein. Kiel is a port city in northern Germany, known for its maritime culture, universities, and sailing events.” This generation approach ensures the semantic integrity and fluent expression of entities and relationships in the path.

[0097] S53. Context sentence generation: The context information of the query triplets extracted in step S3 is represented in the form of triplets, which are divided into the following five types, including single-hop triplets composed of the predecessor nodes of the query head entity, single-hop triplets composed of the successor nodes of the query head entity, single-hop triplets composed of the predecessor nodes of the query tail entity, single-hop triplets composed of the successor nodes of the query tail entity, and triplets not containing the query head entity and tail entity generated by multi-hop expansion; These context triplets comprehensively supplement the semantic and neighborhood relationship information of the query triplets, providing a foundation for context sentence generation.

[0098] Single-hop triplets composed of the predecessor nodes of the query head entity The sentence generation format is: the sequence starts with [CLS], followed by the short description of the head entity and long description , relationship and relationship description , and short description and long description of the tail entity, each part is separated by [SEP] mark; the single-hop triplets of the successor nodes of the tail entity in the query single-hop triplets , that is, the multi-hop triplets unrelated to the query head entity and the query tail entity , the sentence generation format is: the sequence starts with [CLS], followed by the short description of the head entity and long description , relationship and relationship description , and short description and long description , each part is separated by a [SEP] token;

[0099] More specifically, for the query triple For the head entity successor one-hop triple : where the head entity is “Schleswig-Holstein”, the short description is “A state in northern Germany”, the long description is “Schleswig-Holstein is the northernmost state of Germany, bordered by Denmark to the north and known for its coastline and cultural heritage.”; the relation is “is_part_of”, the description is Indicates that an entity is part of another entity; the tail entity is “Germany”, the short description is “A country in central Europe”, the long description is “Germany is a federal republic in central Europe, known for its rich history and economic influence”. The sentence can be generated: Schleswig-Holstein, A state in northern Germany, chleswig-Holstein is thenorthernmost state of Germany, bordered by Denmark to the north and known forits coastline and cultural heritage, is_part_of, Indicates that an entity ispart of another entity, Germany, A country in central Europe, Germany is afederal republic in central Europe, known for its rich history and economicinfluence.

[0100] S54. Context-free sentence generation: When the path and context of the query triple do not exist, the sentence only contains [CLS] and [SEP] tokens;

[0101] S6. Embedding generation: input the natural language sentence generated in step S5 into the Sentence Transformer model to generate query triplets and their negative sampling triplet sentence embedding vectors, path sentence embedding vectors and context sentence embedding vectors;

[0102] S7. Generate prediction results and training: obtain the final result of the induction relationship prediction by calculating the cosine similarity score between the path sentence embedding vectors and the context sentence embedding vectors generated in step S6 and the query triplets and their negative sampling triplet sentence embedding vectors; optimize the model using the loss function.

[0103] Specifically, the cosine similarity is used to measure the similarity between the query triplets and their negative sampling triplet sentence embedding vectors and the path sentence embedding vectors obtained in step S6, which is expressed as follows:

[0104]

[0105] wherein, is the query triplets and their negative sampling triplet sentence embedding vectors, represents the path sentence embedding vectors; similarly, the similarity between the query triplets and their negative sampling triplet sentence embedding vectors and the context sentence embedding vectors is obtained; the highest similarity score is taken as the final score of the query triplets , which is expressed as follows:

[0106] ,

[0107] wherein, represents the embedding vector of the sentence generated with the path or context triplets of the query triplets , represents the index of the path or context triplets of the query triplets , represents the final score of the query triplets, L represents the number of all path or context triplets, represents the maximum value selected from all similarity scores; similarly, the final scores of the negative sampling triplets generated under the head entity mode and the tail entity mode are obtained, and the average value of the final scores of the negative sampling triplets generated under the head entity mode and the tail entity mode is taken as the final result of the induction relationship prediction; the training process is optimized by the cosine embedding loss function, which is expressed as follows:

[0108]

[0109] wherein, represents the minimum interval between positive and negative samples, Label representing the sample, where 1 represents a positive sample and -1 represents a negative sample.

[0110] Example 2

[0111] We used the datasets provided by Grail and the processed version by BERTRL to evaluate the performance of our proposed model in direct prediction and inductive prediction. Each dataset in Grail (WN18RR, FB15k-237, NELL-995) is divided into four inductive subsets (vi, v2, v3, v4). BERTRL adjusted these subsets, renaming WN18RRvi, FB15k-237vi, and NELL-995v2 as WN18RR_full, FB15k-237_full, and NELL-995_full, respectively. The statistics of the datasets are shown in Table 1. The #entity, #relation, and #triple represent the number of entities, relations, and triples, respectively.

[0112] Table 1 Statistics of the three datasets and their variants

[0113]

[0114] To ensure consistency with previous methods, this study adopted the same evaluation metrics as BERTRL: Mean Inverse Rank (MRR) and Hit@1. These metrics are evaluated between each test triple and 50 negative candidate entities. MRR represents the average of the average inverse rank of positive triples, and Hit@1 represents the proportion of positive triples ranked first among candidate entities. It is worth noting that higher MRR and Hit@1 values indicate better performance of the model in the link prediction task.

[0115] Our model is based on the sentence transformer in PyTorch, with the default model being sentence-transformers / all-mpnet-base-v2 from the Hugging Face repository. Training is performed on a single 24GB NVIDIA GeForce RTX 3090 GPU, and the random seed is set to 42 to ensure the reproducibility of the results. During the training and validation phases, each positive triple is paired with 5 negative samples; during the testing phase, each positive triple is paired with 50 negative samples. We set the number of paths loaded for each triple to 3, the search depth to 5, and the support threshold to 5x10-3. In addition, the number of contexts loaded for each triple is set to 3.

[0116] We compare our model with the following baseline models: MINERVA model, RuleN model, GraIL model, KG-BERT model, BERTRL model, KRST model and APST model. Specifically, MINERVA utilizes reinforcement learning for path reasoning; RuleN is a rule-based and embedding-fine-grained evaluation method; GraIL reasons over local subgraph structures via graph neural networks; KG-BERT is the first model that leverages pre-trained language models to predict missing triples; BERTRL incorporates reasoning paths and triples as inputs into pre-trained language models; KRST adopts a sentence transformer for interpretable inductive relation prediction; and APST further improves performance by reducing the dependence on closed paths through anchoring paths based on KRST.

[0117] We compare the MRR and Hit@1 results of the randomly sampled CPNR_R and the CPNR_S model of the present application with the baseline models on the WN18RR_full, FB15K-237_full and NELL-995_full datasets under the direct inference (see Table 2) and the inductive inference (see Table 3) settings. The specific performance is as follows:

[0118] (1) CPNR_S performs well on all datasets, while CPNR_R leads in 2 / 3 of the datasets. Compared with APST, under the direct inference setting, the MRR and Hit@1 of CPNR_S on WN18RR_full are improved by 9.31% and 16.21% respectively, on FB15K-237_full are improved by 28.68% and 43.08% respectively, and on NELL-995_full are improved by 18.60% and 31.95% respectively. Under the inductive inference setting, CPNR_S on WN18RR_full are improved by 7.16% and 18.40% respectively, on FB15K-237_full are improved by 30.10% and 54.43% respectively, and on NELL-995_full are improved by 20.29% and 34.09% respectively. In contrast, the MRR and Hit@1 of CPNR_R on WN18RR_full are improved by 0.55% and 0.60% respectively, and the MRR on NELL-995_full is improved by 0.25%. Under the inductive inference setting, CPNR_R on WN18RR_full are improved by 1.32% and 2.63% respectively, and on NELL-995_full are improved by 2.73% and 2.71% respectively.

[0119] (2) APST performs poorly on the FB15K-237_full dataset in the migration and induction settings, highlighting the advantage of the anchor path strategy in capturing the complex relationships in FB15K-237 and significantly improving the prediction accuracy. Although CPNR_R is slightly inferior to APST on some datasets, it has a clear advantage over KRST. For example, in the FB15K-237 dataset in the direct push setting, the MRR of CPNR_R is 6.67% higher than that of KRST, and the Hit@1 is 5.95% higher. In the induction setting, the MRR of CPNR_R is 3.91% higher than that of KRST, and the Hit@1 is 2.83% higher.

[0120] (3) The semantic negative sampling method enhances model training by generating more challenging negative samples, and has a significant advantage over random sampling. Semantic negative sampling significantly improves the MRR and Hit@1 of CPNR_S compared to CPNR_R. In the direct push setting, WN18RR_full improves by 8.71% and 15.52%, respectively, FB15K-237_full improves by 29.69% and 46.68%, respectively, and NELL-995_full improves by 18.31% and 31.95%, respectively. In the induction setting, WN18RR_full improves by 5.76% and 15.37%, respectively, FB15K-237_full improves by 33.60% and 60.94%, respectively, and NELL-995_full improves by 17.09% and 30.54%, respectively. These results highlight the significant advantage of semantic negative sampling in improving model performance.

[0121] The link prediction results of the method (CPNR_S) of the present application and the prior art on the WN18RR_full, FB15k-237_full and NELL-995_full direct push datasets are shown in Table 2. Among them, the highest score is marked in bold, and the second highest score is marked in underlined form.

[0122] Table 2 Link prediction results on direct push datasets

[0123]

[0124] The link prediction results of the method (CPNR_S) of the present application and the prior art on the WN18RR_full, FB15k-237_full and NELL-995_full induction datasets are shown in Table 3. Among them, the highest score is marked in bold, and the second highest score is marked in underlined form.

[0125] Table 3 Link prediction results on inductive datasets

[0126]

[0127] We present the MRR and Hit@1 ablation study results of the proposed CPNR_R and CPNR_S models on the WN18RR_full, FB15k-237_full, and NELL-995_full datasets in the inductive setting. This study aims to explore the specific impact of different components of CPNR_R and CPNR_S by isolating them. These components include: 1) detailed description retrieval of large language models (LLMs) (w / o retrieval); 2) path extraction and filtering (w / o path); 3) context sampling and filtering (w / o context). As shown in Tables 4 and 5, CPNR_R and CPNR_S outperform their variants in most MRR and Hit@1 performances, with the following specific performances:

[0128] (1) Overall, CPNR_R outperforms other variants in 1 / 3 cases, while CPNR_S performs well in 4 / 4 cases, demonstrating its significant superiority and robustness in the inductive setting. It is worth noting that on some datasets, removing the retrieval module and the context module improves model performance, while removing the path module always leads to performance degradation, further verifying the critical role of paths in model performance.

[0129] (2) w / o retrieval: This module enriches contextual information, enhances semantic representation, reduces ambiguity, and supports complex relationship reasoning by supplementing short descriptions with detailed long descriptions in KGs. Removing the retrieval module slightly reduces the average performance of CPNR_S, further verifying the effectiveness of this module. However, CPNR_R performs best in the inductive setting of WN18RR_full after removing this module. This may be because the WN18RR dataset has a simple structure and clear relationships, and the introduction of long descriptions may introduce noise, thereby reducing model performance. In addition, the performance of CPNR_S significantly decreases after removing this module, further confirming the importance of the retrieval module.

[0130] (3) w / o path: The path module enriches semantic information, enhances the reasoning ability of the model, and significantly improves prediction accuracy by showing how two entities are connected through multiple intermediate relationships and entities. Removing the path module significantly reduces the performance of CPNR_R and CPNR_S, further verifying the core role of paths in the model.

[0131] (4) w / o context: The context module focuses on the local association of the query entity and its neighborhood, which helps to capture the core features and reduce noise. After removing the context module, CPNR_R achieves the highest MRR and Hit@1 in the FB15K-237_full induction setting, indicating that inappropriate context may weaken the performance. At the same time, the performance of CPNR_S decreases significantly, further proving the importance of context information to the model performance.

[0132] Table 4 Ablation experiment results of CPNR_R model.

[0133]

[0134] Table 5 Ablation experiment results of CPNR_R model.

[0135]

[0136] Finally, it should be noted that: the above only for the preferred embodiments of the present application, and not for limiting the present application, although the foregoing embodiments of the present application are described in detail, for those skilled in the art, it still can be modified, or part of the technical features of the equivalent replacement of the technical solutions recorded in the foregoing embodiments. Any modification, equivalent replacement, improvement, etc. within the spirit and principles of the present application shall be included within the scope of protection of the present application.

Claims

1. An inductive relation prediction method of high-efficiency negative sampling and retrieval fusion context path, characterized in that, The method comprises the following steps: S1. Semantic-aware negative sampling: negative sampling is performed through semantic awareness to generate negative sampling triples that are least similar to the query triples; S2. Path extraction and filtering: the path information of the query triples and the negative sampling triples generated in step S1 is extracted using a breadth-first search algorithm, and the paths are screened according to the relationship confidence to obtain the path set of the query triples and the negative sampling triples thereof; S3. Context extraction and filtering: the context triples of the query triples and the negative sampling triples generated in step S1 are explored respectively through a recursive multi-hop context search algorithm, and are filtered according to the cosine similarity to obtain the context triples of the query triples and the negative sampling triples thereof; S4. Detailed information retrieval based on a large language model: the short description of an entity is input into a large language model to generate a corresponding long description of the entity; S5. Sentence generation: the query triples and the negative sampling triples, the path set of the query triples and the negative sampling triples extracted in step S2, and the context triples of the query triples and the negative sampling triples generated in step S3 are all converted into natural language sentences by combining the short description of the entity, the relationship description, and the long description of the entity generated in step S4 to obtain the query triple and negative sampling triple sentence, the path sentence, and the context sentence; S6. Embedding generation: the natural language sentences generated in step S5 are input into a Sentence Transformer model to generate query triple and negative sampling triple sentence embedding vectors, path sentence embedding vectors, and context sentence embedding vectors; S7. Generation of prediction results and training: the cosine similarity scores between the path sentence embedding vectors and the context sentence embedding vectors generated in step S6 and the query triple and negative sampling triple sentence embedding vectors are calculated to obtain the final result of the inductive relationship prediction; and the model is optimized using a loss function.

2. The method of claim 1, wherein, Step S1 specifically comprises: S11. For each entity in the knowledge graph Corresponding short description Input BERT model to generate entity embeddings ; S12. In the head entity mode, selecting query tail entities from the entity set of the knowledge graph S12. In the head entity mode, selecting query tail entities from the entity set of the knowledge graph S12. In the head entity mode, selecting query tail entities from the entity set of the knowledge graph S12. In the head entity mode, selecting query tail entities from the entity set of the knowledge graph S12. In the head entity mode, selecting query tail entities from the entity set of the knowledge graph , , wherein, denotes a set of negative sampling triplets in the head entity mode, denotes a negative sampling tail entity of the set of negative sampling triplets in the head entity mode, denotes taking the top k values, denotes a set of entities, denotes an entity embedding of the query tail entity denotes an entity embedding of negative sampling tail entities denotes the number of entities, denotes a set of negative sampling triplets in the tail entity mode, denotes a negative sampling head entity of the set of negative sampling triplets in the tail entity mode, denotes an entity embedding of the query head entity denotes an entity embedding of negative sampling head entities .​​​ 3. The method of claim 2, wherein, Step S2 specifically comprises: The path information of the query triple and the negative sampling triple generated in step S1 is extracted using a breadth-first search algorithm, and the path is filtered according to the relationship confidence, the query triple The path extraction and filtering process of the query triple is as follows: S21. Path Extraction: In the head entity schema, path extraction is performed by alternating between relations and entities from the head entity. Tracking down to the tail entity step by step The query triple is found in the knowledge graph using a breadth-first search algorithm. From the beginning entity End-to-end entity path ,path Represented as From the path Extracting entities from the beginning End-to-end entity Relationship path Relationship path Represented as Similarly, in the tail entity mode, the tail entity is obtained. End Entity Relationship path ; S22. Path filtering: calculate the confidence of the relation path by using the relation path confidence function, the relation path confidence in the head entity pattern The formula is expressed as follows: , wherein, denotes the number of triples with relation path , denotes the number of triples with relation path , filtered out from the relation path from the head entity to the tail entity with the relation path confidence greater than or equal to a preset relation path confidence threshold in the head entity pattern, to obtain an effective path in the head entity pattern; the preset relation path confidence threshold is set to 5 x 10 -3 ; similarly, an effective path in the tail entity pattern is obtained; Similarly, according to the path extraction and filtering process of the query triple , the negative sampling triple generated in step S1 is subjected to path extraction and filtering to obtain the corresponding valid path.

4. The method of claim 3, wherein, Step S3 specifically comprises: The context triples of the query triples and the negative sampling triples generated in step S1 are obtained through a recursive multi-hop context search algorithm, and are filtered according to the cosine similarity; the context triple search process of the query triples is as follows: S31. Context extraction: recursively apply the multi-hop context search algorithm to explore the query triplets The neighborhood context of the middle and tail entities, and the specific operation steps are as follows: According to the query triple , initialize the head entity node set and the tail entity node set ; the head entity node set is a set containing the head entity , , the tail entity node set is a set containing the tail entity , ; at the same time, create empty head entity context triple sets and empty tail entity context triple sets for storing neighborhood context triples of the head entity and the tail entity; In the single-hop context triple construction, starting from the query head entity and the query tail entity, the nodes and relations directly connected with them are extracted respectively; for the head entity node set , the predecessor nodes and relations connected with them are extracted from the knowledge graph to form triples ; at the same time, the successor nodes and relations connected with them are extracted to generate triples ; these triples are added to the head entity context triple set , and the extracted predecessor nodes and successor nodes are added to the new head entity node set ; similarly, for the tail entity node set , the predecessor nodes and successor nodes of each node and their relations are extracted to generate triples and add them to the tail entity context triple set , and the new tail entity node set is updated; through this process, the single-hop stage completes the direct neighborhood relation expansion of the query head entity and the tail entity, forming the initial context triple set; In the construction of multi-hop context triples, the head entity node set generated in the single-hop phase is used as a basis. Set of tail entity nodes Assign it to the current head entity node set. Set of tail entity nodes and will and Set as an empty set, in the first... In each jump, for the current head entity node set Set of tail entity nodes Extract the predecessor and successor nodes and their relationships, generate the corresponding triples, and add them to the head entity context triple set. Set of entity context triples In the process, the new node is simultaneously added to the updated head entity node set. Set of tail entity nodes By recursively expanding neighborhood relationships through multiple jumps, a set of multi-hop context triples containing deep semantic information is ultimately constructed. and ; The final head entity context set The set of context triples for tail entities Merge into a new set of context triples If querying triples Already exists If so, then remove it; S32. Context Filtering: Using a pre-trained BERT model to filter new sets of context triples. Each context triple in and query triples The entities and relations in the dictionary are encoded to generate an embedding vector for each entity and relation, which is then stored in a dictionary, as shown in the following formula: , , wherein , , denote embedding vectors of the head entity, the relation, and the tail entity in the context triple , , , denote embedding vectors of the head entity, the relation, and the tail entity in the query triple , the embedding vectors of the context triple and the query triple are calculated as follows: , wherein, denotes a context triple embedding vector, denotes a query triple embedding vector; the context triple embedding vector and the query triple embedding vector are computed as cosine similarity, which is formulated as follows: , When the cosine similarity is greater than or equal to a preset threshold 0.9, the context triple corresponding to the context triple vector pair and the similarity score are added to the similarity context triple set ; the context triples in the similarity score are sorted in descending order, and the first context triples are selected as the final context triple set ;​ Similarly, according to steps S31 and S32, the final context triple set of the negative sampling triples generated under the head entity mode and the tail entity mode is obtained.

5. The method of claim 4, wherein, In step S4, the short description of each entity in the knowledge graph is generated by the Gemini large language model to generate a long description .

6. The method of claim 5, wherein, Step S5 specifically comprises: The query triples and the negative sampling triples, the path set of the query triples and the negative sampling triples extracted in step S2, and the context triples of the query triples and the negative sampling triples generated in step S3 are all converted into natural language sentences by combining the short description of the entity, the relationship description, and the long description generated in step S4; the conversion of the query triples, the path set of the query triples, and the context triples of the query triples into natural language sentences includes four scenarios, and the specific manner is as follows: S51. Query triple sentence generation: the sentence starts with [CLS] token, followed by the short description of the head entity of the query triple and the long description ; then the relation description of the query triple ; finally the short description of the tail entity of the query triple and the long description ; the head entity and its short and long descriptions, the relation and its description, the tail entity and its short and long descriptions, the three parts are separated by [SEP] token; similarly, the negative sampling triple is obtained; sentence generation; S52. Path sentence generation: in the head entity pattern from the query head entity to the query tail entity, the sentence starts with a [CLS] token, followed by a short description of the query triple head entity and a long description ; then the first relation in the valid path in the obtained head entity pattern and its relation description ; followed by a short description of the intermediate entity corresponding to the first relation and a long description , repeat for each subsequent relation and entity, until the short description of the tail entity and a long description ; the head entity and its short and long descriptions, the first relation and its relation description, the first intermediate entity and its short and long descriptions, the second relation and its relation description, the second intermediate entity and its short and long descriptions,..., the nth relation and its relation description, the tail entity and its short and long descriptions, separated by [SEP] tokens; similarly, the path sentence in the tail entity pattern from the tail entity to the head entity is obtained; S53. Context sentence generation: the context information of the query triplets extracted in step S3 is represented in the form of triplets, which is specifically divided into the following five types, including single-hop triplets composed of the predecessor nodes of the query head entity, single-hop triplets composed of the successor nodes of the query head entity, single-hop triplets composed of the predecessor nodes of the query tail entity, single-hop triplets composed of the successor nodes of the query tail entity, and multi-hop triplets not containing the query head entity and tail entity triplets generated by multi-hop expansion; the single-hop triplets composed of the predecessor nodes of the query head entity The sentence generation format is: the sequence starts with [CLS], followed by the short description and long description of the head entity, the relationship and the relationship description , and the short description and long description of the tail entity, and each part is separated by a [SEP] marker; similarly, the single-hop triplets composed of the successor nodes of the query head entity, the single-hop triplets composed of the predecessor nodes of the query tail entity, and the single-hop triplets composed of the successor nodes of the query tail entity are obtained. Sentence generation; the single-hop triplets of the successor nodes of the tail entity in the query single-hop triplets , i.e. multi-hop triplets unrelated to the query head entity and the query tail entity , the sentence generation format is: the sequence starts with [CLS], followed by the short description and long description of the head entity, the relationship and the relationship description , and the short description and long description of the successor entity, and each part is separated by a [SEP] marker; Similarly, the context sentences of the negative sampling triples generated under the head entity mode and the tail entity mode are obtained; S54. No context sentence generation: When the path and context of the query triple do not exist, the sentence only contains [CLS] and [SEP] marks.

7. The method of claim 6, wherein, Step S7 specifically comprises: Cosine similarity is used to measure the similarity between the sentence embedding vectors of the query triple and its negative sampling triple obtained in step S6 and the path sentence embedding vector, which is expressed in the formula as follows: wherein, is the embedding vector of the query triple and its negative sampling triple sentence, represents the path sentence embedding vector; similarly, the similarity between the query triple and its negative sampling triple sentence embedding vector and the context sentence embedding vector is obtained; the highest score in the similarity score is taken as the final score of the query triple , which is expressed as follows: , wherein, denotes the embedding vector of the sentence generated by the path or context triple of the query triple , denotes the index of the path or context triple of the query triple , denotes the final score of the query triple, L denotes the number of all path or context triples, denotes selecting the maximum value from all similarity scores; similarly, the final scores of the negative sampling triples generated under the head entity pattern and the tail entity pattern are obtained, and the average value of the final scores of the negative sampling triples generated under the head entity pattern and the tail entity pattern is taken as the final result of the inductive relation prediction; the training process is optimized by the cosine embedding loss function , and the formula is as follows: wherein, represents the minimum interval between positive and negative samples, represents the label of the sample, wherein 1 represents a positive sample and -1 represents a negative sample.

Citation Information

Patent Citations

  • Zero sample knowledge graph completion method based on pre-training language model

    CN117273134A

  • Method, System, and Computer Program Product for Knowledge Graph Based Embedding, Explainability, and / or Multi-Task Learning

    US20220114456A1