A method and system for alleviating hallucination problems of large language models
Patent Information
- Application Number
- CN202611241661.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-17
- Publication Date
- 2026-10-13
AI Technical Summary
[0004]为解决现有缓解幻觉问题的方法所存在的弊端,本申请提供了一种缓解大语言模型幻觉问题的方法及系统,该方法及系统可缓解大语言模型在生成过程中对静态参数化知识的过度依赖,从而提升模型对输入上下文的忠实度与跨任务的泛化能力
本申请提出了一种自适应上下文感知神经元解码框架ACND,其为覆盖“神经元激活→知识表征→生成决策”全流程的轻量级可插拔框架,不依赖特定任务或模型架构,可突破传统方法的粗粒度调控范式,可提升LLMs对上下文的忠实度,减少大模型在处理知识密集型任务时的幻觉现象。
Smart Images

Figure CN122904877A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, specifically to a method and system for alleviating the illusion problem of large language models. Background Technology
[0002] In natural language processing tasks, large language models (LLMs) must handle massive and rapidly evolving external knowledge to meet high requirements for accuracy, logical consistency, and complex reasoning. In this scenario, LLMs face two core challenges: first, insufficient long-context modeling capabilities, making it difficult for the model to maintain semantic consistency when integrating large amounts of new input information, leading to problems such as ambiguous main themes, semantic jumps, and even factual contradictions in the generated content; second, a lag in the model's response to new knowledge, making it prone to relying on parameterized knowledge and thus causing factual illusions. To address these issues, existing methods mainly focus on the following technical paths: 1. Fine-tuning strategy: This strategy aims to update the internal knowledge of existing LLMs by further training on additional data, including datasets containing the latest information or domain-specific datasets. It has become the mainstream method to improve the performance of LLMs on different tasks. Full parameter fine-tuning adapts to downstream tasks by updating all parameters, but it has drawbacks such as high resource consumption and poor generalization, which limits its large-scale application.
[0003] 2. Explanation and Control of the Model's Internal Structure: Feedforward Neural Networks (FFNs) contain a large number of knowledge neurons, some of which handle factual memory, while others process contextual semantics. However, most existing neuron selection mechanisms are static strategies, lacking flexibility in the face of dynamic contexts and becoming a bottleneck for model performance. For example, IRCAN, based on static attribution scores, identifies neurons and selects context-aware neurons through a preset fixed threshold. This mechanism struggles to adapt to new contexts such as the introduction of specialized terminology or sudden semantic shifts in the domain. In tasks with rapidly updating knowledge, neuron activation patterns exhibit significant changes, which static strategies often fail to capture in a timely manner, leading to semantic integration bias and weakening the model's ability to perceive context. 3. The problem of insufficient model response to context can be compensated for by adjusting the decoding strategy in the generation stage. For example, amplifying the output probability differences between different model scales or different layers of the LLM can significantly enhance the model's sensitivity to context, thereby effectively curbing the generation of illusions. For instance, the CAD method achieves context adaptation by directly adjusting the generation distribution probability, prompting the LLM to focus more deeply on contextual information during content generation, greatly improving the accuracy and logical coherence of the output content. However, the limitation of such methods is that they only act on the output probability distribution and cannot reach the solidified knowledge representation structure within the model. The FFN layer is the core of semantic modeling. If contextual information is not fully integrated at this layer, and the probability output is only adjusted in the decoding stage, when there are logical contradictions in the input data, the model cannot complete the identification and correction of conflicting knowledge at the lower-level neural representation stage. This causes the decoding process to still tend to rely on the knowledge path formed by pre-training, ultimately affecting the output quality. Summary of the Invention
[0004] To address the shortcomings of existing methods for mitigating the illusion problem, this application provides a method and system for mitigating the illusion problem in large language models. This method and system can alleviate the excessive reliance of large language models on static parameterized knowledge during the generation process, thereby improving the model's fidelity to the input context and its cross-task generalization ability.
[0005] This application provides a method for alleviating the illusion problem of large language models, including the following steps: S100: Adaptive context-aware neuron selection; S200: Neuron-adaptive contrastive decoding; Step S100 further includes: S110: Calculate the attribution scores of each FFN neuron in the large language model for the input context; S120: Select the context-aware neuron set based on the attribution scores of FFN neurons; S130: The optimal joint hyperparameters of neurons are determined using Bayesian optimization, and the activation enhancement intensity in the optimal joint hyperparameters is used to adjust the gain of the activation values of each neuron in the context-aware neuron set. Step S200 further includes: S210: Using the activation enhancement strength in the optimal joint hyperparameters, the activation value of the optimal context-aware neuron in the FFN layer of the large language model is adjusted by gain. S220: Comparative decoding is performed using a large language model with gain adjustment.
[0006] Optionally, step S110 further includes: neurons Activation value of baseline state Activation value to context state Divided into There are several equally spaced small steps; among which, the number of discretization steps is... Experience value; The approximate attribution score of each FFN neuron to the input context is calculated using the following formula. : .
[0007] Optionally, step S120 further includes: S121: Divide the large language model into three functional regions: shallow region, middle region, and deep region, and define adaptive thresholds for each layer in each functional region. ,in, The preset screening ratio, and It is a regional adaptive factor. , ; Select the attribution scores in each layer that meet the criteria. The FFN neurons constitute a preliminary candidate set; S122: Integrate the initial candidate set of all training samples to construct a candidate set of global context-aware neurons; S123: Count the frequency of each FFN neuron in the candidate set in the training samples, and independently rank the FFN neurons in each layer according to their frequency of occurrence. S124: Determine the screening quota for each functional area, and distribute the screening quota evenly to each layer within the corresponding functional area to obtain the screening quota for each layer. Select the first layer within each layer. A set of high-ranking neurons is combined to obtain a context-aware neuron set. Screening quotas for each functional area The calculation formula is as follows: ; in, , , , These represent the proportional weights of the shallow, middle, and deep layers, respectively.
[0008] Furthermore, the number of layers in the shallow region ranges from [1, ... The number of layers in the middle layer region is []. , The number of layers in the deep region ranges from [ ]. , ];in, L This represents the total number of layers in a large language model. ; , This represents the floor function.
[0009] Optionally, the determination of the optimal joint hyperparameters of the neurons using Bayesian optimization in step S130 includes: Historical evaluation parameters are divided into a good parameter set and a poor parameter set, and probability density functions are fitted to each set respectively. and And perform efficient parameter sampling; In each iteration, the dataset and distribution model are updated, and the parameter configuration is optimized accordingly until convergence.
[0010] Optionally, step S220 further includes: In each decoding step, the contrast intensity adjustment coefficient is... Set to: ; in, Indicates the basic contrast intensity, with a value range of 100%. ; Represents the context-aware score probability distribution With prior score probability distribution The distance between them; Context-aware score Prior score Dynamic contrast intensity adjustment coefficient, for the current word The generation probability is reconstructed, and the reconstructed probability distribution is as follows:
[0011] Furthermore, , ,but: ; in, , indicating a mixed distribution; This represents the Kullback-Leibler divergence.
[0012] Another aspect of this application provides a system for alleviating the illusion problem of large language models, comprising: Adaptive context-aware neuron selection module and neuron adaptive contrast decoding module; The adaptive context-aware neuron selection module further includes: The first submodule is used to calculate the attribution scores of each FFN neuron in the large language model for the input context. The second submodule is used to filter the context-aware neuron set based on the attribution scores of FFN neurons; The third submodule is used to determine the optimal joint hyperparameters of neurons using Bayesian optimization, and to adjust the activation values of each neuron in the context-aware neuron set by using the activation enhancement strength in the optimal joint hyperparameters. The neuron adaptive contrast decoding module further includes: The fourth submodule is used to adjust the gain of the activation value of the optimal context-aware neuron in the FFN layer of the large language model by using the activation enhancement strength in the optimal joint hyperparameters. The fifth submodule is used for comparative decoding using a large language model with gain adjustment.
[0013] Compared with the prior art, this application has the following advantages and beneficial effects: This application proposes an adaptive context-aware neuron decoding framework, ACND, which is a lightweight, pluggable framework covering the entire process of "neuron activation → knowledge representation → generative decision". It does not depend on specific tasks or model architectures, can break through the coarse-grained control paradigm of traditional methods, can improve the fidelity of LLMs to the context, and reduce the illusion phenomenon when large models are dealing with knowledge-intensive tasks.
[0014] The system enhances its fidelity to the input context and its cross-task generalization ability. Extensive experiments on various models and tasks demonstrate that ACND breaks the model's over-reliance on pre-trained parameter knowledge, achieving an adaptive balance between input context and parameterized knowledge, thereby effectively mitigating knowledge conflicts and providing a general and scalable technical solution for the dynamic knowledge utilization of LLMs.
[0015] Experiments have verified that the ACND neural decoding framework of this application is universal and can significantly improve the accuracy on knowledge-intensive tasks, and can alleviate the illusion phenomenon when large models are dealing with knowledge-intensive tasks. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating the method described in this application; Figure 2 This is a schematic diagram of the overall structure of the neural decoding framework ACND in a specific implementation. Figure 3 This example compares ablation experiment results on the ECARE-KRE dataset. Figure 4 This example compares ablation experimental results on the COSE-KRE dataset. Figure 5 This example compares ablation experiment results on the RACE-CC dataset. Detailed Implementation
[0018] The technical solution and effects of this application will be clearly and completely described below with reference to specific embodiments. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0019] The following will combine Figure 1 The specific implementation methods of this application will be described in detail.
[0020] This application provides a method for mitigating the illusion problem in large language models, comprising the steps of: S100: adaptive context-aware neuron selection; and S200: neuron adaptive contrastive decoding.
[0021] In this specific implementation, the adaptive context-aware neuron screening is based on integrated gradient attribution and Bayesian optimization. It performs fine-grained analysis and dynamic screening of neurons in the FFN layer of LLMs, and dynamically adjusts their activation intensity during inference to identify neurons that have a key impact on prediction in the current context.
[0022] Specifically, IG is used to calculate the contribution score of FFN neurons to the predicted answer in context, measuring their sensitivity and contribution to contextual information. Bayesian optimization is introduced to establish posterior uncertainty modeling on the attribution results, further screening out the most representative and stable context-aware neurons (CANs) for prediction. This enables adaptive selection of CAN weights and outputs a set of weighted neuron activation regulation signals. The output neuron activation regulation signals are used to guide downstream activation enhancement and contrast regulation modules, achieving the preservation and amplification of key contextual information and improving the model's robustness in complex scenarios.
[0023] The above step S100 further includes: S110: context-aware neuron attribution calculation; S120: context-aware neuron hierarchical screening; and S130: Bayesian optimized dynamic weight screening.
[0024] In step S110, the attribution scores of all FFN neurons in the large language model to the input context are calculated by IG. The attribution scores represent the contribution scores of FFN neurons to the predicted answer in the input context.
[0025] The evaluation of the first In the FFN layer, the first one neuron Its attribution score is defined as Attribution scores are used to quantify neurons Activate changes to the target answer The impact of generation probability.
[0026] Record neurons separately Activation values under two input conditions: Baseline state: Question only Option set As input, the activation value of the neuron is recorded. ; Context state: based on context ,question Option set Both are used as input to record new activation values. .
[0027] To calculate the attribution score, construct neurons. activation value from Gradually adjust to And observe the target answer. generation probability As shown in equation (1): (1) in, Represents neurons Activation operation, This indicates that the model predicts the target answer given the input conditions. The conditional probability.
[0028] The core of attribution calculation is to observe the change in the probability of the target answer along the path of neuron activation values from the baseline state to the context state, and obtain the neuron's context-aware attribution score by integrating the gradient of the probability with respect to the activation value during this process. Since directly calculating continuous integrals is not feasible in practice, the Riemann integral approximation is used to discretize the integral to efficiently obtain the neuron's attribution score.
[0029] Specifically, neurons The activation value is from the baseline state. To context state Divided into 1. Take 10 equal-interval small steps. Calculate the gradient of the probability pair for activation at each interval point, and sum all gradients to obtain an approximate expression for the attribution score, as shown in Equation (2): (2) in, Indicates the first Interval points, Used to calculate the model probability about The points.
[0030] Here, represents the number of discretization steps, and is an empirical value. In subsequent embodiments, through repeated experiments, it was found that when... When the value is 20, it can ensure both attribution accuracy and computational efficiency, achieving a good balance between accuracy and efficiency.
[0031] Attribution score The higher the value, the more neurons... The more sensitive a neuron is to semantic modeling of context, the more reliable its selection can be for subsequent context-aware neurons.
[0032] In step S120, a set of context-aware neurons (CANs) is selected based on the attribution scores of all FFN neurons.
[0033] In the Transformer model, the responses of each layer to the context vary significantly. To more effectively mine structural semantic information, this specific implementation utilizes context-aware neurons for hierarchical screening. This aims to select the neurons that contribute most to semantic modeling from different semantic levels of the model, thereby enhancing the structural awareness of the screening process and alleviating the problem of uneven distribution of semantic contributions between layers.
[0034] In this specific embodiment, the context-aware neuron hierarchical screening further includes: S121: Based on the attribution scores of all FFN neurons in the model for the input context, filter out those whose attribution scores meet the following criteria. The FFN neurons constitute a preliminary candidate set; Among them, adaptive threshold The method for determining it is as follows: Considering the functional differences of different layers in semantic modeling, the large language model is first divided into three functional regions according to layers: shallow region Middle area Deep regions , L This represents the total number of layers in the large language model. The index must be an integer, using a floor function (denoted as ). ) to determine the region boundary, where .
[0035] To demonstrate the importance of different regions in contextual semantic modeling, in each layer l The upper region is set with an adaptive ratio for selecting high-contribution neurons. Its definition is shown in equation (3): (3) in, The preset screening ratio for globally high-contribution neurons is recommended to be within the range of [5%, 20%]. Considering the high recall rate of attribution scores under the constraint of controllable computational cost, in this embodiment... Setting it to 10% ensures a high recall rate while keeping computational complexity within an acceptable range. and As a region adaptive factor, its core function is to match the heterogeneity in the number of high-quality neurons in shallow and deep regions of the neural network, thereby supporting the accurate screening and efficient utilization of information at different levels. For shallow regions that mainly encode lexical and syntactic features and have high redundancy, the adaptive factor tends to take a smaller value (e.g., 0.5) to filter out redundant information at lower levels; for deep regions that are mainly responsible for high-level semantic modeling and answer generation and have high density of key information, the adaptive factor tends to take a larger value (e.g., 2.0) to expand the search range and prevent the omission of key high-level neurons.
[0036] In this embodiment, it is generally set , The aim is to adaptively adjust the screening ratio of high-quality neurons in different functional regions, ensuring that the remaining neurons can provide sufficient candidate space for the subsequent construction and fine screening of the global candidate set.
[0037] S122: Integrate the initial candidate set of all training samples to construct a candidate set of global context-aware neurons. ; S123: Statistical Candidate Set Frequency of occurrence of each neuron in the training samples Within each layer, based on frequency of occurrence The neurons in this layer are independently sorted to generate a ranking of each neuron's contextual contribution within that layer. ; S124: Determine the screening quota for each functional area, evenly distribute the regional quota to each layer within the corresponding functional area, obtain the screening quota for each layer, and then, within each layer, according to... Select the first High-ranking neurons are combined to form a candidate set of CANs. ; Considering the functional differences of different layers in semantic modeling, and to further reflect the structural value of different regions in semantic modeling, a default region weight is set. The screening quota for each functional area is calculated as shown in equation (4): (4) in, . This represents the total number of neurons in the global candidate set.
[0038] The context-aware neuron hierarchical selection mechanism ensures that the structural contributions of different levels to semantic modeling are taken into account, providing semantically more representative activation units for subsequent neuron enhancement mechanisms.
[0039] Traditional methods rely on static, manually set neuron enhancement parameters, lacking adaptability to task context and thus limiting generalization ability, making it difficult to transfer to different task scenarios. To address these issues, this specific implementation introduces a dynamic weight adjustment mechanism based on Bayesian optimization to adaptively optimize the number and activation enhancement intensity of context-aware neurons, further improving the model's ability to focus on context.
[0040] In this specific embodiment, the Bayesian optimized dynamic weight selection further includes: S131: Constructing Joint Hyperparameters ,in, This represents the optimal number of boosting neurons. Indicates activation enhancement intensity; S132: Determining the optimal joint hyperparameter configuration of sensory neurons using Bayesian optimization methods. ; S133: Utilizing optimal activation strength Gain adjustment is applied to the activation values of the CAN candidate set to enhance the activation representation; The gain adjustment of activation values does not involve modification of model parameters, has good structural compatibility and deployment flexibility, and facilitates fine-grained context adaptation capabilities.
[0041] Enhanced activation representation As shown in equation (6): (6) in, , which represents the activation enhancement intensity and is used to control the activation amplification factor.
[0042] The specific implementation of the above sub-step S132 is as follows: First, an initial evaluation dataset is generated in the parameter space through grid sampling. Then, the historical evaluation parameters were divided into a "good parameter set" (score above the median) and a "poor parameter set" (score below the median), and probability density functions were fitted to each set respectively. and And by maximizing the l / g ratio, efficient parameter sampling is achieved; Next, the dataset and distribution model are updated in each iteration, and the parameter configuration is optimized accordingly; Finally, by monitoring the joint scoring function in the two iterations, The relative rate of change is used to determine whether convergence has occurred. If the relative rate of change is less than 0.1%, the optimization mechanism terminates, and the optimal parameter configuration is obtained. And based on this, update the activation strategy of FFN neurons.
[0043] The dual convergence determination mechanism is based on the joint constraint of model generation accuracy and stubbornness rate. This mechanism abandons the single-dimensional early stopping strategy in traditional optimization and introduces a joint dynamic evaluation of accuracy (measuring context awareness) and stubbornness rate (measuring parameter dependence). By monitoring the joint gain rate after the coupling of the two indicators, it ensures that the model maximizes context understanding accuracy while effectively suppressing stubborn dependence on parameterized illusionary knowledge, thereby avoiding the local optimum trap of "high accuracy but high illusion" or "low illusion but semantic loss".
[0044] In the hyperparameter space, a black-box search is performed using a Bayesian optimization method based on the Tree-structured Parzen Estimator (TPE) to maximize the model's semantic consistency and robustness under context guidance. During this process, a joint scoring function... Constructed as the core evaluation operator, this function aims to couple and map multi-dimensional performance constraints such as accuracy and context faithfulness into a single scalar feedback through a weighted mechanism, thereby quantifying the comprehensive effectiveness of the current hyperparameter configuration and guiding the TPE algorithm to converge toward the optimal solution during iteration. The specific definition of the joint scoring function is shown in equation (7): (7) in, This represents the generation accuracy of the model under the current hyperparameters, used to measure the model's fidelity to contextual knowledge; This represents the model's stubbornness rate under the current hyperparameters, used to measure whether LLMs rely too much on parameterized knowledge and ignore context. This represents the penalty coefficient, which increases with the persistence rate to punish the risk of hallucination.
[0045] The generation quality of LLMs is also limited by two aspects: First, the model's over-reliance on parameterized knowledge will inhibit the full utilization of the input context, especially when the input contains new knowledge or semantically conflicts with the model's existing knowledge. The model tends to output results that are consistent with the parameter memory but inconsistent with the context. Second, most existing contrastive modulation strategies fail to capture the individual differences between neurons in layers. In particular, when the input contains new knowledge or the context and the model's parameterized knowledge have semantic conflicts, existing methods are difficult to effectively adjust the precise balance between the context and the model's parameterized knowledge.
[0046] To overcome the aforementioned bottlenecks, this specific implementation combines a contrastive generation strategy with a neuron-level dynamic control mechanism to construct a three-level contrastive decoding architecture of "key neuron identification → activation enhancement → probability reconstruction". Unlike the traditional strategy that only performs uniform weighting at the output logits layer, a context-aware neuron dynamic activation enhancement mechanism is introduced at the FFN layer, along with JSD-driven dynamic contrast coefficients. A context-aware reconstruction probability distribution is constructed during the decoding stage to achieve fine-grained and interpretable context adaptation capabilities without changing the structure.
[0047] The above step S200 further includes: S210: context-aware neuron activation gain; and S220: neuron adaptive contrastive decoding.
[0048] In sub-step S210, the most representative samples are selected based on the ACNS method. These neurons serve as dynamic enhancement targets during the decoding phase. While maintaining the model structure and parameters, additional activation amplification is applied to these key neurons to guide the model to focus more on neural signals along the critical context paths, thereby providing a clearer and more semantically interpretable representational basis for probability distribution reconstruction. The enhancement process is defined as shown in Equation (8): (8) in, To activate and enhance strength, The number and enhancement strength of the optimal context-aware neurons are dynamically determined by a Bayesian optimization strategy.
[0049] Through neuron-level gain mechanisms, a stronger response to newly introduced knowledge paths in the context can be generated without relying on additional parameters or retraining, thereby enhancing the model's contextual adaptation ability in the generation stage and providing a structure-aware intermediate representation for subsequent comparative decoding.
[0050] Building upon the aforementioned activation gains, a more fine-grained contrastive generation architecture is constructed. Unlike traditional contrastive decoding methods that only employ a uniform weighting strategy at the output logits layer, this application introduces a dynamic contrastive adjustment strategy based on JSD to dynamically model the degree of semantic conflict between the context and the model's parameterized knowledge, achieving more stable and interpretable context adaptation and probabilistic reconstruction.
[0051] Step S220 further includes: To achieve an effective comparison between contextual information and parameterized knowledge, the parameterized knowledge score in the absence of context, i.e., the prior score, is first calculated, which can reflect the inherent parameterized knowledge of the model, as shown in Equation (9): (9) in, Indicates the current moment t All words that have been generated previously ( Tokens )sequence; It represents the activation mode of the model in an empty context, reflecting its parameterization knowledge; and These are fixed output projection matrices and bias terms, respectively, reflecting the model's inherent parametric knowledge preferences.
[0052] Combine the enhanced activation value with contextual information Define the generated word The context-aware score is calculated as shown in equation (10): (10) To quantify the degree of semantic conflict between the current context and the model's parameterized knowledge, and to amplify the contribution of context-related features, a contrast intensity adjustment coefficient based on JSD is introduced. In each decoding step Set as formula (11): (11) in, Indicates the basic contrast intensity, with a value range of 100%. ; To quantify the degree of conflict between context and parameterized knowledge, it serves as a dynamic adjustment factor for the contrast intensity during the decoding process.
[0053] JSD, as a symmetric and bounded probability distribution distance metric, effectively captures the degree of conflict between the context-driven distribution and the prior distribution, making it suitable for progressive dynamic adjustments during the decoding phase. The JSD between the context-aware score distribution and the parameterized knowledge distribution is calculated for each decoding step. For the two probability distributions... , The JSD definition is shown in equation (12): (12) in, It is a mixed distribution.
[0054] Used to quantify probability distribution and The degree of difference between them Used to quantify probability distribution and The degree of difference between them. The Kullback-Leibler (KL) divergence is shown in Equation (13): (13) In equation (13), s Indicates an index. In the probability distribution, the th s The probability of each word appearing In a mixed probability distribution, the first... s The probability of each word appearing.
[0055] A higher JSD value indicates a significant discrepancy between the current context and the model's parameter knowledge, meaning the model needs to rely more on context-related neurons to mitigate semantic conflicts. Conversely, a lower JSD value reflects a high degree of consistency between the model's parameter knowledge and the contextual information.
[0056] Combining the aforementioned context-aware score, prior score, and dynamic contrast intensity coefficient, the current word... The generation probability is reconstructed, and the reconstructed probability distribution is shown in equation (14): (14) After obtaining the reconstructed generation probability distribution, an auto-regressive decoding strategy is used to determine the final output. Specifically, at time step... t The model performs a greedy search based on the reconstructed distribution, selecting the word with the highest probability as the prediction output for the current time step. The predicted term was then added to the historical generation sequence. In this process, the words are used as input conditions for the next time step. This process iterates until the model generates a terminator (EOS) or reaches the maximum length limit. JSD dynamic coefficients guide this decoding selection process in real time, ensuring that the words generated at each step achieve an optimal balance between faithfulness to the context and maintaining linguistic fluency.
[0057] By introducing a neural gain mechanism and combining it with a JSD-driven contrastive decoding strategy, a dynamic balance between context and parameter knowledge is achieved without relying on model parameter updates, which significantly improves the model's context fidelity in semantic conflict scenarios.
[0058] In this specific embodiment, the above method is implemented through the lightweight pluggable framework ACND. ACND is a neural decoding framework that covers the entire process of "neuron activation → knowledge representation → generation decision". It aims to improve the model's ability to faithfully model context information and alleviate generation bias caused by knowledge conflict or context change.
[0059] The neural network decoding framework ACND in this application includes two core modules: (1) ACNS (Adaptive Context-Aware Neuron Selection Module): It is used to dynamically identify context-aware neurons that are highly relevant to task prediction, and to achieve adaptive selection and weight adjustment of key neurons, thereby ensuring that the model accurately perceives key contextual information. (2) NACD (Neural Adaptive Contrast Decoding Module): This module introduces a neuronal activation gain mechanism into the FFN layer of the LLM and combines it with a dynamic contrast modulation strategy based on Jensen-Shannon Divergence (JSD) to reconstruct the generation probability distribution. This mechanism can enhance the model's ability to respond to context, thereby reducing the risk of generating hallucinations and improving the semantic consistency and robustness of the prediction results.
[0060] Example This embodiment selects three representative datasets, including: a dataset built based on the classic dataset RACE, denoted as the RACE-CCR dataset; a dataset built based on ECQA, denoted as the COSE-KRE dataset; and a dataset built based on e-CARE, denoted as the ECARE-KRE dataset.
[0061] The RACE-CCR dataset is used to validate complex context reasoning. Its construction method involves selecting samples from the RACE dataset that meet the following criteria: the question cannot be solved by a single sentence within a paragraph; the correct answer requires integrating multiple (usually non-adjacent) contextual fragments; and distractors contain subtle semantic traps or partial truths. Simultaneously, for each multiple-choice question, a randomly selected incorrect option is designated as the "correct answer," and ChatGPT is used to generate explanatory text supporting this incorrect option as contextual content. Examples of the constructed RACE-CCR dataset are shown in Table 1.
[0062] Table 1 Examples of the RACE-CCR dataset
[0063] The COSE-KRE and ECARE-KRE datasets are conflict knowledge test sets used to test the performance of ACND under conflict or fuzzy knowledge conditions. Examples of the COSE-KRE and ECARE-KRE datasets are shown in Tables 2 and 3, respectively.
[0064] Table 2 Examples of the COSE-KRE dataset
[0065] Table 3 Examples of the ECARE-KRE dataset
[0066] To comprehensively verify the versatility of ACND in multi-domain contextual reasoning, experiments were conducted on several mainstream LLMs, covering different training paradigms and parameter scales, to evaluate ACND's robustness and generalization ability across models, tasks, and complex contextual reasoning scenarios. To ensure consistency in evaluation criteria, following the approach widely adopted in the official MMLU implementation and other benchmarks, a unified prompt was designed for each model through prompt engineering, and the answer was selected based on the highest probability among the options. The model prompt template is shown in Table 4.
[0067] Table 4. Hints used in the hint-based engineering approach
[0068] A dual-metric evaluation method was employed, including accuracy (ACC) and stubbornness rate (SR). Accuracy (ACC) measures the model's ability to select the correct answer under conflicting contexts and is a primary indicator of semantic understanding and reasoning accuracy. Stubbornness rate (SR) measures whether the model still overly relies on its pre-training knowledge paths when faced with input context; a higher SR indicates that the model is more likely to ignore the current context and rely more on the model's parameterized knowledge.
[0069] To comprehensively compare and verify the advantages of ACND, it is compared with the following baselines: Original: Untreated LLMs that rely on their intrinsic knowledge acquired during pre-training for reasoning; this is the baseline metric for evaluating the improvement. Supervised Fine-Tuning (SFT): SFT represents the classic data-driven optimization paradigm. Applying SFT to existing LLMs serves as a baseline for enhancing model performance. IRCAN: A context-modulation method based on neuronal attribution. It first filters key neurons that are context-aware by calculating integral gradients and then reweights them to improve the model's sensitivity to contextual information. CAD: An optimization strategy based on contrastive decoding. It highlights the differences in the impact of contextual information on the results by adjusting the output probabilities of large language models. IRCAN-CAD: A joint optimization method combining IRCAN and CAD, derived from the combined strategy proposed in the original IRCAN paper, aiming to improve the model's ability to handle knowledge conflicts through synergy.
[0070] To systematically evaluate the performance of various methods in scenarios involving conflicts between context and parameterized knowledge, comparative experiments were conducted on different datasets based on two core evaluation metrics: model accuracy and stubbornness rate. Each dataset was randomly partitioned in a 1:1 ratio to construct validation and test sets, ensuring a balanced sample distribution. Detailed experimental results are shown in Table 5. In Table 5, models 1-6 correspond to the large language models Qwen3-4B, Qwen2.5-7B, Baichuan2-7B-SFT, Llama-2-7b-chat, and Qwen2.5-7B-Inst, respectively. The evaluation results include accuracy (ACC) and stubbornness rate (SR), where 44.84 / 43.37 represents an accuracy of 44.84% and a stubbornness rate of 43.37%.
[0071] Taking commonsense reasoning COSE-KRE as an example, the average stubbornness rate in the Original model is as high as 34%, reflecting that LLMs tend to rely on parameterized knowledge by default and fail to make full use of the current context. Although the CAD method achieved an average accuracy improvement of about 8% on multiple models, its effect on alleviating knowledge stubbornness is limited, with an average SR decrease of only 6.9%, indicating that it is still insufficient in suppressing the inherent bias of the model. IRCAN achieved performance improvement on some models, but the accuracy decreased on multiple models, indicating that the static neuron enhancement strategy has an adaptation bottleneck under dynamic changes in context. IRCAN-CAD achieved performance improvement on some models, but its overall performance is still inferior to ACND, indicating that simple module stacking is difficult to achieve optimal collaborative optimization. In contrast, ACND showed the best comprehensive performance on multiple models. The accuracy on Baichuan2-7B-SFT was improved by 16.9% compared to the original model, far exceeding all the comparison methods. At the same time, its SR decreased by 10%, showing a stronger ability to suppress the model's over-reliance on inherent knowledge and more accurately align key information in the input context.
[0072] On the more challenging complex contextual reasoning datasets RACE-CCR and causal reasoning datasets ECARE-KRE, ACND also demonstrates robust and superior overall performance. On RACE-CCR, ACND achieves best overall performance among several mainstream models, demonstrating excellent long text modeling capabilities and task transfer adaptability. On ECARE-KRE, ACND achieves accuracies of 74.93% and 82.94% on the Baichuan2-7B and LLaMA2-7B-chat models, respectively, with SR values decreasing to 25.07 and 17.06, both state-of-the-art results.
[0073] In summary, ACND achieves significant improvements in both accuracy and stubbornness across models and tasks with varying parameter sizes, significantly mitigating the model's path dependence on outdated or irrelevant parameterized knowledge. It effectively enhances the model's semantic fidelity and generative consistency, achieving overall performance at the State-of-the-Art (SOTA) level.
[0074] Table 5 Evaluation results of different models and methods on the test dataset (unit: %)
[0075] Within the ACND framework, the introduction of ACNS and NACD methods inevitably increases computational overhead. However, this overhead is entirely concentrated in the training and offline parameter selection stages, having no substantial impact on inference efficiency. Specifically, the computational cost mainly stems from the following two stages: (1) Neuron attribution computation: To evaluate the context sensitivity of neurons in the FFN layer, the ensemble gradient (IG) method was used to perform gradient integration from the baseline to the context input for each sample, and the process was approximated by discretized Riemann integrals to improve computational efficiency. All neuron attribution computations were performed on a single NVIDIA A6000 GPU with 48GB of video memory. The experimental time depended on the model size, dataset size, and input length, but was generally within an acceptable range. For example, on the COSE-KRE dataset, the neuron attribution computation experiment for the smallest model (4B) took less than 8 hours, while the experiment for the largest model (7B) took an average of less than 15 hours.
[0076] It is worth noting that this attribution calculation process is only executed once during the training phase. During the inference phase, the filtered CANs are directly loaded, eliminating the need for repeated attribution calculations and thus having no impact on inference efficiency.
[0077] (2) Bayesian optimization: for joint hyperparameters The search is also completed offline. Taking the COSE-KRE dataset as an example, the Bayesian optimization experiment of the smallest model Qwen3-4B took less than 2 hours, while the experiment of the largest model (7B) took less than 18 hours. Once the optimal parameters are determined, they can be used indefinitely during the inference phase without introducing additional computational overhead.
[0078] To verify the efficiency and adaptability of ACND across different models and tasks, we conducted practical evaluations on several mainstream model sizes (4B / 7B) and task datasets. The results are shown in Table 6. For the base model, although there is a slight overhead in IG attribution and Bayesian optimization during the training phase, it does not affect the inference efficiency of LLMs. Overall, the results demonstrate that the ACND framework significantly improves context-focusing ability and semantic consistency while exhibiting good inference efficiency and deployment adaptability.
[0079] Table 6. Average computational cost of the ACND framework on different datasets. Qwen3-4B 8 h 2h Llama-2-7b-chat 16 h 5.5h Baichuan2-7B- SFT 15 h 5h Baichuan2-7B 15 h 5h Qwen2.5-7B-Inst 12 h 4.5h Qwen2.5-7B 12 h 4.5h To further evaluate the contribution of each key module in the ACND framework to the overall performance, the following ablation experiment was designed: by removing the two core modules ACNS and NACD respectively, the impact on model performance was systematically analyzed.
[0080] Specific settings include: with / o ACNS: using static thresholds instead of dynamic neuron selection mechanisms; with / o NACD: disabling neuron enhancement and logits reconstruction during contrastive decoding; RanN: randomly selecting and... An equal number of neurons were either boosted or zeroed out to simulate a random boosting strategy without attribution selection. To ensure the reliability and robustness of the experimental results, the experiment was independently repeated 10 times, and the average of these results was reported as the basis for the final analysis, aiming to minimize selection bias and enhance the statistical significance of the findings.
[0081] Please see Figure 3 The figure shows a comparison of ablation experiment results on the ECARE-KRE dataset. As can be seen, removing ACND significantly reduces the accuracy of the model across all tasks, validating the necessity of data-driven attribution and Bayesian optimization strategies for dynamically selecting neurons, and confirming the hypothesis that "data-driven is superior to rule-based settings." Removing NACD improves the model's average stubbornness by 9%, indicating that neuron-level contrastive modulation plays a crucial role in suppressing false activations and enhancing robustness. Overall, ACND can simultaneously improve contextual fidelity and reduce dependence on parameterized knowledge across different models, demonstrating strong robustness and generalization ability while maintaining low performance fluctuations.
[0082] To evaluate the universality and stability under different knowledge-intensive reasoning scenarios, ablation experiments were further conducted on the COSE-KRE and RACE_CCR datasets, such as... Figures 4-5 As shown, in all ablation experiments, the complete ACND framework consistently achieved the highest accuracy and lowest stubbornness, indicating that the ACNS and NACD modules effectively complement each other in terms of dynamic screening and contrastive regulation, synergistically improving the model's expressive power and stability.
[0083] Furthermore, a horizontal comparison of results across different tasks reveals that ACND significantly outperforms the original model and other baseline methods on all tested models. This phenomenon not only highlights the crucial roles of the two core modules, ACNS and NACD, within the methodological framework but also fully demonstrates the framework's robustness and generalization ability across different model architectures.
[0084] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, nor are they 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 improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method for alleviating the large language model illusion problem, characterized in that, Including the following steps: S100: Adaptive context-aware neuron selection; S200: Neuron-adaptive contrastive decoding; Step S100 further includes: S110: Calculate the attribution scores of each FFN neuron in the large language model for the input context; S120: Select the context-aware neuron set based on the attribution scores of FFN neurons; S130: The optimal joint hyperparameters of neurons are determined using Bayesian optimization, and the activation enhancement intensity in the optimal joint hyperparameters is used to adjust the gain of the activation values of each neuron in the context-aware neuron set. Step S200 further includes: S210: Using the activation enhancement strength in the optimal joint hyperparameters, the activation value of the optimal context-aware neuron in the FFN layer of the large language model is adjusted by gain. S220: Comparative decoding is performed using a large language model with gain adjustment.
2. The method for alleviating the large language model illusion problem as described in claim 1, characterized in that: Step S110 further includes: neurons Activation value of baseline state Activation value to context state Divided into There are several equally spaced small steps; among which, the number of discretization steps is... Experience value; The approximate attribution score of each FFN neuron to the input context is calculated using the following formula. :
3. The method for alleviating the large language model illusion problem as described in claim 1, characterized in that: Step S120 further includes: S121: Divide the large language model into three functional regions: shallow region, middle region, and deep region, and define adaptive thresholds for each layer in each functional region. ,in, The preset screening ratio, and It is a regional adaptive factor. , ; Select the attribution scores in each layer that meet the criteria. The FFN neurons constitute a preliminary candidate set; S122: Integrate the initial candidate set of all training samples to construct a candidate set of global context-aware neurons. ; S123: Count the frequency of each FFN neuron in the candidate set in the training samples, and independently rank the FFN neurons in each layer according to their frequency of occurrence. S124: Determine the screening quota for each functional area, and distribute the screening quota evenly to each layer within the corresponding functional area to obtain the screening quota for each layer. Select the first layer within each layer. A set of high-ranking neurons is combined to obtain a context-aware neuron set. Screening quotas for each functional area The calculation formula is as follows: ; in, , , , These represent the proportional weights of the shallow, middle, and deep layers, respectively.
4. The method for alleviating the large language model illusion problem as described in claim 3, characterized in that: The number of layers in the shallow region ranges from [1, ... The number of layers in the middle layer region is []. , The number of layers in the deep region ranges from [ ]. , ];in, L This represents the total number of layers in a large language model. ; , This represents the floor function.
5. The method for alleviating the large language model illusion problem as described in claim 1, characterized in that: The determination of the optimal joint hyperparameters of neurons using Bayesian optimization in step S130 includes: Historical evaluation parameters are divided into a good parameter set and a poor parameter set, and probability density functions are fitted to each set respectively. and And perform efficient parameter sampling; In each iteration, the dataset and distribution model are updated, and the parameter configuration is optimized accordingly until convergence.
6. The method for alleviating the large language model illusion problem as described in claim 1, characterized in that: Step S220 further includes: In each decoding step, the contrast intensity adjustment coefficient is... Set to: ; in, Indicates the basic contrast intensity, with a value range of 100%. ; Represents the context-aware score probability distribution With prior score probability distribution The distance between them; Context-aware score Prior score Dynamic contrast intensity adjustment coefficient, for the current word The generation probability is reconstructed, and the reconstructed probability distribution is as follows: 。 7. The method for alleviating the large language model illusion problem as described in claim 6, characterized in that: make , ,but: ; in, , indicating a mixed distribution; This represents the Kullback-Leibler divergence.
8. A system for alleviating the illusion of large language models, characterized in that, include: Adaptive context-aware neuron selection module and neuron adaptive contrast decoding module; The adaptive context-aware neuron selection module further includes: The first submodule is used to calculate the attribution scores of each FFN neuron in the large language model for the input context. The second submodule is used to filter the context-aware neuron set based on the attribution scores of FFN neurons; The third submodule is used to determine the optimal joint hyperparameters of neurons using Bayesian optimization, and to adjust the activation values of each neuron in the context-aware neuron set by using the activation enhancement strength in the optimal joint hyperparameters. The neuron adaptive contrast decoding module further includes: The fourth submodule is used to adjust the gain of the activation value of the optimal context-aware neuron in the FFN layer of the large language model by using the activation enhancement strength in the optimal joint hyperparameters. The fifth submodule is used for comparative decoding using a large language model with gain adjustment.