A knowledge graph retrieval method, device, medium, and product

CN118227668BActive Publication Date: 2026-08-14BEIJING UNIV OF POSTS & TELECOMM +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-02
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0006]本发明的目的是提供一种知识图谱检索方法、装置、介质及产品,实现了面向复杂查询条件的知识图谱检索,解决了现有的子图检索算法未充分利用关系语义信息,路径匹配方式不合理以及答案推理算法的关系语义存在滞后性,不具备逻辑匹配等问题

Benefits of technology

[0045] This invention discloses a knowledge graph retrieval method, apparatus, medium, and product. First, it obtains the question vector representation of the user's question text and the vector representations of multiple keywords. Based on the vector representations of each keyword, nodes related to each keyword are identified as key nodes in the knowledge graph, and all relations corresponding to each key node are identified as candidate relations. The matching score between each candidate relation and the question vector representation is calculated. The matching scores are sorted in descending order, and a subgraph is constructed based on the candidate relations and corresponding nodes of the first preset number of matching scores. Second, multiple inference instructions are generated based on the question text, and these inference instructions are used step-by-step... The process involves determining the relational reasoning score for each relation in the subgraph; based on the relational reasoning scores of all relations corresponding to each node in the subgraph, determining the node reasoning score for the corresponding node; when the maximum node reasoning score of a node meets a preset confidence threshold, the entity corresponding to the node with the maximum node reasoning score is determined as the answer to the question text; finally, when the maximum node reasoning score of a node does not meet the preset confidence threshold, the node reasoning scores are sorted in descending order, and the nodes with the first two preset number of node reasoning scores are determined as candidate nodes; a question response model is constructed based on a large language model and each candidate node and its corresponding relation to achieve the response to the question text. Addressing the problems of existing subgraph retrieval algorithms not fully utilizing relational semantics and unreasonable matching methods, this invention fuses relations with their head and tail node ontologies to obtain the hidden semantics of the relations; it provides a more reasonable path matching method; addressing the problem of the lag in relational semantics during the reasoning process in graph reasoning algorithms, and the problem that existing reasoning algorithms do not support logical matching, this invention proposes a logic-enhanced relational dynamic update reasoning algorithm, which dynamically updates relational semantics in each round of reasoning and utilizes a large language model to provide logical matching capabilities for the reasoning process. By introducing this method, we can obtain more accurate answers to complex queries, improve retrieval quality, and better serve the military field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118227668B_ABST
    Figure CN118227668B_ABST
Patent Text Reader

Abstract

This invention discloses a knowledge graph retrieval method, apparatus, medium, and product, relating to the field of knowledge graph retrieval technology. The method includes: obtaining vector representations of question text and multiple keywords; determining key nodes and corresponding candidate relations in a knowledge graph; calculating matching scores between each candidate relation and the question vector representation; constructing a subgraph based on the matching scores; generating multiple inference instructions; using each inference instruction to progressively determine the relation inference scores of each relation in the subgraph; determining the node inference scores of corresponding nodes based on all relation inference scores; when the maximum value of a node inference score meets a preset confidence threshold, determining the entity corresponding to the node with the maximum node inference score as the answer; otherwise, sorting the node inference scores from largest to smallest, and selecting the top two preset number of nodes as candidate nodes; constructing a question response model based on a large language model and each candidate node and its corresponding relation, thus realizing knowledge graph retrieval for complex query conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of knowledge graph retrieval technology, and in particular to a graph retrieval method, apparatus, medium and product. Background Technology

[0002] Currently, the relationships and configuration information of weapons and equipment are often presented in the form of knowledge graphs. This representation method helps to reveal and understand the intricate relationships between entities. However, how to accurately identify complex query logic from user queries and effectively retrieve the required information from the knowledge graph to support accurate and reliable decision-making processes remains a pressing problem that needs to be solved.

[0003] Knowledge graph retrieval techniques for complex queries, especially in military simulation systems, have become a research hotspot. Complex queries typically involve multi-hop paths across multiple hierarchical relationships within a knowledge graph, requiring exploration and discovery of target nodes starting from a core entity and traversing multi-hop links. Current techniques mainly fall into two categories: semantic matching-based methods and information retrieval-based methods. The former obtains answers by translating the question into a specific query language such as SPARQL, but this method often requires domain experts to spend considerable time and effort on annotation.

[0004] Existing subgraph retrieval algorithms include personalized PageRank (PPR) and semantic matching-based methods. PPR algorithms can assess the importance of web pages based on their link structure, but they suffer from performance bottlenecks when handling large-scale data, graphs with high sparsity, or low connectivity. To address these issues, researchers have proposed algorithms that combine user history and preferences to achieve personalized result ranking. However, these methods have not adequately considered the deep semantics of relationships and the semantics of questions, resulting in limited quality of retrieved subgraphs. Furthermore, current methods typically only match questions with individual relationships, ignoring complex path semantics.

[0005] In answer reasoning, the final answer needs to be inferred and generated step by step in the subgraph based on complex conditional semantics. Existing reasoning methods all ignore the updating of the relationship chain between the answer and the question, resulting in a lag in relational semantics and making it difficult to fully and accurately reflect the matching information between the question and the answer. At the same time, current graph reasoning algorithms select answers through semantic matching and lack logical matching capabilities. Summary of the Invention

[0006] The purpose of this invention is to provide a knowledge graph retrieval method, device, medium, and product that enables knowledge graph retrieval for complex query conditions. It solves the problems of existing subgraph retrieval algorithms not fully utilizing relational semantic information, unreasonable path matching methods, and the lag in relational semantics and lack of logical matching in answer reasoning algorithms.

[0007] To achieve the above objectives, the present invention provides the following solution:

[0008] A knowledge graph retrieval method, comprising:

[0009] Obtain the question vector representation of the user's question text and the vector representation of multiple keywords;

[0010] Based on the vector representation of each keyword, in the knowledge graph, nodes related to each keyword are identified as key nodes, and all relations corresponding to each key node are identified as candidate relations; one node corresponds to one entity.

[0011] Calculate the matching score between each candidate relation and the question vector representation;

[0012] Sort the matching scores in descending order, and construct a subgraph based on the candidate relationships and corresponding nodes of the first preset number of matching scores;

[0013] Multiple reasoning instructions are generated based on the question text, and the relationship reasoning scores of each relationship in the subgraph are determined step by step using each reasoning instruction.

[0014] Based on the relation reasoning scores of all relations corresponding to each node in the subgraph, the node reasoning score of the corresponding node is determined.

[0015] When the maximum node reasoning score of the node meets the preset confidence threshold, the entity corresponding to the node to which the maximum node reasoning score belongs is determined as the answer to the question text;

[0016] When the maximum value of the node inference score does not meet the preset confidence threshold, the node inference scores are sorted in descending order, and the nodes to which the first second preset number of node inference scores belong are determined as candidate nodes.

[0017] A question response model is constructed based on the large language model, the candidate nodes, and their corresponding relationships to achieve a response to the question text.

[0018] Optionally, a matching score is calculated between each of the candidate relations and the question vector representation, including:

[0019] Any candidate relation is determined as the current candidate relation, the key node corresponding to the current candidate relation is determined as the current head node, and any tail node corresponding to the current candidate relation is determined as the current tail node.

[0020] The ontology of the current head node, the current candidate relationship, and the ontology of the current tail node are concatenated sequentially to obtain the current concatenated text;

[0021] The currently concatenated text is input into the language model to obtain the hidden semantics of the current candidate relation;

[0022] Obtain the explicit description text of the current candidate relationship;

[0023] Based on the explicit description text and hidden semantics of the current candidate relation, determine the mixed semantics of the current candidate relation;

[0024] Update the current head node to any tail node, update the current candidate relationship to any relationship with the updated head node as the head node, update the current tail node to any tail node of the updated current candidate relationship, and return "concatenate the ontology of the current head node, the current candidate relationship and the ontology of the current tail node in sequence to obtain the current concatenated text", until the mixed semantics of the updated current candidate relationship is obtained;

[0025] The current candidate relation and the updated current candidate relation are determined as the current path, and the mixed semantics of the current path are determined based on the mixed semantics of the current candidate relation and the updated current candidate relation;

[0026] The mixed semantics of the current path are reduced in dimensionality to obtain the semantic representation of the path after dimensionality reduction;

[0027] Based on the dimensionality-reduced semantic representation of each candidate relation in the semantic representation of the path, the matching score between the candidate relation and the problem vector representation is obtained.

[0028] Optionally, the relational reasoning score of each relation in the subgraph is determined step by step using the various reasoning instructions, including:

[0029] Define any relation in the subgraph as the initial current relation;

[0030] The inference instructions are numbered sequentially, and the initial current relationship is updated in multiple rounds according to the order of the numbers to obtain the relationship inference score of the current relationship.

[0031] Optionally, the inference instructions are numbered sequentially, and the initial current relation is updated multiple times in the order of the numbers to obtain the relation inference score of the current relation, including:

[0032] The initial semantic representation of the current relation in the current round is obtained by semantic fusion based on the final semantic representation of the current relation in the previous round, the head node of the current relation in the previous round, and the tail node of the current relation in the previous round. Wherein, when the previous round is the initial round, the final semantic representation of the current relation in the previous round is obtained by semantic fusion based on the semantic representation of the current relation in the previous round, the head node of the current relation in the previous round, and the tail node of the current relation in the previous round.

[0033] Semantic fusion and dimensionality reduction are performed on the initial semantic representation of the current relation in the current round and the reasoning instructions in the current round to obtain the final semantic representation of the current relation in the current round;

[0034] The reasoning score of the current relation in the current round is determined based on the final semantic representation of the current relation in the current round and the reasoning instruction in the current round.

[0035] Determine if the current round has reached the maximum number of inference instructions;

[0036] If so, then the reasoning score of the current relation in the current round is determined as the relation reasoning score of the current relation;

[0037] If not, proceed to the next round of updates until the current round reaches the maximum number of the reasoning instruction, and then determine the reasoning score of the current relation in the current round as the relation reasoning score of the current relation.

[0038] Optionally, a question-response model is constructed based on the large language model and each candidate node and its corresponding relationship to implement the response to the question text, including:

[0039] Construct a Prompt based on each candidate node and its corresponding relationship;

[0040] The prompt is input into the large language model to obtain a response to the question text.

[0041] A computer device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the knowledge graph retrieval method described in any of the preceding claims.

[0042] A computer-readable storage medium having a computer program stored thereon, characterized in that, when executed by a processor, the computer program implements the steps of the knowledge graph retrieval method described in any of the preceding claims.

[0043] A computer program product includes a computer program, characterized in that, when executed by a processor, the computer program implements the steps of the knowledge graph retrieval method described in any of the preceding claims.

[0044] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0045] This invention discloses a knowledge graph retrieval method, apparatus, medium, and product. First, it obtains the question vector representation of the user's question text and the vector representations of multiple keywords. Based on the vector representations of each keyword, nodes related to each keyword are identified as key nodes in the knowledge graph, and all relations corresponding to each key node are identified as candidate relations. The matching score between each candidate relation and the question vector representation is calculated. The matching scores are sorted in descending order, and a subgraph is constructed based on the candidate relations and corresponding nodes of the first preset number of matching scores. Second, multiple inference instructions are generated based on the question text, and these inference instructions are used step-by-step... The process involves determining the relational reasoning score for each relation in the subgraph; based on the relational reasoning scores of all relations corresponding to each node in the subgraph, determining the node reasoning score for the corresponding node; when the maximum node reasoning score of a node meets a preset confidence threshold, the entity corresponding to the node with the maximum node reasoning score is determined as the answer to the question text; finally, when the maximum node reasoning score of a node does not meet the preset confidence threshold, the node reasoning scores are sorted in descending order, and the nodes with the first two preset number of node reasoning scores are determined as candidate nodes; a question response model is constructed based on a large language model and each candidate node and its corresponding relation to achieve the response to the question text. Addressing the problems of existing subgraph retrieval algorithms not fully utilizing relational semantics and unreasonable matching methods, this invention fuses relations with their head and tail node ontologies to obtain the hidden semantics of the relations; it provides a more reasonable path matching method; addressing the problem of the lag in relational semantics during the reasoning process in graph reasoning algorithms, and the problem that existing reasoning algorithms do not support logical matching, this invention proposes a logic-enhanced relational dynamic update reasoning algorithm, which dynamically updates relational semantics in each round of reasoning and utilizes a large language model to provide logical matching capabilities for the reasoning process. By introducing this method, we can obtain more accurate answers to complex queries, improve retrieval quality, and better serve the military field. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 This is a schematic diagram of the knowledge graph retrieval method provided in Embodiment 1 of the present invention;

[0048] Figure 2This is a schematic diagram of the graph retrieval technology process for complex query conditions;

[0049] Figure 3 This is a schematic diagram of the graph inference algorithm flow;

[0050] Figure 4 This is a schematic diagram of the application process of the graph inference algorithm;

[0051] Figure 5 This is a diagram of the internal structure of a computer device. Detailed Implementation

[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0053] The purpose of this invention is to provide a knowledge graph retrieval method, apparatus, medium, and product, which aims to realize knowledge graph retrieval for complex query conditions and solve problems such as existing subgraph retrieval algorithms not fully utilizing relational semantic information, unreasonable path matching methods, and the lag in relational semantics of answer reasoning algorithms, which lack logical matching capabilities.

[0054] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0055] Example 1

[0056] like Figure 1 As shown, the knowledge graph retrieval method in this embodiment includes:

[0057] Step 1: Obtain the question vector representation of the user's question text and the vector representation of multiple keywords.

[0058] Specifically, a language model is used as a semantic parsing tool to convert the complex query text (i.e., question text) input by the user into a question vector representation and a vector representation of multiple keywords.

[0059] Step 2: Based on the vector representation of each keyword, identify the nodes related to each keyword as key nodes in the knowledge graph, and identify all relations corresponding to each key node as candidate relations; one node corresponds to one entity.

[0060] Specifically, based on the vector representation of each keyword, key nodes related to each keyword are located in the knowledge graph. Starting from the key nodes, a graph traversal algorithm is used to expand outwards to generate candidate relationships.

[0061] Step 3: Calculate the matching score between each candidate relation and the problem vector representation.

[0062] As an optional implementation, step 3 includes:

[0063] Step 31: Determine any candidate relation as the current candidate relation, determine the key node corresponding to the current candidate relation as the current head node, and determine any tail node corresponding to the current candidate relation as the current tail node.

[0064] Step 32: Concatenate the ontology of the current head node, the current candidate relation, and the ontology of the current tail node in sequence to obtain the current concatenated text.

[0065] Step 33: Input the current concatenated text into the language model to obtain the hidden semantics of the current candidate relation.

[0066] Specifically, the language model is the RoBERT model.

[0067] The formula for calculating the hidden semantics of candidate relations is:

[0068] t ij =R(e i .r ij .e j ).

[0069] Among them, t ij The hidden semantics of candidate relations with the i-th head node and the j-th tail node; e i r is the entity of the i-th node; ij Let e ​​be a candidate relation with the i-th node as the head node and the j-th node as the tail node; j Let j be the entity of the j-th node.

[0070] Step 34: Obtain the explicit description text of the current candidate relationship.

[0071] Step 35: Determine the mixed semantics of the current candidate relation based on the explicit description text and hidden semantics of the current candidate relation.

[0072] Specifically, step 35 includes:

[0073] Step 351: Input the explicit description text of the current candidate relation into the language model to obtain the embedding vector of the explicit description text of the current candidate relation.

[0074] The expression for step 351 is: d ij =R(z) ij ).

[0075] Where, d ijz is the embedding vector of the explicit description text of the candidate relationship with the i-th node as the head node and the j-th node as the tail node; ij R is a candidate relation with the i-th node as the head node and the j-th node as the tail node; R(·) is the vector extraction operation of the language model.

[0076] Step 352: Combine the embedding vector and hidden semantics of the explicit description text of the current candidate relation to obtain the hybrid semantics of the current candidate relation.

[0077] The formula for calculating the hybrid semantics of candidate relations is:

[0078] f ij =[d ij ;t ij ].

[0079] Among them, f ij The mixed semantics of candidate relations with the i-th node as the head node and the j-th node as the tail node.

[0080] Step 36: Update the current head node to any tail node, update the current candidate relation to any relation with the updated head node as the head node, update the current tail node to any tail node of the updated current candidate relation, and return to step 32 until the mixed semantics of the updated current candidate relation is obtained.

[0081] Step 37: Determine the current candidate relation and the updated current candidate relation as the current path, and determine the mixed semantics of the current path based on the mixed semantics of the current candidate relation and the updated current candidate relation.

[0082] Specifically, the formula for calculating the hybrid semantics of a path is as follows:

[0083] m hj =[f hi ;f ij ].

[0084] Among them, f hi The mixed semantics of candidate relations with the head node being the h-th node and the tail node being the i-th node; m hj The mixed semantics of a path consisting of a candidate relation with the i-th head node and the j-th tail node and a candidate relation with the h-th head node and the i-th tail node.

[0085] Step 38: Perform dimensionality reduction on the hybrid semantics of the current path to obtain the semantic representation of the path after dimensionality reduction.

[0086] Specifically, the semantic representation of the path after dimensionality reduction is expressed as follows:

[0087] n hj=ReLU(W s1 (m hj )).

[0088] Where, n hj This represents the mixed semantics of a path consisting of a candidate relation with the i-th head node and the j-th tail node after dimensionality reduction, and a candidate relation with the h-th head node and the i-th tail node; ReLU(·) is the ReLU function; W s1 (·) is the first linear function used for dimensionality reduction.

[0089] Step 39: Based on the dimensionality-reduced semantic representation of each candidate relation in the semantic representation of the path, obtain the matching score between the corresponding candidate relation and the problem vector representation.

[0090] Specifically, the formula for calculating the matching score is as follows:

[0091] s ij =Q T n ij .

[0092] Among them, s ij For path n hj In the algorithm, the head node is the i-th node and the tail node is the j-th node, representing the matching score between the candidate relation and the question vector representation; Q T Let n be the transpose of the problem vector representation Q; ij For path n hj The semantic representation of the candidate relation with the head node being the i-th node and the tail node being the j-th node after dimensionality reduction.

[0093] Step 4: Sort the matching scores in descending order, and construct a subgraph based on the candidate relationships and corresponding nodes of the first preset number of matching scores.

[0094] Step 5: Generate multiple reasoning instructions based on the question text, and use each reasoning instruction to gradually determine the relationship reasoning score of each relationship in the subgraph.

[0095] As an optional implementation, step 5 includes:

[0096] Step 51: Determine any relation in the subgraph as the initial current relation.

[0097] Step 52: Number each inference instruction in sequence, and update the initial current relation in multiple rounds in the order of the numbers to obtain the relation inference score of the current relation.

[0098] As an optional implementation, step 52 includes:

[0099] Step 521: Perform semantic fusion based on the final semantic representation of the current relation in the previous round, the head node of the current relation in the previous round, and the tail node of the current relation in the previous round to obtain the initial semantic representation of the current relation in the current round; wherein, when the previous round is the initial round, the final semantic representation of the current relation in the previous round is obtained by semantic fusion based on the semantic representation of the initial current relation, the head node of the initial current relation, and the tail node of the initial current relation.

[0100] Specifically, the formula for calculating the initial semantic representation of the current relation in round g is:

[0101]

[0102] in, e represents the initial semantic representation of the current relation in round g; (g-1) This is the head node of the current relation in round g-1; This represents the final semantic representation of the current relation in round g-1. It is the tail node of the current relation in the (g-1)th round.

[0103] Step 522: Perform semantic fusion and dimensionality reduction on the initial semantic representation of the current relation in the current round and the inference instructions in the current round to obtain the final semantic representation of the current relation in the current round.

[0104] Specifically, the formula for calculating the final semantic representation of the current relation in round g is:

[0105]

[0106] in, W represents the final semantic representation of the current relation in round g; q (·) represents the dimensionality reduction operation for the fully connected layer; a (g) This is the reasoning instruction for the g-th round.

[0107] Step 523: Determine the reasoning score of the current relation in the current round based on the final semantic representation of the current relation in the current round and the reasoning instruction in the current round.

[0108] Specifically, the formula for calculating the inference score of the current relationship in round g is as follows:

[0109]

[0110] in, W is the reasoning score for the current relation in round g; s2 (·) is the second linear function used for dimensionality reduction.

[0111] Step 524: Determine whether the current round has reached the maximum number of reasoning instructions.

[0112] Step 525: If so, then determine the reasoning score of the current relation in the current round as the relation reasoning score of the current relation.

[0113] Step 526: If not, proceed to the next round of updates until the current round reaches the maximum number of the reasoning instruction, and determine the reasoning score of the current relation in the current round as the relation reasoning score of the current relation.

[0114] Step 6: Based on the relation reasoning scores of all relations corresponding to each node in the subgraph, determine the node reasoning score of the corresponding node.

[0115] Specifically, the arithmetic mean of the relation reasoning scores of all relations corresponding to each node in the subgraph is taken as the node reasoning score of the corresponding node.

[0116] Step 7: When the maximum node inference score of a node meets the preset confidence threshold, the entity corresponding to the node with the maximum node inference score is determined as the answer to the question text.

[0117] Step 8: When the maximum value of a node's inference score does not meet the preset confidence threshold, sort the node inference scores in descending order and determine the nodes to which the first two preset number of node inference scores belong as candidate nodes.

[0118] Step 9: Construct a question response model based on the large language model, each candidate node, and their corresponding relationships to achieve a response to the question text.

[0119] As an optional implementation, step 9 includes:

[0120] Step 91: Construct a Prompt based on each candidate node and its corresponding relationship.

[0121] Specifically, step 91 includes:

[0122] Step 911: Construct a task description to help the large language model understand the type of task to be performed next. Step 912: Construct task hints. Obtain path information from key nodes to candidate nodes as input hints.

[0123] Step 913: Use the user's input question as the question input for the large language model, and use candidate nodes as options.

[0124] Step 92: Input the Prompt into the large language model to obtain the response text of the question.

[0125] Specifically, the task description, task prompts, questions, and options are used as input to the large language model to obtain the output answer. Specific Implementation

[0127] like Figure 2 As shown, in order to implement the method in Embodiment 1, a specific embodiment provides a graph retrieval technology for complex query conditions, including:

[0128] S1: The user submits the query conditions.

[0129] S2: Define the relationship from the problem definition to the target and perform semantic fusion with the ontology of the head and tail nodes.

[0130] S3: Semantically fuse the hidden semantics of the relationship with the explicit text describing the relationship to obtain the mixed semantics of the relationship.

[0131] S4: Semantically fuse the mixed semantics of the current relation with its preceding relation to obtain the path representation.

[0132] S5: Calculate the relationship score by semantically matching the relationship between the question and the target.

[0133] S6: Select candidate relationships to construct a subgraph.

[0134] S7: Generates multiple reasoning instructions based on the question and performs multiple rounds of reasoning.

[0135] S8: Dynamically updates relation semantics to solve the problem of relation lag.

[0136] S9: Dynamically update entity representations and generate entity relevance distributions.

[0137] S10: Build a Prompt and input a large language model.

[0138] S11: Filter answers based on confidence threshold.

[0139] Let's analyze the overall process using the input question, "What food does someone like to eat?" as an example. The overall process is as follows: Figure 1 As shown. The overall process is divided into two modules: subgraph retrieval and answer reasoning, as follows. Figure 3 and Figure 4 As shown.

[0140] (1) Locate the target relationship based on the problem, such as the related relationships such as "like", "hobby", "love", "preference".

[0141] (2) Obtain the head and tail node ontologies of the relation, and concatenate the head and tail node ontologies with the relation text. For example, "person.likes.food", and input it into the language model to obtain its embedding vector representation. This is because different relations may have different semantics in different contexts, so the head and tail entity ontologies are used as context to mine the deeper semantics of the relation.

[0142] (3) Semantic fusion of the implicit semantics of the relationship with the explicit descriptive text of the relationship is performed to further enhance the semantics of the relationship. Specifically, the explicit descriptive text is formatted as ““Preference” refers to an individual’s inclination or preference for a certain thing or activity, indicating liking and selection of a specific object or behavior.” This is then input into the language model to obtain the embedded vector representation. Then, the semantics of the explicit descriptive text of the relationship are semantically fused with the implicit meaning, i.e., vector concatenation, to obtain the mixed semantics of the relationship.

[0143] (4) Construct a path representation based on the hybrid semantics of the current relation and the hybrid semantics of the preceding relation, and use the current path representation and the embedding vector of the question to perform cosine calculation to obtain the overall path score after adding the current relation. Then select the top-K paths with the highest scores to add to the subgraph to complete the subgraph retrieval of the current jump.

[0144] (5) In the initial stage of the reasoning module, the problem will be analyzed and multiple rounds of reasoning instructions will be generated. Each reasoning instruction focuses on a different part of the problem. For example, the first round of reasoning may focus more on "someone" in the question "What food does someone like to eat?", while the second round of reasoning may focus more on "food".

[0145] (6) At the beginning of each round of inference, the semantics of the adjacency relationships of the target node are updated. The semantic representations of the adjacency relationships of the current entity obtained in the previous round of inference, the semantic representations of the head and tail nodes of the relationship in the previous round of inference, and the instructions of the current round are semantically fused to obtain the semantics of the relationship in the new context. The latest representation of the relationship is then reduced in dimensionality through a fully connected layer.

[0146] (7) Perform a dot product between the inference instruction and the semantic representation of the relation to obtain the feature vector of the relation. Input this feature vector into the scoring function to obtain its relevance score to the question. Finally, input the relevance scores of all adjacent relations of the current node into the softmax function to obtain the weights of all adjacent relations in this round of inference. Multiply the relation semantic representation by the weights and complete the entity relevance score calculation via the entity update module.

[0147] (8) Utilizing a large language model to provide logical reasoning capabilities for the graph reasoning process. Since the large language model has zero-shot characteristics, it requires no fine-tuning and is plug-and-play. Therefore, a Prompt template for graph question answering was constructed and directly input into the large language model (LLM). The Prompt content is as follows: Figure 4 As shown.

[0148] Considering the inherent illusion problem of LLM (Local Level Management), which outputs an answer even when it doesn't know the correct one, a confidence threshold is set. When the relevance score of the node output by the inference module is greater than the confidence threshold, the node generated by the inference module is used as the answer. When it is lower than the threshold, the answer output by the LLM is used.

[0149] Example 2

[0150] A computer device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the knowledge graph retrieval method in Embodiment 1.

[0151] Example 3

[0152] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the knowledge graph retrieval method in Embodiment 1.

[0153] Example 4

[0154] A computer program product includes a computer program that, when executed by a processor, implements the steps of the knowledge graph retrieval method in Embodiment 1.

[0155] Example 5

[0156] A computer device, which may be a database, may have an internal structure diagram as shown below. Figure 5 As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores pending transactions. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements the knowledge graph retrieval method in Embodiment 1.

[0157] It should be noted that the object information (including but not limited to object device information, object personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this invention are all information and data authorized by the object or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0158] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided by this invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided by this invention may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided by this invention may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0159] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0160] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A knowledge graph retrieval method, characterized in that, The method includes: Obtain the question vector representation of the user's question text and the vector representation of multiple keywords; Based on the vector representation of each keyword, in the knowledge graph, nodes related to each keyword are identified as key nodes, and all relations corresponding to each key node are identified as candidate relations; one node corresponds to one entity. Calculate the matching score between each candidate relation and the question vector representation; Sort the matching scores in descending order, and construct a subgraph based on the candidate relationships and corresponding nodes of the first preset number of matching scores; Multiple reasoning instructions are generated based on the question text, and the relationship reasoning scores of each relationship in the subgraph are determined step by step using each reasoning instruction. Based on the relation reasoning scores of all relations corresponding to each node in the subgraph, the node reasoning score of the corresponding node is determined. When the maximum node reasoning score of the node meets the preset confidence threshold, the entity corresponding to the node to which the maximum node reasoning score belongs is determined as the answer to the question text; When the maximum value of the node inference score does not meet the preset confidence threshold, the node inference scores are sorted in descending order, and the nodes to which the first second preset number of node inference scores belong are determined as candidate nodes. A question response model is constructed based on the large language model, the candidate nodes, and their corresponding relationships to achieve a response to the question text.

2. The knowledge graph retrieval method according to claim 1, characterized in that, Calculate the matching score between each candidate relation and the question vector representation, including: Any candidate relation is determined as the current candidate relation, the key node corresponding to the current candidate relation is determined as the current head node, and any tail node corresponding to the current candidate relation is determined as the current tail node. The ontology of the current head node, the current candidate relationship, and the ontology of the current tail node are concatenated sequentially to obtain the current concatenated text; The currently concatenated text is input into the language model to obtain the hidden semantics of the current candidate relation; Obtain the explicit description text of the current candidate relationship; Based on the explicit description text and hidden semantics of the current candidate relation, determine the mixed semantics of the current candidate relation; Update the current head node to any tail node, update the current candidate relationship to any relationship with the updated head node as the head node, update the current tail node to any tail node of the updated current candidate relationship, and return "concatenate the ontology of the current head node, the current candidate relationship and the ontology of the current tail node in sequence to obtain the current concatenated text", until the mixed semantics of the updated current candidate relationship is obtained; The current candidate relation and the updated current candidate relation are determined as the current path, and the mixed semantics of the current path are determined based on the mixed semantics of the current candidate relation and the updated current candidate relation; The mixed semantics of the current path are reduced in dimensionality to obtain the semantic representation of the path after dimensionality reduction; Based on the dimensionality-reduced semantic representation of each candidate relation in the semantic representation of the path, the matching score between the corresponding candidate relation and the problem vector representation is obtained.

3. The knowledge graph retrieval method according to claim 1, characterized in that, The relational reasoning score of each relation in the subgraph is determined step by step using the aforementioned reasoning instructions, including: Define any relation in the subgraph as the initial current relation; The inference instructions are numbered sequentially, and the initial current relationship is updated in multiple rounds according to the order of the numbers to obtain the relationship inference score of the current relationship.

4. The knowledge graph retrieval method according to claim 3, characterized in that, The inference instructions are numbered sequentially, and the initial current relation is updated multiple times in the order of the numbers to obtain the relation inference score of the current relation, including: The initial semantic representation of the current relation in the current round is obtained by semantic fusion based on the final semantic representation of the current relation in the previous round, the head node of the current relation in the previous round, and the tail node of the current relation in the previous round. Wherein, when the previous round is the initial round, the final semantic representation of the current relation in the previous round is obtained by semantic fusion based on the semantic representation of the current relation in the previous round, the head node of the current relation in the previous round, and the tail node of the current relation in the previous round. Semantic fusion and dimensionality reduction are performed on the initial semantic representation of the current relation in the current round and the reasoning instructions in the current round to obtain the final semantic representation of the current relation in the current round; The reasoning score of the current relation in the current round is determined based on the final semantic representation of the current relation in the current round and the reasoning instruction in the current round. Determine if the current round has reached the maximum number of inference instructions; If so, the reasoning score of the current relation in the current round is determined as the relation reasoning score of the current relation; If not, proceed to the next round of updates until the current round reaches the maximum number of the reasoning instruction, and then determine the reasoning score of the current relation in the current round as the relation reasoning score of the current relation.

5. The knowledge graph retrieval method according to claim 1, characterized in that, A question-response model is constructed based on a large language model and the candidate nodes and their corresponding relationships to achieve a response to the question text, including: Construct a Prompt based on each candidate node and its corresponding relationship; The prompt is input into the large language model to obtain a response to the question text.

6. A computer device, comprising: The memory and processor contain a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the knowledge graph retrieval method according to any one of claims 1-5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the knowledge graph retrieval method according to any one of claims 1-5.

8. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the knowledge graph retrieval method according to any one of claims 1-5.