Industrial knowledge graph completion and adaptive retrieval method based on large language model
By supplementing and adaptive retrieval methods based on the knowledge map based on large language models, the problem of incompleteness and dynamic renewal computing efficiency and real -time insufficient real -time insufficiency of knowledge maps in industrial scenarios are solved. Search, meet the needs of complex queries and dynamic updates.
Patent Information
- Application Number
- CN202411884224.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-12-20
AI Technical Summary
When the prior art deals with incompleteness and dynamic updates of knowledge graphs in industrial scenarios, the computing efficiency and real-time performance are insufficient, and large language models may produce incorrect paths or inaccurate predictions during the inference process, lack of adaptive planning and Self-correction mechanism.
The industrial knowledge graph completion and adaptive retrieval method based on the large language model is used to complete the knowledge graph completion by obtaining the incomplete knowledge graph, dividing the subgraph, selecting the negative sample set, and using question and answer template mapping and LoRA technology to fine-tune the large language model. At the same time, an adaptive retrieval query module and an adaptive planning strategy are designed to dynamically update the subgraphs, reasoning paths and sub-goal states in the memory submodule to achieve real-time updating and self-correction.
It has significantly improved the completion efficiency and retrieval accuracy of the knowledge graph, can quickly adjust the retrieval path, reduce invalid retrieval, improve retrieval efficiency, and adapt to the needs of complex queries and dynamic updates.
Smart Images

Figure CN119336921A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and specifically relates to an industrial knowledge graph completion and adaptive retrieval method based on a large language model. Background Art
[0002] In industrial scenarios, knowledge graphs, as a structured knowledge representation method, are widely used in recommendation systems, semantic search, intelligent question answering and other fields. However, knowledge graphs often have incompleteness problems, and knowledge graph completion technology is needed to predict and add missing entities and relationships. Traditional knowledge graph completion methods mainly rely on graph structure information, such as knowledge graph embedding technology, but these methods have limitations in dealing with sparsity and scalability issues. In recent years, with the development of large language models (LLMs), researchers have begun to explore the use of these models' powerful language understanding and generation capabilities to enhance the completion effect of knowledge graphs. LLMs can learn the semantic information of entities and relationships through context, thereby improving the accuracy of completion. However, existing research still has shortcomings in how to effectively integrate the reasoning ability of LLMs and the structured information of knowledge graphs, especially when dealing with complex queries in industrial scenarios and dynamically updating knowledge graphs, which requires more flexible and adaptive planning methods.
[0003] In addition, existing knowledge graph completion methods face challenges in computational efficiency and real-time performance when processing large-scale and dynamically changing industrial data. At the same time, LLM may produce incorrect paths or inaccurate predictions during reasoning on the knowledge graph, which requires adaptive planning and self-correction mechanisms to dynamically adjust the reasoning strategy. Although some studies have attempted to improve this problem through interactive exploration and iterative reasoning, these methods often lack the ability to effectively identify and correct incorrect reasoning paths. Therefore, how to design a system that can combine the semantic understanding of LLM and the structured information of the knowledge graph, while having adaptive planning and self-correction capabilities, has become a hot topic and challenge in current research. These systems need to be able to dynamically adjust the exploration path according to the semantics of the problem, record and utilize historical reasoning information, and perform self-correction when necessary to improve the efficiency and accuracy of knowledge graph completion and query. Summary of the invention
[0004] In order to solve the shortcomings of the existing technology, improve the integrity and query efficiency of the knowledge graph, and especially improve the ability to process complex queries in industrial scenarios, the present invention adopts the following technical solutions:
[0005] The industrial knowledge graph completion and adaptive retrieval method based on a large language model includes the following steps:
[0006] Step 1: Obtain the incomplete knowledge graph;
[0007] Step 2: Divide the incomplete knowledge graph into multiple subgraphs and select negative sample sets based on the subgraphs. Determine the final information set based on the size of the negative sample set. Use question-answer template mapping to integrate the information into questions and input them into the constructed large language model. After training the large language model, fine-tune the large language model through LoRA technology, change a small number of parameters to adapt to the completion task, and obtain the completed knowledge graph.
[0008] Step 3: Receive the user's query question and perform task decomposition in the adaptive retrieval query module, find the reasoning path in the knowledge graph to extract relevant information, perform entity retrieval and relationship retrieval through the adaptive planning strategy submodule, and update the subgraph, reasoning path and sub-goal status in the memory submodule in real time;
[0009] Step 4: Evaluate the retrieved information to determine whether it meets the user's query requirements and output the final query results.
[0010] Furthermore, the knowledge graph completion in step 2 includes the following steps:
[0011] Step 2.1: Construct a neighborhood subgraph through neighborhood sampling and filter the knowledge graph triples related to a specific relationship, remove the correct triples to obtain a negative sample set;
[0012] Step 2.2: Perform entity pruning and compression on the subgraph formed by extracting relevant information from the neighborhood sampling, remove entities that are more than 5 steps away, and obtain the contextual neighborhood information set;
[0013] Step 2.3: Information merging: The final information set is composed of the adjusted negative sample set and the context neighborhood information set;
[0014] Step 2.4: Use question-answer template mapping to complete the knowledge graph completion task, integrate information into questions, input them into the large language model for training, and obtain the knowledge graph completion large model. Use the knowledge graph completion large model to generate completed triples and merge them back into the knowledge graph to obtain the completed knowledge graph;
[0015] Step 2.5: Use LoRA technology to fine-tune the large language model, adapt it to the task by changing a small number of parameters, reduce resource consumption, and maintain the model's generalization ability.
[0016] Furthermore, in step 2.1, first construct the entity The knowledge graph neighborhood subgraph centered on , Contains all Directly related entities and relationships, then, from Filter out and specific relationship Related triple sets , then, from Remove the correct triples from , get the negative sample set ;
[0017] In step 2.2, (e, r) is used to represent the missing triple, e represents the entity, and r represents the relationship. For each triple in the knowledge graph G, starting from entity e, relevant information is extracted through the neighborhood sampling method to form a subgraph G. e , and prune and compress it, limit the size of the subgraph, remove entities that are more than 5 steps away from e, and define the subgraph:
[0018] G e = {(h, r, t) ∈ G : d(e, h) ≤ 5 ∨ d(e, t) ≤ 5}
[0019] Then, from G e Remove negative samples and generate To distinguish positive and negative samples, for large graphs G, the p parameter is introduced to limit the path depth of the subgraph. C(e, p) represents the contextual neighborhood information set centered on e and with a depth of p. When p=0, C(e, p) is empty; when p=1, only direct neighbors are considered; when p>1, deeper paths are considered. The goal is to accurately obtain and utilize C(e, p) according to the value of p.
[0020] Furthermore, in step 2.3, a negative sample set is extracted from the triplet And the neighborhood information set C(e, p), C(e, p) represents the contextual neighborhood information set with e as the center and depth p, and the number of contextual information sets M is set. For each triplet, the final information set is determined according to the size of the negative sample set: if the size of the negative sample set is greater than or equal to M, M samples are randomly selected from it; if it is less than M, samples are supplemented from the neighborhood information set until the total number reaches M. The final information set D(e, M) includes the adjusted negative sample set and the supplemented neighborhood information set. If the size of the negative sample set has reached M, the neighborhood information set will not be included. This method ensures that the number of information sets meets the requirements while maintaining the diversity and information balance of the data set.
[0021] Furthermore, in step 2.4, for the missing triple (h, r, ?), h represents the subject, and a basic template is constructed. :
[0022]
[0023] For each triple in G, a subgraph set is obtained by subgraph partitioning , for any pair (e, r), we get the corresponding subgraph , Contains negative sample sets Or the neighborhood information set C(e, p), if Not empty, use template Prompt the model to give an answer outside the list to help the model reason, where:
[0024]
[0025] If C(e, p) is not empty, use Provides neighborhood information of e to help the model perform reasoning, where:
[0026]
[0027] Finally, this information is combined into questions , input to the large language model LLM for LoRA fine-tuning training:
[0028]
[0029] Thus, a large model of knowledge graph completion is obtained.
[0030] Furthermore, in step 2.4, in LoRA fine-tuning, the pre-trained weight matrix W is obtained by two small-rank matrices and The product update of , the updated weight is expressed as:
[0031]
[0032] and Updated in fine-tuning, The update rule is:
[0033]
[0034] in, represents the learning rate, L represents the loss function;
[0035] The cross entropy loss function is used to measure the similarity between the predicted entity and the actual entity. The formula is:
[0036]
[0037] in, represents the predicted entity, and A represents the actual entity;
[0038] For a pre-trained large language model M with parameter θ, the training set contains For questions and answers, Represents the training set of the knowledge graph. The goal of fine-tuning is to find the parameters , so that the loss function is minimized:
[0039]
[0040] Among them, M(θ′) represents the model output after fine-tuning, and Q represents the question.
[0041] Furthermore, the adaptive planning strategy in step 3 includes the following steps:
[0042] Step 3.1: Receive the query question raised by the user and decompose the answer task into multiple subtasks; analyze the semantics through the large language model LLM, and subdivide the answer task into multiple subtasks containing specific conditions, including obtaining basic information, analyzing noise characteristics, checking maintenance records, etc. The large language model LLM decomposes the question q into a series of subtasks for retrieving and reasoning the knowledge graph;
[0043] The subtask series is represented as O = {o1, o2, o i , ...}, where O represents the sub-goal set, represents the i-th sub-goal. The sub-tasks in O will refer to each other's results, reflecting the dependencies in the reasoning process;
[0044] Step 3.2: Extract relevant information by searching for reasoning paths in the knowledge graph, focusing on the reasoning paths related to the question. When starting the path exploration, determine the starting points corresponding to the subject entities mentioned in the question. When facing question q, use these subject entities as the starting points of the reasoning paths. In subsequent iterations, focus on the reasoning paths that are more relevant to the question and put aside other paths. The subject entity is the core entity that is most relevant to the query question.
[0045] Step 3.3: Dynamically update the subgraph, reasoning path, and sub-goal status in the memory submodule to reflect the current reasoning progress. The data stored in the memory submodule provides background information of historical retrieval and reasoning for review;
[0046] Since LLM may forget some conditions during reasoning, decomposing the problem to obtain sub-goals helps LLM remember multiple conditions in the problem. The sub-goal status records the latest information related to each sub-goal, assists LLM in remembering the known situation of each condition, and adjusts the exploration direction during reflection. Then, LLM is used to update the information related to the sub-goal to the sub-goal status according to the semantic information of the problem q, the sub-goal O, the historical sub-goal status, the reasoning path P and the knowledge base of LLM. , where S has the same length as O.
[0047] Furthermore, in step 3.2, the initial entity set is as follows:
[0048]
[0049] in, Represents the initial entity set at the beginning of path exploration, represents the set of subject entities associated with question q, Represents a specific entity in the knowledge graph, Indicates the total number of subject entities;
[0050] In the subsequent D-th iteration, each reasoning path Include triples, namely:
[0051]
[0052] express Contains from Start to All triples of and Represent the subject entity and the object entity respectively. express and Since in the Dth round of iteration, only those paths that are most relevant to the problem in the D-1th round are explored, the length of each path is different. The tail entities and relationship sets to be explored are recorded as and , is their length, using the large language model LLM from the current entity set Among the neighboring entities, identify the most relevant entity based on question q. , and use this to expand the reasoning path P.
[0053] Furthermore, in order to cope with the complexity of processing a large number of neighboring entities using a large language model (LLM), an adaptive planning strategy that is not restricted to a fixed number of relations and entities is adopted, which includes a two-step process: relation exploration and entity exploration;
[0054] The relationship exploration is to find The relationships of all tail entities in the search result are collected, and the relationships that are most relevant to the question q and the sub-goal O are selected; first, search and collect The relations of all tail entities in form a candidate relation set , and use these relations to expand the reasoning path to form a set of candidate reasoning paths ; Then, based on the semantics and tail entity of question q , candidate relationship and sub-goal O, using LLM from Filter out the relationship with the tail entity The matching relevant reasoning path P;
[0055] The entity exploration is to use and To retrieve surrounding entities and find entities closely related to question q; in the relationship exploration stage, the extended reasoning path P and the new tail relationship are obtained. ; For each path in P , by querying or To obtain the candidate entity set , here and yes In the face of many candidate entities, a pre-trained small model is used to calculate the similarity between the entity and the question to improve the recall rate; then, all candidate entities are combined into , and use these entities to expand P to , in the candidate reasoning path Based on the semantic information of question q and , and The knowledge triples formed by Filter out the tail entity The matching relevant reasoning path P.
[0056] Furthermore, in step 3.3, after two rounds of exploration, the subgraph in memory is dynamically updated. , reasoning path P and sub-goal state S to reflect the current reasoning progress; the subgraph brings together all relations and entities retrieved from the knowledge graph, and its update helps the subsequent self-correction and determines the correct entity to fall back to; in the Dth round of iteration, by adding the candidate relation set and candidate entity sets To refresh the sub-image ,In order for LLM to better understand the relationship between entities and perform path correction, the reasoning path P is updated to maintain the semantic connection within the knowledge graph.
[0057] The advantages and beneficial effects of the present invention are:
[0058] The present invention can significantly improve the completion efficiency and retrieval accuracy of knowledge graphs in industrial scenarios. By utilizing the powerful semantic understanding and generation capabilities of the large language model (LLM), it can effectively predict and complete the missing information in the knowledge graph and enhance the integrity of the knowledge graph. In addition, the adaptive path retrieval and memory update mechanism further enhances the flexibility and accuracy of the system, enabling the retrieval path to be quickly adjusted in the face of complex queries, reducing invalid retrieval and improving retrieval efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 is a flow chart of a method in an embodiment of the present invention.
[0060] Figure 2 It is a structural diagram of a knowledge graph completion module based on a large model in an embodiment of the present invention.
[0061] Figure 3 It is a schematic diagram of the structure of the adaptive search query module in an embodiment of the present invention. DETAILED DESCRIPTION
[0062] The specific implementation of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the present invention, and is not used to limit the present invention.
[0063] like Figure 1 As shown, the industrial knowledge graph completion and adaptive retrieval method based on a large language model of the present invention includes the following steps:
[0064] Step 1: Input the incomplete knowledge graph G=(E,T), where E is the entity set and T is the triple set.
[0065] The knowledge graph (KG) consists of three main parts: G = {E, R, T}. E represents the entity set, covering different individuals such as people, places, and equipment; R represents the relationship set, including various connections between entities, such as "failure cause" and "solution"; T is a triple set in the form of:
[0066] {(h, r, t) | h∈E, r∈R, t∈E},
[0067] Among them, h, r, and t refer to the subject, relation, and object in the triple respectively. In a given knowledge graph G, the training set consists of The validation set consists of three tuples, and the validation set consists of T valida The test set consists of three tuples, test In particular, T valida and T test The subgraph information in is based on Generated. In the link prediction task, each triple needs to be predicted bidirectionally, that is, predicting the missing subject (h, r, ?) and the missing object (?, r, t). These two types of missing triples are simplified as (e, r), where e is the known subject or object and r is the relationship between them. It is the combination of all these parts. ,in .
[0068] The input incomplete knowledge graph G=(E, T), where E is the entity set and T is the triple set.
[0069] Step 2: Build a knowledge graph completion module based on the large model, and divide the incomplete knowledge graph into multiple subgraphs through the subgraph partitioning module. Determine the final information set D(e,M) based on the size of the negative sample set, design the question-answer template mapping, and use the LoRA technology to fine-tune the large model to complete the knowledge graph completion. Figure 2 As shown in the figure, knowledge graph completion includes the following steps:
[0070] Step 2.1: Negative sample filtering: Use the neighborhood sampling technique to construct a neighborhood subgraph and filter the set of triples related to a specific relationship, remove the correct triples to obtain the negative sample set;
[0071] Generate negative sample set , in order to ensure that there is no information leakage between the training set and the test set, and to more accurately evaluate the generalization ability of the model. First, we construct The neighborhood subgraph centered on , including all directly related entities and relationships. Then, from Filter out and specific relationship Related triple sets . Then, from Remove the correct triples from , get the negative sample set .
[0072] Step 2.2: Neighborhood information pruning: extract relevant information through neighborhood sampling method to form a subgraph, prune and compress it, remove entities that are more than 5 steps away, and obtain the contextual neighborhood information set;
[0073] Let (e, r) represent the missing triple. For each triple in G, starting from entity e, extract relevant information through neighborhood sampling method to form a subgraph G e , and prune and compress it. Limit the size of the subgraph and remove entities that are more than 5 steps away from e. Subgraph definition:
[0074] G e= {(h, r, t) ∈ G : d(e, h) ≤ 5 ∨ d(e, t) ≤ 5}
[0075] Then, from G e Remove negative samples and generate , to distinguish positive and negative samples. For large graphs G, the p parameter is introduced to limit the path depth of the subgraph. C(e, p) represents the contextual neighborhood information set centered on e and with a depth of p. When p=0, C(e, p) is empty; when p=1, only direct neighbors are considered; when p>1, deeper paths are considered. The goal is to accurately obtain and utilize C(e, p) according to the value of p.
[0076] Step 2.3: Information merging: The final information set is composed of the adjusted negative sample set and the context neighborhood information set;
[0077] Synthesize the final information set and extract the negative sample set from the triplet And the neighborhood information set C(e, p), C(e, p) represents the contextual neighborhood information set centered on e and with a depth of p, and the number of contextual information sets M is set. For each triple, the final information set is determined according to the size of the negative sample set: if the size of the negative sample set is greater than or equal to M, M samples are randomly selected from it; if it is less than M, samples are supplemented from the neighborhood information set until the total number reaches M. The final information set D(e,M) includes the adjusted negative sample set and the supplemented neighborhood information set. If the size of the negative sample set has reached M, the neighborhood information set will not be included. This method ensures that the number of information sets meets the requirements while maintaining the diversity and information balance of the data set.
[0078] Step 2.4: Use question-answer template mapping to complete the knowledge graph completion task, integrate information into questions, input them into the large language model for training, and obtain the knowledge graph completion large model. Use the knowledge graph completion large model to generate completed triples and merge them back into the knowledge graph to obtain the completed knowledge graph. The training of the large language model uses LoRA fine-tuning technology to adapt to the task by changing a small number of parameters, reducing resource consumption and maintaining the model's generalization ability.
[0079] For the missing triples (h, r, ?), a basic template is designed :
[0080]
[0081] For each triple in G, a subgraph set is obtained by subgraph partitioning For any pair (e, r), we get the corresponding subgraph , which contains the negative sample set Or the neighborhood information set C(e, p). If Not empty, use Prompt the model to give an answer outside the list to help the model reason.
[0082]
[0083] If C(e, p) is not empty, use Provides neighborhood information of e to help the model perform reasoning.
[0084]
[0085] Finally, this information is integrated into questions and input into LLM for LoRA fine-tuning training:
[0086]
[0087] Thus, a large model of knowledge graph completion is obtained.
[0088] Step 2.5: Use LoRA technology to fine-tune the large language model, adapt to the task by changing a small number of parameters, reduce resource consumption, and maintain the model's generalization ability;
[0089] LoRA fine-tuning large model, instruction-based fine-tuning is a training method to optimize the performance of large language models on specific tasks. As an efficient fine-tuning technique, LoRA adapts to tasks by changing a small number of parameters, reducing resource consumption while maintaining the generalization ability of the model. In LoRA fine-tuning, the pre-trained weight matrix W is obtained by two small-rank matrices and The product update of , the updated weight is expressed as:
[0090]
[0091] and Updated in fine-tuning, The update rule is:
[0092]
[0093] in, is the learning rate and L is the loss function.
[0094] The cross entropy loss function is used to measure the similarity between the predicted entity and the actual entity. The formula is:
[0095]
[0096] in, represents the predicted entity and A represents the actual entity.
[0097] For a pre-trained large language model M with parameter θ, the training set contains For questions and answers. The goal of fine-tuning is to find the parameters , so that the loss function is minimized:
[0098]
[0099] Where M(θ′) is the model output after fine-tuning and Q represents the question.
[0100] Step 3: Receive the user's question and perform task decomposition in the adaptive retrieval query module. After entity exploration and relationship exploration through the adaptive planning strategy submodule, update the subgraph, reasoning path and sub-goal status in the memory submodule. Evaluate the performance and output the query results. According to the results of task decomposition, adaptively retrieve entities and relationships related to the question. Update the memory submodule and record the current retrieval progress and sub-goal status. Figure 3 As shown, the specific implementation of the adaptive retrieval query module includes the following steps:
[0101] Step 3.1: Receive the query question raised by the user and decompose the answer task into multiple subtasks. LLM analyzes semantics to subdivide the answer task into multiple subtasks with specific conditions, including obtaining basic information, analyzing noise characteristics, checking maintenance records, etc. LLM decomposes the question q into a series of subtasks for retrieving and reasoning about the knowledge graph. The subtask series is represented as O = {o1, o2, o3, ...}. Where O represents the sub-goal set, represents the i-th sub-goal. The sub-tasks in O will refer to each other's results, reflecting the dependencies in the reasoning process.
[0102] Step 3.2: Extract relevant information by searching for reasoning paths in the knowledge graph, focusing on the reasoning paths related to the question. When starting the path exploration, determine the starting points corresponding to the subject entities mentioned in the question. Faced with question q, use these subject entities as the starting points of the reasoning path, recorded as:
[0103]
[0104] in, Represents the initial entity set at the beginning of path exploration, represents the set of subject entities associated with question q, Represents a specific entity in the knowledge graph, The total number of subject entities.
[0105] In subsequent iterations, focus on the reasoning paths that are more relevant to the problem and put aside other paths. For example, in the Dth iteration, each reasoning path Include triples, namely:
[0106]
[0107] in, and Representing subject and object entities respectively, is the specific relationship between them. Since in the Dth round of iteration, only those paths that are most relevant to the problem in the D-1th round are explored, the length of each path is different. The tail entity and relationship set to be explored are respectively denoted as and , is their length. Use LLM to extract the Among the neighboring entities, identify the most relevant entity based on question q. , and use this to expand the reasoning path P. In order to cope with the complexity of using LLM to handle a large number of neighboring entities, an adaptive planning strategy that is not restricted to a fixed number of relations and entities is proposed. The strategy includes a two-step process: relation exploration and entity exploration.
[0108] Relationship exploration is about finding The relationships of all tail entities in the search result are searched, and the relationships that are most relevant to the question q and the sub-goal O are selected. The relations of all tail entities in form a candidate relation set , and use these relations to expand the reasoning path to form a set of candidate reasoning paths Next, based on the semantics of question q, the tail entity , candidate relationship and sub-goal O, using LLM from Filter out the relationship with the tail entity The matching relevant reasoning path P.
[0109] Entity exploration is the use of and To retrieve surrounding entities and find entities closely related to question q. In the relationship exploration phase, the extended reasoning path P and the new tail relationship are obtained. For every path in P , by querying or To obtain the candidate entity set , here and yes In the face of many candidate entities, a pre-trained small model is used to calculate the similarity between the entity and the question to improve the recall rate. After that, all candidate entities are combined into , and use these entities to expand P to In the candidate reasoning path Based on the semantic information of question q and , and The knowledge triples formed by Filter out the tail entity The matching relevant reasoning path P.
[0110] Step 3.3: Dynamically update the subgraph, reasoning path, and subgoal status in memory to reflect the current reasoning progress. The data stored in memory provides background information for historical retrieval and reasoning. After two rounds of exploration, the subgraph in memory is dynamically updated. , reasoning path P and sub-goal state S to reflect the current reasoning progress.
[0111] The subgraph brings together all the relations and entities retrieved from the knowledge graph, and its update helps in subsequent self-correction and determines the correct entity to fall back to. In the Dth iteration, by adding the candidate relation set and candidate entity sets To refresh the sub-image In order to enable LLM to better understand the relationship between entities and perform path correction, the reasoning path P is updated to maintain the semantic connection within the knowledge graph.
[0112] Since LLM may forget some conditions during reasoning, decomposing the problem to obtain sub-goals helps LLM remember multiple conditions in the problem. The sub-goal status records the latest information related to each sub-goal, assisting LLM to remember the known situation of each condition and adjust the exploration direction during reflection. Then, LLM is used to update the information related to the sub-goal to the sub-goal status based on the semantic information of the problem q, sub-goal O, historical sub-goal status, reasoning path P and LLM's knowledge base. , where S has the same length as O.
[0113] Step 4: Evaluate the retrieved information to determine whether it meets the user's query requirements. Output the final query results and provide them to the user.
[0114] Step 4.1: Evaluate whether the information collected so far is sufficient to derive the answer. If the information is sufficient, combine the reasoning path, sub-goal status and its knowledge base to give the answer;
[0115] After completing path exploration and memory updating, LLM evaluates whether the information collected so far, including the stored sub-goal states and reasoning paths, is sufficient to deduce the answer, e.g. Figure 3 As shown, the specific implementation of the reflection and self-correction module includes the following steps:
[0116] If LLM deems the information sufficient, it will combine the reasoning path, sub-goal status and its knowledge base to give an answer.
[0117] If the information is insufficient, the existing path needs to be further extended or the current path may be wrong.
[0118] Since the reasoning ability of LLM cannot always guarantee the correctness of path exploration, a reflection mechanism is designed to determine whether and how to correct the reasoning path: when LLM feels that the information is insufficient, it enters the reflection stage and uses LLM to retrieve entities based on question q, sub-goal status S, reasoning path P, and the next round of planned retrieval. To consider whether to adjust the exploration direction, LLM needs to provide reasons for reflection. If there are entities other than The tail entity in S is explored along the current path. In the self-correction process, LLM decides to search for the tail entity in S according to the sub-goal status in S and the additional retrieval reasons obtained through reflection. Which entities are traced back to in Added new exploration entities To perform self-correction, expressed as .
[0119] Step 4.2: Output the query results based on the retrieved information. If the information is insufficient, enter the reflection stage to consider whether to adjust the exploration direction. If necessary, make self-corrections and continue to explore or correct the reasoning path.
[0120] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. Industrial knowledge graph completion and adaptive retrieval method based on large language model, characterized by The steps include: Step 1: Obtain the incomplete knowledge graph; Step 2: Divide the incomplete knowledge graph into multiple subgraphs and select negative sample sets based on the subgraphs. Determine the final information set based on the size of the negative sample set. Use question-answer template mapping to integrate the information into questions and input them into the constructed large language model. The large language model is trained and fine-tuned to change a small number of parameters to adapt to the completion task, and the completed knowledge graph is obtained. Step 3: Receive the user's query question, decompose the task, find the reasoning path in the knowledge graph to extract relevant information, perform entity retrieval and relationship retrieval through adaptive planning strategy, and update the subgraph, reasoning path and sub-goal status in real time; Step 4: Evaluate the retrieved information to determine whether it meets the user's query requirements and output the final query results.
2. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 1, characterized in that: The knowledge graph completion in step 2 includes the following steps: Step 2.1: Construct a neighborhood subgraph through neighborhood sampling and filter the knowledge graph triples related to a specific relationship, remove the correct triples to obtain a negative sample set; Step 2.2: Perform entity pruning and compression on the subgraph formed by extracting relevant information from the neighborhood sampling to obtain the contextual neighborhood information set; Step 2.3: Information merging: The final information set is composed of the adjusted negative sample set and the context neighborhood information set; Step 2.4: Use question-answer template mapping to complete the knowledge graph completion task, integrate information into questions, input them into the large language model for training, and obtain the knowledge graph completion large model. Use the knowledge graph completion large model to generate completed triples and merge them back into the knowledge graph to obtain the completed knowledge graph; Step 2.5: Use LoRA technology to fine-tune the large language model to adapt it to the task by changing a small number of parameters.
3. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 2 is characterized by: In step 2.1, first construct the entity The knowledge graph neighborhood subgraph centered on , Contains all Directly related entities and relationships, then, from Filter out and specific relationship Related triple sets , then, from Remove the correct triples from , get the negative sample set ; In step 2.2, (e, r) is used to represent the missing triple, e represents the entity, and r represents the relationship. For each triple in the knowledge graph G, starting from entity e, relevant information is extracted through the neighborhood sampling method to form a subgraph G. e , and prune and compress it to limit the size of the subgraph; then, from G e Remove negative samples and generate , C(e, p) represents the contextual neighborhood information set centered on e and with a depth of p.
4. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 2 is characterized by: In step 2.3, a negative sample set is extracted from the triplet And the neighborhood information set C(e, p), C(e, p) represents the contextual neighborhood information set centered on e and with a depth of p, and sets the number of contextual information sets M. For each triplet, the final information set is determined according to the size of the negative sample set: if the size of the negative sample set is greater than or equal to M, M samples are randomly selected from it; If it is less than M, samples are supplemented from the neighborhood information set until the total number reaches M. The final information set D(e,M) includes the adjusted negative sample set and the supplemented neighborhood information set. If the size of the negative sample set has reached M, the neighborhood information set will not be included.
5. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 2 is characterized by: In step 2.4, for the missing triple (h, r, ?), h represents the subject, and the basic template is constructed ; For each triple in G, obtain a subgraph set by subgraph partitioning , for any pair (e, r), we get the corresponding subgraph , Contains negative sample sets Or the neighborhood information set C(e, p), if Not empty, use template Prompt the model to give an answer outside the list; if C(e, p) is not empty, use Provide neighborhood information of e; Finally, this information is combined into questions , input into the large language model to obtain the knowledge graph completion large model.
6. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 2 is characterized by: In step 2.4 of LoRA fine-tuning, the pre-trained weight matrix W is obtained by two small-rank matrices and The product update of , the updated weight is expressed as: , and Updated in fine-tuning, The update rule is: , in, represents the learning rate, L represents the loss function; The cross entropy loss function is used to measure the similarity between the predicted entity and the actual entity. The formula is: , in, represents the predicted entity, and A represents the actual entity; For a pre-trained large language model M with parameter θ, the training set contains For questions and answers, Represents the training set of the knowledge graph. The goal of fine-tuning is to find the parameters , so that the loss function is minimized: , Among them, M(θ′) represents the model output after fine-tuning, and Q represents the question.
7. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 1, characterized in that: The adaptive planning strategy in step 3 includes the following steps: Step 3.1: Receive the query question raised by the user and decompose the answer task into multiple subtasks; analyze the semantics through the large language model and subdivide the answer task into multiple subtasks containing specific conditions; The subtask series is represented as O = {o1, o2, o i , ...}, where O represents the sub-goal set, represents the i-th sub-goal. The sub-tasks in O will refer to each other's results, reflecting the dependencies in the reasoning process; Step 3.2: Extract relevant information by searching for reasoning paths in the knowledge graph, focusing on the reasoning paths related to the question. When starting the path exploration, determine the starting points corresponding to the subject entities mentioned in the question. When facing question q, use these subject entities as the starting points of the reasoning paths. In subsequent iterations, focus on the reasoning paths that are more relevant to the question and put aside other paths. The subject entity is the core entity that is most relevant to the query question. Step 3.3: Dynamically update the subgraph, reasoning path, and sub-goal status in the memory submodule to reflect the current reasoning progress.
8. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 7 is characterized by: In step 3.2, the initial entity set is as follows: , in, Represents the initial entity set at the beginning of path exploration, represents the set of subject entities associated with question q, Represents a specific entity in the knowledge graph, Indicates the total number of subject entities; In the subsequent D-th iteration, each reasoning path Include triples, namely: , express Contains from Start to All triples of and Represent the subject entity and the object entity respectively. express and Since in the Dth round of iteration, only those paths that are most relevant to the problem in the D-1th round are explored, the length of each path is different. The tail entities and relationship sets to be explored are recorded as and , is their length, using the large language model from the current entity set Among the neighboring entities, identify the most relevant entity based on question q. , and use this to expand the reasoning path P.
9. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 8, characterized in that: Adopting an adaptive planning strategy that is not restricted to a fixed number of relations and entities, it includes a two-step process: relation exploration and entity exploration; The relationship exploration is to find The relationships of all tail entities in the search result are collected, and the relationships that are most relevant to the question q and the sub-goal O are selected; first, search and collect The relations of all tail entities in form a candidate relation set , and use these relations to expand the reasoning path to form a set of candidate reasoning paths ; Then, based on the semantics and tail entity of question q , candidate relationship and sub-goal O, using LLM from Filter out the relationship with the tail entity The matching relevant reasoning path P; The entity exploration is to use and To retrieve surrounding entities and find entities closely related to question q; in the relationship exploration stage, the extended reasoning path P and the new tail relationship are obtained. ; For each path in P , by querying or To obtain the candidate entity set , here and yes The tail entities and relations in the ; then, all candidate entity sets are merged into , and use these entities to expand P to , in the candidate reasoning path Based on the semantic information of question q and , and The knowledge triples formed by Filter out the tail entity The matching relevant reasoning path P.
10. The industrial knowledge graph completion and adaptive retrieval method based on a large language model according to claim 9, characterized in that: In step 3.3, after exploration, the subgraph in memory is dynamically updated , reasoning path P and sub-goal state S; In the Dth iteration, by adding the candidate relationship set and candidate entity sets To refresh the sub-image , update the reasoning path P to maintain the semantic connection within the knowledge graph.
Citation Information
Patent Citations
Information retrieval optimization method and system based on small sample knowledge graph completion
CN116955650A
Knowledge graph generation type question answering method and system based on large language model
CN117033608A
Military question and answer method and system for large language model-driven knowledge graph multi-hop reasoning
CN118036742A
Knowledge graph completion method
CN119150975A
Composite symbolic and non-symbolic artificial intelligence system for advanced reasoning and semantic search
US20240386015A1
Cited By
Personalized voice question and answer method and device based on large model and refrigeration equipment
CN119832914A
Intelligent dialogue system for time sequence memory management and task distribution
CN120086338A
Activity assessment method for factual knowledge question, product, equipment and medium
CN120180060A
Power system data retrieval method and system based on knowledge graph and comparative learning
CN121051137A
Inference method, system and equipment of wide constraint large language model and medium
CN121146067A