Relationship-driven adaptive knowledge graph question answering and path guiding method and system

By using an adaptive knowledge graph question answering and path guidance method, the reasoning depth is dynamically adjusted and the large language model is explicitly guided, which solves the accuracy and flexibility problems of the large language model in knowledge-intensive question answering and achieves efficient and interpretable answer generation.

CN121094145BActive Publication Date: 2026-01-09SUZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511622400.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-07
Publication Date
2026-01-09
Estimated Expiration
2045-11-07

AI Technical Summary

Technical Problem

Existing large language models suffer from insufficient accuracy, lagging knowledge updates, and inflexible reasoning depth in knowledge-intensive question-answering tasks, especially in complex multi-hop reasoning scenarios where it is difficult to balance accuracy, flexibility, and interpretability.

Method used

By extracting relevant subgraphs from the knowledge graph, encoding them using a pre-trained language model, dynamically calculating relation activation probabilities, generating step-level and global relation masks, constructing a relation transition matrix, adaptively selecting the optimal number of inference hops, and guiding the large language model to generate answers through few-sample paths.

Benefits of technology

It significantly improves the accuracy and efficiency of question answering, reduces inaccurate answers and illusions, enhances the interpretability and robustness of the system, and is suitable for high-precision application scenarios with limited resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121094145B_ABST
    Figure CN121094145B_ABST
Patent Text Reader

Abstract

The application discloses a kind of relationship-driven adaptive knowledge graph question answering and path guiding method and system, it is related to artificial intelligence technical field, the method first pass through multi-step graph reasoning, the activation probability of relationship in knowledge graph is dynamically calculated and relationship mask is generated;Then, the original question vector is fused with global relationship mask, the optimal reasoning hop is adaptively determined by jump number selector model, and candidate reasoning path is generated;Finally, the few-sample prompt containing "question-path-thought chain-answer" is constructed, and the large language model is guided to generate the final answer according to the path logic.The application overcomes the inflexibility caused by fixed reasoning hop in the prior art, and the model illusion problem caused by the lack of explicit path guidance, significantly improves the accuracy, reliability and explainability of knowledge question answering.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and particularly relates to a relationship-driven adaptive knowledge graph question answering and path guiding method and system. BACKGROUND

[0002] With the rapid development of Large Language Models (LLMs) in the field of natural language processing, they have shown strong capabilities in tasks such as question answering and reasoning, and have gradually been applied to knowledge-intensive scenarios such as medicine, law, and education. However, due to the fact that existing large language models mainly rely on their internal parameterized knowledge for generation, there are still inherent limitations when dealing with complex questions that require accurate and dynamic external knowledge.

[0003] In knowledge-intensive question answering tasks, existing methods generally face the following technical bottlenecks:

[0004] Firstly, the model is prone to "hallucinations", i.e., due to the lack of reliable external knowledge support, the generated answers may sound reasonable but are not consistent with the facts, seriously affecting the accuracy and credibility of the answers.

[0005] Secondly, the model has the problem of knowledge update lag. Once the knowledge of a large language model is fixed in the parameters through training, it is difficult to reflect rapidly changing domain knowledge in real time, and it cannot meet the application requirements of high timeliness.

[0006] In order to make up for the above defects, attempts have been made in existing technologies to introduce knowledge graphs into question answering systems. Knowledge graphs store a large amount of entities, relationships, and facts in a structured way, and can provide reliable external knowledge sources for large language models. However, the existing combination methods still have obvious deficiencies, mainly in two aspects:

[0007] On the one hand, when using a knowledge graph for multi-hop reasoning, the number of hops (i.e., the reasoning depth) is usually determined by a pre-set fixed value, or is only judged according to the text features of the question. This method lacks dynamic perception ability of the internal relationship structure of the knowledge graph, and cannot flexibly adjust the reasoning depth according to the specific entity relationship network involved in the current question. This leads to unnecessary deep reasoning when facing simple questions, reducing efficiency, and insufficient reasoning depth when facing complex questions, reducing the accuracy and flexibility of question answering.

[0008] On the other hand, when providing reasoning path information to a large language model, existing methods often simply concatenate the path as additional input information, lacking explicit guidance to the model. The large language model may not effectively interpret the logical chain implied by the "entity-relation" sequence in the path, resulting in valuable path information not being fully utilized, and the model still relying on its internal parameter knowledge to answer, failing to fully leverage the potential of knowledge graphs in improving the factual accuracy and explainability of answers.

[0009] Therefore, the prior art is difficult to simultaneously consider the accuracy of answers, the flexibility of reasoning, and the explainability of the generation process in complex multi-hop reasoning scenarios. This problem has become a technical problem to be solved urgently in knowledge-intensive applications such as medical diagnosis, legal consultation, and scientific research assistance, which have high precision requirements. SUMMARY

[0010] To this end, embodiments of the present application provide a relationship-driven adaptive knowledge graph question answering and path guidance method and system, which are used to solve the problems of insufficient flexibility caused by fixed reasoning hop number and low knowledge utilization efficiency and poor answer reliability of a large language model caused by lack of explicit path guidance in the prior art.

[0011] To solve the above technical problems, embodiments of the present application provide a relationship-driven adaptive knowledge graph question answering and path guidance method, which comprises:

[0012] extracting a subgraph related to an input question from a knowledge graph, encoding a question text into an original question vector using a pre-trained language model, and initializing an entity state vector based on a topic entity in the question;

[0013] performing multi-step reasoning within a preset maximum reasoning step number, and for each reasoning step, calculating an activation probability of a candidate relation in the knowledge graph based on a current question vector;

[0014] generating a step-level relation mask based on the activated relation of each step, and updating a global relation activation mask;

[0015] constructing a relation transition matrix based on the activation probability, and updating the entity state vector based on the relation transition matrix;

[0016] concatenating the original question vector and the global relation activation mask into a fusion feature vector, inputting the fusion feature vector into a hop number selector model, outputting a weight distribution of each reasoning step, selecting a step with the largest weight as an optimal reasoning hop number, and calculating a final entity score based on the entity state vector;

[0017] selecting candidate answer entities based on the final entity scores, generating reasoning paths from the topic entity to each of the candidate answer entities with the optimal reasoning hop number as the maximum reasoning depth, and screening N paths with the highest average relation scores as candidate reasoning paths;

[0018] constructing a prompt containing a fixed number of examples, each example including an original question, a serialized path, a thinking chain, and an answer, and concatenating the examples, a target question, and the candidate reasoning paths as an input sequence;

[0019] inputting the input sequence into a large language model to obtain a final answer.

[0020] Preferably, the activation probability of the candidate relation in the knowledge graph is calculated based on the current question vector, specifically including:

[0021] calculating attention queries wherein is a linear projection function, is an original question vector, is a relation context;

[0022] calculating word attention weights wherein is a normalized exponential function, are hidden states of the first word, respectively;

[0023] calculating the question vector at the first step wherein represents the weight of the first word at the first reasoning step, represents the hidden state of the first word;

[0024] calculating the activation probability of the candidate relation using the question vector at the first step wherein is a multi-layer perceptron, is an activation function.

[0025] Preferably, the step-level relation mask is generated based on the activated relation at each step, and the global relation activation mask is updated, specifically including:

[0026] identifying all triples with a target entity probability greater than zero from the knowledge graph, and extracting a relation index set in these triples wherein the target entity probability is the product of the subject probability and the relation probability in the triple;

[0027] ​Generating step-level relation mask The extracted relations are marked as 1 in , that is , where , is the relation index, and is the total number of relations in the subgraph.

[0028] Filtering the activation probability of candidate relations , only keeping the probability value corresponding to the activated relation pair;

[0029] Updating the global relation activation mask , where is the logical or operation.

[0030] Extracting the relation context , where is the relation feature conversion function, which is used to convert the activation probability of the filtered candidate relation to the relation context .

[0031] Preferably, the relation transition matrix is constructed based on the activation probability, and the entity state vector is updated based on the relation transition matrix, specifically including:

[0032] Constructing a relation transition matrix , , where represents the transition probability from entity to , and represents the activation probability of the th relation in the th step, is the relation index, represents the relation index between entity and entity , is the activation probability of the candidate relation in the th step, is the entity-relation-entity triple mapping matrix, is the total number of entities in the subgraph.

[0033] Calculating the entity state vector , where is the entity state vector in the th step.

[0034] Preferably, the original question vector and the global relation activation mask are spliced into a fusion feature vector, input into a multi-layer perceptron of a jump number selector model, output the weight distribution of each reasoning step, and select the step with the largest weight as the optimal reasoning jump number, specifically including:

[0035] The hop selector model is a multi-layer perceptron , output wherein is a T-dimensional vector, representing the weight distribution of each inference step;

[0036] selecting the optimal inference hop wherein is the inference weight of the i-th step, is the maximum inference step number; calculating the final entity score

[0037] wherein is the entity state vector of the i-th step. Preferably, the candidate answer entity is selected based on the final entity score, the optimal inference hop is taken as the maximum inference depth, the inference path from the topic entity to each of the candidate answer entities is generated, and the N paths with the highest average relationship scores are selected as candidate inference paths, specifically comprising:

[0038] For each candidate answer entity, the inference path from the topic entity to each of the candidate answer entities is generated, and the path length does not exceed the optimal inference hop K;

[0039] The average relationship score of each inference path is calculated, that is, the mean of all relationship activation probabilities in the inference path;

[0040]

[0041] For each candidate answer entity, the N paths with the highest average relationship scores are selected as candidate inference paths.

[0042] Preferably, the prompt containing a fixed number of examples is constructed, specifically comprising:

[0043] The fixed number of examples is three, and each example includes an original question, a serialized path, a thinking chain and an answer;

[0044] The serialized path adopts the format of “entity→relationship→entity”;

[0045] The thinking chain is used to explicitly map the path logic to the answer constraint;

[0046] The examples, the target question and the candidate inference paths are spliced in sequence to form an input sequence.

[0047] The embodiment of the present application also provides a relationship-driven adaptive knowledge graph question answering and path guiding system, which is used to realize the relationship-driven adaptive knowledge graph question answering and path guiding method described above, and specifically comprises:

[0048] ​​The initialization module is configured to extract a subgraph related to the input question from the knowledge graph, encode the question text into an original question vector using a pre-trained language model, and initialize an entity state vector based on a topic entity in the question.

[0049] The relationship reasoning module is configured to perform multi-step reasoning within a preset maximum reasoning step number, and for each reasoning step, calculate an activation probability of a candidate relationship in the knowledge graph based on a current question vector.

[0050] The relationship mask management module is configured to generate a step-level relationship mask based on the activated relationship of each step, and update a global relationship activation mask.

[0051] The entity state update module is configured to construct a relationship transition matrix based on the activation probability, and update the entity state vector based on the relationship transition matrix.

[0052] The adaptive hop number selection module is configured to concatenate the original question vector and the global relationship activation mask into a fusion feature vector, input the fusion feature vector into a hop number selector model, output a weight distribution of each reasoning step, select a step with the maximum weight as an optimal reasoning hop number, and calculate a final entity score based on the entity state vector.

[0053] The path generation module is configured to select a candidate answer entity based on the final entity score, generate a reasoning path from the topic entity to each candidate answer entity with the optimal reasoning hop number as the maximum reasoning depth, and filter N paths with the highest average relationship scores as candidate reasoning paths.

[0054] The path guidance module is configured to construct a prompt containing a fixed number of examples, each example including an original question, a serialized path, a thinking chain, and an answer, and concatenate the examples, a target question, and the candidate reasoning paths into an input sequence.

[0055] The answer generation module is configured to input the input sequence into a large language model to obtain a final answer.

[0056] The embodiment of the present application also provides an electronic device, which comprises a processor, a memory and a bus system, the processor and the memory are connected through the bus system, the memory is used for storing instructions, and the processor is used for executing the instructions stored in the memory to realize the relationship-driven adaptive knowledge graph question answering and path guidance method.

[0057] The embodiment of the present application also provides a computer storage medium, which stores a computer software product, the computer software product comprises a plurality of instructions, and is used to make a computer device execute the relationship-driven adaptive knowledge graph question answering and path guidance method.

[0058] From the above technical solution, the present application has the following beneficial effects:

[0059] (1) The relationship-driven adaptive reasoning is realized, and the accuracy and efficiency of the question and answer are significantly improved: the present application dynamically determines the optimal reasoning hop number through the mechanism of "relation activation mask tracking-double feature fusion-weight optimization". It overcomes the limitations of fixed hop number or only relying on problem text features in the prior art, and can flexibly adjust the reasoning depth according to the actual association between entities in the knowledge graph. This avoids over-reasoning for simple problems and insufficient reasoning for complex problems, thereby realizing higher answer accuracy and more efficient path retrieval in complex multi-hop question and answer scenarios.

[0060] (2) The "illusion" of the large language model is effectively suppressed through explicit few-shot path guidance, and the fidelity and reliability of the answer are enhanced: the present application designs a structured "question-path-thinking chain-answer" few-shot prompting mechanism. This mechanism not only provides the model with a reasoning path, but also explicitly teaches the model how to interpret and utilize the logical relationships in the path through the "thinking chain" template. This strong guidance enables the large language model to strictly follow the factual basis provided by the external knowledge graph when generating answers, rather than relying on its internal parameterized knowledge that may be inaccurate or outdated, thereby significantly reducing factual errors and "illusion" phenomena and generating more reliable answers.

[0061] (3) The explainability and robustness of the system are improved, and the application scenarios and deployment feasibility of the technology are widened: the answer generated by the present application is accompanied by a clear reasoning path and logical derivation process, making the answer generation process transparent, traceable and verifiable, greatly enhancing the explainability and user trust of the system. At the same time, as a model-independent framework, this method can stably improve the performance of large language models of different sizes, especially small models with weaker performance, showing good robustness. This enables high-precision knowledge services to be achieved by deploying small models combined with the present method in resource-constrained scenarios, effectively reducing the cost and threshold of technology landing, and being more suitable for professional fields such as medicine and law that require high accuracy. BRIEF DESCRIPTION OF DRAWINGS

[0062] In order to more clearly illustrate the technical solutions in the embodiments or the prior art, the drawings needed in the embodiments will be briefly described below. The features and advantages of the present application can be more clearly understood by referring to the drawings. The drawings are schematic and should not be construed as any limitation on the present application. Those skilled in the art can obtain other drawings from these drawings without creative labor. Among them:

[0063] Figure 1is a flow chart of a relationship-driven adaptive knowledge graph question answering and path guidance method provided by the present application.

[0064] Figure 2 is a reasoning flow chart of the method of the present application.

[0065] Figure 3 is a block diagram of a relationship-driven adaptive knowledge graph question answering and path guidance system provided by the present application. DETAILED DESCRIPTION

[0066] To make the purposes, technical solutions and advantages of the embodiments of the present application clearer, 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 some embodiments of the present application, rather than all the embodiments. 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.

[0067] Embodiment one: in order to solve the problems of insufficient flexibility caused by fixed reasoning hop number and low knowledge utilization efficiency and poor answer reliability of large language models caused by lack of explicit path guidance in the prior art, as shown in Figure 1 the present application proposes a relationship-driven adaptive knowledge graph question answering and path guidance method, which comprises:

[0068] S1: extracting a subgraph related to an input question from a knowledge graph, using a pre-trained language model to encode the question text into an original question vector, and initializing an entity state vector based on the topic entity in the question;

[0069] S2: performing multi-step reasoning within a preset maximum reasoning step number, for each reasoning step, calculating the activation probability of the candidate relationship in the knowledge graph based on the current question vector;

[0070] S3: generating a step-level relationship mask based on the activated relationship of each step, and updating a global relationship activation mask;

[0071] S4: constructing a relationship transition matrix based on the activation probability, and updating the entity state vector based on the relationship transition matrix;

[0072] S5: concatenating the original question vector and the global relationship activation mask into a fusion feature vector, inputting the jump number selector model, outputting the weight distribution of each reasoning step, selecting the step with the largest weight as the optimal reasoning hop number, and calculating the final entity score based on the entity state vector;

[0073] S6: Select candidate answer entities based on final entity scores, generate reasoning paths from the topic entity to each candidate answer entity with the maximum reasoning depth as the optimal reasoning hop number, and filter the top N paths with the highest average relationship scores as candidate reasoning paths;

[0074] S7: Construct prompts containing a fixed number of examples, each example including the original question, serialized path, thinking chain, and answer, and splice the examples, target question, and candidate reasoning paths into input sequences;

[0075] S8: Input the input sequences into a large language model to obtain the final answer.

[0076] From the above technical solution, the present application proposes a relationship-driven adaptive knowledge graph question answering and path guiding method. The method first initializes data through step S1 to prepare question representation and entity state for graph reasoning; then performs the core multi-step graph reasoning process in steps S2-S4, dynamically calculates relationship activation probability, constructs relationship mask, and updates entity state to realize probability propagation based on knowledge graph structure; then through the key innovation of step S5, the adaptive hop number selection mechanism, the problem semantics and relationship mask features are fused to intelligently determine the optimal reasoning depth and calculate the final entity score; based on this, step S6 generates high-quality candidate reasoning paths; finally, through the few-shot path guiding mechanism designed in steps S7-S8, a prompt containing an explicit thinking chain is constructed to guide the large language model to accurately understand and utilize the reasoning path to generate the final answer. This complete technical solution cooperates through the dual modules of "graph reasoning dynamic decision" and "LLM explicit guidance", effectively solves the limitations of fixed hop number reasoning, and significantly improves the accuracy, reliability, and explainability of question answering.

[0077] In step S1, a subgraph related to the input question is extracted from the knowledge graph. A pre-trained language model (such as the "bert-base-uncased" version of BERT) is used to encode the question text into an original question vector (the dimension of the original question vector is 768), and output the hidden state sequence of the question ). Based on the topic entity in the question, the entity state vector is initialized , is the total number of entities in the subgraph, and the topic entity corresponds to the position of 1 and the rest are 0, and a triple matrix is constructed (records the relationship index between entities).

[0078] In step S2, multi-step reasoning is performed within the preset maximum reasoning step , is determined by the dataset scenario). For each reasoning step ,

[0079] S21: Calculate attention query where is a linear projection function that maps the question vector and the relational context to the same attention space (initially set to a zero vector of the same dimension as the original question vector ).

[0080] S22: Calculate word attention weights where is a normalized exponential function, are the hidden states of the th word, respectively; the higher the weight, the more critical the word is to the current reasoning.

[0081] S23: Calculate the th question vector where is the weight of the th word under the th step of reasoning, is the hidden state of the th word.

[0082] S24: Calculate the activation probability of candidate relations using the th question vector where is a multi-layer perceptron (the input vector of the multi-layer perceptron has a dimension of 768, and the output vector has a dimension of m, where m is the total number of relations in the subgraph), is an activation function used to normalize the probability values. Each element in represents the activation probability of the corresponding relation at the current step, and the higher the score, the closer the relationship is to the question.

[0083] In step S3, the relationship activation mask (initially a vector of all 0s) dynamically records the relationships that contribute to the answer during the reasoning process. For each step ( ), the mask is generated and updated according to the following process:

[0084] S31: Identify all triples with a target entity probability greater than zero from the knowledge graph, and extract the set of relationship indices in these triples ​(e.g., ‘parents’ has index 2), where the target entity probability is the product of the head probability and the relation probability in the triple (e.g., ‘virtual individual A → parents → virtual individual B’, assuming the probability of virtual individual A is 1 and the probability of the relation parents is 0.85, then the probability of virtual individual B is 0.85).

[0085] S32: Generating step-level relation mask (initially all 0 vector), mark the extracted relations as 1 in , i.e. ( ), is the relation index, is the total number of relations in the subgraph.

[0086] S33: Filtering the activation probability of candidate relations , only keep the probability value corresponding to the active relation pair.

[0087] S34: Updating the global relation activation mask , where is the logical or operation, is the floating-point error threshold, mainly to eliminate the error of computer floating-point operation.

[0088] S35: Extracting relation context , where is the relation feature conversion function, which is used to convert the activation probability of the filtered candidate relation to the relation context , so as to update the question vector subsequently.

[0089] In step S4, the relation transition matrix is constructed based on the activation probability, and the entity state vector is updated based on the relation transition matrix, specifically including:

[0090] S41: Constructing relation transition matrix , , where represents the transition probability from entity to , represents the activation probability of the th relation in the th step, is the relation index, represents the relation index between entity and entity , is the activation probability of the candidate relation in the th step, is the entity-relation-entity triple mapping matrix, the total number of entities in the subgraph;

[0091] S42: Calculate the entity state vector , where is the entity state vector of the i-th step. The current entity state is obtained by multiplying the entity state of the previous step and the transition probability, realizing the propagation of entity probability in the knowledge graph. This step realizes the propagation of entity probability along the active relationship to the 1-hop neighbor. Through this step, the probability value of the entity on the entity chain related to the answer will gradually increase.

[0092] In step S5, the original question vector is spliced with the global relationship activation mask into a fusion feature vector, input into the jump number selector model multilayer perceptron, and the weight distribution of each reasoning step is output, and the step with the largest weight is selected as the optimal reasoning jump number, which specifically includes:

[0093] S51: Splice the original question vector (the dimension of the original question vector is 768) and the global relationship activation mask (the dimension of the global relationship activation mask is ) into a fusion feature vector (the dimension of the fusion feature vector is ), input into the jump number selector model (multilayer perceptron). Output , where is a T-dimensional vector, representing the weight distribution of each reasoning step.

[0094] S52: Select the optimal reasoning jump number , where is the reasoning weight of the i-th step.

[0095] S53: Calculate the final entity score , where is the entity state vector of the i-th step.

[0096] In step S6, based on the final entity score, select the candidate answer entity, take the optimal reasoning jump number as the maximum reasoning depth, generate the reasoning path from the theme entity to each candidate answer entity, and select the top N paths with the highest average relationship score as the candidate reasoning path. Specifically, it includes:

[0097] S61: Based on the final entity score , select the top-k entities with the highest confidence (k=10 in this embodiment) as candidate answer entities .

[0098] ​​​S62: For each candidate answer entity, generate reasoning paths from the topic entity to each candidate answer entity with the optimal reasoning hop K as the maximum reasoning depth (i.e. the path length does not exceed the optimal reasoning hop K).

[0099] S63: Calculate the average relation score (the mean of all relation activation probabilities in the reasoning path) of each reasoning path, and select the top N paths (N = 1 in this embodiment) with the highest scores for each candidate answer entity as the candidate reasoning paths.

[0100] In step S7, prompts containing a fixed number of examples (E = 3 in this embodiment) are constructed, each example including:

[0101] Original question: natural language query, for example, "what did virtual individual C do?";

[0102] Serialized path: in the format of "entity→relation→entity", for example, "virtual individual C→people.person.profession→Escritor";

[0103] Thinking chain: explicitly map the path logic to the answer constraint, for example, "virtual individual C-people.person.profession-answer (profession)".

[0104] Answer format: explicit output requirements.

[0105] This embodiment uses a fixed three examples (not dynamically selected with the problem), and experiments have verified that the number 3 is optimal (E = 3). Too many examples will increase the cognitive load of LLMs, resulting in performance degradation.

[0106] Finally, the (few-shot) examples, the target question, and the candidate reasoning paths are spliced to form the final input sequence of the LLM.

[0107] In step S8, the input sequence is input into a large language model (such as the GPT series), and the model outputs the final answer by combining the question, the reasoning path, and the few-shot prompt.

[0108] Further, model training optimization (for graph reasoning models) is performed, and the graph reasoning model is trained according to steps S1 to S6 with the following settings:

[0109] Data source: Training set of public benchmark datasets such as WebQSP, CompWebQ, SimpleQuestions, WebQuestions, etc. Subgraph construction method: SimpleQuestions takes the 1-hop neighbor of the theme entity, WebQSP and WebQuestions use the bidirectional 2-hop extension of the theme entity and supplement the reverse relationship, and CompWebQ uses the PageRank algorithm to retrieve the subgraph.

[0110] Training parameters: 60 rounds of training with RAdam optimizer, learning rate set to 1e-3 and 1e-5 (BERT part).

[0111] Loss function: The training loss is the final entity score L2 distance with answer vector a: where is a one-hot encoded vector (1 for the corresponding position of a single answer entity, and 1 for all correct entity positions of a multiple answer entity, the dimension is consistent with ).

[0112] In order to further illustrate the advantages of the present application, the following specific cases are described.

[0113] Case 1: A complete multi-hop question answering scene implementation process

[0114] This case takes multi-hop question answering as an example to illustrate the method flow. Figure 2

[0115] I. Application scenario

[0116] Input question Q: what is the name of virtual individual A's brother? (What is the name of virtual individual A's brother?)

[0117] Knowledge graph (example fragment): ('virtual individual A', 'parents', 'virtual individual B');

[0118] ('virtual individual B', 'children', 'virtual individual D');

[0119] ('virtual individual A','sibling', 'virtual individual E') (Note: This is an interference item).

[0120] II. The specific implementation steps are as follows:

[0121] 1. Step S1: Initialization

[0122] The system receives the question Q and encodes it into a vector ​Meanwhile, the subject entity that is identified as problematic is virtual individual A, and its initial entity state vector is set to 1 in the corresponding position in the vector.

[0123] 2. Steps S2 to S4: Multi-step graph reasoning and relation mask generation

[0124] The system performs a graph reasoning process with a preset maximum hop count T = 2:

[0125] (1) When , the first-hop reasoning:

[0126] a. Starting from virtual individual A, the model calculates the scores of all one-step relations. The relation parents gets a high score (e.g., 0.9) due to its high relevance, and the relation sibling also gets a certain score (e.g., 0.7).

[0127] b. The entity state propagates to virtual individual B and virtual individual E.

[0128] c. Generate step mask mask_1: Since the parents and sibling relations are activated, these two relations are marked as 1 in mask_1.

[0129] d. Update the global mask mask: At this time, the positions of parents and sibling in mask are activated to 1.

[0130] (2) When , the second-hop reasoning:

[0131] a. Starting from the entity activated in the first hop (such as virtual individual B), the model calculates the scores of a new round of relations. The relation children gets a high score (e.g., 0.95).

[0132] b. The entity state further propagates to virtual individual D.

[0133] c. Generate step mask mask_2: The relation children is marked as 1 in mask_2.

[0134] d. Update the global mask mask: At this time, the positions of parents, sibling, and children in mask are all activated to 1.

[0135] 3. Step S5: Adaptive hop count selection

[0136] The original question vector is compared with the final global mask After concatenation, the data is input into the hop count selector model. Since the mask contains information about successful two-hop inference chains (parents->children), the hop count selector model determines that this is a 2-hop problem and outputs the optimal inference hop count K=2.

[0137] 4. Step S6: Inference Path Generation

[0138] Based on the instruction K=2 and the scores during the reasoning process, the system generates and selects the reasoning path P with the highest score:

[0139] Virtual individual A → parents → Virtual individual B → children → Virtual individual D.

[0140] 5. Step S7: Few-sample path guidance

[0141] The system constructs a prompt in the following format, ready to be input into the large language model:

[0142] [The fixed example section contains 3 examples of "question-path-thinking chain-answer"]

[0143] The question is:

[0144] Q: What is the name of virtual entity A's brother?

[0145] K: path1: Virtual individual A -> parents -> Virtual individual B -> children -> Virtual individual D.

[0146] Think about it: The path shows that virtual individual A's parent is virtual individual B, and virtual individual B's child is virtual individual D. Therefore, virtual individual D is virtual individual A's brother. The answer is the entity at the end of the 'children' relation.

[0147] A:

[0148] 6. Step S8: Generate the answer.

[0149] The large language model receives the above prompts, accurately understands the reasoning path based on the logical guidance of the "think" part, and finally generates the answer.

[0150] Final answer A: Virtual individual D.

[0151] Case 2: A complex multi-hop QnA scenario with entity constraints

[0152] This case aims to illustrate the technical effect of the present application when dealing with complex problems with multiple constraints.

[0153] I. Application scenario

[0154] Input question Q: Who is the director of the movie starring virtual individual F that was released in 1994?

[0155] Knowledge graph (example fragment):

[0156] ('Forrest Gump','release_year', '1994');

[0157] ('Forrest Gump','starring', 'virtual individual F');

[0158] ('Forrest Gump', 'directed_by', 'virtual individual G');

[0159] ('Saving Private Ryan','release_year', '1998');

[0160] ('Saving Private Ryan','starring', 'virtual individual F');

[0161] ('Saving Private Ryan', 'directed_by', 'virtual individual H').

[0162] The complexity of this scenario lies in:

[0163] The need to simultaneously satisfy two constraints: "starring virtual individual F" and "release year 1994".

[0164] The reasoning path involves a "actor -> movie -> director" conversion, with the intermediate entity (movie) needing to be filtered.

[0165] II. Specific implementation steps are as follows:

[0166] 1. Step S1: Initialization

[0167] The system receives the question Q and encodes it into a vector The subject entity virtual individual F is identified, while the constraint condition release_year = 1994 is extracted from the question.

[0168] 2. Steps S2-S4: Multi-step graph reasoning and relation mask generation

[0169] The system performs graph reasoning:

[0170] (1) When , the first hop, from actor to movie:

[0171] Starting from virtual individual F, the model activates the inverse relation of the relation starring (starring_of), and the entity state propagates to Forrest Gump and Saving Private Ryan. The starring_of relation in the global mask is activated.

[0172] (2) When , the second hop, from movie to attribute / director:

[0173] Starting from Forrest Gump and Saving Private Ryan, the model activates the release_year relation for verifying the constraint condition, and activates the directed_by relation for answering the question. The release_year and directed_by relations in the global mask are activated.

[0174] 3. Step S5: Adaptive hop count selection

[0175] Multiple relations such as starring_of, release_year, and directed_by are activated in the relation mask, reflecting the complexity of the task. The hop count selector model determines that a hop count of K=2 is needed to fully express the "actor → movie → director" chain, for example.

[0176] 4. Step S6: Reasoning path generation and filtering

[0177] The system generates two candidate paths and filters them using the constraint condition release_year = 1994 extracted in step S1.

[0178] Path 1: Virtual individual F → starring_of → Forrest Gump → directed_by → virtual individual G (satisfies the year constraint, retained);

[0179] Path 2: Virtual Individual F -> starring_of -> Saving Private Ryan -> directed_by -> Virtual Individual H (Does not satisfy the year constraint, discarded) The final optimal path P is path 1.

[0180] 5. Step S7: Few-shot Path Guidance

[0181] System constructs a prompt (Prompt) containing the verification logic:

[0182] The question is:

[0183] Q: Who is the director of the movie starring Virtual Individual F that was released in 1994?

[0184] K: path1: Virtual Individual F -> starring_of -> Forrest Gump -> directed_by -> Virtual Individual G

[0185] think: The path starts with Virtual Individual F. 'Forrest Gump' is a movie starring Virtual Individual F. I need to check if 'Forrest Gump' was released in 1994. Yes, it was. The path then shows that the director of 'Forrest Gump' is Virtual Individual G. This answers the question.

[0186] A:

[0187] 6、Step S8: Generate Answer

[0188] LLM generates the final answer based on the thought chain containing the verification steps.

[0189] Final answer A: Virtual Individual G.

[0190] Example Two: As shown, the present application provides a relationship-driven adaptive knowledge graph question answering and path guidance system, which is used to realize the relationship-driven adaptive knowledge graph question answering and path guidance method of the above-mentioned example one, and specifically comprises: Figure 3

[0191] ​The initialization module 100 is configured to extract a subgraph related to the input question from the knowledge graph, encode the question text into an original question vector using a pre-trained language model, and initialize an entity state vector based on a topic entity in the question.

[0192] The relationship reasoning module 200 is configured to perform multi-step reasoning within a preset maximum reasoning step number, and for each reasoning step, calculate an activation probability of a candidate relationship in the knowledge graph based on a current question vector.

[0193] The relationship mask management module 300 is configured to generate a step-level relationship mask based on the activated relationship of each step, and update a global relationship activation mask.

[0194] The entity state update module 400 is configured to construct a relationship transition matrix based on the activation probability, and update the entity state vector based on the relationship transition matrix.

[0195] The adaptive hop number selection module 500 is configured to concatenate the original question vector and the global relationship activation mask into a fusion feature vector, input the fusion feature vector into a hop number selector model, output a weight distribution of each reasoning step, select a step with the maximum weight as an optimal reasoning hop number, and calculate a final entity score based on the entity state vector.

[0196] The path generation module 600 is configured to select a candidate answer entity based on the final entity score, generate a reasoning path from the topic entity to each candidate answer entity with the optimal reasoning hop number as the maximum reasoning depth, and filter N paths with the highest average relationship score as candidate reasoning paths.

[0197] The path guidance module 700 is configured to construct a prompt containing a fixed number of examples, each example including an original question, a serialized path, a thinking chain, and an answer, and concatenate the examples, a target question, and candidate reasoning paths into an input sequence.

[0198] The answer generation module 800 is configured to input the input sequence into a large language model to obtain a final answer.

[0199] The relationship-driven adaptive knowledge graph question answering and path guiding system of the embodiment is used for realizing the relationship-driven adaptive knowledge graph question answering and path guiding method, and therefore the specific embodiments of the relationship-driven adaptive knowledge graph question answering and path guiding system can be seen from the embodiment part of the relationship-driven adaptive knowledge graph question answering and path guiding method, for example, the initialization module 100, the relationship reasoning module 200, the relationship mask management module 300, the entity state updating module 400, the adaptive hop number selection module 500, the path generation module 600, the path guiding module 700, and the answer generation module 800 are respectively used for realizing steps S1, S2, S3, S4, S5, S6, S7, and S8 in the relationship-driven adaptive knowledge graph question answering and path guiding method, and therefore the specific embodiments can be referred to the description of the respective embodiment part, and to avoid redundancy, details are not described herein.

[0200] Embodiment three: The embodiment of the present application provides an electronic device, the electronic device includes a processor, a memory and a bus system, the processor and the memory are connected through the bus system, the memory is used for storing instructions, and the processor is used for executing the instructions stored in the memory to realize the relationship-driven adaptive knowledge graph question answering and path guiding method.

[0201] Embodiment four: The embodiment of the present application provides a computer storage medium, the computer storage medium stores a computer software product, the computer software product includes a plurality of instructions, so that a computer device executes the relationship-driven adaptive knowledge graph question answering and path guiding method.

[0202] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program codes.

[0203] The present application is described with reference to flowcharts and / or block diagrams according to the method, device (system), and computer program product of the embodiment of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of the flows and / or blocks in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices produce a machine that implements the functions described in the flowcharts and / or block diagrams. Figure 1apparatuses that implement the functions specified in the flowchart(s) or flow diagram(s) and / or block(s). Figure 1

[0204] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flowchart(s) or flow diagram(s) and / or block(s). Figure 1 Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flowchart(s) or flow diagram(s) and / or block(s). Figure 1 Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flowchart(s) or flow diagram(s) and / or block(s).

[0205] Obviously, the above-described embodiments are only examples and are not intended to limit the present application. Based on the above description, those skilled in the art can make other variations and changes to the present application. Here, it is not necessary or possible to exhaust all the embodiments. The obvious changes or variations derived therefrom are still within the scope of the present application.​​​

Claims

1. A relationship-driven adaptive knowledge graph question answering and path guiding method, characterized in that, The method comprises the following steps: extracting a subgraph related to the input question from a knowledge graph, encoding the question text into an original question vector using a pre-trained language model, and initializing an entity state vector based on the subject entity in the question; performing multi-step reasoning within a preset maximum reasoning step number, and for each reasoning step, calculating the activation probability of the candidate relationship in the knowledge graph based on the current question vector; generating a step-level relationship mask based on the activated relationship at each step and updating the global relationship activation mask; constructing a relationship transition matrix based on the activation probability and updating the entity state vector based on the relationship transition matrix; concatenating the original question vector and the global relationship activation mask into a fusion feature vector, inputting the jump number selector model, outputting the weight distribution of each reasoning step, selecting the step with the maximum weight as the optimal reasoning jump number, and calculating the final entity score based on the entity state vector; selecting a candidate answer entity based on the final entity score, generating a reasoning path from the subject entity to each candidate answer entity with the optimal reasoning jump number as the maximum reasoning depth, and selecting the top N paths with the highest average relationship score as candidate reasoning paths; constructing a prompt containing a fixed number of examples, each example including an original question, a serialized path, a thinking chain, and an answer, and concatenating the examples, the target question, and the candidate reasoning paths into an input sequence; inputting the input sequence into a large language model to obtain the final answer. 2.The relationship-driven adaptive knowledge graph question answering and path guidance method of claim 1, wherein, The method further comprises the following steps: Computing attention queries where is a linear projection function, is the original problem vector, is the relational context; Computing word attention weights where is a normalized exponential function, are the hidden states of the th word, respectively; Calculate the first Step Problem Vector ,in Indicates the first The next step of reasoning The weight of each word, Indicates the first The hidden state of each word; Using the first Step problem vector Computing activation probabilities for candidate relations where is a multilayer perceptron, is an activation function. 3.The relationship-driven adaptive knowledge graph question answering and path guidance method of claim 1, wherein, The method further comprises the following steps: Identify all triples whose target entity probability is greater than zero from the knowledge graph, and extract the set of relation indexes in these triples wherein the target entity probability is the product of the subject probability and the relation probability in the triple Generating step-level relationship mask The extracted relationship is marked as 1 in , that is , where , is the relationship index, and is the total number of relationships in the subgraph. Filtering activation probabilities of candidate relations , only keeping the probability value corresponding to the activated relation; Updating global relationship activation masks wherein is a logical OR operation; extracting relation context wherein is a relation feature transformation function for transforming the activation probabilities of the filtered candidate relations into relation context . 4.The relationship-driven adaptive knowledge graph question answering and path guidance method of claim 1, wherein, The method further comprises the following steps: constructing a relation transition matrix , wherein denotes a transition probability from an entity to , denotes an activation probability of the th relation in the th step, is a relation index, denotes a relation index of the entity to the entity , is an activation probability of the candidate relation in the th step, is an entity-relation-entity triple mapping matrix, is the total number of entities in the subgraph; Computing entity state vector wherein is the entity state vector for the step. 5.The relationship-driven adaptive knowledge graph question answering and path guidance method of claim 1, wherein, The method further comprises the following steps: The hop selector model is a multi-layer perceptron , output wherein is a T-dimensional vector representing the weight distribution of each inference step; Selecting optimal inference hop count wherein is the inference weight for the step, is the maximum inference step count; Computing final entity scores wherein is the entity state vector of the step. 6.The relationship-driven adaptive knowledge graph question answering and path guidance method of claim 1, wherein, The method further comprises the following steps: The method further comprises the following steps: For each candidate answer entity, generate a reasoning path from the subject entity to each candidate answer entity, and the path length does not exceed the optimal reasoning jump number K. Calculate the average relationship score of each reasoning path, which is the mean of all relationship activation probabilities in the reasoning path. 7.The relationship-driven adaptive knowledge graph question answering and path guidance method of claim 1, wherein, Select the top N paths with the highest average relationship score for each candidate answer entity as the candidate reasoning paths. The method further comprises the following steps: The fixed number of examples is three, and each example includes an original question, a serialized path, a thinking chain, and an answer. The serialized path uses the "entity→relationship→entity" format. The thinking chain is used to explicitly map the path logic to the answer constraints. Concatenate the examples, the target question, and the candidate reasoning paths in order to form the input sequence.

8. A relation-driven adaptive knowledge graph question answering and path guiding system, characterized in that, The system is used to implement the relationship-driven adaptive knowledge graph question answering and path guiding method according to any one of claims 1 to 7, and specifically comprises: An initialization module configured to extract a subgraph related to an input question from a knowledge graph, encode a question text into an original question vector using a pre-trained language model, and initialize an entity state vector based on a topic entity in the question; A relationship reasoning module configured to perform multi-step reasoning within a preset maximum reasoning step number, and for each reasoning step, calculate an activation probability of a candidate relationship in the knowledge graph based on a current question vector; A relationship mask management module configured to generate a step-level relationship mask based on an activated relationship at each step and update a global relationship activation mask; An entity state updating module configured to construct a relationship transition matrix based on the activation probability and update the entity state vector based on the relationship transition matrix; An adaptive hop number selection module configured to concatenate the original question vector and the global relationship activation mask into a fusion feature vector, input the fusion feature vector into a hop number selector model, output a weight distribution of each reasoning step, select a step with the largest weight as an optimal reasoning hop number, and calculate a final entity score based on the entity state vector; A path generation module configured to select a candidate answer entity based on the final entity score, generate a reasoning path from the topic entity to each candidate answer entity with the optimal reasoning hop number as a maximum reasoning depth, and filter N paths with the highest average relationship scores as candidate reasoning paths; A path guiding module configured to construct a prompt including a fixed number of examples, each example including an original question, a serialized path, a thinking chain, and an answer, and concatenate the examples, a target question, and the candidate reasoning paths into an input sequence; An answer generation module configured to input the input sequence into a large language model to obtain a final answer.

9. An electronic device, comprising: The electronic device includes a processor, a memory, and a bus system, the processor and the memory are connected through the bus system, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to implement the relationship-driven adaptive knowledge graph question answering and path guiding method according to any one of claims 1 to 7.

10. A computer storage medium, characterized in that, The computer storage medium stores a computer software product, the computer software product includes a plurality of instructions to make a computer device execute the relationship-driven adaptive knowledge graph question answering and path guiding method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Knowledge map optimal path query system and method based on depth reinforcement learning

    CN109241291A

  • Large model combined knowledge graph reasoning method for false news detection

    CN120448619A