A large model hallucination removal method based on a multi-layer fusion contrast decoding framework

By employing a multi-layered fusion contrast decoding framework and a context-guided factual refocusing module, the illusion phenomenon in large language models is resolved, improving the accuracy and realism of the model output and enhancing the model's generalization ability.

CN119886323BActive Publication Date: 2025-11-18SHENZHEN MSU-BIT UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411703424.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-11-18
Estimated Expiration
2044-11-26

AI Technical Summary

Technical Problem

Large language models are prone to illusions when generating text, resulting in inaccurate and unreliable outputs. Existing methods rely on external resources and have insufficient generalization ability.

Method used

A multi-layer fusion contrast decoding framework is adopted, which combines the final and intermediate layer information of the original model and the illusion model for contrast decoding. A context-guided factual refocusing module is introduced to optimize the decoding strategy and improve the accuracy and realism of the model output.

Benefits of technology

It significantly reduces hallucinations, improves the accuracy and realism of model output, reduces dependence on external resources, and enhances the model's generalization ability across different tasks and datasets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119886323B_ABST
    Figure CN119886323B_ABST
Patent Text Reader

Abstract

The application provides a large model hallucination removal method based on a multi-layer fusion contrast decoding framework, comprising: constructing a large language hallucination removal strategy based on a multi-layer fusion contrast decoding framework, wherein the multi-layer fusion contrast decoding framework of the large language hallucination removal strategy comprises a contrast decoding module based on multi-layer fusion and a fact refocusing module based on context guidance, wherein the contrast decoding module is used for contrast decoding calculation by combining the information of the final layer and the intermediate layer between the original model and the hallucination model, and the fact refocusing module is used for further optimization of the contrast decoding calculation process; and the large language hallucination removal strategy is applied to a large language model to remove hallucinations in natural language processing tasks. The technical scheme of the application not only can improve the accuracy and authenticity of the output of the large language model, but also has good generalization ability and low calculation cost, and is suitable for various natural language processing tasks and application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer technology, and particularly to a large model hallucination removal method based on a multi-layer fusion contrast decoding framework. BACKGROUND

[0002] With the rapid development of artificial intelligence technology, large language models (LLMs) have become a hot research direction in the field of natural language processing (NLP). These models learn rich language knowledge and patterns through pre-training on massive text data, and thus exhibit impressive performance on various NLP tasks.

[0003] However, a key problem faced by large language models in performing natural language processing tasks is the hallucination phenomenon. Hallucination refers to the phenomenon that the model often outputs content that is inconsistent with real-world knowledge or contrary to user expectations when generating text. This phenomenon not only damages the accuracy and credibility of the model output, but also limits the use of the model in application scenarios that require high accuracy, such as automatic news generation, intelligent customer service, and educational assistance. The occurrence of this phenomenon may be due to various factors such as data quality problems encountered by the model during training, unreasonable model structure design, or defects in decoding strategies.

[0004] Existing research attempts to alleviate the hallucination phenomenon by introducing additional external knowledge bases, improving model architecture, or optimizing decoding strategies, but these methods often require a large amount of manual intervention, consume a large amount of computing resources, and are difficult to adapt to different application scenarios and data distributions, further leading to poor accuracy and authenticity of the model output. In addition, these methods may also encounter problems such as decreased model generalization ability and poor scalability in practical applications. SUMMARY

[0005] Therefore, the present application provides a large model hallucination removal method based on a multi-layer fusion contrast decoding framework to at least solve the above problems.

[0006] The application provides a large model hallucination removal method based on a multi-layer fusion contrast decoding framework, comprising: constructing a large language hallucination removal strategy based on a multi-layer fusion contrast decoding framework, wherein the multi-layer fusion contrast decoding framework of the large language hallucination removal strategy comprises a multi-layer fusion contrast decoding module and a context-guided fact refocusing module, wherein the contrast decoding module is used for contrast decoding calculation combined with the information of the final layer and the intermediate layer between the original model and the hallucination model, and the fact refocusing module is used for further optimization of the contrast decoding calculation process; and the large language hallucination removal strategy is applied to a large language model to remove hallucinations in natural language processing tasks.

[0007] In an implementation manner, the contrast decoding module is used for contrast decoding calculation combined with the information of the final layer and the intermediate layer between the original model and the hallucination model, and specifically comprises: a. hallucination model construction: injecting hallucination information into the original model by supervised fine-tuning of the original model on a data set containing non-fact data to obtain a hallucination model; b. contrast decoding: inputting Query X={x1, x2,..., x n} into the original model and the hallucination model respectively to obtain corresponding text reply output distributions, and further realizing contrast decoding by subtracting the probability distribution of the text reply of the original model and the hallucination model; and c. multi-layer fusion: performing multi-layer fusion contrast decoding between the original model and the hallucination model, and fusing the contrast decoding results between the final output layer and the intermediate layer of the two models.

[0008] In another implementation manner, the hallucination model construction process in step a is represented as:

[0009] θ * =FT(θ, D)

[0010] Wherein, FT represents a supervised fine-tuning operation, θ represents an original model, θ* represents a hallucination model, and D is a data set containing hallucination information.

[0011] In another implementation manner, the contrast decoding process in step b is represented as:

[0012] F t =logp(χ t |χ <t ; θ) - λlogp(χ t | χ<t ; θ * )

[0013] p(χ t | χ<t ; θ) = softmax(logit θ (χt |χ <t ))

[0014]

[0015] where F t represents the result of the final layer contrastive decoding between the original model and the hallucination model, θ represents the original model, θ* represents the hallucination model, λ is a hyperparameter that controls the proportion of contrastive decoding when decoding the final layer, p(χ t |χ <t ; θ) represents the standard decoding process of an autoregressive large language model, p(χ t |X <t ; θ) predicts the t-th word according to the results of the previous t-1 words in the reply generation process, logit θ represents the predicted probability of text generation, and softmax is an activation function.

[0016] In another implementation, the multi-layer fusion process in step c includes:

[0017] c11. Contrastively decoding the intermediate layer between the original model and the hallucination model in parallel, which can be expressed by the formula as:

[0018] F′ t = log p(χ t |χ <t ; θ; L) - λ' log p(χ t | χ<t ; θ * ; L)

[0019] where F' t represents the result of the intermediate layer contrastive decoding between the two models, λ' is a hyperparameter that controls the proportion of contrastive decoding when decoding the intermediate layer, and L is a hyperparameter used to specify the intermediate layer of the restoration model and the hallucination model selected by humans;

[0020] c12. Fusing the results of the final layer contrastive decoding and the intermediate layer contrastive decoding of the original model and the hallucination model to achieve a more perfect contrastive decoding calculation, which can be expressed by the formula as:

[0021] F ML = F t + ωF' t

[0022] where F ML represents the result of multi-layer fusion contrastive decoding, and ω is a hyperparameter that controls the proportion of multi-layer fusion.

[0023] In another implementation, the fact refocusing module is used to further optimize the contrast decoding calculation process, specifically including:

[0024] d. Introducing context guidance to the query Query in the process of large language model coding to encourage the large language model to pay more attention to key words or phrases representing facts in the sentence during the contrast decoding process. This step is expressed in formula as:

[0025] F TR =logp(χ t |(χ <t ||χ context );θ)-λ”logp(χ t |(χ <t ||χ context );θ * )

[0026] Where F TR represents the contrast decoding result of the fact refocusing module, λ" is the hyperparameter for controlling the proportion of contrast decoding when decoding the fact refocusing module, X context represents the introduced context information;

[0027] e. The output distribution of the fact refocusing module is fused with the output distribution of the multi-layer fusion contrast decoding module to further improve the authenticity of the output of the large language model. This process is represented as:

[0028] F Final =F ML ±ω’F TR

[0029] p(χ t |χ <t )=softmaX(F Final )

[0030] Where F Final represents the final output distribution of the large language model, and ω' is the hyperparameter for controlling the fusion proportion when calculating the final output distribution.

[0031] In summary, the present application proposes a large model hallucination removal method based on a multi-layer fusion contrast decoding framework. The method adjusts the decoding strategy of the model through multi-layer fusion contrast decoding between the original model and the hallucination model, improves the accuracy and authenticity of the model output, and further improves the performance of the model. At the same time, in the contrast decoding framework, the fact refocusing module based on context guidance is used to enhance the fact encoding and improve the perception ability of the model for text generation, effectively solving the problems of low computational efficiency, dependence on external data resources, and insufficient hallucination removal precision of existing large language model hallucination removal methods. Attached Figure Description

[0032] Figure 1 This is a flowchart illustrating the steps of the large-model illusion removal method based on a multi-layer fusion contrast decoding framework according to an embodiment of the present invention.

[0033] Figure 2 This is a schematic diagram of the architecture of the large model illusion removal method based on a multi-layer fusion contrast decoding framework according to an embodiment of the present invention. Detailed Implementation

[0034] To facilitate understanding, prior art of the present invention will be described by way of example before a detailed description of specific embodiments thereof.

[0035] Related research indicates that the hallucination problem arises from multiple factors. First, pre-training data may contain erroneous or outdated information, which the model may replicate during learning and generation. Second, the model may overfit the training data during fine-tuning, leading to unreliable outputs when faced with unseen data. Furthermore, the model's decoding strategy can also contribute to the hallucination phenomenon; for example, a greedy decoding strategy might select locally optimal words instead of globally most suitable ones, thus affecting the accuracy of the output.

[0036] In recent years, numerous representative research works have emerged in the field to address this problem. One typical type of research uses external knowledge bases to enhance the factuality of models. For example, through retrieval enhancement methods, the model can retrieve relevant information from external knowledge bases when generating each word to help generate more accurate content. Another type of research uses knowledge editing, which involves locating neurons within the model that store incorrect knowledge or cause the model to output illusory information, and correcting them to improve the accuracy and factuality of the model's output. However, these methods typically require additional computational resources and have limited generalization ability across different tasks and datasets.

[0037] Currently, there are many models and methods in the study of illusion removal from large language models. Five common approaches are: reinforcement learning methods based on human feedback, retrieval-based augmentation generation methods, model editing-based methods, representation editing-based methods, and contrastive decoding-based methods.

[0038] Human feedback-based reinforcement learning methods train models to accurately predict human-preferred factual summaries by constructing high-quality corpora and utilizing human feedback. Reinforcement learning is used to reward or punish the model's output based on human preferences, guiding the model to generate more accurate content. However, these methods require a large amount of human feedback, which is costly and inefficient. Moreover, over-reliance on human feedback may cause the model to overfit the training data, affecting its generalization ability in real-world applications.

[0039] Retrieval-augmented generation methods improve the factual accuracy of generated content by retrieving relevant information from external knowledge bases and combining it with large language models. Retrieval-augmented methods typically include a retrieval module that retrieves relevant information from a knowledge base and a generation module that generates text based on the retrieved information. These methods rely on external knowledge bases, limiting the model's independence and generalization ability. Additionally, the retrieval process may increase computational costs and make it difficult to apply in environments without external knowledge support.

[0040] Model editing-based methods modify the model's internal knowledge by techniques such as fine-tuning, meta-learning, or positional editing to change the model's knowledge storage and reduce hallucination. Model editing methods usually require adjusting the model's parameters to reflect new knowledge and information. The main problem with these methods is that they are complex to operate, requiring a deep understanding of the model's internal structure and knowledge representation, and are inefficient and costly. Additionally, the editing process may affect the model's other abilities, such as its original language understanding capabilities.

[0041] Representation editing-based methods improve the factual accuracy of generated content by editing the model's output representations during the reasoning phase. Representation editing methods usually focus on the model's attention mechanism, adjusting attention weights to guide the model to focus on more accurate information and correct the model's output. However, these methods mainly modify the model's attention mechanism to adjust the output representation, which may not fundamentally solve the hallucination problem. Additionally, representation editing may require a large amount of computational resources and time consumption, and requires a high level of understanding of the model's internal mechanisms.

[0042] Contrastive decoding-based methods guide the original model to generate more accurate content by comparing its output distribution with that of one or more other models. However, existing methods usually only focus on the final layer comparison or only perform comparison within a single model, ignoring the useful information that the intermediate layers of the model may contain for hallucination removal. Meanwhile, the simple and rough comparison calculation of previous contrastive decoding methods can easily destroy the original output distribution, leading to poor performance of the model in some scenarios.

[0043] This invention innovates upon existing contrast decoding methods by introducing a multi-layer fusion contrast decoding framework in addition to the final layer contrast decoding of the model. This framework further enhances the performance of the model by simultaneously combining the contrast information from the intermediate and final layers of the original and illusion models.

[0044] Furthermore, this invention also designs a factual refocusing module that utilizes contextual guidance to enhance the model's ability to perceive factual content. This multi-layered fusion and factual perception-enhanced contrastive decoding method helps to effectively reduce the illusion phenomenon in large language models and generate more accurate and realistic text content.

[0045] Specifically, this invention improves the illusion removal method based on contrastive decoding by combining information from the final and intermediate layers between the original model and the illusion model for contrastive decoding. By integrating information from the intermediate and final output layers of the model, it captures the knowledge representation within the model more comprehensively, which helps to handle complex language queries more stably. Furthermore, it designs a context-guided factual refocusing module to guide the model to enhance factual encoding, strengthen the model's ability to capture factual content, and enrich the contrastive decoding framework. This avoids the simple and crude contrastive calculations of traditional contrastive decoding and improves the authenticity and credibility of text generated by large language models.

[0046] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0047] See Figure 1 An embodiment of the present invention provides a method for removing large-model hallucinations based on a multi-layer fusion contrast decoding framework, comprising:

[0048] Step S101: Construct a large-scale language de-illusion strategy based on a multi-layer fusion contrast decoding framework. The multi-layer fusion contrast decoding framework of the large-scale language de-illusion strategy includes a multi-layer fusion-based contrast decoding module and a context-guided factual refocusing module. The contrast decoding module is used to perform contrast decoding calculations by combining the information of the final layer and intermediate layer between the original model and the illusion model. The factual refocusing module is used to further optimize the contrast decoding calculation process.

[0049] Step S102: Apply the large-scale language de-illusion strategy to the large-scale language model to remove illusions in natural language processing tasks.

[0050] Optionally, the contrast decoding module is used to perform contrast decoding calculations by combining information from the final and intermediate layers between the original model and the illusion model, specifically including: a. Illusion model construction: by supervising the fine-tuning of the original model on a dataset containing non-factual data, illusion information is injected into the original model to obtain the illusion model; b. Contrast decoding: the query X = {x1, x2, ..., x...} is used to perform contrast decoding calculations. n The text responses are input into the original model and the hallucination model respectively, and the corresponding text response output distributions are obtained respectively. Further, the text response probability distributions of the original model and the hallucination model are subtracted to achieve comparative decoding; c. Multi-layer fusion: Multi-layer fusion comparative decoding is performed between the original model and the hallucination model, and the comparative decoding results between the final output layer and the intermediate layer of the two models are fused together.

[0051] Optionally, the process of constructing the illusion model in step a can be represented as follows:

[0052] θ * =FT(θ, D)

[0053] Where FT represents supervised fine-tuning operation, θ represents the original model, θ* represents the hallucination model, and D is the dataset containing hallucination information.

[0054] Optionally, the comparison decoding process in step b is represented as follows:

[0055] F t =logp(χ) t |χ <t ;θ)-λlogp(χ t | χ<t ;θ * )

[0056] p(χ t |χ <t ;θ)=softmax(logit θ (X t |X <t ))

[0057]

[0058] Among them, F t This represents the final layer contrast decoding result between the original model and the illusion model, where θ represents the original model, θ* represents the illusion model, λ is a hyperparameter controlling the contrast decoding ratio during the final layer decoding, and p(χ) t |χ <t ;θ) represents the standard decoding process of a large autoregressive language model, p(χ) t |χ <t;θ) In the response generation process, predict the t-th word based on the results of the previous t-1 words, logit θ This represents the predicted probability of text generation, and softmax is the activation function.

[0059] Optionally, the multi-layer fusion process in step c includes:

[0060] c11. Perform parallel comparative decoding on the intermediate layers between the original model and the illusion model. This step is expressed by the following formula:

[0061] F′ t =logp(χ) t |χ <t ;θ;L)-λ'logp(χ t | χ<t ;θ * ;L)

[0062] Among them, F' t This represents the result of the intermediate layer comparison decoding between the two models. λ' is a hyperparameter that controls the comparison decoding ratio during intermediate layer decoding, and L is a hyperparameter used to specify the intermediate layer between the artificially selected restoration model and the illusion model.

[0063] c12. The results of the final layer comparison decoding of the original model and the hallucination model are fused with the results of the intermediate layer comparison decoding to achieve a more complete comparison decoding calculation. This calculation process is expressed by the following formula:

[0064] F ML =F t +ωF' t

[0065] Among them, F ML This represents the result of multi-layer fusion comparison decoding, where ω is a hyperparameter that controls the multi-layer fusion ratio.

[0066] Optionally, the factual refocusing module is used to further optimize the comparison decoding calculation process, specifically including:

[0067] d. Introducing contextual guidance into the query during the encoding process of the large language model to encourage it to pay more attention to factual keywords or phrases in the sentence during contrastive decoding. This step is expressed by the formula:

[0068] F TR =logp(χ) t |(χ <t ||X context );θ)-λ”logp(χ t |(χ <t ||χcontext );θ * )

[0069] Among them, F TR χ represents the contrast decoding result of the factual refocusing module, where λ” is a hyperparameter controlling the contrast decoding ratio during decoding by the factual refocusing module. context Indicates the context information being introduced;

[0070] e. The output distribution of the factual refocusing module is fused with the output distribution of the multi-layer fusion contrast decoding module to further improve the realism of the output of the large language model. This process is represented as follows:

[0071] F Final =F ML +ω'F TR

[0072] p(χ t |χ <t ) = softmax(F Final )

[0073] Among them, F Final ω' represents the final output distribution of the large language model, and is a hyperparameter that controls the fusion ratio when calculating the final output distribution.

[0074] Specifically, the solution of the present invention is further described with reference to the following examples:

[0075] See Figure 2 This is a schematic diagram of the architecture of the large-model illusion removal method based on a multi-layer fusion contrast decoding framework according to an embodiment of the present invention. Figure 2 The module consists of two main parts: the upper part shows the multi-layer fusion-based contrast decoding module (located in the blue box above), and the lower part shows the context-guided factual refocusing module (located in the gray box below). Figure 2 The middle arrow illustrates the data flow of the output distribution during the model inference phase. After comparison and decoding by the two modules, the final output distribution is formed (e.g., ...). Figure 2 (As shown in the bottom right corner).

[0076] The illusion removal method for large language models based on a multi-layer fusion contrastive decoding framework mainly consists of two parts: a multi-layer fusion-based contrastive decoding module and a context-guided factual refocusing module. This method combines the original model and the illusion model within a multi-layer fusion contrastive decoding framework to adjust the model's decoding strategy, improving the accuracy and realism of the model's output. Simultaneously, within the contrastive decoding framework, the context-guided factual refocusing module enhances factual encoding, improving the large language model's ability to perceive the factual nature of generated text. This effectively alleviates the problems of low computational efficiency, reliance on external data resources, and insufficient illusion removal accuracy inherent in existing large language model illusion removal methods.

[0077] First, given the query Query X = {x1, x2, ..., x n The method proposed in this patent utilizes a multi-layered fusion contrastive decoding framework to adjust the model's decoding strategy and output distribution, ultimately generating a more accurate and realistic text response, Response Y={Y1,Y2,…,Y}. m}

[0078] Secondly, the details of the multi-layer fusion-based contrast decoding module and the context-guided factual refocusing module are explained.

[0079] A. Multi-layer fusion-based comparison decoding module

[0080] Multi-layer fusion-based contrast decoding is the core module of this invention. It achieves more refined contrast decoding by comparing the output distribution of the final and intermediate layers of the multi-layer fusion between the original model and the illusion model. The specific implementation steps are as follows:

[0081] a. Illusion Model Construction:

[0082] First, an illusion model needs to be constructed as a comparison object for contrastive decoding to assist the original model in adjusting the decoding strategy. By supervising the original model on a dataset containing non-factual data, illusion information is injected into the original model to obtain the illusion model. This step can be described by the following formula:

[0083] θ * =FT(θ, D)

[0084] Where FT represents supervised fine-tuning operation, θ represents the original model, θ* represents the hallucination model, and D is the dataset containing hallucination information.

[0085] It should be understood that the hallucination model is obtained by supervising the injection of hallucination information.

[0086] b. Comparison and decoding: QueryX = {x1, x2, ..., x...} n The text responses are input into the original model and the hallucination model respectively, yielding corresponding text response output distributions. Further, comparative decoding is achieved by subtracting the probability distributions of the text responses from the original model and the hallucination model. Taking the comparative decoding of the final layer of the model as an example, this process can be described by the following formula:

[0087] F t =logp(χ) t |χ <t ;θ)-λlogp(χ t | χ<t ;θ * )

[0088] p(χ t |χ <t ;θ)=softmax(logit θ (χ t |χ <t ))

[0089]

[0090] Among them, F t This represents the final layer contrast decoding result between the original model and the illusion model, where θ represents the original model, θ* represents the illusion model, λ is a hyperparameter controlling the contrast decoding ratio during the final layer decoding, and p(χ) t | χ<t ;θ) represents the standard decoding process of a large autoregressive language model, p(χ) t |χ <t ;θ) In the response generation process, predict the t-th word based on the results of the previous t-1 words, logit θ This represents the predicted probability of text generation, and softmax is the activation function.

[0091] c. Multi-layer fusion: A multi-layer fusion comparative decoding is performed between the original model and the illusion model. This involves combining the comparative decoding results from the final output layer and the intermediate layer (i.e., the early exit layer) of both models to achieve a more comprehensive and complete comparative decoding. The specific implementation steps are as follows:

[0092] c11. Perform parallel comparative decoding on the intermediate layers between the original model and the illusion model. This step is expressed by the following formula:

[0093] F′ t =logp(χ) t |χ <t ;θ;L)-λ'logp(χ t |χ<t ;θ * ;L)

[0094] Among them, F' t This represents the result of the intermediate layer comparison decoding between the two models. λ' is a hyperparameter that controls the comparison decoding ratio during intermediate layer decoding, and L is a hyperparameter used to specify the intermediate layer between the artificially selected restoration model and the illusion model.

[0095] c12. The results of the final layer comparison decoding of the original model and the hallucination model are fused with the results of the intermediate layer comparison decoding to achieve a more complete comparison decoding calculation. This calculation process is expressed by the following formula:

[0096] F ML =F t +ωF′ t

[0097] Among them, F ML This represents the result of multi-layer fusion comparison decoding, where ω is a hyperparameter that controls the multi-layer fusion ratio.

[0098] B. Context-guided factual refocusing module

[0099] The factual refocusing module aims to add contextual guidance to the query, directing the model to focus more on factual information, enhancing factual encoding, and further improving the authenticity of sentences throughout the comparison and decoding process. The specific implementation steps are as follows:

[0100] d. Introducing contextual guidance into the query during the encoding process of the large language model to encourage it to pay more attention to factual keywords or phrases in the sentence during contrastive decoding. This step is expressed by the formula:

[0101] F TR =logp(χ) t |(χ <t ||χ context );θ)-λ”logp(χ t |(χ <t ||χ context );θ * )

[0102] Among them, F TR χ represents the contrast decoding result of the factual refocusing module, where λ” is a hyperparameter controlling the contrast decoding ratio during decoding by the factual refocusing module. context Indicates the context information being introduced;

[0103] e. The output distribution of the factual refocusing module is fused with the output distribution of the multi-layer fusion contrast decoding module to further improve the realism of the output of the large language model. This process is represented as follows:

[0104] F Final =F ML +ω'F TR

[0105] p(χ t |χ <t ) = softmax(F Final )

[0106] Among them, F Final ω' represents the final output distribution of the large language model, and is a hyperparameter that controls the fusion ratio when calculating the final output distribution.

[0107] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0108] (1) This invention improves the hallucination removal method based on contrast decoding by combining the information of the final and intermediate layers between the original model and the hallucination model for contrast decoding. This fully utilizes the knowledge representation of different models and different levels within the models, avoids the simple and rough contrast calculation of traditional contrast decoding, significantly reduces hallucination phenomena, and improves the accuracy and factuality of the model output.

[0109] (2) The present invention designs a context-guided factual refocusing module, which guides the model to enhance factual encoding and pay more attention to the factuality of text generation during the comparison decoding process, thereby enriching the original comparison decoding framework, further optimizing the comparison decoding calculation process, and improving the authenticity and fluency of the generated content.

[0110] (3) The method of this invention is not limited to the field of illusion removal in large language models. Its core idea is to adjust the model output strategy and correct the model output by using more multi-layered contrastive decoding, so as to improve the text generation of large language models. This method performs well on different base models and plays an important role in improving the reasoning ability and security of large language models. Therefore, the method of this invention has broad application prospects.

[0111] To fully verify the effectiveness and advancement of the proposed method, extensive experiments were conducted on the widely used large-scale language model illusion removal datasets TruthfulQA and FACTOR, based on a multi-layer fusion contrastive decoding framework. The results were compared with state-of-the-art illusion removal methods. MCI, MC2, MC3, and Accuracy were used as evaluation metrics on both datasets. Experimental results show that in most scenarios, the proposed method outperforms the best current illusion removal methods based on contrastive decoding or representation editing across all metrics.

[0112] Furthermore, comparative experiments were conducted with and without the multi-layer fusion-based contrast decoding module, as well as with and without the context-guided factual refocusing module. Removing the multi-layer fusion-based contrast decoding module significantly reduced the model's text generation accuracy, demonstrating the effectiveness and necessity of introducing multi-layer fusion contrast decoding. Simultaneously, removing the context-guided factual refocusing module also resulted in a certain degree of decrease in the model's output accuracy. Moreover, using both modules together better enhanced the illusion removal effect, indicating that introducing multi-layer fusion contrast decoding and guiding the model to enhance factual encoding can effectively improve the contrast decoding framework, enhancing the factual accuracy of the model's output without affecting its fluency.

[0113] It should be noted that the present invention can be a method, system, apparatus, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of the present invention.

[0114] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example, but not limited to, electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0115] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0116] The computer program instructions used to perform the operations of this invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, Python, etc., and conventional procedural programming languages ​​such as "C" or similar languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing state information from the computer-readable program instructions. This electronic circuitry can execute the computer-readable program instructions to implement various aspects of the invention.

[0117] Various aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0118] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0119] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0120] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions. It will be known to those skilled in the art that implementation in hardware, implementation in software, and implementation using a combination of software and hardware are equivalent.

[0121] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, and are not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein. The scope of the invention is defined by the appended claims.

Claims

1. A method for removing large-model illusions based on a multi-layer fusion contrast decoding framework, characterized in that, include: A large-scale language de-illusion strategy based on a multi-layer fusion contrastive decoding framework is constructed. The multi-layer fusion contrastive decoding framework of the large-scale language de-illusion strategy includes a contrastive decoding module based on multi-layer fusion and a context-guided factual refocusing module. The contrastive decoding module is used to perform contrastive decoding calculation by combining the information of the final layer and intermediate layer between the original model and the illusion model. The factual refocusing module is used to further optimize the contrastive decoding calculation process. The aforementioned large-scale language de-illusion strategy is applied to a large-scale language model to remove hallucinations in natural language processing tasks. The comparison decoding module is used to perform comparison decoding calculations by combining the information from the final layer and intermediate layers between the original model and the illusion model. Specifically, it includes: a. Illusion Model Construction: Illusion model is obtained by supervising the original model on a dataset containing non-factual data and injecting hallucination information into the original model; b. Comparison and Decoding: Query The text responses are input into the original model and the hallucination model respectively, and the corresponding text response output distributions are obtained respectively. Further, the text response probability distributions of the original model and the hallucination model are subtracted to achieve comparative decoding. c. Multi-layer fusion: Perform multi-layer fusion comparative decoding between the original model and the illusion model, and fuse the results by combining the comparative decoding results between the final output layer and the intermediate layer of the two models; Step c, the multi-layer fusion process, includes: c11. Performing parallel comparative decoding on the intermediate layers between the original model and the illusion model, this step is expressed by the formula: in, This represents the result of the intermediate layer comparison decoding between the two models. It is a hyperparameter that controls the contrast decoding ratio during intermediate layer decoding. L is a hyperparameter used to specify the intermediate layer between the manually selected restoration model and the illusion model. c12. The results of the final layer comparison decoding of the original model and the hallucination model are fused with the results of the intermediate layer comparison decoding to achieve a more complete comparison decoding calculation. This calculation process is expressed by the following formula: in, F ML This indicates the result of multi-layer fusion comparison decoding. It is a hyperparameter that controls the multi-layer fusion ratio; The factual refocusing module is used to further optimize the comparison decoding calculation process, specifically including: d. During the encoding process of the large language model, contextual guidance is introduced into the query to encourage the large language model to pay more attention to keywords or phrases representing facts in the sentence during contrastive decoding. This step is expressed by the formula: in, F TR This indicates the comparison decoding results of the factual refocusing module. It is a hyperparameter that controls the contrast decoding ratio during the decoding process of the factual refocusing module. Indicates the context information being introduced; e. The output distribution of the factual refocusing module is fused with the output distribution of the multi-layer fusion contrast decoding module to further improve the realism of the output of the large language model. This process is represented as follows: in, F Final This represents the final output distribution of the large language model. It is a hyperparameter that controls the fusion ratio during the final output distribution calculation.

2. The method according to claim 1, characterized in that, The process of constructing the hallucination model in step a is represented as follows: in, FT This indicates the need for oversight and fine-tuning. θ Represents the original model. θ* Represents a hallucination model. D It is a dataset containing hallucination information.

3. The method according to claim 2, characterized in that, The comparison and decoding process in step b is represented as follows: in, F t This represents the result of the final layer comparison decoding between the original model and the illusion model. θ Represents the original model. θ* Represents a hallucination model. λ It is a hyperparameter that controls the contrast decoding ratio during the final layer decoding. This represents the standard decoding process for large autoregressive language models. During the response generation process, the t-th word is predicted based on the results of the previous t-1 words, logit θ This represents the predicted probability of text generation, and softmax is the activation function.

Citation Information

Patent Citations

  • Big language model illusion relieving method based on contrast decoding

    CN118964552A

  • Comparison decoding illusion mitigation method and device based on multiple modes, and terminal

    CN118966387A