A method and device for automatically correcting hallucination problems in large language models based on knowledge graphs

Through the automatic correction method based on the knowledge graph, combined with the large language model and the knowledge graph, the model viewpoints are extracted, detected, selected and verified, which solves the problem of fact illusion in the reasoning process of the large language model and improves the accuracy and reliability of the output. .

CN117688186BActive Publication Date: 2024-09-10INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311511960.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-14
Publication Date
2024-09-10
Estimated Expiration
2043-11-14

AI Technical Summary

Technical Problem

Large language models are prone to factual hallucinations during the reasoning process, and existing methods are insufficient to solve this problem, especially in complex multi-step reasoning.

Method used

An automatic correction method based on the knowledge graph is adopted, and through the steps of opinion extraction, entity detection, fact selection and opinion verification, the large language model is combined with the knowledge graph to gradually verify and correct the erroneous expressions output by the model to ensure its accuracy.

Benefits of technology

It effectively reduces the risk of wrong answers in model output, improves the accuracy and reliability of answers, can automatically correct multi-hop viewpoints in iterative cycles, and reduces the impact of memory bias and encoder defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117688186B
    Figure CN117688186B
Patent Text Reader

Abstract

The present invention discloses an automatic correction method and device for the hallucination problem of a large language model based on a knowledge graph, and the steps include: using a large language model to extract the viewpoints to be verified in the text; using a few sample prompts to extract the named entities in the viewpoints to be verified; screening the triples related to the viewpoints to be verified from the knowledge graph; verifying the correctness of the viewpoints according to the screened triples, and giving modification suggestions; and correcting the wrong statements in the text in combination with the modification suggestions of all viewpoints. The present invention can automatically perform the above steps using a large language model, and correct the text generated by the large language model according to any given knowledge graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method for correcting large prediction model hallucinations, and in particular to an automatic correction method and device for large prediction model hallucination problems based on a knowledge graph, and belongs to the technical field of natural language processing. Background Art

[0002] Large language models (LLMs) have attracted much attention in the field of artificial intelligence, and their representative models such as ChatGPT and LLaMA have had a profound impact in many fields such as society, business, and research. These powerful models can generate natural language text and perform tasks such as text generation, question answering, and translation. Their flexibility and wide applicability make them one of the key technologies in the field of AI today. However, despite the power of these models, they still face a severe challenge, namely the problem of fact hallucination.

[0003] The fact hallucination problem refers to the fact that large language models often produce false statements about factual information due to their lack of intrinsic knowledge. This problem is particularly important for real-world applications, as the accuracy of facts is crucial in decision making, information dissemination, and problem solving. The fact hallucination problem has attracted widespread attention in the natural language processing community and has become one of the research hotspots.

[0004] One of the root causes of factual illusions is data problems during the training process. Automated large-scale data collection may cause false information to be incorporated into the training data, thereby affecting the output quality of the model. In addition, excessive repetition of certain data may introduce memory bias, causing the model to be more susceptible to false statements.

[0005] Another issue is the imperfections of the encoders in pre-trained language models and the differences between different decoding strategies. These factors can lead to false statements in the text generated by the model. Recent research has emphasized the confidence of the model output as an indicator of potential hallucinations, that is, how confident the model is in its answer when generating text.

[0006] To alleviate the fact hallucination problem of large language models, researchers are trying to integrate knowledge graphs (KGs) with these models. Knowledge graphs contain a large amount of high-quality factual information, which can significantly improve the model's factual knowledge if used in conjunction with large language models. Recent work focuses on enhancing the model's understanding of facts by retrieving entities in the knowledge graph that are relevant to the model input and then using the obtained fact triples as additional contextual information.

[0007] However, current methods are limited to retrieving factual knowledge related to entities explicitly mentioned in the query. The basic capabilities of large language models often involve complex multi-step reasoning, which requires verification and supplementation of possible factual knowledge used in the reasoning process. Therefore, previous methods are not sufficient to address the problem of fact hallucinations that may occur during the reasoning process of large language models. This problem remains one of the urgent challenges in the field of natural language processing and requires further research and innovation. Summary of the invention

[0008] In order to more effectively alleviate the hallucination problem of large language models, the present invention provides a method and device for automatically correcting the hallucination problem of large language models based on knowledge graphs.

[0009] The technical solution adopted by the present invention is summarized as follows:

[0010] An automatic correction method for the hallucination problem of a large language model based on a knowledge graph comprises the following steps:

[0011] Use the large language model to extract the viewpoints in the text that need to be verified for correctness, and obtain the viewpoints to be verified;

[0012] Combine the information in the knowledge graph to determine the correctness of the extracted viewpoints to be verified, obtain the verification results and give modification suggestions;

[0013] Use a large language model to correct incorrect statements in the text based on verification results and modification suggestions.

[0014] Furthermore, the extracting of viewpoints in the text that need to be checked for correctness using the large language model includes:

[0015] Through the use of a few sample prompts, the large language model can generate opinions that are worth testing and reduce the generation of useless opinions;

[0016] A named entity extraction mechanism is established to extract the named entities contained in the opinions using a few-sample prompt method.

[0017] Furthermore, the correctness of the extracted viewpoints to be verified is judged by combining the information in the knowledge graph, obtaining the verification results and providing modification suggestions, including:

[0018] Use a large language model to determine fact triplets in the knowledge graph that are relevant to opinion verification;

[0019] For large language models with limited input length, use a block-by-block approach to filter fact triples.

[0020] The correctness of the viewpoint is judged based on the screened fact triples, the verification results are obtained and corresponding modification suggestions are given.

[0021] Furthermore, the block division is to disrupt the order of the fact triples and divide them into a number of sub-blocks of the same size according to the setting of hyperparameters.

[0022] Furthermore, the screening of fact triples block by block is to guide the language model to select fact triples in the sub-block that are related to the model's viewpoint description by means of few-sample prompts.

[0023] Furthermore, the correcting of erroneous expressions in the text includes: after obtaining the verification results of all viewpoints, using a large language model to make fine-grained corrections to the erroneous expressions therein by means of a small number of sample prompts.

[0024] Furthermore, the overall process of the method is automatically completed by a large language model, and the viewpoints involving multiple hops in the text can be verified in an iterative manner.

[0025] An automatic correction device for the hallucination problem of a large language model based on a knowledge graph, comprising the following parts:

[0026] 1) Opinion Extractor: Given the model’s answer as input, the opinion extractor extracts the opinions in the model’s answer that need to be factually verified. Typically, the model’s answer usually contains various factual statements, so the main function of the opinion extractor is to separate these statements for further verification.

[0027] 2) Entity Detector and Knowledge Retriever: Given a set of extracted model viewpoints, the entity detector starts to work, and its task is to identify key entities from the viewpoints. These entities are important elements that need to be verified in the knowledge graph. Then, the knowledge retriever further uses these entities to retrieve relevant fact triples in the knowledge graph, which contain factual information related to these entities.

[0028] 3) Fact Selector: Given a set of fact triples in the graph, select those most relevant to the model’s opinion from the fact triples retrieved from the knowledge graph. This step ensures that only the most relevant information is used to verify the model’s opinion.

[0029] 4) Opinion Verifier: Given a set of fact triples related to the model's opinions, the opinion verifier verifies the factuality of the model's opinions using fact triples retrieved from the knowledge graph. It evaluates the consistency of the model's opinions with known facts and suggests modifications to the model's answers to make them more accurate and credible.

[0030] 5) Answer Corrector: Given a series of opinion validators’ factual verification of the model’s opinions and suggestions for modifying the model’s answers, the answer corrector modifies the model’s original answers.

[0031] The present invention can iterate multiple times and ensure the factual correctness of the model's answers through the cycle of "extraction-detection-selection-verification-correction".

[0032] Compared with the prior art, the present invention has the following beneficial effects:

[0033] 1) We introduce an innovative approach that leverages knowledge graphs to address the hallucination problem of large language models, thereby improving the accuracy of responses.

[0034] 2) We propose a framework to mitigate hallucinations during inference in large language models, which helps reduce the risk of incorrect responses.

[0035] 3) By fully leveraging the capabilities of large language models and performing iterative cycles without the need for additional training operations, the model’s hallucination problem is effectively alleviated, improving the quality and reliability of answers. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 Flowchart of the automatic correction method for the hallucination problem of large language models based on knowledge graphs.

[0037] Figure 2 Schematic diagram of the opinion extractor.

[0038] Figure 3 Schematic diagram of entity detector.

[0039] Figure 4 Schematic diagram of a fact selector.

[0040] Figure 5 Schematic diagram of the opinion validator and answer corrector. DETAILED DESCRIPTION

[0041] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below.

[0042] The present invention includes: (i) extracting model opinions from model answers; (ii) extracting entities from model opinions for verifying their factuality in the knowledge graph; (iii) retrieving facts related to the model opinions from the knowledge graph; (iv) verifying the factual correctness of the model opinions; (v) correcting real-time errors in model answers. The above steps are all automatically performed using a large language model without the need for additional manual repetitive work. This process can be iterated and repeated multiple times to ensure that all facts in the generated answers are consistent with the facts in the knowledge graph.

[0043] The present invention provides an automatic correction method for the large prediction model hallucination problem based on knowledge graph, such as Figure 1 As shown, it includes five key parts:

[0044] 1. Opinion Extractor:

[0045] Given the model's answer as input, the opinion extractor extracts all the opinions in the model's answer that need to be factually verified. The main idea of ​​the opinion extractor is that the model's answer usually contains various factual statements, so it is necessary to list them point by point. The present invention uses the contextual learning ability of the large language model and gives opinion extraction examples in the model input, so that the model can fully learn the opinion extraction task, propose fine-grained model opinions, ensure the atomicity of the model opinions, and reduce the difficulty of subsequent factual verification. The present invention makes full use of the contextual learning ability of the large language model to extract opinions from the model's answers, and enables the model to learn the ability of opinion extraction by giving opinion extraction samples in the model input.

[0046] For example, given a question “When is Frédéric Chopin's father's birthday?”, the model's initial answer is “Frédéric Chopin's father is Nicolas Chopin, he was born on June 17.” The present invention uses a viewpoint extractor to extract two viewpoints: “Frédéric Chopin's father is Nicolas Chopin.” and “Nicolas Chopin was born on June 17.”, such as Figure 2 shown.

[0047] By extracting the model viewpoints, we then use the entity detector to extract entities that play a key role in factual verification for knowledge graph retrieval.

[0048] 2. Entity Detector and Knowledge Retriever:

[0049] Key entities in opinions play a key role in opinion verification. The task of the entity detector is to identify key entities from the extracted model opinions, which play an important role in the subsequent factual verification. Next, the knowledge retriever uses these key entities to retrieve relevant fact triples from the knowledge graph. These triples will then be passed to the fact selector to filter out the information most relevant to the model opinion, thereby improving the accuracy and efficiency of verification.

[0050] Specifically, in the implementation part of the entity detector, the present invention uses the contextual learning ability of the large language model, gives a named entity recognition example in the model input, and enables the model to fully learn the named entity recognition task and thus extract entities in the knowledge graph that play an important role in factual verification. Then, the knowledge retriever uses the knowledge graph query language to query the fact triples related to the entity. Through this method, as many fact triples as possible can be retrieved to ensure that the triples related to the model's views will not be missed, thereby ensuring the recall rate.

[0051] For example, for the model viewpoint "Frédéric Chopin's father is Nicolas Chopin." mentioned above, the present invention can extract two entities "Frédéric Chopin" and "Nicolas Chopoin" using the entity detector, such as Figure 3 Then the knowledge retriever uses the knowledge graph query language to query the fact triples related to these two entities, as shown in Figure 4 As shown in the figure, the triple ("Frédéric Chopin", "father", "Nicolas Chopoin") is included in a series of recalled fact triples. In the next step, the purpose of the fact selector is to select this triple that is helpful for testing the factuality of the model's viewpoint.

[0052] 3. Fact Selector:

[0053] Given a series of fact triples in the graph, select those fact triples that are most relevant to the model's opinion from the fact triples retrieved from the knowledge graph. This step ensures that only the most relevant information is used to verify the model's opinion. Specifically, the main bottleneck of this step is that the large number of fact triples retrieved by the knowledge retriever usually exceeds the context length limit of the large language model, so it is usually unrealistic for the large language model to select key triples from all retrieved fact triples at once. The present invention proposes to divide the fact triples recalled by the knowledge retriever into blocks, and let the large language model judge each block of fact triples in turn whether it plays a key role in the factual verification of the model's opinion, thereby avoiding the introduction of too much irrelevant knowledge to the opinion verifier.

[0054] Among them, the fact triples recalled by the knowledge retriever are divided into blocks, which means that the order of the retrieved fact triples is disrupted and divided into several sub-blocks of the same size according to the hyperparameter settings.

[0055] Among them, judging whether each fact triple plays a key role in the factual verification of the model's opinion. Specifically, through the method of few-sample prompts, the language model is guided to select the triples in the input sub-block that are related to the model's opinion description. This step mainly utilizes the language model's ability to understand the real world and its ability to understand and execute simple instructions. For complex text generation tasks, the difficulty of judging whether two texts are related is greatly reduced, so errors in the model generation process can be discovered in this way.

[0056] Give a small number of examples as input to the model

[0057] For example, for the model view "Frédéric Chopin's father is Nicolas Chopoin.", the knowledge detector detects two fact triples: ("Frédéric Chopin", "father", "Nicolas Chopin") and ("Nicolas Chopin", "family name", "Chopin"), and the fact selector can select the triple that is useful for the claim: ("Frédéric Chopin", "father", "Nicolas Chopin").

[0058] After the fact selector selects the triples that are useful for verifying the model's claims, the opinion validator verifies whether the model's opinions are factually correct and proposes modifications to the model output.

[0059] 4. Opinion Validator:

[0060] Given a series of fact triples related to the model's opinions, the opinion verifier verifies the factuality of the model's opinions using the fact triples retrieved from the knowledge graph. It evaluates the consistency of the model's opinions with known facts and proposes modifications to the model's answers to make them more accurate and credible. The main idea of ​​this part is to hope that the model can propose a fine-grained modification suggestion, thereby lowering the threshold for model correction. If the model is directly corrected by relying solely on the retrieved knowledge, this will increase the difficulty of model correction.

[0061] Among them, the consistency between the model's viewpoint and the known facts is evaluated by constructing the model's viewpoint and the selected fact triples one by one into the form of implicit reasoning. For example, for the selected triple ('Nicolas Chopin','date ofbirth','1771-04-15T00:00:0') (Nicolas Chopin, date of birth, 1771-04-15T00:00:0), can it be inferred that the model's viewpoint "Nicolas Chopin was born on June 17." (Nicolas Chopin was born on June 17.) If not, it is considered that the model's viewpoint is contrary to the facts.

[0062] Among them, the suggestion to modify the model's answer is to make the model modify the existing view according to the fact triplet that contradicts the model's view through a few-sample prompt. For example, when it is found that the model's view "Nicolas Chopin was born on June 17." is inconsistent with the fact (i.e., the fact triplet) ('Nicolas Chopin','date of birth','1771-04-15T00:00:0'), the instruction "correct the target view according to the existing facts" is used to make the language model imitate the few-sample example and modify the wrong view to "Nicolas Chopin was born on April 15."

[0063] For example, for the viewpoint "Nicolas Chopin was born on June 17.", the viewpoint verifier can judge that the model viewpoint is contrary to the facts in the knowledge graph based on the fact triple ('Nicolas Chopin','date of birth','1771-04-15T00:00:0') given by the knowledge selector, so the viewpoint verifier gives the suggestion "The evidence suggests that Nicolas Chopin was born on April 15, 1771, not June 17, 1771 as stated in the proposed answer.", such as Figure 5 shown.

[0064] Based on the evaluation given by the opinion validator, the answer corrector can modify the model's initial answer in a targeted manner.

[0065] 5. Answer Corrector:

[0066] Given a series of factual verifications of the model's opinions and model answer modification suggestions by the opinion validator, the answer corrector modifies the model's original answer. The present invention uses the contextual learning ability of the large language model and gives an example of the model answer modification process in the model input, so that the model can fully understand the framework proposed by the present invention and more effectively modify the model output.

[0067] For example, in the previous article, the model's answer "Frédéric Chopin's father is Nicolas Chopin, he was born on June 17." (Frédéric Chopin's father is Nicolas Chopin, born on June 17.), the viewpoint verifier gives a modification suggestion "The evidence suggests that Nicolas Chopin was born on April 15, 1771, not June 17, 1771 as stated in the proposed answer." (The evidence shows that Nicolas Chopin was born on April 15, 1771, not June 17, 1771 as stated in the proposed answer.), and the answer corrector corrects the answer according to the suggestion of the viewpoint verifier to obtain "Frédéric Chopin's father is Nicolas Chopin, he was born on April 15." (Frédéric Chopin's father is Nicolas Chopin, born on April 15.), such as Figure 5 As shown, the automatic correction of the hallucination problem of the entire large language model based on the knowledge graph is completed.

[0068] Another embodiment of the present invention provides a computer device (computer, server, smart phone, etc.), which includes a memory and a processor, the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for executing each step in the method of the present invention.

[0069] Another embodiment of the present invention provides a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk), wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the steps of the method of the present invention are implemented.

[0070] The above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the same. A person skilled in the art may modify or make equivalent substitutions for the technical solutions of the present invention without departing from the principle and scope of the present invention. The protection scope of the present invention shall be subject to the claims.

Claims

1. An automatic correction method for the hallucination problem of a large language model based on a knowledge graph, characterized in that: The following steps are involved: Use the large language model to extract the viewpoints in the text that need to be verified for correctness, and obtain the viewpoints to be verified; Combine the information in the knowledge graph to determine the correctness of the extracted viewpoints to be verified, obtain the verification results and give modification suggestions; Use the large language model to correct incorrect statements in the text based on the verification results and modification suggestions; The use of a large language model to extract viewpoints in a text that need to be checked for correctness includes: Through the use of a few sample prompts, the large language model can generate opinions that are worth testing and reduce the generation of useless opinions; Adopt named entity extraction mechanism and extract named entities contained in opinions by using few-sample prompts; The correctness of the extracted viewpoints to be verified is judged by combining the information in the knowledge graph, obtaining the verification results and providing modification suggestions, including: Use a large language model to determine fact triplets in the knowledge graph that are relevant to opinion verification; For large language models with limited input length, use a block-by-block approach to filter fact triples. The correctness of the viewpoint is judged based on the fact triples obtained by screening, the verification results are obtained, and corresponding modification suggestions are given; The correcting of the erroneous expressions in the text includes: after obtaining the verification results of all viewpoints, using a large language model to make fine-grained corrections to the erroneous expressions therein by means of a small number of sample prompts; The steps of the method for automatically correcting the large language model hallucination problem based on the knowledge graph are all automatically performed using a large language model and repeated multiple times through iteration to ensure that all facts in the generated answer are consistent with the facts in the knowledge graph.

2. The method according to claim 1, characterized in that The block division is to shuffle the order of the fact triples and divide them into a number of sub-blocks of the same size according to the setting of the hyperparameters.

3. The method according to claim 2, characterized in that The screening of fact triples block by block is to guide the language model to select fact triples in the sub-block that are related to the model's viewpoint description by means of few-sample prompts.

4. An automatic correction device for large language model hallucination problems based on knowledge graphs using any of the methods described in claims 1 to 3, characterized in that: include: The opinion extractor is used to extract the opinions that need to be verified in the text using a large language model to obtain the opinions to be verified; Entity detectors, used to identify key entities from the viewpoint to be verified; Knowledge retriever, which is used to retrieve relevant fact triples in the knowledge graph using key entities identified by entity detector; A fact selector, used to select the fact triples most relevant to the model's viewpoint from the retrieved fact triples; The opinion validator is used to judge the correctness of the opinion based on the selected fact triples, obtain the verification results and give corresponding modification suggestions; The answer corrector is used to correct incorrect statements in the text using verification results and modification suggestions.

5. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing each step in the method according to any one of claims 1 to 3.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.