Large model illusion removal method based on multilayer fusion contrast decoding framework
By adopting a multi-layer fusion contrast decoding framework and factual refocus module in large language models, the illusion phenomenon problem that the model appears in natural language processing tasks is solved, the accuracy and authenticity of the output is improved, and the use of computing resources is optimized.
Patent Information
- Application Number
- CN202411703424.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-11-26
Smart Images

Figure CN119886323A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of computer technology, and in particular to a large model hallucination removal method based on a multi-layer fusion contrast decoding framework. Background Art
[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 have learned rich language knowledge and patterns through pre-training on massive text data, thus showing impressive performance in a variety of NLP tasks.
[0003] However, large language models face a key problem when performing natural language processing tasks: hallucination. Hallucination refers to the fact that when a model generates text, it often outputs content that is inconsistent with real-world knowledge or contrary to user expectations. 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 precision, such as automatic news generation, intelligent customer service, and educational assistance. This phenomenon may be caused by a variety of factors, such as data quality issues encountered during the training process, unreasonable model structure design, or defects in the decoding strategy.
[0004] Existing research attempts to mitigate hallucinations by introducing additional external knowledge bases, improving model architectures, or optimizing decoding strategies. However, these methods often require a lot of manual intervention, consume huge computing resources, and are difficult to adapt to different application scenarios and data distributions, further resulting in poor accuracy and authenticity of model output. In addition, these methods may also encounter problems such as reduced model generalization ability and poor scalability in practical applications. Summary of the invention
[0005] In view of this, the present invention provides a large model hallucination removal method based on a multi-layer fusion contrast decoding framework to at least solve the above-mentioned problem.
[0006] The present invention provides a large-model hallucination removal method based on a multi-layer fusion contrast decoding framework, comprising: constructing a large-scale language hallucination removal strategy based on the multi-layer fusion contrast decoding framework, wherein the multi-layer fusion contrast decoding framework of the large-scale language hallucination removal strategy comprises a contrast decoding module based on multi-layer fusion and a factual refocusing module based on context guidance, wherein the contrast decoding module is used to combine the information of the final layer and the intermediate layer between the original model and the hallucination model to perform contrast decoding calculation, and the factual refocusing module is used to further optimize the contrast decoding calculation process; applying the large-scale language hallucination removal strategy to the large-scale language model to perform hallucination removal on the hallucination phenomenon in the natural language processing task.
[0007] In one implementation, the contrast decoding module is used to perform contrast decoding calculations by combining the information of the final layer and the intermediate layer between the original model and the hallucination model, specifically including: a. Hallucination model construction: by fine-tuning the original model in a supervised manner on a data set containing non-factual data, injecting hallucination information into the original model to obtain a hallucination model; b. Contrast decoding: query QueryX = {x1, x2, ..., x n} are respectively input into the original model and the hallucination model to obtain the corresponding text reply output distribution, and further comparative decoding is achieved by subtracting the probability distribution of the text replies of the original model and the hallucination model; 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 combined for fusion.
[0008] In another implementation, the hallucination model construction process in step a is expressed as:
[0009] θ * = FT(θ, D)
[0010] Where FT represents the supervised fine-tuning operation, θ represents the original model, θ* represents the hallucinated model, and D is the dataset containing the hallucinated information.
[0011] In another implementation, the comparative decoding process in step b is expressed as:
[0012] F t =logp(χ t | <t ;θ)-λlogp(χ t | χ<t θ * )
[0013] p(χ t | χ<t ; θ) = softmax(logit θ (xt | <t ))
[0014]
[0015] Among them, F t represents the result of the final layer contrast decoding between the original model and the hallucination model, θ represents the original model, θ* represents the hallucination model, λ is a hyperparameter that controls the contrast decoding ratio during the final layer decoding, and p(χ t | <t ; θ) represents the standard decoding process of the autoregressive large language model, p(χ t |X <t ; θ) In the response generation process, the tth word is predicted based on the results of the previous t-1 words, logit θ Represents the predicted probability of text generation, and softmax is the activation function.
[0016] In another implementation, the multi-layer fusion process in step c includes:
[0017] c11. Perform comparative decoding on the intermediate layers between the original model and the hallucination model in parallel. This step is expressed by the formula:
[0018] F′ t =logp(χ t | <t ;θ;L)-λ'logp(χ t | χ<t θ * ; L)
[0019] Among them, F' t represents the result of contrast decoding of the intermediate layer between the two models, λ' is a hyperparameter for controlling the contrast decoding ratio during intermediate layer decoding, and L is a hyperparameter for specifying the artificially selected intermediate layers of the restoration model and the hallucination model;
[0020] c12. The results of the final layer contrast decoding of the original model and the hallucination model and the results of the intermediate layer contrast decoding are merged to achieve a more complete contrast decoding calculation. This calculation process is expressed by the formula:
[0021] F ML =F t +ωF' t
[0022] Among them, F ML It represents the result of multi-layer fusion contrast decoding, and ω is a hyperparameter that controls the ratio of multi-layer fusion.
[0023] In another implementation, the factual refocusing module is used to further optimize the contrast decoding calculation process, specifically including:
[0024] d. Introducing context guidance into the query Query during the encoding process of the large language model to encourage the large language model to pay more attention to the key words or phrases representing facts in the sentence during the comparative decoding process. This step is expressed by the formula:
[0025] F TR =logp(χ t |(x <t ||χ context );θ)-λ”logp(χ t |(x <t ||χ context );θ * )
[0026] Among them, F TR represents the contrast decoding result of the factual refocusing module, λ" is a hyperparameter for controlling the contrast decoding ratio when the factual refocusing module is decoding, and X context Indicates the context information introduced;
[0027] e. Fusing the output distribution of the factual refocusing module 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 expressed as:
[0028] F Final =F ML ±ω'F TR
[0029] p(χ t | <t )=softmax(F Final )
[0030] 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.
[0031] In summary, the present invention proposes a large model hallucination removal method based on a multi-layer fusion contrast decoding framework. The method adjusts the model's decoding strategy 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 factual encoding is enhanced with the help of a factual refocusing module guided by context, which improves the model's perception of the factuality of text generation, effectively alleviating the existing large language model hallucination removal methods, such as low computational efficiency, reliance on external data resources, and insufficient hallucination removal accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a flowchart of the steps of a large model hallucination removal method based on a multi-layer fusion contrast decoding framework according to an embodiment of the present invention;
[0033] Figure 2 Schematic diagram of the architecture of a large model hallucination removal method based on a multi-layer fusion contrast decoding framework according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] For the sake of ease of understanding, before describing the specific embodiments of the present invention in detail, the prior art of the present invention is first exemplarily described.
[0035] Related research shows that there are many reasons for the hallucination problem. First, the pre-training data may contain erroneous or outdated information, and the model may copy these inaccurate data during the learning and generation process. Second, the model may overfit the training data during the fine-tuning stage, resulting in unreliable output when faced with unseen data. In addition, the model's decoding strategy may also cause hallucinations. For example, a greedy decoding strategy may select the locally optimal word instead of the most appropriate word globally, thereby affecting the accuracy of the output.
[0036] In recent years, in order to solve this problem, many representative research works have emerged in the research field. One typical research is to use external knowledge bases to enhance the factuality of the model. For example, through the retrieval enhancement method, the model can retrieve relevant information in the external knowledge base when generating each word to assist in generating more accurate content. Another type of research is through knowledge editing, that is, locating neurons that store incorrect knowledge inside the model or cause the model to output hallucination information, and correcting them to improve the accuracy and factuality of the model output. However, these methods usually require additional computing resources and have limited generalization capabilities on different tasks and datasets.
[0037] At present, there are many models and methods in the research of hallucination removal of large language models. There are five common solutions: reinforcement learning methods based on human feedback, methods based on retrieval-enhanced generation, methods based on model editing, methods based on representation editing, and methods based on contrastive decoding.
[0038] Reinforcement learning methods based on human feedback build high-quality corpora and use human feedback to train models so that the models can accurately predict factual summaries of human preferences. Reinforcement learning is used to reward or punish the output of the model based on human preferences to guide the model to generate more accurate content. This type of method requires a lot of manual feedback, which is costly and inefficient. In addition, over-reliance on human feedback may cause the model to overfit the training data, affecting its generalization ability in practical applications.
[0039] Retrieval-enhanced generation methods are based on retrieving relevant information from an external knowledge base and generating text in combination with a large language model to improve the authenticity of the generated content. Retrieval-enhanced methods usually include a retrieval module for retrieving relevant information from a knowledge base and a generation module for generating text in combination with the retrieved information. This type of method relies on an external knowledge base, which limits the independence and generalization ability of the model. In addition, the retrieval process may increase the computational cost and is difficult to apply in an environment without external knowledge support.
[0040] Model editing-based methods modify the knowledge within the model, such as through fine-tuning, meta-learning, or location editing, to change the model's knowledge storage, thereby reducing hallucination phenomena. Model editing methods usually require adjustments to the model's parameters to reflect new knowledge and information. The main problem faced by this type of method is that the operation is complex, requires a deep understanding of the model's internal structure and knowledge representation, and is inefficient and costly. In addition, the editing process may affect other capabilities of the model, such as its original language understanding ability.
[0041] Representation editing-based methods improve the authenticity of generated content by editing the representation of the model output during the model's inference phase. Representation editing methods usually focus on the model's attention mechanism, and guide the model to focus on more accurate information by adjusting the attention weights, thereby correcting the model output. However, this type of method mainly adjusts the representation of the model output by modifying the model's attention mechanism, which may not be sufficient to fundamentally solve the hallucination problem. In addition, representation editing may require a lot of computing resources and time consumption, and has high requirements for the study of the model's internal mechanisms.
[0042] The contrastive decoding method guides the original model to generate more accurate content by comparing the output distribution of the original model with the output distribution of one or more other models. However, existing methods usually only focus on the final layer comparison of the model or only compare within a single model, ignoring the useful information that the intermediate layers of the model may contain for hallucination removal; at the same time, the simple and rough contrast calculation of the previous contrastive decoding method easily destroys the original output distribution, resulting in poor performance of the model in some scenarios.
[0043] The present invention has made innovations based on the existing contrast decoding methods. On the basis of the contrast decoding of the final layer of the model, a multi-layer fusion contrast decoding framework has been introduced to further improve the performance of the model by combining the contrast information of the original model and the intermediate and final layers of the hallucination model.
[0044] In addition, the present invention also designs a factual refocusing module, which uses contextual guidance to enhance the model's perception of factual content. This multi-layer fusion and factual perception enhanced contrastive decoding method helps to effectively reduce the hallucination phenomenon of large language models and generate more accurate and realistic text content.
[0045] Specifically, the present invention improves the hallucination removal method based on contrastive decoding by combining the information of the final layer and the intermediate layer between the original model and the hallucination model for contrastive decoding, integrating the information of the intermediate layer and the final output layer of the model, and more comprehensively capturing the knowledge representation inside the model, which helps to more stably process complex language queries; and designs a factual refocusing module based on context guidance to guide the model to enhance factual encoding, strengthen the model's ability to capture factual content, enrich the contrastive decoding framework, so as to avoid the simple and rough contrast calculation of traditional contrastive decoding, and improve the authenticity and credibility of text generated by large language models.
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] See also Figure 1 A large model hallucination removal method based on a multi-layer fusion contrast decoding framework according to an embodiment of the present invention includes:
[0048] Step S101, constructing a large-scale language de-hallucination strategy based on a multi-layer fusion contrast decoding framework, wherein the multi-layer fusion contrast decoding framework of the large-scale language de-hallucination strategy includes a contrast decoding module based on multi-layer fusion and a factual refocusing module based on context guidance, wherein the contrast decoding module is used to combine the information of the final layer and the intermediate layer between the original model and the hallucination model to perform contrast decoding calculation, and the factual refocusing module is used to further optimize the contrast decoding calculation process;
[0049] Step S102: Apply the large-scale language de-hallucination strategy to a large-scale language model to perform de-hallucination on hallucination phenomena in natural language processing tasks.
[0050] Optionally, the contrast decoding module is used to perform contrast decoding calculations by combining the information of the final layer and the intermediate layer between the original model and the hallucination model, specifically including: a. Hallucination model construction: by fine-tuning the original model in a supervised manner on a data set containing non-factual data, injecting hallucination information into the original model to obtain a hallucination model; b. Contrast decoding: query Query X = {x1, x2, ..., x n} are respectively input into the original model and the hallucination model to obtain the corresponding text reply output distribution, and further comparative decoding is achieved by subtracting the probability distribution of the text replies of the original model and the hallucination model; 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 combined for fusion.
[0051] Optionally, the hallucination model construction process in step a is expressed as:
[0052] θ * = FT(θ, D)
[0053] Where FT represents the supervised fine-tuning operation, θ represents the original model, θ* represents the hallucinated model, and D is the dataset containing the hallucinated information.
[0054] Optionally, the comparative decoding process in step b is expressed as:
[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 represents the result of the final layer contrast decoding between the original model and the hallucination model, θ represents the original model, θ* represents the hallucination model, λ is a hyperparameter that controls the contrast decoding ratio during the final layer decoding, and p(χ t | <t ; θ) represents the standard decoding process of the autoregressive large language model, p(χ t | <t; θ) In the response generation process, the tth word is predicted based on the results of the previous t-1 words, logit θ 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 comparative decoding on the intermediate layers between the original model and the hallucination model in parallel. This step is expressed by the formula:
[0061] F′ t =logp(χ t | <t ;θ;L)-λ'logp(χ t | χ<t θ * ; L)
[0062] Among them, F' t represents the result of contrast decoding of the intermediate layer between the two models, λ' is a hyperparameter for controlling the contrast decoding ratio during intermediate layer decoding, and L is a hyperparameter for specifying the artificially selected intermediate layers of the restoration model and the hallucination model;
[0063] c12. The results of the final layer contrast decoding of the original model and the hallucination model and the results of the intermediate layer contrast decoding are merged to achieve a more complete contrast decoding calculation. This calculation process is expressed by the formula:
[0064] F ML =F t +ωF' t
[0065] Among them, F ML It represents the result of multi-layer fusion contrast decoding, and ω is a hyperparameter that controls the ratio of multi-layer fusion.
[0066] Optionally, the factual refocusing module is used to further optimize the contrast decoding calculation process, specifically including:
[0067] d. Introducing context guidance into the query Query during the encoding process of the large language model to encourage the large language model to pay more attention to the key words or phrases representing facts in the sentence during the comparative decoding process. This step is expressed by the formula:
[0068] F TR =logp(χ t |(x <t ||X context );θ)-λ”logp(χ t |(x <t ||χcontext );θ * )
[0069] Among them, F TR represents the contrast decoding result of the factual refocusing module, λ" is a hyperparameter for controlling the contrast decoding ratio when the factual refocusing module is decoding, and χ context Indicates the context information introduced;
[0070] e. Fusing the output distribution of the factual refocusing module 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 expressed as:
[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 scheme of the present invention is further described according to the following examples:
[0075] See also Figure 2 Schematic diagram of the architecture of a large model hallucination removal method based on a multi-layer fusion contrast decoding framework according to an embodiment of the present invention. Figure 2 The figure mainly consists of two parts. The top part shows the contrast decoding module based on multi-layer fusion (located in the upper blue box), and the bottom part shows the factual refocusing module based on context guidance (located in the lower gray box). Figure 2 The arrow in the middle shows the data flow of the output distribution in the model inference phase, which is calculated by the comparison decoding framework of the two modules to form the final output distribution (such as Figure 2 lower right corner).
[0076] The large-scale language model hallucination removal method based on the multi-layer fusion contrastive decoding framework mainly consists of two parts: a contrastive decoding module based on multi-layer fusion and a factual refocusing module based on context guidance. This method combines the contrastive decoding framework of multi-layer fusion between the original model and the hallucination model to adjust the model's decoding strategy and improve the accuracy and authenticity of the model output. At the same time, in the contrastive decoding framework, the factual encoding is enhanced with the help of the factual refocusing module based on context guidance, which improves the perception of the factuality of text generation by the large-scale language model, and effectively alleviates the existing large-scale language model hallucination removal methods with low computational efficiency, dependence on external data resources, and insufficient hallucination removal accuracy. Problems.
[0077] First, given a query Query X = {x1, x2, ..., x n}, the method proposed in this patent can use the multi-layer fusion contrast decoding framework to adjust the model's decoding strategy and output distribution, and finally generate a text response Response Y={Y1,Y2,…,Y m}.
[0078] Secondly, the details of the contrastive decoding module based on multi-layer fusion and the context-guided factual refocusing module are explained.
[0079] A. Contrastive decoding module based on multi-layer fusion
[0080] Contrastive decoding based on multi-layer fusion is the core module of the present invention, which realizes more sophisticated contrastive decoding by combining the output distribution comparison of the multi-layer fusion of the final layer and the intermediate layer between the original model and the hallucination model. The specific implementation steps are as follows:
[0081] a. Hallucination model construction:
[0082] First, we need to build an amateur model as a comparison object for comparative decoding to assist the original model in adjusting the decoding strategy. By fine-tuning the original model in a supervised manner on a dataset containing non-factual data, and injecting the amateur information into the original model, we can obtain the amateur model. This step can be described by the formula:
[0083] θ * = FT(θ, D)
[0084] Where FT represents the supervised fine-tuning operation, θ represents the original model, θ* represents the hallucinated model, and D is the dataset containing the hallucinated information.
[0085] It should be understood that the hallucination model is obtained by injecting hallucination information through supervised fine-tuning.
[0086] b. Comparative decoding: QueryX = {x1, x2, ..., x n} are respectively input into the original model and the hallucination model to obtain the corresponding text reply output distribution, and further contrast decoding is achieved by subtracting the probability distribution of the text reply of the original model and the hallucination model. Taking the contrast decoding of the final layer of the model as an example, this process can be described by the formula:
[0087] F t =logp(χ t | <t ;θ)-λlogp(χ t | χ<t θ * )
[0088] p(χ t | <t ; θ) = softmax(logit θ (x t | <t ))
[0089]
[0090] Among them, F t represents the result of the final layer contrast decoding between the original model and the hallucination model, θ represents the original model, θ* represents the hallucination model, λ is a hyperparameter that controls the contrast decoding ratio during the final layer decoding, and p(χ t | χ<t ; θ) represents the standard decoding process of the autoregressive large language model, p(χ t | <t ; θ) In the response generation process, the tth word is predicted based on the results of the previous t-1 words, logit θ Represents the predicted probability of text generation, and softmax is the activation function.
[0091] c. Multi-layer fusion: Perform multi-layer fusion contrast decoding between the original model and the hallucination model, and combine the contrast decoding results between the final output layer and the intermediate layer (i.e., the early exit layer) of the two models to achieve more comprehensive and complete contrast decoding. The specific implementation steps are as follows:
[0092] c11. Perform comparative decoding on the intermediate layers between the original model and the hallucination model in parallel. This step is expressed by the formula:
[0093] F′ t =logp(χ t | <t ;θ;L)-λ'logp(χ t |χ<t θ * ; L)
[0094] Among them, F' t represents the result of contrast decoding of the intermediate layer between the two models, λ' is a hyperparameter for controlling the contrast decoding ratio during intermediate layer decoding, and L is a hyperparameter for specifying the artificially selected intermediate layers of the restoration model and the hallucination model;
[0095] c12. The results of the final layer contrast decoding of the original model and the hallucination model and the results of the intermediate layer contrast decoding are merged to achieve a more complete contrast decoding calculation. This calculation process is expressed by the formula:
[0096] F ML =F t +ωF′ t
[0097] Among them, F ML It represents the result of multi-layer fusion contrast decoding, and ω is a hyperparameter that controls the ratio of multi-layer fusion.
[0098] B. Context-guided factual refocusing module
[0099] The factuality refocusing module aims to add contextual guidance to the query to guide the model to pay more attention to the factuality, enhance the factual encoding, and further enhance the authenticity of the sentence in the entire contrastive decoding process. The specific implementation steps are as follows:
[0100] d. Introducing context guidance into the query Query during the encoding process of the large language model to encourage the large language model to pay more attention to the key words or phrases representing facts in the sentence during the comparative decoding process. This step is expressed by the formula:
[0101] F TR =logp(χ t |(x <t ||χ context );θ)-λ”logp(χ t |(x <t ||χ context );θ * )
[0102] Among them, F TR represents the contrast decoding result of the factual refocusing module, λ" is a hyperparameter for controlling the contrast decoding ratio when the factual refocusing module is decoding, and χ context Indicates the context information introduced;
[0103] e. Fusing the output distribution of the factual refocusing module 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 expressed as:
[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 present invention has the following beneficial effects:
[0108] (1) The present invention is the first to improve the hallucination removal method based on contrast decoding by combining the information of the final layer and the intermediate layer between the original model and the hallucination model for contrast decoding, so as to make full use of the knowledge representation of different models and different levels within the model, avoid the simple and rough contrast calculation of traditional contrast decoding, significantly reduce the hallucination phenomenon, and improve the accuracy and factuality of the model output.
[0109] (2) The present invention designs a context-guided factual refocusing module to guide the model to enhance factual encoding and pay more attention to the factuality of text generation during the contrastive decoding process, thereby enriching the original contrastive decoding framework, further optimizing the contrastive decoding calculation process, and improving the authenticity and fluency of the generated content.
[0110] (3) The method of the present invention is not limited to the field of large language model hallucination removal. Its core idea is to adjust the model output strategy and correct the model output with the help of more multi-level contrast decoding to improve the text generation of large language models. This method has good performance on different base models and plays an important role in improving the reasoning ability and security of large language models. Therefore, the method of the present invention has broad application prospects.
[0111] In order to fully verify the effectiveness and advancement of the method of the present invention, a large number of experiments were conducted on the widely used large-scale language model hallucination evaluation datasets TruthfulQA and FACTOR for the large-scale language model hallucination removal method based on the multi-layer fusion contrast decoding framework proposed in the present invention, and compared with the currently more advanced hallucination removal methods. The experiments used MCl, MC2, MC3 and Accuracy as evaluation indicators on the two datasets. The experimental results show that in most scenarios, this method is superior to the current best hallucination removal methods based on contrast decoding or representation editing in all indicators.
[0112] In addition, comparative experiments were conducted without and with the contrastive decoding module based on multi-layer fusion, as well as without and with the factual refocusing module based on context guidance. After removing the contrastive decoding module based on multi-layer fusion, the text generation accuracy of the model was significantly reduced, which shows the effectiveness and necessity of introducing multi-layer fusion contrastive decoding; at the same time, after removing the factual refocusing module based on context guidance, the accuracy of the model output also decreased to a certain extent. And the two modules are used together to better enhance the effect of hallucination removal, which shows that the introduction of contrastive decoding based on multi-layer fusion and guiding the model to enhance factual encoding can effectively improve the contrastive decoding framework and improve the factuality and accuracy of the model output without affecting the fluency of the model output.
[0113] It should be noted that the present invention may be a method, a system, an apparatus and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0114] Computer readable storage medium can be a tangible device that can hold and store instructions used by an instruction execution device. Computer readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive list) of computer readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, for example, a punch card or a convex structure in a groove on which instructions are stored, and any suitable combination thereof. The computer readable storage medium used here is not interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagated by a waveguide or other transmission medium (for example, a light pulse by an optical fiber cable), or an electrical signal transmitted by a wire.
[0115] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0116] The computer program instructions for performing the operation of the present 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" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of 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., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present invention.
[0117] Various aspects of the present invention are described herein with reference to the flow charts and / or block diagrams of the methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each box of the flow chart and / or block diagram and the combination of each box in the flow chart and / or block diagram 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 device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in 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 so that a series of operating steps are 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 implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0120] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a part of a module, a program segment or an instruction, and a part of the module, a program segment or an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.
[0121] Embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present invention is defined by the appended claims.
Claims
1. A large model hallucination removal method based on a multi-layer fusion contrast decoding framework, characterized in that: include: Constructing a large-scale language de-hallucination strategy based on a multi-layer fusion contrastive decoding framework, wherein the multi-layer fusion contrastive decoding framework of the large-scale language de-hallucination strategy includes a contrastive decoding module based on multi-layer fusion and a factual refocusing module based on context guidance, wherein the contrastive decoding module is used to combine the information of the final layer and the intermediate layer between the original model and the hallucination model to perform contrastive decoding calculation, and the factual refocusing module is used to further optimize the contrastive decoding calculation process; The large-scale language dehallucination strategy is applied to a large-scale language model to remove hallucination phenomena in natural language processing tasks.
2. The method according to claim 1, characterized in that: The contrast decoding module is used to perform contrast decoding calculation by combining the information of the final layer and the intermediate layer between the original model and the hallucination model, specifically including: a. Construction of hallucination model: by fine-tuning the original model in a supervised manner on a data set containing non-factual data, hallucination information is injected into the original model to obtain a hallucination model; b. Comparative decoding: Query X = {x1, x2, ..., x n } are respectively input into the original model and the hallucination model to obtain the corresponding text reply output distribution, and further comparative decoding is achieved by subtracting the probability distribution of the text reply of the original model and the hallucination model; c. Multi-layer fusion: Perform multi-layer fusion comparative decoding between the original model and the hallucination model, and combine the comparative decoding results between the final output layer and the intermediate layer of the two models for fusion.
3. The method according to claim 2, characterized in that The hallucination model construction process in step a is expressed as: θ*=FT(θ,D) Where FT represents the supervised fine-tuning operation, θ represents the original model, θ* represents the hallucinated model, and D is the dataset containing the hallucinated information.
4. The method according to claim 3, characterized in that The comparative decoding process in step b is expressed as: F t =logp(x t ||x <t ;θ)-λlogp(x t | x<t ;θ * ) p(x t |x <t ;θ)=softmax(logit θ (x t |x <t ) p(x t |x <t ;θ * )=softmax(logit θ* (x t |x <t )) Among them, F t represents the result of the final layer contrast decoding between the original model and the hallucination model, θ represents the original model, θ* represents the hallucination model, λ is a hyperparameter that controls the contrast decoding ratio during the final layer decoding, and p(X t |X <t ; θ) represents the standard decoding process of the autoregressive large language model, p(x t |x <t ; θ) In the response generation process, the tth word is predicted based on the results of the previous t-1 words, logit θ Represents the predicted probability of text generation, and softmax is the activation function.
5. The method according to claim 4, characterized in that The multi-layer fusion process in step c includes: c11. Perform comparative decoding on the intermediate layers between the original model and the hallucination model in parallel. This step is expressed by the formula: F' t =logp(x t |x <t ;θ;L)-λ'logp(x t | x<t ;θ * (L) Among them, F′ t represents the result of contrast decoding of the intermediate layer between the two models, λ′ is a hyperparameter for controlling the contrast decoding ratio during intermediate layer decoding, and L is a hyperparameter for specifying the artificially selected intermediate layers of the restoration model and the hallucination model; c12. The results of the final layer contrast decoding of the original model and the hallucination model and the results of the intermediate layer contrast decoding are merged to achieve a more complete contrast decoding calculation. This calculation process is expressed by the formula: F ML =F t +ωF’ t Among them, F ML It represents the result of multi-layer fusion contrast decoding, and ω is a hyperparameter that controls the ratio of multi-layer fusion.
6. The method according to claim 5, characterized in that The factual refocusing module is used to further optimize the contrast decoding calculation process, specifically including: d. Introducing context guidance into the query Query during the encoding process of the large language model to encourage the large language model to pay more attention to the key words or phrases representing facts in the sentence during the comparative decoding process. This step is expressed by the formula: F TR =logp(x t |x <t ||x context );θ)-λ”logp(x t |(x <t ||x context );i * ) Among them, F TR represents the contrast decoding result of the factual refocusing module, λ" is a hyperparameter for controlling the contrast decoding ratio when the factual refocusing module is decoding, and X context Indicates the context information introduced; e. Fusing the output distribution of the factual refocusing module 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 expressed as: F Final =F ML +ω'F TR p(x t |x <t )=softmax(F Final ) 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.
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
Preventing hallucinations in language models by mapping to facts as explanations
WO2024157059A1