Knowledge graph retrieval reasoning method and system based on big language model enhancement

By adopting a knowledge graph search inference method enhanced by a large language model in the knowledge graph intelligent question-and-answer system, using entity extraction and hybrid search technology, combined with a width-first traversal algorithm, the shortcomings of the knowledge graph intelligent question-and-answer system in terms of user question flexibility and answer validity are solved, and a higher quality question-and-answer service is achieved.

CN120123487AInactive Publication Date: 2025-06-10CENT SOUTH UNIV +1

Patent Information

Application Number
CN202510614741.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2025-06-10
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The current knowledge graph intelligent question-and-answer system has shortcomings in the flexibility of user questions and the effectiveness of answers, and it is difficult to meet the growing needs of users.

Method used

A knowledge graph retrieval inference method based on large language model enhancement is adopted, and a hybrid search method of entity extraction, fuzzy matching and vector search is combined with a width-first traversal algorithm to construct a prompt template to generate answers to user questions.

Benefits of technology

It improves the performance of the knowledge graph question-and-answer system, realizes accurate understanding and efficient reasoning of user questions, provides higher quality question-and-answer services, and solves the problems of poor user question flexibility and insufficient answer validity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120123487A_ABST
    Figure CN120123487A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of knowledge graph question answering, and discloses a knowledge graph retrieval reasoning method and system based on big language model enhancement, and the method comprises the steps: carrying out the entity extraction of a user question through a big language model, and generating a candidate entity list; retrieving entity nodes corresponding to the candidate entity list in a knowledge graph database through a mixed retrieval method of fuzzy matching and vector retrieval; re-screening the entity nodes by using a large language model to generate a starting node list; performing width-first traversal on each node in the starting node list in an edge-in direction and an edge-out direction, and retrieving a reasoning path in the knowledge graph; constructing the reasoning path into a prompt template, and inputting the prompt template into a large language model to generate an answer to the user question; according to the method, the big language model is utilized to analyze questions and query the knowledge graph in the knowledge graph question-answering scene, question-answering is performed based on the knowledge graph path, and the effectiveness and accuracy of user knowledge graph question-answering are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of knowledge graph question answering, and particularly to a knowledge graph retrieval and reasoning method and system enhanced by a large language model. Background Art

[0002] With the rapid development of artificial intelligence technology, the question answering system, as an interdisciplinary research direction of information retrieval and natural language processing, has received extensive attention. When dealing with natural language questions raised by users, traditional question answering systems often have problems such as inaccurate semantic understanding of questions and unnatural and smooth answers, making it difficult to meet the growing needs of users.

[0003] In recent years, the emergence of large language models (LLMs) such as ChatGPT has brought new opportunities for the development of question answering systems. Large language models perform excellently in understanding and responding to human instructions, can generate relatively natural and smooth answers, and have had a profound impact on natural language question answering. However, large language models also have some limitations. For example, their performance in vertical fields is not ideal. Due to the lack of training for vertical fields, the generated results may lack authenticity and accuracy, and even produce "hallucinated facts". In addition, large language models have high requirements for hardware resources, and the training and deployment costs are relatively large, which limits their application in some scenarios.

[0004] At the same time, as a structured knowledge representation form, the knowledge graph can store and represent rich domain knowledge in the form of a knowledge network composed of elements such as entities, relationships, and attributes, providing accurate and clear knowledge support for question answering systems. Integrating the knowledge graph with the question answering system can effectively improve the performance of the question answering system, help the system better understand the semantics of user questions, and thus give more accurate and valuable answers. However, the early knowledge graph question answering technology was limited by the scale of the knowledge graph, computing power, and natural language processing ability, resulting in low accuracy.

[0005] In order to overcome the respective limitations of large language models and knowledge graph question answering technology and give full play to their advantages, researchers have begun to explore the combination of large language models and knowledge graphs to build a more powerful and intelligent question answering system. At present, although some studies have tried to apply large language models to enhance the performance of knowledge graph question answering, there are still many problems and challenges, such as how to effectively integrate the natural language understanding of large language models and the structured knowledge of knowledge graphs, and how to improve the efficiency of complex reasoning question answering. Therefore, there is an urgent need for a new knowledge graph retrieval and reasoning question answering system enhanced by a large language model, which can make full use of the powerful language understanding and generation capabilities of large language models and the rich structured knowledge of knowledge graphs to achieve accurate understanding and efficient reasoning of user questions, so as to provide higher-quality question answering services. Summary of the Invention

[0006] The present invention provides a knowledge graph retrieval and reasoning method and system enhanced by a large language model to solve the problems of poor flexibility of user questions and insufficient effectiveness of answer responses in the current field of knowledge graph intelligent question answering.

[0007] To achieve the above object, the present invention is implemented through the following technical solutions: In a first aspect, the present invention provides a knowledge graph retrieval and reasoning method enhanced by a large language model, including: Using a large language model to perform entity extraction on a user question to generate a list of candidate entities; Through a hybrid retrieval method of fuzzy matching and vector retrieval, retrieve entity nodes corresponding to the list of candidate entities in a knowledge graph database; Using a large language model to re-screen the entity nodes to generate a list of starting nodes; For each node in the list of starting nodes, perform breadth-first traversal in both the in-edge direction and the out-edge direction to retrieve the reasoning paths in the knowledge graph; Construct the reasoning paths into a prompt template and input it into the large language model to generate an answer to the user question.

[0008] Optionally, the steps of entity extraction specifically include: Construct an entity extraction prompt template, and its template structure satisfies the following relational expression: ; In the formula, is the entity extraction prompt template, is the prompt word, is the input text to be filled; Call the large language model to output a list of candidate entities according to the entity extraction prompt template.

[0009] Optionally, the hybrid retrieval method includes: fuzzy matching and vector retrieval; Fuzzy matching: Use the ik_smart tokenizer to tokenize the entities in the user question and match them with the entity nodes in the knowledge graph database; Vector retrieval: Vectorize the entities in the user question through the paraphrase-MiniLM-L6-v2 model, calculate the cosine similarity between it and the pre-stored entity vectors in the knowledge graph database, and screen the entity nodes with a similarity higher than the threshold. Among them, the calculation of the cosine similarity satisfies the following relational expression: ; In the formula, represents the inner product of vectors, are the vectors and Norm.

[0010] Optionally, use a large language model to re-screen the entity nodes, including: Construct a re-screening prompt template, and its template structure satisfies the following relational expression: ; In the formula, is the re-screening prompt template, is the prompt word containing the screening instruction, is the candidate entity list and the user question text; Call the large language model to output the screened starting node list according to the re-screening prompt template.

[0011] Optionally, the steps of breadth-first traversal specifically include: Initialize the in-edge queue and out-edge queue for each starting node respectively; Process the queue in a loop according to the maximum hop count limit, and query the adjacent nodes of the current node when expanding the path; If the path length does not reach the maximum hop count limit, add the new node to the queue and continue traversing; If the path length reaches the maximum hop count limit, add the path to the result set.

[0012] Optionally, the processing of the queue in a loop according to the maximum hop count limit includes: processing the out-edge queue and processing the in-edge queue; Processing the out-edge queue includes: selecting the out-edge queue node and the path corresponding to the current node from the out-edge queue. If the path length reaches the maximum hop count limit, stop expanding. Otherwise, query the target nodes of all out-edges of the out-edge queue node and the description attributes corresponding to all out-edge target nodes, and call the edge processing method to process the out-edges in the out-edge queue; Processing the in-edge queue includes: selecting the in-edge queue node and the path corresponding to the current node from the in-edge queue. If the path length reaches the maximum hop count limit, stop expanding. Otherwise, query the source nodes of all in-edges of the in-edge queue node and the description attributes corresponding to all in-edge source nodes, and call the edge processing method to process the in-edges in the in-edge queue.

[0013] Optionally, constructing the inference path into a prompt template and inputting it into the large language model to generate the answer to the user question includes: Parse the nodes and edges in the inference path and construct the context containing the path semantics; Input the context as a prompt template into the large language model and predict the answer sequence through the autoregressive generation method.

[0014] Optionally, the parsing of the nodes and edges in the inference path includes: Obtain the nodes and edges in the inference path, and extract the description information of the nodes and edges in the inference path as path information; The constructing the context containing path semantics includes: Construct the parsed path information into the context required by the large language model, where the context includes: the starting node, the target node, the intermediate nodes in the path, and the relationship descriptions between the nodes.

[0015] Optionally, the knowledge graph database is constructed using Neo4j or OrientDB, and the adjacent relationships between entity nodes are stored through a graph structure.

[0016] In a second aspect, an embodiment of the present application provides a knowledge graph retrieval and inference system enhanced based on a large language model, including a processor and a memory; The memory is used to store a computer program; The processor, when executing the program stored on the memory, implements any of the method steps in the first aspect.

[0017] Beneficial effects: The knowledge graph retrieval and inference method enhanced based on the large language model provided by the present invention constructs a prompt template, and performs entity extraction on the user's question according to the scenario requirements; calls a hybrid retrieval method that combines fuzzy matching and vector retrieval implemented based on Elasticsearch; this retrieval method can retrieve the nodes corresponding to the entities in the user's question in the knowledge graph database and output a list of nodes; there may be obviously irrelevant entities among the retrieved knowledge graph entity nodes, and here the large language model is used for further screening, and the breadth-first traversal algorithm is used to traverse the relevant paths one by one for the final entity node list. The breadth-first traversal algorithm performs breadth-first traversals on the in-edge direction and the out-edge direction respectively. After the traversed paths are structurally organized, they form a prompt template and are passed to the large language model, and the large language model generates answers; this solution uses the prompt template to effectively extract entities from the user's input question, uses the hybrid retrieval method for knowledge graph entity alignment retrieval and screening, traverses the adjacent paths in both the out-edge and in-edge directions of the retrieved entity nodes, and finally uses the powerful generation ability of the general large model with a large number of parameters to analyze the relevant inference paths to generate effective answers, and can perform question-answering reasoning for specific scenario requirements, solving problems such as poor flexibility of user questions and insufficient effectiveness of answer responses existing in the current knowledge graph intelligent question-answering field; In a further solution, the retrieval algorithm for the inference path performs a breadth-first traversal of the inference path starting from the starting entity node, considering both incoming edges and outgoing edges. In the first case, all outgoing edge nodes from the starting node are traversed, and the traversed paths are saved in an array, that is, a breadth-first traversal is performed from the starting point for all paths starting from this node. In the second case, all incoming edge nodes are traversed, that is, all paths ending at this node are traversed. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 is a flowchart of a knowledge graph retrieval and inference method based on large language model enhancement according to a preferred embodiment of the present invention; Figure 2 is an optimized recommendation framework diagram according to a preferred embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0019] The technical solutions of the present invention will be described clearly and completely below. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0020] Unless otherwise defined, the technical terms or scientific terms used in the present invention shall have the ordinary meaning understood by those of ordinary skill in the art to which the present invention pertains. The "first", "second" and similar terms used in the present invention do not denote any order, quantity or importance, but are only used to distinguish different components. Similarly, terms such as "a" or "one" do not denote a quantity limitation, but mean that there is at least one. "Connection" or "connected" and similar terms are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right", etc. are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship also changes accordingly.

[0021] Embodiment 1: Please refer to Figure 1 - Figure 2 , in this embodiment, a knowledge graph retrieval and inference method based on large language model enhancement is disclosed, including the following steps: S1: Use a large language model to extract entities from the user's question and generate a list of candidate entities; S2: Through a hybrid retrieval method of fuzzy matching and vector retrieval, retrieve entity nodes corresponding to the candidate entity list in the knowledge graph database; S3: Use a large language model to re-screen the entity nodes and generate a list of starting nodes; S4: For each node in the starting node list, perform breadth-first traversal in both the incoming edge direction and the outgoing edge direction to retrieve the inference paths in the knowledge graph. S5: Construct the inference paths into prompt templates and input them into the large language model to generate answers to user questions.

[0022] Among them, the large language model includes but is not limited to versions of GPT-3, PaLM, LLaMA, Qwen, etc. with more than 1 billion parameters. The inference path traversal algorithm used is a breadth-first traversal algorithm that separately considers the incoming edge direction and the outgoing edge direction. Among them, the outgoing edge traversal of a certain node is a path traversal starting from that node, and the incoming edge traversal of a certain node is a path traversal where the inference path ends at that node.

[0023] The present invention can also use a hybrid retrieval method to find the nodes in the knowledge graph database corresponding to the user question, that is, to align the problem entity with the entities in the knowledge graph database, providing a feasible technical solution for knowledge graph retrieval and reasoning. The knowledge graph can be stored in a dedicated knowledge graph database, such as neo4j and orientdb databases, and the adjacent relationships between nodes are not represented by multi-dimensional arrays.

[0024] Example 2: Example 2 is a preferred example of Example 1. The difference between it and Example 1 is that the specific steps of the knowledge graph retrieval and reasoning method enhanced based on the large language model are expanded: Specifically, in this example, a knowledge graph retrieval and reasoning method enhanced based on the large language model is disclosed. Through techniques such as prompt engineering, generation and vector retrieval of large models, and breadth-first traversal algorithms, it effectively addresses the knowledge graph question and answer scenario to improve the user experience of using the knowledge graph question and answer system.

[0025] In this example, the knowledge graph retrieval and reasoning method enhanced based on the large language model is applied to an actual scenario to display the process details, which specifically includes the following steps: Step 1: Determination of the starting point of the knowledge graph The scenario faced by this example is knowledge graph question and answer. The most crucial thing in knowledge graph question and answer is to retrieve the paths related to the question answer from the knowledge graph. Therefore, the goal of Step 1 of the present invention is to locate the nodes in the knowledge graph from the question, and then retrieve the paths that may help answer the question, so as to improve the accuracy of intelligent answers and the effectiveness of retrieval. In order to be able to retrieve potentially effective inference paths from the knowledge graph database, this example needs to first determine the starting nodes in the knowledge graph. There can be multiple starting nodes, and we can call the path traversal algorithm for each of these starting nodes one by one.

[0026] The method adopted by the present invention to determine the starting node of the knowledge graph is to extract entities from the user question "question", and extract the potentially useful entities from the question, denoted as , where n is the number of entities found in the question. Similar entities are retrieved from the knowledge graph database through the entities in the question, and then the obviously irrelevant entity nodes are removed. The remaining nodes retrieved can be used as the starting nodes for traversing the inference path. For extracting entities from the user question, in this example, a prompt template is constructed, which mainly includes in its structure: prompt words and input text to be filled.

[0027] Prompt words refer to phrases or keywords used to guide the large language model for understanding and generation, including task instructions and expected outputs. In this example, the prompt word part is represented by text. For example, set the task instructions and expected output descriptions "Extract all named entities from the following question, including people, organizations, etc., and only return the entities as a string array in the format of . Do not include any extra words or explanations in your reply. The following is the question for which you are to extract entities." The input text to be filled refers to the original question text of the user, represented by . For example, a sample of the original question text of a user .

[0028] In this example, the prompt template is constructed as: .

[0029] The large language model outputs the extracted entities through the prompt template. For the entities in the extracted question, a hybrid retrieval of fuzzy matching and vector retrieval can be used to retrieve nodes similar to the question entities in the knowledge graph database , where m is the number of nodes retrieved from the database. For fuzzy matching, the ik_smart tokenizer is used to tokenize the input, and then it is matched with the knowledge graph nodes.

[0030] The basic working process of the ik_smart tokenizer is to segment the input text through dictionary matching and the maximum forward matching algorithm, which is especially suitable for dealing with problems such as polyphonic words and ambiguous words in the Chinese language. Suppose the input sentence is , where represents the i-th character in the text. The ik_smart tokenizer matches with the words in the dictionary and uses the maximum forward matching algorithm (MFM) to sequentially find the longest substring that can match the words in the dictionary from left to right, and uses it as a candidate for word segmentation.

[0031] The basic idea of maximum forward matching is to start from the leftmost end of the input text and first match the longest word. If the match is successful, it is segmented into that word; if the match fails, the matching length is continuously reduced until a matching word is found or the match fails.

[0032] Suppose the sentence to be segmented is , whose length is N, and there is a set of words in the dictionary , and each word w belongs to . For each position i: ; The formula shows that each time the algorithm starts from the current position 𝑖 and matches the longest vocabulary to the right until the match is successful.

[0033] For vector retrieval, it is necessary to first use Elasticsearch to pre-store all entity node vectors of the knowledge graph. The vector embedding model uses the paraphrase-MiniLM-L6-v2 model to vectorize the problem entity. For a given entity , this model generates the corresponding vector , and matches the problem entity vector with the node vectors in the database.

[0034] The vectorization process can be expressed as: ; Embed represents the embedding process using the paraphrase-MiniLM-L6-v2 model.

[0035] Vector retrieval retrieves similar nodes through similarity calculation. Specifically, the present invention uses cosine similarity to measure the similarity between the input entity and each node vector in the database. Suppose the node vectors in the database are , then the cosine similarity between the problem entity and the database node can be calculated by the following formula: ; Among them, represents the inner product of vectors, are the norms (i.e., the lengths of the vectors) of vectors and respectively.

[0036] Vector retrieval is performed by calculating the cosine similarity between the input entity and the database node vectors. All the nodes obtained by fuzzy matching and vector retrieval are used for subsequent knowledge graph path traversal.

[0037] It should be noted that among the nodes obtained by hybrid retrieval, there may be nodes that are obviously irrelevant. If these nodes are used for subsequent path traversal, it will cause a relatively high delay. Therefore, the present invention uses a large language model for a re-screening process to finally obtain a list of starting nodes that can be used for inference path traversal. , where k is the number of starting node lists, and prompt words are designed in this re-screening process.

[0038] In this example, the prompt word part is represented by text. For example, set the task instruction and expected output description: = Please retain the entities related to the entities involved in the question from the following entity list and eliminate the entities that are obviously irrelevant to the question. Return these entities in the format of a string array ['', '']. The following is the candidate entity list and the question: The input text to be filled is the original question text of the user, represented by , for example, a list of candidate entities for a user and the question The candidate entity list is..., and the question is how many engines does the Wedgetail early warning aircraft have.

[0039] The prompt template for this example is constructed as: .

[0040] Step 2: Path retrieval based on the knowledge graph The present invention is oriented to the knowledge graph question answering scenario and needs to traverse the paths that may help answer the question based on the starting nodes retrieved in step 1.

[0041] After obtaining the starting node list Ls, the present invention retrieves the inference paths in the knowledge graph by calling the breadth-first search (BFS) algorithm. The specific steps are as follows: 1. Initialize the queue: Initialize two queues for each starting node, which are used to process out-edges and in-edges respectively. Each queue stores the current node name and its path.

[0042] 2. Process the queue in a loop: Process the out-edge queue: Take out the current node and its path from the out-edge queue. If the current path length reaches the maximum hop limit, stop expanding. Otherwise, query the target nodes and their description attributes of all out-edges of the current node, and call the `process_edges` edge processing method to process these out-edges.

[0043] Process the in-edge queue: Take out the current node and its path from the in-edge queue. If the current path length reaches the maximum hop limit, stop expanding. Otherwise, query the source nodes and their description attributes of all in-edges of the current node, and call the `process_edges` method to process these in-edges.

[0044] 3. Process Edges: In the `process_edges` method, batch query all adjacent nodes. Then, based on whether the current path length reaches the maximum hop limit, decide whether to add the path to the result set or continue to expand the path.

[0045] Process Outgoing and Incoming Edges: If the current path length reaches the maximum hop limit, add the path to the result set; otherwise, continue to expand the path and add the new node and its path to the queue.

[0046] 4. Return Results: Finally, return the list of all paths that meet the rules.

[0047] Through the above steps, the present invention can efficiently retrieve the reasoning paths that may contain the answers to the questions in the knowledge graph, providing reasoning path support for subsequent reasoning and analysis.

[0048] Step Three: Inference Generation Based on the Retrieved Paths The model base used in this implementation example is Qwen2.5-7b-Instruct. This model base uses a large-scale Chinese dataset for incremental pre-training and has certain basic Chinese semantic and instruction understanding capabilities, which are suitable for the knowledge graph question-answering scenario faced by the present invention.

[0049] After obtaining the reasoning paths, the process of generating answers by the present invention through the large language model is as follows: 1. Path Parsing: First, parse the obtained reasoning paths. Each path consists of a series of nodes and edges, representing the reasoning process from the starting node to the target node. During the parsing process, extract the description information of the key nodes and edges in the path for subsequent processing.

[0050] 2. Construct Context: Construct the context required by the large language model from the parsed path information. The context includes the starting node, the target node, the intermediate nodes in the path, and their relationship descriptions. By constructing a detailed context, ensure that the large language model can fully understand the semantics of the reasoning path.

[0051] 3. Call the Large Language Model to Obtain Answers: Input the constructed context into the large language model. The large language model generates the answer to the user's question based on the context information. The model infers a logical answer by understanding the relationships between the nodes and edges in the path.

[0052] The process of the large model generating answers is based on an autoregressive model. Its basic idea is to gradually predict individual tokens (usually words or subwords) to form a complete answer through the input prompts or context. In each step of the generation process, the model predicts the next most appropriate token based on the previously generated tokens and the input context information.

[0053] Specifically, the model generation process is conditional: given the input prompt , and the partially generated answer: ; The model will predict the next token based on this information , and the model selects the most appropriate token by maximizing the conditional probability, usually by calculating the probability distribution of the tokens.

[0054] Assume the input is 𝑋, and the model needs to generate an answer sequence , where each is a token (which could be a word or sub - word), and the generation process of the large - model can be expressed as: ; In this formula, the generation process is autoregressive: the generation of each token depends not only on the input context information 𝑋, but also on the previously generated token sequence .

[0055] Through the above steps, the present invention can utilize the large - language model to generate accurate and fluent answers based on understanding the reasoning path of the knowledge graph, providing an intelligent question - answering service for users.

[0056] Step Four: Case Demonstration of the Knowledge Graph Question - Answering Process User's question: "Which company developed the Wedgetail Early Warning Aircraft?".

[0057] Entities extracted from the question: ["Wedgetail Early Warning Aircraft", "company"].

[0058] Similar entity nodes in the database: ['Wedgetail Early Warning Aircraft', 'Tailless', 'ASP Early Warning Aircraft', 'G550 Early Warning Aircraft', 'Magnetic Tail Detection Satellite'] Entity nodes filtered by the large - language model: ['Wedgetail Early Warning Aircraft'] Inference path retrieval: Wedgetail Early Warning Aircraft (equipped with) -> AN / APG - 73 (technical regime) -> continuous wave Wedgetail Early Warning Aircraft (belongs to) -> United States Wedgetail Early Warning Aircraft (equipped with) -> AN / APG - 73 (antenna scanning method) -> manual scanning Wedgetail Early Warning Aircraft (equipped with) -> AN / APG - 73 (pulse width type) -> fixed pulse width Wedgetail Early Warning Aircraft (number of engines) -> twin - engine Wedgetail Early Warning Aircraft (flight speed) -> subsonic.

[0059] Answer generation: "Boeing Company of the United States".

[0060] The embodiment of the present application further provides a knowledge graph retrieval and reasoning system enhanced based on a large language model, including a processor and a memory; The memory is used to store a computer program; The processor is configured to, when executing the program stored on the memory, implement any of the method steps in the knowledge graph retrieval and reasoning method enhanced based on a large language model.

[0061] The above-mentioned knowledge graph retrieval and reasoning system enhanced based on a large language model can implement each of the above-mentioned embodiments of the knowledge graph retrieval and reasoning method enhanced based on a large language model, and can achieve the same beneficial effects, which will not be elaborated here.

[0062] The preferred specific embodiments of the present invention have been described in detail above. It should be understood that those of ordinary skill in the art can make many modifications and variations based on the concept of the present invention without creative efforts. Therefore, any technical solutions that can be obtained by those skilled in the art in the technical field of the present application through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art shall fall within the protection scope determined by the claims.

Claims

1. A knowledge graph retrieval reasoning method based on large language model enhancement, characterized in that: include: Use a large language model to extract entities from user questions and generate a candidate entity list based on the entity extraction results; Retrieving entity nodes corresponding to the candidate entity list in the knowledge graph database through a hybrid retrieval method of fuzzy matching and vector retrieval; Rescreening the entity nodes using a large language model, and generating a starting node list based on the rescreening results; For each node in the starting node list, perform breadth-first traversal in the incoming edge direction and the outgoing edge direction respectively to retrieve the reasoning path in the knowledge graph; The reasoning path is constructed as a prompt template and input into a large language model to generate answers to user questions.

2. The knowledge graph retrieval and reasoning method based on large language model enhancement according to claim 1 is characterized in that: The steps of entity extraction include: Construct an entity extraction prompt template, whose template structure satisfies the following relationship: ; In the formula, Extract hint templates for entities, For the prompt word, The input text to be filled; The large language model is called to output a candidate entity list according to the entity extraction prompt template.

3. The knowledge graph retrieval and reasoning method based on large language model enhancement according to claim 1 is characterized in that: Hybrid retrieval methods include: fuzzy matching and vector retrieval; Fuzzy matching: Use a tokenizer to tokenize entities in user questions and match them with entity nodes in the knowledge graph database; Vector retrieval: The entities in the user's question are vectorized through the model, and the cosine similarity between the vectorized entity vector and the pre-stored entity vector in the knowledge graph database is calculated. The entity nodes with similarity higher than the threshold are screened. The calculation of cosine similarity satisfies the following relationship: ; In the formula, represents the cosine similarity, represents the vector inner product, They are vectors and The norm of .

4. The knowledge graph retrieval and reasoning method based on large language model enhancement according to claim 1 is characterized in that: The entity nodes are re-screened using a large language model, including: Construct a re-screening prompt template, whose template structure satisfies the following relationship: ; In the formula, To re-screen the prompt template, is a prompt word containing a filtering instruction. The candidate entity list and the user question text; The large language model is called to output a filtered starting node list according to the re-filtering prompt template.

5. The knowledge graph retrieval and reasoning method based on large language model enhancement according to claim 1 is characterized in that: The steps of breadth-first traversal include: Initialize the incoming edge queue and outgoing edge queue for each starting node; The queue is processed cyclically according to the maximum hop count limit, and the adjacent nodes of the current node are queried when the path is extended; If the path length does not reach the maximum hop limit, add the new node to the queue and continue traversing; If the path length reaches the maximum hop limit, the path is added to the result set.

6. The knowledge graph retrieval and reasoning method based on large language model enhancement according to claim 5 is characterized in that: The cyclic processing of the queue according to the maximum hop count limit includes: processing the outgoing edge queue and processing the incoming edge queue; Processing the outgoing edge queue includes: selecting the outgoing edge queue node and the path corresponding to the current node from the outgoing edge queue, if the path length reaches the maximum hop limit, then stop expanding, otherwise, query the target nodes of all outgoing edges of the outgoing edge queue node and the description attributes corresponding to the target nodes of all outgoing edges, and call the edge processing method to process the outgoing edges in the outgoing edge queue; Processing the incoming edge queue includes: selecting the incoming edge queue node and the path corresponding to the current node from the incoming edge queue. If the path length reaches the maximum hop limit, stop expanding. Otherwise, query the source nodes of all incoming edges of the incoming edge queue node and the description attributes corresponding to the source nodes of all incoming edges, and call the edge processing method to process the incoming edges in the incoming edge queue.

7. The knowledge graph retrieval and reasoning method based on large language model enhancement according to claim 1 is characterized in that: The reasoning path is constructed as a prompt template and input into a large language model to generate an answer to the user's question, including: Parse the nodes and edges in the reasoning path and build a context containing the path semantics; The context is input into a large language model as a prompt template, and the answer sequence is predicted through autoregressive generation.

8. The knowledge graph retrieval and reasoning method based on large language model enhancement according to claim 7 is characterized in that: The nodes and edges in the analytical reasoning path include: Obtaining nodes and edges in the reasoning path, and extracting description information of the nodes and edges in the reasoning path as path information; The build contains a context for path semantics, including: The parsed path information is constructed into the context required by the large language model, where the context includes: the start node, the target node, the intermediate nodes in the path, and the relationship description between the nodes.

9. The knowledge graph retrieval and reasoning method based on large language model enhancement according to claim 1 is characterized in that: The knowledge graph database is constructed using Neo4j or OrientDB, and the adjacent relationships between entity nodes are stored through a graph structure.

10. A knowledge graph retrieval and reasoning system based on large language model enhancement, characterized in that: Including processor and memory; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 9 when executing a program stored in a memory.

Citation Information

Patent Citations

  • Intelligence intelligent question and answer method based on knowledge graph

    CN115422323A

  • Military question and answer method and system for large language model-driven knowledge graph multi-hop reasoning

    CN118036742A

  • Auxiliary medical management method and system based on natural questions and answers and knowledge graph

    CN118568228A

  • Knowledge retrieval method and device

    CN119202137A

  • Intelligent questioning and answering method, system and equipment for electric power safety knowledge and storage medium

    CN119311818A

Cited By

  • Chemical reaction path reasoning method and device, related equipment and program product

    CN120340650A

  • Industry question and answer enhancement method and system based on multi-dimensional label automatic extraction

    CN120578746A

  • Question answering method and device and storage medium

    CN120579645A

  • A method, device and storage medium for question answering

    CN120579645B

  • Psychological medical map retrieval method based on enhanced large model

    CN120611069A