Model illusion suppression method based on knowledge graph and RAG fusion
By integrating knowledge graphs and RAG methods, and combining entity relationship consistency verification and standardization processing, the illusion problem of large language models in question-answering, selection, and judgment tasks is solved, thereby improving the accuracy and consistency of the generated results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-07
AI Technical Summary
Large language models exhibit illusion phenomena in question-answering, selection, and judgment tasks. Existing technologies, such as single knowledge graphs or RAG methods, are insufficient to fully address the reliability requirements of diverse scenarios, resulting in generated content that does not match reality.
By integrating the structured knowledge of knowledge graphs with the RAG retrieval database, an enhanced generation mechanism is constructed. Combined with entity relationship consistency verification and standardization processing, the generation quality is improved and the hallucination phenomenon is suppressed.
It significantly reduces the hallucination rate, improves the accuracy of responses, enhances the semantic support and structural consistency of generated results, and adapts to various question scenarios.
Smart Images

Figure CN121809688A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a model hallucination suppression method based on knowledge graph and retrieval augmented generation (RAG) fusion, which is suitable for improving the answer accuracy of large language models in question answering, selection and judgment tasks, and reducing the model hallucination phenomenon. BACKGROUND
[0002] With the rapid development of large language models (LLM), they have shown strong generation capabilities in natural language processing tasks, but the "hallucination phenomenon" (i.e. generating content that does not conform to the facts) has become a key problem that restricts their reliability. This phenomenon is mainly caused by the limitations of the training data of large language models. The training data has limited coverage, poor timeliness, and the model relies on parameterized memory to store knowledge, which leads to problems such as "fabricated information" and "confused concepts" when dealing with tasks that exceed the training distribution or require accurate factual support.
[0003] In the prior art, the means for suppressing model hallucination mainly fall into two categories: one is the method based on knowledge graph, which introduces structured entity and relationship knowledge to provide a clear logical framework for the model. However, the construction of knowledge graph relies on manual definition or rule constraints, which is difficult to cover complex semantic information in unstructured text, and has weak adaptability to dynamically updated knowledge, which may lead to reasoning gaps due to knowledge missing; the other is the method based on retrieval augmented generation (RAG), which provides context support for the model by retrieving external text library to enhance the factual basis of the answer. However, RAG technology relies on semantic similarity matching, and the retrieval results may contain noise information or content with low relevance to the question, and cannot effectively identify potential logical conflicts between entities in the text, which may lead the model to generate hallucination content based on incorrect retrieval results.
[0004] While using knowledge graphs or RAG techniques alone can alleviate model hallucinations to some extent, they have significant limitations: knowledge graphs, although providing structured knowledge, struggle with complex semantic text, such as parsing content containing a large amount of descriptive language, failing to fully capture its semantic details; RAGs, while enhancing semantic understanding through retrieval, may contain noise or missing key logical relationships in the retrieval results, for example, when retrieved text fragments contain ambiguous expressions or implicit errors, the model struggles to identify them. Furthermore, in practical applications, large language models have varying requirements for the precision of knowledge retrieval and the depth of logical reasoning when facing different types of questions, such as question-and-answer, choice, and judgment questions, making it difficult for a single technique to meet the reliability needs of diverse scenarios. For example, question-and-answer questions require precise factual knowledge, choice questions rely on a clear judgment of the relationship between options and the question stem, and judgment questions require rigorous verification of the correctness of the content; all of these make it difficult for a single knowledge graph or RAG technique to comprehensively address these challenges. Therefore, a method that integrates the advantages of both is urgently needed, using the synergistic effect of structured knowledge and semantic retrieval to more effectively suppress model hallucinations. Summary of the Invention
[0005] This invention aims to address the "illusion phenomenon" that exists in existing large language models when handling question-and-answer, choice, correct-answer judgment, and incorrect-answer judgment questions. It provides a model illusion suppression method based on the fusion of knowledge graphs and RAG (Research Aggregator). By integrating the structured knowledge of knowledge graphs with the semantic retrieval capabilities of the RAG retrieval database, an enhanced generation mechanism is constructed to overcome the limitations of single techniques in suppressing illusions, ultimately improving the accuracy of model responses and reducing the illusion rate.
[0006] The present invention provides a model-based hallucination suppression method based on the fusion of knowledge graph and retrieval enhancement generation, which specifically includes the following steps:
[0007] 1. A knowledge enhancement mechanism that integrates structured and semantic representations.
[0008] This paper proposes a fusion-based knowledge enhancement method that embeds two different types of knowledge sources—structured knowledge graphs and unstructured semantic text—into the contextual input of a large language model through a unified mechanism. Knowledge graphs provide explicit entity relationship structures, while semantic texts enrich linguistic expression; their combined approach improves the model's generative quality.
[0009] Define the generation of the enhanced context as follows:
[0010] ;
[0011] in:
[0012] : A set of structured triples extracted from a knowledge graph;
[0013] : Relevant text vector set recalled by RAG semantic retrieval mechanism
[0014] : Form the final input context for large model generation, containing graph structure information and language fragments.
[0015] 2. Recall text filtering mechanism based on entity relationship consistency
[0016] Based on the traditional RAG semantic similarity recall, the invention further introduces a verification mechanism based on entity relationship consistency in the knowledge graph. If the entity pair in the recalled text has a semantic conflict in the graph, it is considered inconsistent with the structured knowledge, and is not used to generate the context.
[0017] The specific judgment rules are as follows:
[0018]
[0019] Among them Indicates that the relationship semantics are mutually exclusive, such as "support" and "deny". This mechanism ensures the consistency of facts in the generated context and improves the logical integrity of the large model generation semantics.
[0020] 3. Standardized entity and relationship label driven knowledge cleaning mechanism
[0021] Standardize the original text data, normalize the entities and map the relationship labels to build a high-consistency and high-specification knowledge text input source.
[0022] (1) Entity normalization: unify the same entities in different forms to standard form:
[0023]
[0024] (2) Relationship standardization: map the fuzzy or diversified relationship in the original natural language to a limited set:
[0025]
[0026] This module ensures that the knowledge graph structure is clear, easy to retrieve and compare, and adapts to the knowledge alignment needs of large models.
[0027] 4. Design a model-independent enhanced input interface that can be integrated with any large language model supporting text generation. The enhancement mechanism runs as an independent input module and does not depend on the internal structure of the model, with high scalability.
[0028] The standard generation input format is defined as:
[0029]
[0030] Wherein:
[0031] : original question;
[0032] : enhanced context generated by the invention;
[0033] : text generation function of any large language model.
[0034] 5. Prompt-guided structured entity and relation extraction mechanism
[0035] Construct a unified structured extraction format, and use a preset prompt to guide the language model to extract the expected entity and relation structure.
[0036] The set is as follows:
[0037] Entity type set:
[0038] Relation label set:
[0039] The extraction output format is:
[0040] Entity output:
[0041]
[0042] Relation output (standard triple):
[0043]
[0044] This mechanism improves the structure and controllability of knowledge graph construction, and is suitable for multiple text types and multi-domain semantic expression.
[0045] 6. Graph triple and RAG text joint construction to generate context method
[0046] A composite context construction method is used to input structured knowledge and unstructured corpus into the generation module. The context contains two parts:
[0047]
[0048] Wherein:
[0049] : semantic related text segment recalled by the RAG module;
[0050] Entity relationship triplets extracted in the knowledge graph.
[0051] 7. Configurable enhancement strategy framework for multi-question types
[0052] The present application proposes an enhanced framework supporting multi-strategy combination, adapting to different problem scenarios and knowledge dependency, and supporting flexible deployment and rapid switching.
[0053] The strategy set is:
[0054]
[0055] LLM: basic language model;
[0056] KG: knowledge graph enhancement;
[0057] RAG: semantic recall enhancement;
[0058] KG+RAG: the fusion strategy proposed by the present application.
[0059] 8. Multi-index evaluation system supports multi-type problem effect verification
[0060] The present application constructs a set of general evaluation index system for different task types (such as question and answer type, selection type, and judgment type), which is used to evaluate the influence of enhancement strategy on generation quality.
[0061] Question and answer type and selection type index:
[0062]
[0063] Among them, is the accuracy, is the illusion rate.
[0064] Judgment type index (applicable to binary classification task):
[0065]
[0066] All models are run under unified parameters to ensure that the comparison results are repeatable and quantifiable.
[0067] The application provides a model hallucination inhibition method fusing a knowledge graph and an RAG mechanism, aiming at the hallucination problem commonly existing in current large language models in open question answering and complex generation tasks, a multi-level and double-channel knowledge enhancement system is constructed. Based on standardized data preprocessing, through structured knowledge graph construction driven by a large language model and construction of a semantic vectorization RAG retrieval library, the structure and semantics are cooperatively supported. In the answer generation process, the application filters the semantic retrieval results by using the structural relationship between entities in the graph through a designed entity consistency verification mechanism, and eliminates information that is similar in semantics but contradictory in fact, thereby effectively inhibiting hallucination caused by false recall. Finally, the candidate text and the corresponding graph information are jointly input as enhanced context into the large model, so that the generation result has more semantic support and structural constraint. Through the design of four generation strategies and the introduction of six local large language models for systematic experimental verification, the application significantly reduces the hallucination rate in question answering, selection and judgment tasks, and improves the answer accuracy and stability; especially in the scene involving logical relationship judgment between entities, the fusion scheme shows higher structural consistency and content credibility compared with the traditional RAG or only relying on the graph strategy. BRIEF DESCRIPTION OF DRAWINGS
[0068] Figure 1 is the overall architecture diagram of the application.
[0069] Figure 2 is a knowledge graph construction and cleaning details diagram.
[0070] Figure 3 is an RAG semantic retrieval and vector library construction details diagram.
[0071] Figure 4 is an entity relationship consistency verification details diagram.
[0072] Figure 5 is a context fusion input and LLM generation details diagram. DETAILED EMBODIMENT
[0073] In order to clearly illustrate the technical implementation process of the application, the specific implementation of the model hallucination inhibition method based on the fusion of knowledge graph and RAG will be described in detail below in combination with the module design, core algorithm logic and experimental verification data.
[0074] 1. Knowledge graph construction and standardization mechanism
[0075] By extracting entities and triple relationships from structured text, a knowledge graph is constructed, and the entities and relationships therein are standardized processed to ensure their retrievability and consistency in subsequent recall verification and enhanced generation.
[0076] Specifically includes the following technical steps:
[0077] (1) Entity and relationship extraction: Use a large language model with prompt control capability, input the answer analysis text after text cleaning, and output standardized structured results, including:
[0078] Entity name and entity type;
[0079] Relationship structure in the form of triple .
[0080] (2) Entity normalization mechanism: Use synonym mapping table to unify entities with different expressions but the same semantics into standard entities,
[0081] For example:
[0082]
[0083] (3) Relationship label standardization mechanism: Map the extracted original semantic relationship to a limited relationship set , the mapping function is as follows:
[0084]
[0085] (4) Graph storage structure: Store the extracted entities and relationships as CSV tables:
[0086] Entity table fields: id, name, type
[0087] Relationship table fields: source_id, target_id, relation_type
[0088] 2. RAG semantic recall library construction
[0089] In terms of semantic enhancement, RAG structure is adopted, the standard answer text is vectorized and encoded, a semantic retrieval library is constructed, and relevance recall is performed in the question input stage.
[0090] (1) Text encoding model: Use a text embedding model to perform vectorization encoding on each cleaned standard answer text :
[0091]
[0092] (2) Vector index construction: All vector sets are constructed into an approximate nearest neighbor index structure to form a semantic library:
[0093]
[0094] (3) Question vectorization and recall: The user input question The same embedding generation is performed:
[0095]
[0096] And perform cosine similarity matching on the vector library:
[0097]
[0098] Extract Top-k related text as candidate knowledge text fragments.
[0099] 3. Illusion filtering mechanism based on graph relationship conflict detection
[0100] To solve the problem of fact error that may be introduced in semantic recall, the invention introduces a conflict detection mechanism based on knowledge graph entity relationship consistency verification to filter the candidate text.
[0101] (1) Entity pair extraction: for each recall text , extract the involved entity pair .
[0102] (2) Graph relationship retrieval: retrieve in the graph database whether there is and and satisfy:
[0103]
[0104] That is, there is a conflict relationship.
[0105] (3) Text elimination: if the candidate text contains a conflict entity relationship pair, it is considered as a potential illusion source, and the elimination operation is performed.
[0106] 4. Context fusion and generation mechanism
[0107] The context construction mechanism combines structure and semantics to form the generation context of the final input large language model.
[0108] (1) Context fusion formula:
[0109]
[0110] Where is the filtered semantic text, is the graph triple.
[0111] (2) Generation input and output:
[0112] The above fusion context and the question are input into the target language model:
[0113]
[0114] The model supports the final answer generation according to semantics and structure guidance.
Claims
1. A model-based hallucination suppression method based on the fusion of knowledge graph and RAG, characterized in that, The method includes: S1. Read the dataset of question-and-answer, selection, correct answer judgment, and incorrect answer judgment questions, extract the corresponding standard answers and explanations, and process them through text denoising, entity normalization and relation standardization to form the knowledge base text; S2. Use a large language model to identify entities and relationships from knowledge base text, construct a knowledge graph and store it in a graph database, and at the same time construct the cleaned standard answers into a RAG retrieval library; S3. Embed the knowledge graph and RAG retrieval library into the RAG framework retrieval module to form an enhanced generation mechanism that combines structured knowledge and semantic retrieval; S4. Based on the enhanced generation mechanism, configure different generation strategies, including a generation strategy based solely on a large language model, a generation strategy that integrates a knowledge graph, a generation strategy that integrates RAG, and a generation strategy that integrates both knowledge graph and RAG. S5. Using the standard answer in the dataset as a benchmark, count the number of correct and incorrect answers for each strategy according to the question type, calculate the illusion rate and accuracy rate, and use them as the evaluation basis for the model's generated results.
2. The model hallucination suppression method based on knowledge graph and RAG fusion according to claim 1, characterized in that: The text denoising includes: removing redundant modifiers, correcting punctuation errors, and spelling correction; the entity normalization is performed using a preset thesaurus mapping table. Implementation, if entity Then the entity is normalized into a unified entity. The relation standardization uses mapping rules to uniformly convert synonymous relations with different expressions into a preset set of relation labels. Standard relational tags in [the language].
3. The model hallucination suppression method based on knowledge graph and RAG fusion according to claim 1, characterized in that: The large language model clarifies the set of entity types by inputting preset prompt words. With relational tag set This guides the model to output structured results; In the entity recognition process, the model identifies entities from the text based on the entity type system defined in the prompt words. ,in During the relation identification process, the model outputs relations in the form of triples. ,in Represents the head entity and the tail entity. Indicates the type of standardized relation.
4. The model hallucination suppression method based on knowledge graph and RAG fusion according to claim 1, characterized in that: The graph database is a graph database, and the knowledge graph files store structured data in a structured storage format; the entity tables are represented in the form of triples as follows: ; The relation table is represented in triplet form as follows: ; The RAG retrieval library is built on the RAG framework and uses a text embedding model as the embedding module for each cleaned standard answer text. Perform semantic encoding to generate vectors ,Right now: ,in ; All vectors A semantic vector library is formed, which is called by the RAG framework retrieval module to achieve Top-k text fragment retrieval and assist in generating context.
5. The model hallucination suppression method based on knowledge graph and RAG fusion according to claim 1, characterized in that: In the enhanced generation mechanism, the retrieval module is built based on the RAG framework and processes the input question. A text embedding model is used for encoding to generate question vectors. ; By calculating and retrieving the vector of each text in the database Cosine similarity: ; Select the top 5 candidate texts based on similarity; then query the relationships between entities involved in the candidate texts in the knowledge graph. If conflicts exist, i.e.: ; If a candidate text is found to be in conflict with an entity, it is considered a conflict and is removed. The remaining candidate text and its corresponding entity's structured relationship in the knowledge graph together form an enhanced context, which is then input into the generative model to generate the answer.
6. The model hallucination suppression method based on knowledge graph and RAG fusion according to claim 1, characterized in that: The method employs multiple locally deployed large language models, all of which run in a unified hardware environment and generate consistent parameters.
7. The model hallucination suppression method based on knowledge graph and RAG fusion according to claim 1, characterized in that: The evaluation metrics for the question-and-answer and multiple-choice questions include accuracy and illusion rate, and their calculation formulas are as follows: ; Number of incorrect answers; Number of correct answers; Total number of questions.
8. The model hallucination suppression method based on knowledge graph and RAG fusion according to claim 1, characterized in that: The judgment-type problem uses binary classification performance evaluation metrics, including precision, recall, and F1 score, which are calculated as follows: ; : Indicates the number of positive samples that the model correctly identifies as positive; : Indicates the number of negative samples that the model misclassifies as positive; : Indicates the number of positive samples that the model misclassifies as negative.