A large model reasoning method and device based on knowledge graph retrieval enhancement

By decomposing complex problems in large language models, searching and scoring evidence subgraphs in the knowledge graph, converting triples into text evidence, and combining multi-task instruction fine-tuning technology and regression scoring machine, the big model is solved in knowledge-intensive type The hallucination phenomena and complex multi-hop questions in the task were answered with insufficient ability, achieving more accurate knowledge integration and question answering.

CN118939783BActive Publication Date: 2025-02-07HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411429185.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2025-02-07
Estimated Expiration
2044-10-14

AI Technical Summary

Technical Problem

In the prior art, when using large language models for knowledge-intensive tasks, there is hallucination phenomenon, and it is difficult to effectively combine external knowledge to answer complex multi-hop questions.

Method used

By breaking complex problems into multiple subproblems, searching in the knowledge graph, and scoring and pruning the retrieved evidence subgraphs, converting triples into smooth text evidence, combining multitasking instruction fine-tuning techniques and regression Scorer to enhance the knowledge retrieval and reasoning skills of large models.

Benefits of technology

实现了大模型在知识密集型任务中更准确地结合外部知识,减少了错误的积累,提高了对复杂多跳问题的回答能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939783B_ABST
    Figure CN118939783B_ABST
Patent Text Reader

Abstract

The present invention provides a large model reasoning method and device based on knowledge graph retrieval enhancement, which relates to the field of natural language processing technology. The method includes: using ChatGPT to generate a multi-instruction fine-tuning data set; according to the multi-instruction fine-tuning data set, autoregressive training is performed on the large language model to obtain a fine-tuned large language model; based on the knowledge graph, according to the knowledge-intensive query and the knowledge entity set, iterative reasoning is performed through the fine-tuned large language model to obtain the first evidence subgraph; based on the regression scorer and the preset score threshold, the first evidence subgraph is pruned to obtain the second evidence subgraph; based on the second prompt template, according to the second evidence subgraph and the knowledge-intensive query, the fine-tuned large language model is used to perform joint reasoning to obtain the query reasoning result. The present invention is a large model reasoning method based on knowledge graph enhancement that effectively combines external knowledge and accurately answers complex multi-hop questions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and in particular to a large model reasoning method and device based on knowledge graph retrieval enhancement. Background Art

[0002] Knowledge-intensive tasks (KITs) refer to tasks that require a lot of expertise, information processing, and comprehension. Knowledge-intensive tasks often involve complex decision-making, in-depth analysis, creative thinking, or advanced problem-solving skills. In the field of natural language processing, knowledge-intensive tasks specifically refer to those tasks that require understanding and utilizing a wide range of background knowledge, facts, and information to generate accurate, relevant, and in-depth outputs. At a time when large language models (LLMs) are developing in full swing, large language models have demonstrated very powerful semantic understanding and text generation capabilities. How to use large language models for knowledge-intensive tasks is also a very challenging topic. Given the evolving nature of real-world knowledge, LLMs often show limitations in domain-specific expertise or constantly updated knowledge. This deficiency often leads to hallucinations in their responses, where the generated content deviates significantly from factual accuracy.

[0003] In order to alleviate the hallucination problem of LLMs in knowledge-intensive tasks, some researchers have combined LLMs with external knowledge sources, such as knowledge graphs (KGs), to enhance knowledge question answering tasks, taking the knowledge graph question answering task (KGQA) as an example. This enhancement process usually involves retrieving factually relevant knowledge from a wide range of knowledge bases to assist LLMs in constructing answers that rely on this externally retrieved information.

[0004] However, there are still several shortcomings of the public solutions. The existing technologies have limited ability to accurately handle complex queries, including queries that require multi-hop reasoning or understand negation. In black-box testing on proprietary models such as ChatGPT, in-context learning (ICL) techniques are often used, where external knowledge is directly incorporated into the prompt to guide the model's response generation. Although these training-free methods make the integration of external knowledge possible, they do not enhance the interaction between LLMs and knowledge graphs, but instead limit the potential of LLMs to efficiently acquire and deploy knowledge, especially when supervisory signals are available.

[0005] Knowledge graphs organize the relationships between entities in a structured manner. Using KG retrieval to enhance LLMs has been shown to be effective in alleviating the phenomenon of hallucination. There is an increasing number of studies on KG retrieval, which can be roughly divided into two approaches. Semantic parsing-based methods encode the input question, convert it into a logical form, and perform retrieval on the KG. For example, Semantic Structure based Query Graph Prediction for Question Answering over Knowledge Graph (SSKGQA) uses natural language questions to generate query graphs, trying to use the semantic structure of the questions to eliminate incorrect query graph structures; Rank-and-Generate approach for Knowledge Base Question Answering (RnG-KBQA) introduces a ranking and generation framework, which ranks candidate logical forms from questions and generates the final logical form based on the top k candidates. However, these methods require the generation of executable SPARQL statements and additional label information.

[0006] Based on information retrieval methods, PullNet (Open Domain Question Answering with Iterative Retrieval on Knowledge Bases and Text) extracts subgraphs of the KG starting from the subject entity and uses graph neural networks to predict entity answers in the subgraph. Universal Knowledge Question Answering (UniK-QA) is based on the Seq2Seq framework, which retrieves triples from the knowledge graph and combines them with the question to generate answers. Nevertheless, this approach relies on the accuracy of the retrieved subgraphs or triples. A knowledge graph retrieval framework (Direct Fact Retrieval, DiFaR) improves retrieval accuracy by exploiting the representation similarity between queries and triples, but encounters difficulties in handling complex multi-hop questions and answers (QA).

[0007] An increasing number of studies have been devoted to leveraging the reasoning capabilities of LLMs to solve the Knowledge Graph Question Answering (KGQA) problem. Knowledge-Augmented language model PromptING (KAPING) and a combination of knowledge graph and large language model (KGGPT) prompt LLMs to generate answers by placing retrieved triples in predefined prompts. However, they ignore that the triples retrieved by KGs are not in the form of natural language text, which increases the difficulty of reasoning for LLMs. Retrieve-Rewrite-Answer addresses this issue by introducing a pre-training task and fine-tuning open-source LLMs on a KGs-to-text corpus, converting text in triple form into free-form text that is easier for LLMs to understand. Nevertheless, the above methods do not filter the extracted triples. This oversight may lead to irrelevant information being fed into LLMs, misleading them to generate incorrect results.

[0008] In the existing technology, there is a lack of a large-model reasoning method based on knowledge graph enhancement that can effectively combine external knowledge and accurately answer complex multi-hop questions. Summary of the invention

[0009] In order to solve the technical problem that the existing technology introduces additional noise, causes the accumulation of errors, and hinders the large language model from effectively combining external knowledge when answering complex multi-hop questions, the embodiment of the present invention provides a large model reasoning method and device based on knowledge graph retrieval enhancement. The technical solution is as follows:

[0010] On the one hand, a large model reasoning method based on knowledge graph retrieval enhancement is provided, the method is implemented by a large model reasoning device, and the method includes:

[0011] Inserting the task instruction prompt text into the first prompt template to obtain a first text prompt; generating corpus using ChatGPT according to the first text prompt to obtain a knowledge-driven multi-instruction fine-tuning dataset;

[0012] According to the multi-instruction fine-tuning dataset, autoregressive training is performed on the large language model to obtain a fine-tuned large language model;

[0013] Acquire a knowledge-intensive query and a corresponding knowledge entity set; based on the knowledge graph, perform iterative reasoning through the fine-tuned large language model according to the knowledge-intensive query and the knowledge entity set to obtain a first evidence subgraph;

[0014] Based on the regression scorer and a preset score threshold, pruning the first evidence subgraph to obtain a second evidence subgraph;

[0015] Based on the second prompt template, according to the second evidence subgraph and the knowledge-intensive query, joint reasoning is performed through the fine-tuned large language model to obtain a query reasoning result.

[0016] On the other hand, a large model reasoning device based on knowledge graph retrieval enhancement is provided, and the device is applied to a large model reasoning method based on knowledge graph retrieval enhancement, and the device includes:

[0017] A data set generation module, used to insert the task instruction prompt text into the first prompt template to obtain a first text prompt; based on the first text prompt, use ChatGPT to generate corpus to obtain a knowledge-driven multi-instruction fine-tuning data set;

[0018] A model training module, used to perform autoregressive training on the large language model according to the multi-instruction fine-tuning data set to obtain a fine-tuned large language model;

[0019] A subgraph reasoning module is used to obtain a knowledge-intensive query and a corresponding knowledge entity set; based on the knowledge graph, iterative reasoning is performed through the fine-tuned large language model according to the knowledge-intensive query and the knowledge entity set to obtain a first evidence subgraph;

[0020] A subgraph pruning module, configured to prune the first evidence subgraph based on a regression scorer and a preset score threshold to obtain a second evidence subgraph;

[0021] A joint reasoning module is used to perform joint reasoning based on the second prompt template, the second evidence subgraph and the knowledge-intensive query through the fine-tuned large language model to obtain a query reasoning result.

[0022] On the other hand, a large model reasoning device is provided, comprising: a processor; a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, any one of the large model reasoning methods based on knowledge graph retrieval enhancement is implemented.

[0023] On the other hand, a computer-readable storage medium is provided, in which at least one instruction is stored, and the at least one instruction is loaded and executed by a processor to implement any one of the above-mentioned large model reasoning methods based on knowledge graph retrieval enhancement.

[0024] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0025] The present invention proposes a large model reasoning method based on knowledge graph retrieval enhancement, which decomposes a complex problem into multiple sub-problems, and a large language model searches in the knowledge graph according to each sub-problem; by scoring each fact triple on the retrieved evidence subgraph, and pruning the knowledge triple. The present invention converts the triple into fluent text evidence, and finally the evidence in text form is input into the LLM together with the question for joint reasoning. The multi-task instruction fine-tuning technology is adopted to train the LLM through multiple tasks at the same time, and the knowledge and its ability to apply knowledge are injected into the LLM; the regression scorer based on the LLM gives the LLM the ability to identify and screen noise evidence in the process of knowledge retrieval and reasoning. The present invention is a large model reasoning method based on knowledge graph enhancement that effectively combines external knowledge and accurately answers complex multi-hop questions. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0027] Figure 1 It is a flow chart of a large model reasoning method based on knowledge graph retrieval enhancement provided by an embodiment of the present invention;

[0028] Figure 2 It is a block diagram of a large model reasoning device based on knowledge graph retrieval enhancement provided by an embodiment of the present invention;

[0029] Figure 3 It is a structural diagram of a large model reasoning device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The technical solution of the present invention is described below in conjunction with the accompanying drawings.

[0031] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "example" in the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or it can be either of the two.

[0032] In the embodiments of the present invention, "image" and "picture" can sometimes be used interchangeably. It should be noted that when the difference between them is not emphasized, the meanings they intend to express are the same. "of", "corresponding, relevant" and "corresponding" can sometimes be used interchangeably. It should be noted that when the difference between them is not emphasized, the meanings they intend to express are the same.

[0033] In the embodiments of the present invention, sometimes the subscripts such as W 1 It may be written in non-subscript form such as W1. When the difference is not emphasized, the meaning is the same.

[0034] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.

[0035] The embodiment of the present invention provides a large model reasoning method based on knowledge graph retrieval enhancement, which can be implemented by a large model reasoning device, which can be a terminal or a server. Figure 1 The flowchart of the large model reasoning method based on knowledge graph retrieval enhancement is shown. The processing flow of the method may include the following steps:

[0036] S1. Insert the task instruction prompt text into the first prompt template to obtain the first text prompt; according to the first text prompt, use ChatGPT to generate corpus to obtain a knowledge-driven multi-instruction fine-tuning dataset.

[0037] In a feasible implementation, the present invention constructs a knowledge-driven multi-instruction fine-tuning dataset to improve the ability of LLMs to be integrated and applied with knowledge graphs.

[0038] ChatGPT is used as a corpus generator. To create training data, the present invention first predefines the first prompt template for each task. , and the command prompt text related to each task Insert into prompt template In the first text prompt . Input into ChatGPT to get the corresponding training corpus The generated training corpus was manually screened and used as a multi-instruction fine-tuning dataset. .

[0039] Among them, the task instruction prompt text is constructed according to the needs of the optimization task; the optimization task includes query decomposition, subgraph retrieval, evidence text generation and joint reasoning.

[0040] In a feasible implementation manner, the task instruction prompt text used in the present invention is inserted into a first prompt template to obtain a first text prompt. The first prompt template includes a query decomposition template, a subgraph retrieval template, an evidence text generation template and a joint reasoning template.

[0041] The query decomposition template is as follows:

[0042] "Please divide the given query into several subqueries, each of which can be represented by a triple. The generated subqueries should be numbered and formatted as follows: (sequence number), (sentence), (entity set). The entity set of each subquery should contain no more than two entities. The "##" symbol should be used to separate entities."

[0043] The following are some examples:

[0044] Query 1: Yes! I know that "Banana Man" starring Tim Brooke-Taylor first aired on October 3, 1983!

[0045] Entity Set: ["1983-10-03", Tim Brooke-Taylor, Banana Man]

[0046] Decomposition results:

[0047] 1. "Banana Man" starring Tim Brooke-Taylor. Entity set: [Tim Brooke-Taylor, Banana Man];

[0048] 2. "Banana Man" was first broadcast on October 3, 1983. Entity set: ["1983-10-03", Banana Man]

[0049] The subgraph retrieval template is as follows:

[0050] “I will give you a set of relations. Please find the top [k] relations that are relevant to a given query.” The specific example is as follows:

[0051] Query 1: "Banana Man" stars Tim Brooke-Taylor.

[0052] Relationship set: [owner, director, starring, first broadcast, writer]

[0053] First 2 relationships: [starring actor, director]

[0054] The template for generating evidence text is as follows:

[0055] "Your task is to convert the knowledge graph in triple format into a single sentence and retain the original words or expressions in the triples as much as possible. The knowledge graph is: {xxx}, and the sentence is: ".

[0056] The template of the joint reasoning module is as follows:

[0057] “You should verify the correctness of the query based on the given evidence text, each of which is a sentence generated from a triple in the knowledge graph. Answer in {true, false}.”

[0058] What is correct in the above description is that any information in the query is supported by evidence text. The specific example is as follows:

[0059] Query 1: Yeah! I know there was a TV show starring Tim Brooke-Taylor that first aired on October 3, 1983!

[0060] Evidence text: "Banana Man" was first broadcast on October 3, 1983. "Banana Man" starred Tim Brooke-Taylor.

[0061] Answer: {Correct}, This statement is supported by the evidence because the banana man refers to the television show.

[0062] Query 2: Really? Jamie Lawrence is the music composer for the 83-minute film “Death on Factory Farms” directed by Sarah Teale!

[0063] Evidence text: Jamie Lawrence composed the music for the documentary Death on Factory Farms. Death on Factory Farms was directed by Sarah Teale.

[0064] Answer: {False}, there is no evidence of a length of 83 minutes.

[0065] S2. Perform autoregressive training on the large language model according to the multi-instruction fine-tuning dataset to obtain the fine-tuned large language model.

[0066] In one possible implementation, during the multi-task instruction fine-tuning phase, language and entity knowledge is injected into LLMs by focusing on the optimization of four tasks: query decomposition, which enables the model to learn how to split multi-hop questions into single-hop sub-queries; subgraph exploration, which enhances the ability to predict the next relation; evidence text generation, which enhances the model's ability to translate evidence from the structural format of the graph into a coherent text form, bridging the gap between graph-based data and natural language; and joint reasoning, which enables the model to integrate the generated evidence text with the original question to derive the correct answer.

[0067] During training, the autoregressive training objective focuses on training the LLM to predict subsequent tokens based on previous tokens. Specifically, the prompt For different task templates, is the output of the model, and the training objective function is as follows (1):

[0068] (1);

[0069] in, Represents all parameters of the model, and the prompt contains demonstration examples of different tasks; for query decomposition, By query and entity sets Padding. For text evidence generation, Contains evidence subgraph For joint reasoning, Contains evidence and query .

[0070] S3. Obtain knowledge-intensive queries and corresponding knowledge entity sets. Based on the knowledge graph, perform iterative reasoning on the knowledge-intensive queries and knowledge entity sets through a fine-tuned large language model to obtain the first evidence subgraph.

[0071] Optionally, based on the knowledge graph, according to the knowledge-intensive query and the knowledge entity set, the fine-tuned large language model is used to perform iterative reasoning to obtain a first evidence subgraph, including:

[0072] The knowledge-intensive query and knowledge entity set are input into the fine-tuned large language model to perform query decomposition, and a sub-query set and a sub-query entity set are obtained;

[0073] Based on the knowledge graph, perform relationship retrieval according to the sub-query entity set to obtain the first relationship set corresponding to the sub-query entity set;

[0074] According to the subquery set and the first relationship set, the fine-tuned large language model is used to perform relevance screening to obtain a second relationship set;

[0075] Based on the knowledge graph, according to the sub-query entity set and the second relationship set, the fine-tuned large language model is used for iterative reasoning to obtain the first evidence subgraph.

[0076] In one feasible implementation, in this step, the knowledge-intensive query is obtained , and the set of knowledge entities related to the query , the goal is to predict the number of hops of the query and obtain a series of decomposed sub-queries , and determine the entity subset corresponding to the subquery The present invention uses a fine-tuned large language model to achieve the above goal. The expression of this process is as follows (2):

[0077] (2);

[0078] in, Indicates the number of subqueries after decomposition, which usually corresponds to the number of hops in the original query. It is a predefined decomposition template. Indicates that the query and entity sets Fill in the sequence obtained after decomposing the template. Use the large language model in the subgraph Specifically, the retrieval reasoning process is divided into multiple iterations, and finally a complete chain is formed. , which can be expressed as the following formula (3):

[0079] (3);

[0080] in, is the head entity of the reasoning path in the t-th iteration reasoning; is the relationship of the reasoning path in the t-th iteration reasoning; is the tail entity of the reasoning path in the t-th iteration reasoning.

[0081] For each iteration, the large language model takes the relationship as the target of the selection path. The present invention formulates the relationship selection task as an optimization problem, whose goal is to generate an inference path , to maximize the Extract a set of relations from The probability of , the process is as follows (4):

[0082] (4);

[0083] in, represents the historical reasoning path, represents the parameters of the large language model, Represents a given query ,entity and knowledge graph The probability of generating a historical reasoning path, Indicates that through the query ,entity , knowledge graph and historical reasoning paths Generate a relationship set probability.

[0084] S4. Based on the regression scorer and a preset score threshold, prune the first evidence subgraph to obtain a second evidence subgraph.

[0085] Optionally, based on the regression scorer and a preset score threshold, pruning the first evidence subgraph to obtain a second evidence subgraph includes:

[0086] Inputting the first evidence subgraph into the regression scorer for regression mapping to obtain an evidence score set;

[0087] Based on a preset score threshold and according to the evidence score set, the first evidence subgraph is pruned to obtain a second evidence subgraph.

[0088] In a feasible implementation, in subgraph pruning, in order to improve the evidence subgraph The present invention proposes a regression scorer based on a large language model to Perform pruning and reordering. Given a subquery and its corresponding evidence subgraph The present invention uses a large language model to jointly encode the query and the subgraph to obtain the hidden layer state , and obtain the corresponding evidence score according to the hidden layer state.

[0089] The regression scorer is trained using the preset training data. The mean square error loss is used as the objective function during the training process, which is expressed as the following formula (5):

[0090] (5);

[0091] in, is the number of samples, For the actual score, Finally, the present invention sorts the obtained evidence triples according to the scores and sets the threshold To filter out triple reasoning paths that are not relevant to the problem.

[0092] The regression scorer is constructed from a large language model and a single multi-layer perceptron.

[0093] In one possible implementation, a single multilayer perceptron is integrated after the large language model for regression training to convert Mapping to the corresponding score The mapping formula can be expressed as the following formula (6):

[0094] (6);

[0095] S5. Based on the second prompt template, according to the second evidence subgraph and the knowledge-intensive query, joint reasoning is performed through the fine-tuned large language model to obtain the query reasoning result.

[0096] Optionally, based on the second prompt template, according to the second evidence subgraph and the knowledge-intensive query, joint reasoning is performed through the fine-tuned large language model to obtain a query reasoning result, including:

[0097] Based on the second prompt template and the second evidence subgraph, text generation is performed by fine-tuning the large language model to obtain evidence text;

[0098] Based on the evidence text and knowledge-intensive queries, a fine-tuned large language model is used for joint reasoning to obtain query reasoning results.

[0099] In a feasible implementation, for the question-answering scenario, the task of the large language model is to generate the most accurate answer consistent with the question based on the provided evidence. For the fact verification scenario, the large language model evaluates the evidence to determine whether it confirms or refutes the initial statement. The present invention uses a fine-tuned large language model to uniformly handle the tasks in these two scenarios and generate the final reasoning answer. The expression of this process is as follows (7):

[0100] (7);

[0101] in, represents the answer generated by the large model, Indicates the text of evidence, Represents a predefined template. Indicates that the query The second prompt text is formed by filling the template with the evidence text.

[0102] Optionally, based on the second prompt template and according to the second evidence subgraph, text generation is performed by using a fine-tuned large language model to obtain evidence text, including:

[0103] Linearize the second evidence subgraph to obtain triple text;

[0104] Based on the second prompt template, performing text language conversion on the triple text to obtain the second prompt text;

[0105] The second prompt text is input into the fine-tuned large language model for text generation to obtain the evidence text.

[0106] In a feasible implementation manner, for Evidence subgraph of triples , the present invention linearizes the head entity, the relationship and the tail entity into a text triple form by connecting them. The triple text is converted into a natural language form. Specifically, the present invention uses a predefined second prompt template Converting knowledge triples into second text prompts , and Input into the trained large language model to generate evidence text , this process can be expressed as the following formula (8):

[0107] (8);

[0108] The present invention proposes a large model reasoning method based on knowledge graph retrieval enhancement, which decomposes a complex problem into multiple sub-problems, and a large language model searches in the knowledge graph according to each sub-problem; by scoring each fact triple on the retrieved evidence subgraph, and pruning the knowledge triple. The present invention converts the triple into fluent text evidence, and finally the evidence in text form is input into the LLM together with the question for joint reasoning. The multi-task instruction fine-tuning technology is adopted to train the LLM through multiple tasks at the same time, and the knowledge and its ability to apply knowledge are injected into the LLM; the regression scorer based on the LLM gives the LLM the ability to identify and screen noise evidence in the process of knowledge retrieval and reasoning. The present invention is a large model reasoning method based on knowledge graph enhancement that effectively combines external knowledge and accurately answers complex multi-hop questions.

[0109] Figure 2 1 is a block diagram of a large model reasoning device based on knowledge graph retrieval enhancement according to an exemplary embodiment, and the device is used for a large model reasoning method based on knowledge graph retrieval enhancement. Figure 2 The device includes a data set generation module 210, a model training module 220, a subgraph reasoning module 230, a subgraph pruning module 240 and a joint reasoning module 250. Among them:

[0110] The data set generation module 210 is used to insert the task instruction prompt text into the first prompt template to obtain a first text prompt; according to the first text prompt, ChatGPT is used to generate corpus to obtain a knowledge-driven multi-instruction fine-tuning data set;

[0111] A model training module 220 is used to perform autoregressive training on the large language model according to the multi-instruction fine-tuning data set to obtain a fine-tuned large language model;

[0112] The subgraph reasoning module 230 is used to obtain the knowledge-intensive query and the corresponding knowledge entity set; based on the knowledge graph, iterative reasoning is performed according to the knowledge-intensive query and the knowledge entity set through the fine-tuned large language model to obtain the first evidence subgraph;

[0113] A subgraph pruning module 240, configured to prune the first evidence subgraph based on a regression scorer and a preset score threshold to obtain a second evidence subgraph;

[0114] The joint reasoning module 250 is used to perform joint reasoning based on the second prompt template, the second evidence subgraph and the knowledge-intensive query through the fine-tuned large language model to obtain a query reasoning result.

[0115] Among them, the task instruction prompt text is constructed according to the needs of the optimization task; the optimization task includes query decomposition, subgraph retrieval, evidence text generation and joint reasoning.

[0116] Optionally, the subgraph reasoning module 230 is further configured to:

[0117] The knowledge-intensive query and knowledge entity set are input into the fine-tuned large language model to perform query decomposition, and a sub-query set and a sub-query entity set are obtained;

[0118] Based on the knowledge graph, perform relationship retrieval according to the sub-query entity set to obtain the first relationship set corresponding to the sub-query entity set;

[0119] According to the subquery set and the first relationship set, the fine-tuned large language model is used to perform relevance screening to obtain a second relationship set;

[0120] Based on the knowledge graph, according to the sub-query entity set and the second relationship set, the fine-tuned large language model is used for iterative reasoning to obtain the first evidence subgraph.

[0121] Optionally, the subgraph pruning module 240 is further configured to:

[0122] Inputting the first evidence subgraph into the regression scorer for regression mapping to obtain an evidence score set;

[0123] Based on a preset score threshold and according to the evidence score set, the first evidence subgraph is pruned to obtain a second evidence subgraph.

[0124] The regression scorer is constructed from a large language model and a single multi-layer perceptron.

[0125] Optionally, the joint reasoning module 250 is further configured to:

[0126] Based on the second prompt template and the second evidence subgraph, text generation is performed by fine-tuning the large language model to obtain evidence text;

[0127] Based on the evidence text and knowledge-intensive queries, a fine-tuned large language model is used for joint reasoning to obtain query reasoning results.

[0128] Optionally, the joint reasoning module 250 is further configured to:

[0129] Linearize the second evidence subgraph to obtain triple text;

[0130] Based on the second prompt template, performing text language conversion on the triple text to obtain the second prompt text;

[0131] The second prompt text is input into the fine-tuned large language model for text generation to obtain the evidence text.

[0132] The present invention proposes a large model reasoning method based on knowledge graph retrieval enhancement, which decomposes a complex problem into multiple sub-problems, and a large language model searches in the knowledge graph according to each sub-problem; by scoring each fact triple on the retrieved evidence subgraph, and pruning the knowledge triple. The present invention converts the triple into fluent text evidence, and finally the evidence in text form is input into the LLM together with the question for joint reasoning. The multi-task instruction fine-tuning technology is adopted to train the LLM through multiple tasks at the same time, and the knowledge and its ability to apply knowledge are injected into the LLM; the regression scorer based on the LLM gives the LLM the ability to identify and screen noise evidence in the process of knowledge retrieval and reasoning. The present invention is a large model reasoning method based on knowledge graph enhancement that effectively combines external knowledge and accurately answers complex multi-hop questions.

[0133] Figure 3 is a schematic diagram of the structure of a large model inference device provided by an embodiment of the present invention, such as Figure 3 As shown, the large model reasoning device may include the above Figure 2 The large model reasoning device based on knowledge graph retrieval enhancement is shown. Optionally, the large model reasoning device 310 may include a first processor 2001.

[0134] Optionally, the large model inference device 310 may further include a memory 2002 and a transceiver 2003 .

[0135] The first processor 2001, the memory 2002 and the transceiver 2003 may be connected via a communication bus.

[0136] Combine the following Figure 3 The components of the large model inference device 310 are introduced in detail:

[0137] The first processor 2001 is the control center of the large model inference device 310, which can be a processor or a general term for multiple processing elements. For example, the first processor 2001 is one or more central processing units (CPUs), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention, such as one or more microprocessors (digital signal processors, DSPs), or one or more field programmable gate arrays (field programmable gate arrays, FPGAs).

[0138] Optionally, the first processor 2001 can perform various functions of the large model reasoning device 310 by running or executing a software program stored in the memory 2002 and calling data stored in the memory 2002.

[0139] In a specific implementation, as an embodiment, the first processor 2001 may include one or more CPUs, such as Figure 3 CPU0 and CPU1 are shown in FIG.

[0140] In a specific implementation, as an embodiment, the large model reasoning device 310 may also include multiple processors, such as Figure 3 The first processor 2001 and the second processor 2004 are shown in FIG. Each of these processors may be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The processor here may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).

[0141] The memory 2002 is used to store the software program for executing the solution of the present invention, and is controlled to be executed by the first processor 2001. The specific implementation method can refer to the above method embodiment, which will not be repeated here.

[0142] Optionally, the memory 2002 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compressed optical disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 2002 may be integrated with the first processor 2001, or may exist independently, and may be accessed through the interface circuit ( Figure 3 (not shown) is coupled to the first processor 2001, which is not specifically limited in this embodiment of the present invention.

[0143] The transceiver 2003 is used to communicate with a network device or a terminal device.

[0144] Optionally, the transceiver 2003 may include a receiver and a transmitter ( Figure 3 The receiver is used to implement a receiving function, and the transmitter is used to implement a sending function.

[0145] Optionally, the transceiver 2003 may be integrated with the first processor 2001, or may exist independently and communicate with the first processor 2001 through the interface circuit ( Figure 3 (not shown) is coupled to the first processor 2001, which is not specifically limited in this embodiment of the present invention.

[0146] It should be noted that Figure 3 The structure of the large model reasoning device 310 shown in the figure does not constitute a limitation on the router. The actual knowledge structure recognition device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0147] In addition, the technical effects of the large model reasoning device 310 can refer to the technical effects of the large model reasoning method based on knowledge graph retrieval enhancement described in the above method embodiment, and will not be repeated here.

[0148] It should be understood that the first processor 2001 in the embodiment of the present invention may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0149] It should also be understood that the memory in the embodiments of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0150] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.

[0151] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.

[0152] In the present invention, "at least one" means one or more, and "plurality" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0153] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0154] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0155] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0156] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0157] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0158] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0159] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0160] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A large model reasoning method based on knowledge graph retrieval enhancement, characterized in that: The method comprises: Inserting the task instruction prompt text into the first prompt template to obtain a first text prompt; generating corpus using ChatGPT according to the first text prompt to obtain a knowledge-driven multi-instruction fine-tuning dataset; The multi-instruction fine-tuning dataset is used to enhance the reasoning application capability of a large language model combined with a knowledge graph; According to the multi-instruction fine-tuning dataset, autoregressive training is performed on the large language model to obtain a fine-tuned large language model; Acquire a knowledge-intensive query and a corresponding knowledge entity set; based on the knowledge graph, perform iterative reasoning through the fine-tuned large language model according to the knowledge-intensive query and the knowledge entity set to obtain a first evidence subgraph; The method of obtaining a first evidence subgraph by iteratively reasoning based on the knowledge graph, according to the knowledge-intensive query and the knowledge entity set, through the fine-tuned large language model includes: Inputting the knowledge-intensive query and the knowledge entity set into the fine-tuned large language model to perform query decomposition, and obtaining a sub-query set and a sub-query entity set; Based on the knowledge graph, performing relationship retrieval according to the sub-query entity set to obtain a first relationship set corresponding to the sub-query entity set; According to the subquery set and the first relationship set, using the fine-tuned large language model to perform relevance screening to obtain a second relationship set; Based on the knowledge graph, according to the sub-query entity set and the second relationship set, the fine-tuned large language model is used to perform iterative reasoning to obtain a first evidence subgraph; Based on the regression scorer and a preset score threshold, pruning the first evidence subgraph to obtain a second evidence subgraph; Based on the second prompt template, according to the second evidence subgraph and the knowledge-intensive query, joint reasoning is performed through the fine-tuned large language model to obtain a query reasoning result; The method of performing joint reasoning based on the second prompt template, the second evidence subgraph and the knowledge-intensive query through the fine-tuned large language model to obtain the query reasoning result includes: Based on the second prompt template and the second evidence subgraph, text generation is performed by using the fine-tuned large language model to obtain evidence text; According to the evidence text and the knowledge-intensive query, the fine-tuned large language model is used to perform joint reasoning to obtain a query reasoning result; The step of generating text based on the second prompt template and the second evidence subgraph by using the fine-tuned large language model to obtain evidence text includes: Linearizing the second evidence subgraph to obtain triple text; Based on the second prompt template, performing text language conversion on the triple text to obtain a second prompt text; The second prompt text is input into the fine-tuned large language model to generate text and obtain evidence text.

2. The large model reasoning method based on knowledge graph retrieval enhancement according to claim 1 is characterized in that: The task instruction prompt text is constructed according to the requirements of the optimization task; the optimization task includes query decomposition, subgraph retrieval, evidence text generation and joint reasoning.

3. The large model reasoning method based on knowledge graph retrieval enhancement according to claim 1 is characterized in that: The step of pruning the first evidence subgraph based on the regression scorer and the preset score threshold to obtain the second evidence subgraph includes: Inputting the first evidence subgraph into a regression scorer for regression mapping to obtain an evidence score set; Based on a preset score threshold and according to the evidence score set, the first evidence subgraph is pruned to obtain a second evidence subgraph.

4. The large model reasoning method based on knowledge graph retrieval enhancement according to claim 3 is characterized in that: The regression scorer is built from a large language model and a single multilayer perceptron.

5. A large model reasoning device based on knowledge graph retrieval enhancement, the large model reasoning device based on knowledge graph retrieval enhancement is used to implement the large model reasoning method based on knowledge graph retrieval enhancement as described in any one of claims 1-4, characterized in that: The device comprises: A data set generation module, used to insert the task instruction prompt text into the first prompt template to obtain a first text prompt; based on the first text prompt, use ChatGPT to generate corpus to obtain a knowledge-driven multi-instruction fine-tuning data set; The multi-instruction fine-tuning dataset is used to enhance the reasoning application capability of a large language model combined with a knowledge graph; A model training module, used to perform autoregressive training on the large language model according to the multi-instruction fine-tuning data set to obtain a fine-tuned large language model; A subgraph reasoning module is used to obtain a knowledge-intensive query and a corresponding knowledge entity set; based on the knowledge graph, iterative reasoning is performed through the fine-tuned large language model according to the knowledge-intensive query and the knowledge entity set to obtain a first evidence subgraph; Wherein, the subgraph reasoning module is further used for: Inputting the knowledge-intensive query and the knowledge entity set into the fine-tuned large language model to perform query decomposition, and obtaining a sub-query set and a sub-query entity set; Based on the knowledge graph, performing relationship retrieval according to the sub-query entity set to obtain a first relationship set corresponding to the sub-query entity set; According to the subquery set and the first relationship set, using the fine-tuned large language model to perform relevance screening to obtain a second relationship set; Based on the knowledge graph, according to the sub-query entity set and the second relationship set, the fine-tuned large language model is used to perform iterative reasoning to obtain a first evidence subgraph; A subgraph pruning module, configured to prune the first evidence subgraph based on a regression scorer and a preset score threshold to obtain a second evidence subgraph; A joint reasoning module, configured to perform joint reasoning based on the second prompt template, the second evidence subgraph and the knowledge-intensive query through the fine-tuned large language model to obtain a query reasoning result; Wherein, the joint reasoning module is further used for: Based on the second prompt template and the second evidence subgraph, text generation is performed by using the fine-tuned large language model to obtain evidence text; According to the evidence text and the knowledge-intensive query, the fine-tuned large language model is used to perform joint reasoning to obtain a query reasoning result; Wherein, the joint reasoning module is further used for: Linearizing the second evidence subgraph to obtain triple text; Based on the second prompt template, performing text language conversion on the triple text to obtain a second prompt text; The second prompt text is input into the fine-tuned large language model to generate text and obtain evidence text.

6. A large model reasoning device, characterized in that: The large model reasoning device comprises: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Large model reasoning analysis method, system and product based on external knowledge enhancement

    CN117575026A

  • Knowledge graph multi-hop question and answer method and device based on big language model enhancement

    CN118551001A