Large model illusion suppression method, system and equipment based on dynamic knowledge base and multi-modal consistency constraint
By constructing a dynamic knowledge base and multimodal consistency constraints, the illusion problem in content generation by large language models is solved, real-time updating of the knowledge base and multimodal verification are realized, and the accuracy and consistency of the generated content are improved.
Patent Information
- Application Number
- CN202511937736.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-01-20
AI Technical Summary
Existing large language models are prone to factual illusions when generating content, and existing solutions suffer from problems such as insufficient timeliness of knowledge bases, inadequate multimodal verification, and poor real-time performance of correction mechanisms.
A dynamic knowledge base is constructed, dynamic credibility weights are calculated through multi-source heterogeneous data, and multimodal consistency constraints are introduced during the generation process. Cross-modal feature comparison and constraint loss function are used to correct the generated content, and the model generation accuracy is improved by combining end-to-end optimization process.
It achieves minute-level updates to the knowledge base, supports multimodal cross-validation, reduces the illusion rate, ensures the real-time accuracy and logical consistency of generated content, and reduces latency.
Smart Images

Figure CN121365699A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of artificial intelligence, and particularly relates to a large model hallucination suppression method, system and device based on a dynamic knowledge base and multi-modal consistency constraints. BACKGROUND
[0002] In recent years, large language models (LLMs) represented by the GPT (Generative Pre-trained Transformer) series have made breakthrough progress in tasks such as text understanding, dialogue generation, and code writing. However, these models often exhibit "hallucination" when generating content, i.e., generating information that does not conform to objective facts or is logically self-contradictory. This hallucination problem severely limits their application in fields such as finance, medicine, and law, where information accuracy is highly required.
[0003] Currently, the mainstream method for suppressing large model hallucination generally relies on retrieval-augmented generation (RAG) technology. This technology retrieves relevant information from an external knowledge base and provides it as context to the large language model to guide it to generate more accurate content. However, existing solutions generally have the following shortcomings:
[0004] First, the timeliness of the knowledge base is insufficient. Most solutions use static or quasi-static knowledge bases, which have low content update frequency and cannot keep up with rapidly changing real-world knowledge (such as the latest news events, scientific discoveries, etc.), resulting in hallucinations when the model answers questions related to recent knowledge.
[0005] Second, the verification dimension is single. Traditional retrieval-augmented methods mainly rely on text modal matching and verification, ignoring the rich facts contained in image, video, and other modal information. When faced with complex facts that require multi-modal cross-verification, the text-based verification mechanism is not sufficient and can be easily misled by one-sided or incorrect text information.
[0006] Finally, the real-time performance of the correction mechanism is poor. Some methods use post-processing to verify and correct the generated content. This "generate first, correct later" mode not only increases system latency but also cannot fundamentally prevent hallucinations during the generation process.
[0007] Therefore, how to build a dynamic and multi-modal cross-verification knowledge system and perform real-time constraints during the model generation phase to suppress hallucinations from the source is a technical problem that needs to be solved in the field of large language models.
[0008] Based on this, the application proposes a large model hallucination suppression method, system and equipment based on dynamic knowledge base and multi-modal consistency constraint. SUMMARY
[0009] In order to solve the above-mentioned problems in the prior art, that is, the fact hallucination problem of the existing large language model when generating content, the application provides a large model hallucination suppression method, system and equipment based on dynamic knowledge base and multi-modal consistency constraint.
[0010] In a first aspect of the application, a large model hallucination suppression method based on dynamic knowledge base and multi-modal consistency constraint is proposed, comprising:
[0011] A knowledge base of multi-source heterogeneous data is constructed and dynamically maintained, a dynamic credibility weight is calculated for each piece of knowledge, which is fused with a preset data source authority score, a time decay factor for representing the timeliness of the knowledge, and a multi-modal consistency score calculated by cross-modal feature comparison;
[0012] In the process of driving the large language model to generate content, knowledge related to the current generation context and meeting the preset retrieval condition in terms of dynamic credibility weight is retrieved from the knowledge base fused with the dynamic credibility weight;
[0013] In the generation decoding stage of the model, a constraint loss term is added to the initial preset generation loss function, wherein the constraint loss term is calculated according to the similarity between the feature vector of the current generation content and the weighted average feature vector of the retrieved knowledge, and the generation probability of the subsequent word element is adjusted using the combined loss function, so as to correct the logical consistency and factual accuracy of the generated content.
[0014] Further, the multi-source heterogeneous data at least includes text data, image data, video data and structured data.
[0015] Further, when constructing and dynamically maintaining the knowledge base of multi-source heterogeneous data, it includes collecting and cleaning the multi-source heterogeneous data;
[0016] Among them, the text data is subjected to deduplication processing based on the minimum hash algorithm, the image data and the video data are subjected to semantic label extraction based on a pre-trained object detection model and text extraction based on optical character recognition, and the structured data is subjected to conversion to a resource description framework triple format.
[0017] Further, the dynamic credibility weight is calculated by:
[0018] The data source authority score is obtained based on a preset source type mapping table;
[0019] The time decay factor is calculated based on an exponential decay function, and a multimodal consistency score is obtained by calculating a cross-modal feature similarity;
[0020] The data source authority score, the time decay factor, and the multimodal consistency score are weighted and fused with preset weight coefficients to obtain a dynamic credibility weight;
[0021] The sum of the weight coefficients is 1.
[0022] Further, the step of calculating the multimodal consistency score comprises:
[0023] A feature vector of the text data is extracted using a pre-trained text encoder;
[0024] A feature vector of the image data is extracted using a pre-trained image encoder;
[0025] For video data, a feature vector of the video modality is generated by extracting key frames and extracting features using the image encoder, and calculating the mean value thereof;
[0026] A loss function based on information noise contrast estimation is used to perform cross-modal contrast learning by calculating the cosine similarity of positive sample pairs and the cosine similarity of negative sample pairs in the same training batch, and introducing a temperature coefficient for adjustment, so as to align the feature spaces of the text data, the image data, and the video data;
[0027] The multimodal consistency score is calculated using the aligned feature spaces.
[0028] Further, a constraint loss term is added to the initially preset generation loss function, and the method is as follows:
[0029] The cosine similarity between the feature vector of the current generated content and the weighted average feature vector of the retrieved knowledge is calculated;
[0030] The numerical value 1 is subtracted from the cosine similarity to obtain the constraint loss term;
[0031] The constraint loss term is multiplied by a preset constraint intensity coefficient;
[0032] The multiplied constraint loss term is linearly added to the initially preset generation loss function to obtain a combined loss function for adjusting the subsequent token generation probability.
[0033] Further, the method further comprises an end-to-end joint optimization process, which performs the following steps:
[0034] An adversarial training data set containing factual hallucination samples is constructed;
[0035] The large language model is fine-tuned based on the adversarial training data set by adopting a distributed training strategy and an adaptive optimization algorithm, wherein the fine-tuning process comprises a linear preheating phase.
[0036] In the inference stage, the knowledge retrieval operation is performed by the approximate nearest neighbor index, and the cache management is implemented by the elimination strategy based on the access time ordering of the knowledge fragments.
[0037] In the second aspect of the present application, a large model hallucination suppression system based on a dynamic knowledge base and multi-modal consistency constraint is proposed, based on a large model hallucination suppression method based on a dynamic knowledge base and multi-modal consistency constraint, the system comprises:
[0038] A dynamic knowledge base engine is used to build and dynamically maintain a knowledge base of multi-source heterogeneous data, and to calculate a dynamic credibility weight for each piece of knowledge by fusing a data source authority score, a time decay factor and a multi-modal consistency score;
[0039] A multi-modal alignment module is used to align the feature spaces of text, image and video data through cross-modal contrast learning to calculate the multi-modal consistency score;
[0040] A consistency constraint controller is integrated into the generation layer of the large language model, used to retrieve relevant knowledge from the dynamic knowledge base during the generation process, and perform the following operations: calculate the similarity between the feature vector of the current generated content and the weighted average feature vector of the retrieved knowledge, generate a constraint loss term based on the similarity, and inject the constraint loss term into the initial preset generation loss function;
[0041] A joint optimization module is used to perform an end-to-end joint optimization process, including organizing an adversarial training data set, scheduling a model fine-tuning process, and managing knowledge retrieval and cache strategies in the inference stage.
[0042] Further, the output end of the dynamic knowledge base engine is connected to the retrieval interface of the consistency constraint controller to provide weighted relevant knowledge for the generation process;
[0043] The output end of the multi-modal alignment module is connected to the update interface of the dynamic knowledge base engine and the constraint calculation unit of the consistency constraint controller, respectively, to provide the multi-modal consistency score to update the knowledge weight, and to provide the aligned feature space to calculate the similarity;
[0044] The control end of the joint optimization module is connected to the dynamic knowledge base engine and the large language model, used to coordinate the triggering of incremental updates of the knowledge base and incremental fine-tuning of the model according to user feedback and inference results, forming a closed-loop optimization.
[0045] In the third aspect of the present application, an electronic device is provided, comprising:
[0046] at least one processor; and
[0047] a memory communicatively connected with the at least one processor; wherein,
[0048] the memory stores instructions executable by the processor, the instructions being executed by the processor to implement a large model hallucination suppression method based on a dynamic knowledge base and multi-modal consistency constraints.
[0049] The beneficial effects of the present application are:
[0050] Through the dynamic credibility weight model, combined with the time decay factor, the minute-level update of the knowledge base is realized, ensuring that the model can obtain the latest factual information, and solving the problem of information lag of the traditional static knowledge base.
[0051] Multi-modal consistency constraints are introduced, cross-validation is performed on various information sources such as text, image and video, the one-sidedness or error that may be caused by a single text information source is effectively avoided, and the hallucination rate of the model is significantly reduced.
[0052] The constraint loss function is directly injected in the decoding stage of the model, realizing real-time intervention and correction of the generated content, compared with the traditional post-processing verification method, the delay is lower, and the correction effect is more thorough.
[0053] By constructing a closed-loop joint optimization framework, the updating of the knowledge base and the fine-tuning of the model are mutually promoted, and through the efficient retrieval and caching mechanism, it is ensured that the system can still maintain a low reasoning delay while providing high-accuracy content. BRIEF DESCRIPTION OF DRAWINGS
[0054] Other features, objects and advantages of the present application will become more apparent from the following detailed description of non-limiting embodiments made with reference to the accompanying drawings:
[0055] Figure 1 is a flowchart of the large model hallucination suppression method based on a dynamic knowledge base and multi-modal consistency constraints of the present application;
[0056] Figure 2 is an architectural diagram of the large model hallucination suppression system based on a dynamic knowledge base and multi-modal consistency constraints of the present application;
[0057] Figure 3 is a structural schematic diagram of a computer system of a server for implementing the method, system and device embodiments of the present application. DETAILED DESCRIPTION
[0058] The application will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related application, and not to limit the application. In addition, it should be noted that only the parts related to the application are shown in the drawings for ease of description.
[0059] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict. The present application will be described in detail below with reference to the accompanying drawings and embodiments.
[0060] The first embodiment of the present application provides a large model hallucination suppression method based on dynamic knowledge base and multi-modal consistency constraint, comprising the following steps:
[0061] Step S10, a knowledge base of multi-source heterogeneous data is constructed and dynamically maintained, a dynamic credibility weight of a preset data source authority score, a time decay factor for representing the timeliness of knowledge, and a multi-modal consistency score calculated by cross-modal feature comparison are calculated for each piece of knowledge;
[0062] Step S20, in the process of driving the large language model to generate content, knowledge related to the current generation context and meeting the preset retrieval condition of dynamic credibility weight is retrieved from the knowledge base fused with the dynamic credibility weight;
[0063] Step S30, in the generation decoding stage of the model, a constraint loss term is added to the initial preset generation loss function, wherein the constraint loss term is calculated according to the similarity between the feature vector of the current generation content and the weighted average feature vector of the retrieved knowledge, and the generation probability of the subsequent word element is adjusted by using the combined loss function, so as to correct the logical consistency and factual accuracy of the generated content.
[0064] In order to more clearly illustrate the present application, a large model hallucination suppression method based on dynamic knowledge base and multi-modal consistency constraint, the following will be combined Figure 1 The steps in the embodiments of the present application are described in detail, including steps S10-S30, and the steps are described in detail as follows:
[0065] Step S10, a knowledge base of multi-source heterogeneous data is constructed and dynamically maintained, a dynamic credibility weight of a preset data source authority score, a time decay factor for representing the timeliness of knowledge, and a multi-modal consistency score calculated by cross-modal feature comparison are calculated for each piece of knowledge;
[0066] In this embodiment, the multi-source heterogeneous data at least includes text data, image data, video data and structured data, when constructing and dynamically maintaining the knowledge base of multi-source heterogeneous data, including collecting and cleaning the multi-source heterogeneous data;
[0067] Among them, the deduplication processing based on the minimum hash algorithm is performed on the text data, the semantic label extraction based on the pre-trained object detection model and the text extraction based on the optical character recognition are performed on the image data and the video data, and the conversion to the resource description framework triple format is performed on the structured data.
[0068] In the embodiment, the dynamic credibility weight is calculated by the following method:
[0069] The data source authority score is obtained based on a preset source type mapping table;
[0070] The time decay factor is calculated based on an exponential decay function, and the multi-modal consistency score is obtained by calculating the cross-modal feature similarity;
[0071] The data source authority score, the time decay factor and the multi-modal consistency score are weighted and fused with preset weight coefficients to obtain a dynamic credibility weight;
[0072] The sum of the weight coefficients is 1.
[0073] In the implementation process, real-time or quasi-real-time data pulling is performed from a plurality of preset, heterogeneous data sources. The data specifically can include: obtaining the latest news events in JSON format by continuously calling the API interface provided by the news service provider; using a document parsing library such as PyMuPDF to batch parse the PDF files stored in the academic paper library and extract the text and chart information therein; processing real-time video streams by integrating the FFmpeg tool, such as setting to extract a key image every 5 seconds; and deploying an Apache Kafka consumer client to subscribe to the user interaction log stream in real time and mine valuable factual information therefrom. Through such a multi-source acquisition strategy, it is ensured that the knowledge base can cover data in multiple dimensions from news current affairs, professional knowledge to user feedback.
[0074] After data acquisition, since the original data often contains noise, redundancy and format problems, cleaning and preprocessing operations must be performed to convert them into a standardized format for knowledge graph construction.
[0075] For the collected text data, regular expression-based rules are first applied to filter out common advertisements, copyright statements and other non-knowledge content. To solve the content duplication problem in large-scale text, the MinHash algorithm is used. In this embodiment, the length of the hash signature can be set to 64 bits, and the Jaccard similarity between texts is calculated to efficiently identify and eliminate low-quality duplicate content that is highly overlapped or identical in semantics.
[0076] For image data, and keyframes extracted from video streams, the embodiment adopts a dual information extraction strategy: on the one hand, a pre-trained object detection model on large-scale visual datasets, such as YOLOv7, is used to automatically identify and label the main objects and scenes in the image, generating a set of semantic labels; on the other hand, by calling mature optical character recognition (OCR) engines such as Tesseract, embedded text that may exist in the image is extracted. This process converts unstructured visual information into structured label and text information.
[0077] For table-like data (such as CSV files) from structured databases or logs, the semantic web toolkit Apache Jena is used to automatically convert them into Resource Description Framework (RDF) triples, which is the standard representation of building knowledge graphs, greatly facilitating subsequent knowledge fusion and reasoning. The triple format is the subject-predicate-object format.
[0078] After completing the standardization of the data, a dynamic credibility weight W is calculated for each piece of knowledge entity e to be stored in the database. e The weight is a comprehensive indicator that aims to quantify the reliability and timeliness of knowledge, and its calculation formula is: , represents the data authority score. The system maintains a configurable source type mapping table, which pre-sets authority scores for different levels of data sources, for example, knowledge from a top academic journal library scores 0.9, knowledge from an official authoritative media scores 0.8, and knowledge from ordinary social media or user-generated content scores 0.3. The second term, is a time decay factor that measures the freshness of knowledge, which is calculated by an exponential decay function . Where, is the current system time, is the publication time of the knowledge, and the decay coefficient λ can be set to 0.01 in this embodiment, which corresponds to a half-life of about 3 months for knowledge weight, ensuring that newly occurring knowledge can obtain a higher weight. The third term, is the multi-modal consistency score, which is calculated by calculating the similarity between different modal feature representations of the knowledge as an internal cross-validation indicator. Finally, the three scores are weighted and summed by a set of pre-set weight coefficients α, β, γ that add up to 1 to obtain the final dynamic credibility weight. In a preferred configuration, these coefficients can take values α=0.5, β=0.3, γ=0.2.
[0079] In this embodiment, the step of calculating the multi-modal consistency score includes:
[0080] extracting feature vectors of the text data using a pre-trained text encoder;
[0081] extracting feature vectors of the image data using a pre-trained image encoder;
[0082] For video data, by extracting key frames and extracting features using the image encoder, the mean value thereof is calculated to generate a feature vector of the video modality;
[0083] By calculating the cosine similarity of positive sample pairs and the cosine similarity of negative sample pairs in the same training batch, and introducing a temperature coefficient for adjustment, a loss function based on information noise contrast estimation is adopted to perform cross-modal contrast learning, thereby aligning the feature spaces of the text data, image data and video data;
[0084] The multi-modal consistency score is calculated using the aligned feature space.
[0085] In specific implementation, for text data, the present application adopts a large-scale autoregressive language model, such as the RoBERTa-large model, which contains 24 Transformer layers and can deeply capture the semantic information of the text and stably output a 768-dimensional feature vector for the input text sequence.
[0086] For image data, a visual and language pre-trained model, such as CLIP-ViT-L / 14, is adopted, which is based on the Vision Transformer architecture, in which the image is divided into 14x14 pixel patches, and finally a 512-dimensional feature vector is generated, which can capture both the visual content and the semantic concept of the image.
[0087] For more complex video data, the system first adopts a key frame extraction strategy for dimension reduction processing, for example, a fixed time interval is set to extract a frame of image from the video stream, and the extracted key frame image sequence is input into the aforementioned CLIP-ViT-L / 14 to extract the feature vector of each frame, and finally a single feature vector that can comprehensively represent the core content of the entire video is generated by calculating the arithmetic mean of these feature vectors.
[0088] After obtaining the respective independent feature vectors of the text, image and video, since they come from different encoders and have different dimensions, these vectors cannot be directly compared in the original feature space. Therefore, cross-modal contrast learning is used to align these heterogeneous feature spaces. The present embodiment adopts an improved information noise contrast estimation (InfoNCE) loss function to guide this alignment process. The specific mathematical expression of the loss function is:
[0089] ;
[0090] where sim(·) function represents cosine similarity calculation, which measures the consistency of two feature vectors in direction. With a positive sample pair, i.e. they are semantically associated text and image, e.g. from MS-COCO and other image-text pair datasets. While negative samples are randomly sampled feature vectors from other samples in the same training batch. Temperature coefficient τ is a hyper-parameter, in this embodiment its default value is set to 0.05, which is used to adjust the sensitivity of the model to the similarity of positive and negative sample pairs, smaller value will encourage the model to distinguish similar negative samples.
[0091] By minimizing this contrastive loss function on large-scale multi-modal datasets such as MS-COCO and HowTo100M (video-text pair), the parameters of the text encoder and image / video encoder in the model will be fine-tuned, so that semantically related content of different modalities is pulled closer in the shared feature space, while semantically unrelated content is pushed further apart. After training, these aligned encoders can be used to calculate the final consistency score. In specific applications, for a knowledge entry in the knowledge base containing multi-modal information, such as a piece of text and a matching image, the system calls the aligned encoders to extract its text features and image features respectively, and then calculates the cosine similarity between the two feature vectors. This calculated similarity value is a scalar between -1 and 1, which is directly used as the multi-modal consistency score of the knowledge , and finally integrated into the calculation of dynamic confidence weight , providing an internal cross-validation basis for the reliability of the knowledge.
[0092] Step S20, in the process of driving the large language model to generate content, retrieving knowledge related to the current generation context and meeting the preset retrieval conditions of the dynamic confidence weight from the knowledge base fused with the dynamic confidence weight;
[0093] In practice, when a large language model (LLM) is driven to generate textual content, for example, in the decoding phase of responding to a user query or performing a specific content creation task, the system performs a knowledge retrieval step in real time. The purpose of this step is to provide factual basis from an external dynamic knowledge base for each step of the model generation, thereby actively correcting potential hallucinations. The retrieval process is used to obtain the most relevant and credible knowledge fragments in terms of semantics. Specifically, after the model generates a sequence of text, i.e., the "current generation context", which can include the user's initial input and the partial output generated by the model, the context is first input into the same pre-trained text encoder used when building the knowledge base, for example, a RoBERTa-large model with 24 Transformer layers and an output of 768-dimensional vectors, to generate a query feature vector.
[0094] Subsequently, the system uses this query vector to perform a high-speed approximate nearest neighbor search in the pre-constructed vector index to recall the most relevant candidate knowledge in terms of semantics. The present embodiment uses the Facebook AI Similarity Search library to build and query the index. Specifically, the index structure uses an efficient index scheme configured by the IVF2048 (i.e., an inverted file using 2048 cluster centers) and PQ32 (i.e., product quantization using 32 sub-quantizers) parameter combination. This configuration can greatly compress vector storage space and speed up similarity calculation while ensuring high recall rate. The goal of this stage is to quickly filter out the Top-K candidate knowledge fragments that are most semantically similar to the current generation context from hundreds of millions of knowledge entries, and K is a configurable hyperparameter, K=50 in the present embodiment.
[0095] After obtaining the Top-K candidate knowledge list, the system enters a key reordering and filtering stage, which deeply integrates the dynamic credibility weight of the core of the present invention. The system reads the pre-computed and stored values of each candidate knowledge fragment and filters them according to a pre-set retrieval condition. This condition can be a simple threshold, for example, only keeping those knowledge with a dynamic credibility weight greater than 0.7, thereby directly eliminating low-quality, outdated, or multi-modal conflict knowledge.
[0096] Furthermore, the system can design a fusion ranking score, which is a combination of the semantic similarity score and the dynamic credibility weight The candidate set is then re-ranked by a combined score, which is a weighted combination of the retrieval score and the constraint loss. Finally, after a series of retrieval, filtering and re-ranking operations, the system outputs a much smaller list of high-quality knowledge, which is not only highly relevant to the current generation task, but also has its factual accuracy and timeliness quantitatively guaranteed, laying a solid foundation for subsequent injection of constraint loss function and real-time correction.
[0097] To further improve the overall performance of the system, the retrieval module is also assisted by a memory cache server using the Least Recently Used (LRU) strategy, which is used to cache high-frequency queries and their corresponding retrieval results, ensuring instant response when dealing with repeated or similar contexts.
[0098] Step S30, in the generation decoding stage of the model, a constraint loss term is added to the initially preset generation loss function, wherein the constraint loss term is calculated according to the similarity between the feature vector of the current generation content and the weighted average feature vector of the retrieved knowledge, and the combined loss function is used to adjust the generation probability of the subsequent word units, so as to correct the logical consistency and factual accuracy of the generation content.
[0099] In this embodiment, a constraint loss term is added to the initially preset generation loss function, and the method is as follows:
[0100] Calculate the cosine similarity between the feature vector of the current generation content and the weighted average feature vector of the retrieved knowledge;
[0101] Subtract the cosine similarity from the value 1 to obtain the constraint loss term;
[0102] Multiply the constraint loss term by a preset constraint strength coefficient;
[0103] Linearly add the multiplied constraint loss term to the initially preset generation loss function to obtain a combined loss function for adjusting the generation probability of subsequent word units.
[0104] In the implementation of this embodiment, the system needs to obtain two key feature vectors. The first one is the feature vector of the current generation content This vector is calculated by concatenating the user input with the part of the text sequence generated by the model up to the current time step, and then feeding the concatenated complete context into a pre-trained text encoder, such as the RoBERTa-large model, which is the same as the one used in the construction of the knowledge base. This ensures that the semantic representation of the generated content and the semantic representation of the knowledge in the knowledge base are in the same aligned feature space, so that they can be directly compared meaningfully.
[0105] The second one is the weighted average feature vector of the retrieved knowledge In step S20, the system has retrieved a set of knowledge snippets from the dynamic knowledge base that are relevant to the current context semantics and have high credibility. To fuse these discrete knowledge points into a unified, authoritative guidance signal, the system performs a weighted average of their feature vectors. The specific calculation is as follows: multiply the feature vector v i of each retrieved knowledge snippet i by its corresponding dynamic credibility weight W ei , then add up all the results, and finally divide by the sum of all the weights.
[0106] After obtaining the two core feature vectors and , the system begins to calculate the constraint loss term . The first step is to calculate the cosine similarity between the two vectors, which measures the degree of consistency between the current generation direction of the model and external knowledge facts, with a value range of [-1, 1]. The second step is to subtract the cosine similarity from the value 1 to obtain L constraint =1-sim(f text ,f knowledge ). This design has a clear physical meaning: when the generated content is completely consistent with the knowledge, the similarity is 1, the loss term is 0, and no penalty is applied; when the two directions are completely opposite, the similarity is -1, the loss term reaches a maximum value of 2, and the maximum penalty is applied.
[0107] Finally, the system integrates this calculated constraint loss term into the final loss function of the model. The initial preset generation loss function is usually the standard cross-entropy loss , which aims to maximize the probability of the model predicting the correct next word token. The invention multiplies the constraint loss term by a preset constraint strength coefficient λ, then linearly adds it to the initial , forming a combined total loss function: ;
[0108] Among them, the constraint strength coefficient λ in this embodiment can be set to a value range of 0.1 to 1.0, and the initial value is preferably 0.7, used to balance the relationship between following the original language pattern and following external factual knowledge.
[0109] In the actual decoding process, the system uses this combined loss function to adjust the generation probability of subsequent word tokens. Specifically, the model calculates Regarding the gradient of its output layer logits, and using this gradient information to update or correct the original logits distribution, and then generating the final token probability distribution through the Softmax function. This revised probability distribution will reduce the generation probability of those tokens that may lead to conflicts with the knowledge base, while increasing the probability of those tokens that are consistent with the knowledge facts, thereby fundamentally guiding the model to generate more accurate and reliable content.
[0110] The method described in this embodiment also includes an end-to-end joint optimization process that performs the following steps:
[0111] Constructing an adversarial training dataset containing factual hallucination samples;
[0112] Using a distributed training strategy and adaptive optimization algorithm to fine-tune the large language model based on the adversarial training dataset, where the fine-tuning process includes a linear warm-up phase.
[0113] In the inference phase, perform knowledge retrieval operations through approximate nearest neighbor indexing, and implement a cache management strategy based on access time ordering for knowledge fragments.
[0114] In the implementation of this embodiment, the construction of the dataset is not simply using standard corpus, but through mixing real data with carefully constructed hallucination samples. The sources of hallucination samples are diverse. On the one hand, it can rely on human annotation, and domain experts can write statements that seem reasonable but contradict facts for specific topics (such as medical, legal); on the other hand, it can also use automated methods, for example, using another unconstrained large language model to generate text containing factual errors, and then screening. In this embodiment, a preferred dataset source is to expand the publicly available FEVER dataset, use the existing "Refutes" category samples as negative examples, and generate more diverse hallucination samples, finally form a mixed training set containing a large number of positive examples (factually correct) and negative examples (factually incorrect), in order to improve the discrimination ability of the model.
[0115] After obtaining the adversarial training dataset, the system performs efficient model fine-tuning. Considering the huge parameter quantity of large language models, usually more than 100 billion, traditional single-machine training methods are difficult to handle. Therefore, the embodiment adopts an advanced distributed training strategy. Specifically, the system adopts the ZeRO-3 parallel strategy in the DeepSpeed framework. This strategy reduces the peak memory pressure of a single GPU by distributing the model's parameters, gradients, and optimizer states to the memory of all GPUs in the cluster, allowing efficient full-parameter fine-tuning on a standard computing cluster consisting of 8 NVIDIA A100 GPUs. In terms of optimization algorithms, the system selects the AdamW optimizer in the adaptive optimization algorithm and configures an initial learning rate of 3e-5. To ensure the stability of the training process, the fine-tuning process also includes a linear warm-up phase, in which the learning rate increases linearly from 0 to the preset 3e-5 in the first 10% of the total training steps, and then decays according to the predetermined strategy.
[0116] The process also optimizes the inference stage of the model to ensure the real-time response capability of the system. When the model is deployed online and receives user requests, the efficiency of knowledge retrieval is crucial. To this end, the system adopts a retrieval scheme based on approximate nearest neighbor (ANN) index. Specifically, all knowledge feature vectors in the knowledge base are pre-loaded into a high-performance index constructed by the Faiss library. This index uses the parameter configuration of IVF2048 and PQ32, which can significantly improve the retrieval speed of massive vectors while sacrificing a small amount of accuracy, ensuring that the response time of a single retrieval is stable within 50 milliseconds. At the same time, to further reduce the latency of high-frequency queries;
[0117] The embodiment also implements an efficient cache management mechanism. This mechanism uses a least recently used (LRU) strategy based on access time ordering, which caches frequently queried or system-highly-retrieved knowledge fragments and their feature vectors in high-speed memory. When a new retrieval request arrives, the system will first query the cache. Through the joint optimization of training and inference, the invention forms a complete closed loop from data, training to deployment, ensuring the efficiency, stability and reliability of hallucination suppression in practical applications.
[0118] Although the above embodiment describes the steps in the above order, those skilled in the art can understand that, in order to achieve the effect of the embodiment, the steps do not have to be executed in this order, they can be executed simultaneously (in parallel) or in reverse order, and these simple changes are within the scope of the invention.
[0119] As Figure 2As shown, the second embodiment of the present application proposes a large model hallucination suppression system based on a dynamic knowledge base and multi-modal consistency constraints, based on a large model hallucination suppression method based on a dynamic knowledge base and multi-modal consistency constraints, the system comprises:
[0120] A dynamic knowledge base engine is used to build and dynamically maintain a knowledge base of multi-source heterogeneous data, and to calculate a dynamic credibility weight for each piece of knowledge by fusing data source authority scores, time decay factors and multi-modal consistency scores;
[0121] A multi-modal alignment module is used to align the feature spaces of text, image and video data through cross-modal contrast learning to calculate the multi-modal consistency score;
[0122] A consistency constraint controller is integrated into the generation layer of the large language model, used to retrieve relevant knowledge from the dynamic knowledge base during generation, and perform the following operations: calculate the similarity between the feature vector of the current generated content and the weighted average feature vector of the retrieved knowledge, generate a constraint loss term based on the similarity, and inject the constraint loss term into the initial preset generation loss function;
[0123] A joint optimization module is used to perform an end-to-end joint optimization process, including organizing an adversarial training data set, scheduling a model fine-tuning process, and managing knowledge retrieval and caching strategies in the inference stage.
[0124] In this example, the output end of the dynamic knowledge base engine is connected to the retrieval interface of the consistency constraint controller to provide weighted relevant knowledge for the generation process;
[0125] The output end of the multi-modal alignment module is connected to the update interface of the dynamic knowledge base engine and the constraint calculation unit of the consistency constraint controller, respectively, to provide multi-modal consistency scores to update knowledge weights and to provide aligned feature spaces to calculate similarity;
[0126] The control end of the joint optimization module is connected to the dynamic knowledge base engine and the large language model, used to coordinate the triggering of incremental updates of the knowledge base and incremental fine-tuning of the model according to user feedback and inference results, forming a closed-loop optimization.
[0127] In this embodiment, the connection of the multi-modal alignment module and other modules is realized as two independent service interfaces:
[0128] The output end is connected to the update interface of the dynamic knowledge base engine, and the specific implementation is as follows: when the knowledge base engine processes a new multi-modal knowledge item, it sends the text and image / video data of the item to an internal calculation service (such as a gRPC service) provided by the multi-modal alignment module. After the service calculation is completed, a floating point value, i.e. the multi-modal consistency score, is returned synchronously The knowledge base engine then uses the score to update the dynamic confidence weight of the knowledge.
[0129] The output thereof is connected with a consistency constraint controller, and the consistency constraint controller is specifically implemented as follows: the multi-modal alignment module encapsulates the trained text encoder into an independent text embedding service. When the consistency constraint controller needs to calculate the feature vector of the current generated content , the service is directly called, the text string is transmitted, and the service returns a 768-dimensional feature vector conforming to the alignment feature space, thereby ensuring the effectiveness of subsequent similarity calculation.
[0130] The joint optimization module serves as the control brain of the system, and the connection mode is embodied as the issuance of control signaling and the scheduling of a work flow. The joint optimization module is connected with the dynamic knowledge base engine and the training management interface of the large language model through an internal message queue (such as RabbitMQ or Kafka) or direct API calling. When the system receives user correction feedback or monitors a low-confidence generation case, the joint optimization module performs the following operations: on the one hand, an instruction is sent to the update API of the dynamic knowledge base engine, and the corrected fact information is carried to adjust the weight of the corresponding knowledge or add new knowledge; on the other hand, the case is formatted and stored in the adversarial training data set, and a preset automated training pipeline (such as Jenkins or Kubeflow Pipeline) is triggered, the pipeline loads the latest model parameters and data set, and performs an incremental fine-tuning task on the large language model, thereby realizing closed-loop adaptive optimization of the entire system.
[0131] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process and related description of the system described above can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0132] It should be noted that the large model hallucination suppression system based on a dynamic knowledge base and multi-modal consistency constraints provided in the foregoing embodiments is only exemplified by the division of the foregoing functional modules, and in actual application, the foregoing functions can be completed by different functional modules according to needs, that is, the modules or steps in the embodiments of the present application are further decomposed or combined, for example, the modules in the foregoing embodiments can be combined into one module, or can be further split into multiple sub-modules to complete all or part of the functions described above. The names of the modules and steps involved in the embodiments of the present application are only for distinguishing the modules and steps, and should not be considered as an improper limitation on the present application.
[0133] The electronic device of the third embodiment of the present application comprises:
[0134] at least one processor; and
[0135] a memory in communication connection with the at least one processor; wherein
[0136] The memory stores instructions executable by the processor, and the instructions are executed by the processor to implement the above-mentioned large model hallucination suppression method based on dynamic knowledge base and multi-modal consistency constraint.
[0137] A computer-readable storage medium of a fourth embodiment of the application, the computer-readable storage medium stores computer instructions, and the computer instructions are used to be executed by the computer to implement the above-mentioned large model hallucination suppression method based on dynamic knowledge base and multi-modal consistency constraint.
[0138] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes and related descriptions of the storage device and the processing device described above can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.
[0139] Those skilled in the art should appreciate that the modules, method steps of various examples described in connection with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. The software modules, method steps corresponding to the program can be placed in random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art. In order to clearly illustrate the interchangeability of electronic hardware and software, the components and steps of each example have been generally described in the above description. Whether the functions are performed in electronic hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the application.
[0140] Reference is made below to Figure 3 which shows a structural schematic diagram of a computer system of a server for implementing the method, system and device embodiments of the present application. Figure 3 The server shown is only an example and should not impose any limitation on the functions and use range of the embodiments of the present application.
[0141] As Figure 3As shown, the computer system includes a central processing unit (CPU) 301 which can perform various appropriate actions and processes in accordance with a program stored in a read only memory (ROM) 302 or a program loaded from a storage section 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the system are also stored. The CPU 301, the ROM 302, and the RAM 303 are connected to each other through a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0142] Connected to the I / O interface 305 are an input section 306 including a keyboard, a mouse, etc.; an output section 307 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; the storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as required. A removable recording medium 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 310 as required, so that a computer program read out therefrom is installed in the storage section 308 as required.
[0143] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program comprising program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication section 309, and / or installed from the removable medium 311. When the computer program is executed by the central processing unit (CPU) 301, the above-described functions defined in the methods of the present application are performed. It should be noted that the computer readable medium of the present application can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may, for example, be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any suitable combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus or device. In the present application, the computer readable signal medium can include a data signal carried in a baseband or as part of a carrier wave, in which the computer readable program code is carried. Such a propagated data signal can take any of a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate or transport a program for use by or in connection with an instruction execution system, apparatus or device. Program code contained on the computer readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire line, optical fiber cable, RF, etc., or any suitable combination of the above.
[0144] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0145] The computer program instructions can also be loaded onto a computer or other programmable information processing apparatus to cause a series of operations to be performed on the computer or other programmable information processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable information processing apparatus implement the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0146] The terms "first", "second", etc. are used to distinguish between similar objects, and are not used to describe or indicate a particular order or sequence.
[0147] The terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus.
[0148] The technical scheme of the present application has been described in combination with the preferred embodiments shown in the drawings, but it is easy for those skilled in the art to understand that the protection scope of the present application is obviously not limited to these specific embodiments. Those skilled in the art can make equivalent changes or replacements to the related technical features without departing from the principles of the present application, and the technical schemes after the changes or replacements will all fall within the protection scope of the present application.
Claims
1. A large model hallucination suppression method based on a dynamic knowledge base and multi-modal consistency constraints, characterized in that, The method comprises the following steps: constructing and dynamically maintaining a knowledge base of multi-source heterogeneous data, calculating a dynamic credibility weight for each piece of knowledge, which is a fusion of a preset data source authority score, a time decay factor for representing the timeliness of the knowledge, and a multimodal consistency score calculated by cross-modal feature comparison; in the process of driving a large language model to generate content, retrieving knowledge related to the current generation context and meeting the preset retrieval conditions of the dynamic credibility weight from the knowledge base fused with the dynamic credibility weight; in the generation decoding stage of the model, adding a constraint loss term to the initially preset generation loss function, wherein the constraint loss term is calculated according to the similarity between the feature vector of the current generation content and the weighted average feature vector of the retrieved knowledge, and the combined loss function is used to adjust the generation probability of the subsequent word units, thereby correcting the logical consistency and factual accuracy of the generated content.
2. The large model hallucination suppression method based on dynamic knowledge base and multi-modal consistency constraint according to claim 1, characterized in that, The multi-source heterogeneous data at least includes text data, image data, video data and structured data.
3. The method of claim 2, wherein the method is based on a dynamic knowledge base and multi-modal consistency constraints. When constructing and dynamically maintaining the knowledge base of multi-source heterogeneous data, the multi-source heterogeneous data is collected and cleaned. Among them, the text data is subjected to deduplication processing based on the minimum hash algorithm, the image data and the video data are subjected to semantic label extraction based on a pre-trained object detection model and text extraction based on optical character recognition, and the structured data is converted into a resource description framework triple format.
4. The large model hallucination suppression method based on dynamic knowledge base and multi-modal consistency constraint according to claim 1, characterized in that, The calculation method of the dynamic credibility weight is as follows: obtain the data source authority score based on a preset source type mapping table; calculate the time decay factor based on an exponential decay function, and obtain the multimodal consistency score by calculating the cross-modal feature similarity; weight and fuse the data source authority score, the time decay factor and the multimodal consistency score with preset weight coefficients to obtain the dynamic credibility weight; wherein the sum of each weight coefficient is 1.
5. The method of claim 1, wherein, The steps of calculating the multimodal consistency score include: extracting the feature vector of the text data using a pre-trained text encoder; extracting the feature vector of the image data using a pre-trained image encoder; for video data, extracting features by extracting key frames and using the image encoder, calculating the mean value to generate a feature vector of the video modality; using a loss function based on information noise contrast estimation, calculating the cosine similarity of positive sample pairs and the cosine similarity of negative sample pairs in the same training batch, and introducing a temperature coefficient for adjustment to perform cross-modal contrast learning, thereby aligning the feature spaces of text data, image data and video data; calculate the multimodal consistency score using the aligned feature space.
6. The method of claim 1, wherein the method is based on a dynamic knowledge base and multi-modal consistency constraints. The method of adding a constraint loss term to the initially preset generation loss function is as follows: calculate the cosine similarity between the feature vector of the current generation content and the weighted average feature vector of the retrieved knowledge; subtract the cosine similarity from the value 1 to obtain the constraint loss term; multiply the constraint loss term by a preset constraint intensity coefficient; linearly add the multiplied constraint loss term and the initially preset generation loss function to obtain a combined loss function for adjusting the generation probability of subsequent word units.
7. The method of claim 1, wherein the method is based on a dynamic knowledge base and multi-modal consistency constraints. The method further comprises an end-to-end joint optimization process which performs the following steps: constructing an adversarial training dataset containing factual hallucination samples; adopting a distributed training strategy and an adaptive optimization algorithm to fine-tune a large language model based on the adversarial training dataset, wherein the fine-tuning process includes a linear warm-up phase; in the inference stage, performing knowledge retrieval operations through approximate nearest neighbor indexing, and implementing a cache management policy based on access time ordering for knowledge fragments.
8. A large model hallucination suppression system based on dynamic knowledge base and multi-modal consistency constraints, based on the large model hallucination suppression method based on dynamic knowledge base and multi-modal consistency constraints of any one of claims 1-7, characterized in that, The system comprises: a dynamic knowledge base engine for constructing and dynamically maintaining a knowledge base of multi-source heterogeneous data, and calculating a dynamic credibility weight for each piece of knowledge by fusing data source authority scores, time decay factors, and multi-modal consistency scores; a multi-modal alignment module for aligning the feature spaces of text, image, and video data through cross-modal contrastive learning to calculate the multi-modal consistency scores; a consistency constraint controller integrated into the generation layer of a large language model, for retrieving relevant knowledge from the dynamic knowledge base during the generation process, and performing the following operations: calculating the similarity between the feature vector of the current generated content and the weighted average feature vector of the retrieved knowledge, generating a constraint loss term based on the similarity, and injecting the constraint loss term into the initial preset generation loss function; a joint optimization module for performing an end-to-end joint optimization process, including organizing adversarial training datasets, scheduling model fine-tuning processes, and managing knowledge retrieval and caching strategies in the inference stage.
9. The large model hallucination suppression system based on dynamic knowledge base and multi-modal consistency constraint according to claim 8, characterized in that, The output of the dynamic knowledge base engine is connected to the retrieval interface of the consistency constraint controller to provide weighted relevant knowledge for the generation process; The output of the multi-modal alignment module is connected to the update interface of the dynamic knowledge base engine and the constraint calculation unit of the consistency constraint controller, respectively, to provide multi-modal consistency scores for updating knowledge weights and aligned feature spaces for calculating similarity; The control end of the joint optimization module is connected to the dynamic knowledge base engine and the large language model, for coordinating the triggering of incremental updates of the knowledge base and incremental fine-tuning of the model based on user feedback and inference results, forming a closed-loop optimization.
10. An electronic device, comprising: comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the processor, the instructions being executed by the processor to implement the method of claim 1-7.
Citation Information
Patent Citations
RAG-based multi-source heterogeneous data fusion system
CN120450024A
Knowledge graph construction method and system based on large language model technology
CN120523966A
Commemorative venue privatized knowledge base system based on large language model and illusion constraint resisting method of commemorative venue privatized knowledge base system
CN120541163A
Question answering method and system based on knowledge graph
CN121071073A
Question and answer processing method and related device
CN121071093A
Cited By
Dynamic weighted multi-knowledge-base-based medical question and answer enhanced generation method and system
CN121597846A
Multimodal image processing method and system based on constraint propagation
CN121636743A
AIGC intelligent agent based on fusion of multiple models
CN121660110A
Illusion mitigation method and device for multi-modal large language model
CN121661442A
Dynamic causal enhanced intelligent medical illusion detection and correction method and system
CN121768645A