Large model thinking chain knowledge distillation method and system based on anti-fact reasoning

By identifying key causal lexical units to construct counterfactual questions and performing causal mediation analysis, the inference chain of large language models is optimized, solving the problems of causal consistency and stability in inference tasks of large pre-trained models and achieving more reliable data support for inference chains.

CN121365743APending Publication Date: 2026-01-20SHANDONG JIANZHU UNIV

Patent Information

Application Number
CN202511935459.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-01-20

AI Technical Summary

Technical Problem

Existing large-scale pre-trained language models suffer from redundant reasoning chains, instability, and weak causal consistency in reasoning question answering, common sense reasoning, and explanatory tasks. Existing methods struggle to systematically quantify the causal contribution of reasoning chains and fail to maintain causal consistency in counterfactual environments.

Method used

By identifying key causal terms and applying minimal semantic perturbation to construct counterfactual questions, multi-perspective reasoning chains are generated. High-fidelity distillation datasets are selected using causal mediation analysis, and large language models are trained to optimize the consistency of thought chains. A joint loss function is constructed to improve causal reliability and logical consistency.

Benefits of technology

It improves the causal reliability and logical consistency of the large model's thought chain, provides more stable inference chain data support, and enhances the causal consistency and interpretability of downstream applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121365743A_ABST
    Figure CN121365743A_ABST
Patent Text Reader

Abstract

The invention provides a large model thinking chain knowledge distillation method and system based on anti-factual reasoning, and belongs to the technical field of artificial intelligence and natural language processing. Comprising the steps that minimum semantic disturbance is applied to a key position of an original reasoning task data set, and an anti-fact problem is constructed; based on the original problem and the anti-fact problem, calling a large language model to generate a multi-view reasoning chain; a high-loyalty distillation data set is screened out through causal intermediary analysis, and thinking chain consistency optimization training is carried out on the large language model; and deploying the large language model after optimization training to a downstream task. According to the method, by analyzing the anti-fact space of the input problem and quantifying the causal contribution of the inference chain to the final decision, the causal reliability and logic consistency of the large model thinking chain can be improved, and then effective data support is provided for downstream inference application.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of artificial intelligence and natural language processing, and particularly relates to a large model thought chain knowledge distillation method and system based on counterfactual reasoning. BACKGROUND

[0002] The statements in this section merely provide background information related to the present application and do not necessarily constitute prior art.

[0003] Large pre-training language models (LLMs) exhibit strong reasoning capabilities in reasoning and answering questions, common sense reasoning, and explanatory tasks. Chain-of-Thought (CoT), as a method of making models explicitly generate intermediate reasoning steps, can effectively improve the logical interpretability and multi-step reasoning performance of models. However, the thought chains generated by traditional LLMs still have several shortcomings: first, the reasoning chain often contains redundant explanations, false causes, or reasoning steps unrelated to the final decision; second, the reasoning chain is easily affected by input noise and semantic drift, leading to unstable reasoning processes and even hallucinations; third, the consistency of the reasoning chain under counterfactual scenarios is weak, making it difficult to maintain the directionality and robustness of the causal structure.

[0004] To improve the quality of the reasoning chain, existing research attempts to modify the reasoning process of LLMs based on diversified prompts, logical consistency constraints, or answer verification mechanisms. However, these methods still have obvious technical defects: (1) Existing methods mostly rely on heuristic rules and cannot systematically quantify the causal contribution of the reasoning chain, or only focus on the surface language quality of the reasoning chain while ignoring its real impact on the final answer.

[0005] (2) Although some methods in existing technologies consider introducing counterfactual samples or perturbation mechanisms to overcome existing defects, they mostly stay at the semantic replacement level and cannot maintain the causal consistency of the reasoning chain under counterfactual environments, and may even destroy the logical structure of the original task. SUMMARY

[0006] To overcome the shortcomings of the existing technologies, the present application provides a large model thought chain knowledge distillation method and system based on counterfactual reasoning, which can improve the causal reliability and logical consistency of the large model thought chain by analyzing the counterfactual space of the input question and quantifying the causal contribution of the reasoning chain to the final decision, thereby providing effective data support for downstream reasoning applications.

[0007] To achieve the above purpose, one or more embodiments of the present application provide the following technical solutions: The application provides a large model thinking chain knowledge distillation method based on counterfactual reasoning.

[0008] A large model thinking chain knowledge distillation method based on counterfactual reasoning comprises the following steps: An original reasoning task data set is obtained, each sample in the original reasoning task data set containing question text, candidate options and standard answers; by identifying key causal word elements affecting answer prediction, minimum semantic perturbation is applied at the corresponding position to construct a counterfactual question; Based on the original question and the counterfactual question, a large language model is called to generate multi-perspective reasoning chains containing positive reasoning chains and negative reasoning chains, and a set of paired reasoning chain samples with causal contrast properties is constructed as causal perturbation samples; The causal influence effect is calculated through causal intermediary analysis, and the causal perturbation samples with a causal influence effect higher than a preset threshold are selected as a high-fidelity distillation data set; Based on the high-fidelity distillation data set, the large language model is subjected to thinking chain consistency optimization training, a joint loss function containing reasoning chain preference loss, positive language modeling loss, counterfactual constraint loss and causal ordering loss is constructed, and finally the large language model after optimization training is deployed to a downstream task.

[0009] Further, the key causal word elements are identified by using dependency syntax analysis and semantic role labeling methods; wherein the key causal word elements include core predicates, conditional constraints and logical modification components.

[0010] Further, the minimum semantic perturbation is applied at the corresponding position to construct a counterfactual question, comprising: according to the identified key causal word elements, performing minimum editing operation through a semantic replacement function to generate a question in counterfactual form as a counterfactual question.

[0011] Further, semantic consistency verification and logical constraint filtering are introduced to maintain the content integrity, clear causal relationship and correct logical structure of the multi-perspective reasoning chain.

[0012] Further, when constructing the causal perturbation samples, the pseudo causal perturbation caused by expression differences is eliminated by calculating semantic similarity.

[0013] Further, each sample in the high-fidelity distillation data set contains question text, candidate answer set, standard answer, positive reasoning chain, negative reasoning chain and causal influence weight.

[0014] Further, the joint loss function is represented as: ; wherein, is a joint loss function, denotes a reasoning chain preference loss, denotes a positive language modeling loss, denotes a counterfactual constraint loss, denotes a causal ordering loss; denotes the total number of training samples; denotes a causal fidelity weight obtained by causal intermediary analysis; denotes a balance coefficient of the reasoning preference loss, the language modeling loss, the counterfactual constraint loss and the causal ordering loss, respectively.

[0015] The second aspect of the present application provides a large model thinking chain knowledge distillation system based on counterfactual reasoning.

[0016] A large model thinking chain knowledge distillation system based on counterfactual reasoning, comprising: A causal disturbance generation module is configured to: obtain an original reasoning task data set, each sample in the original reasoning task data set containing question text, candidate options and standard answers; by identifying key causal word units that affect answer prediction, a minimum semantic disturbance is applied at the corresponding position to construct a counterfactual question; based on the original question and the counterfactual question, a large language model is called to generate a multi-perspective reasoning chain containing a positive reasoning chain and a negative reasoning chain, and a set of paired reasoning chain samples with causal contrast properties are constructed as causal disturbance samples; A fidelity screening module is configured to: calculate causal impact effects through causal intermediary analysis, and screen out causal disturbance samples with a causal impact effect higher than a preset threshold as a high-fidelity distillation data set; A thinking chain consistency optimization module is configured to: based on the high-fidelity distillation data set, perform thinking chain consistency optimization training on the large language model, and construct a joint loss function containing a reasoning chain preference loss, a positive language modeling loss, a counterfactual constraint loss and a causal ordering loss; A model deployment module is configured to: deploy the large language model after optimization training to a downstream task. The third aspect of the present application provides a computer readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps of the large model thinking chain knowledge distillation method based on counterfactual reasoning according to the first aspect of the present application.

[0017] The fourth aspect of the present application provides an electronic device comprising a memory, a processor and a program stored on the memory and executable on the processor, wherein the processor implements the steps of the large model thinking chain knowledge distillation method based on counterfactual reasoning according to the first aspect of the present application when executing the program.

[0018] The above one or more technical solutions have the following beneficial effects: (1) The application first acquires an original reasoning task data set, identifies key causal word elements affecting answer prediction, applies minimum semantic disturbance at the corresponding position, constructs counterfactual questions, and then based on the original question and the counterfactual question, respectively calls a large language model to generate multi-perspective reasoning chains containing positive and negative reasoning chains. Finally, the causal influence effect is calculated through causal intermediary analysis, and the causal disturbance samples with a causal influence effect higher than a preset threshold are selected as a high-fidelity distillation data set. Compared with the prior art, the application not only considers the influence of semantic disturbance on the answer, but also better quantifies the causal contribution of the reasoning chain.

[0019] (2) The application calculates the causal influence effect through causal intermediary analysis, and selects the causal disturbance samples with a causal influence effect higher than a preset threshold as a high-fidelity distillation data set. Then, based on the high-fidelity distillation data set, the large language model is subjected to thought chain consistency optimization training. Therefore, the application can not only maintain the causal consistency of the reasoning chain in the counterfactual environment, but also will not destroy the logical structure of the original task.

[0020] The advantages of the additional aspects of the application will be partially given in the following description, partially will become obvious from the following description, or will be understood by the practice of the application. BRIEF DESCRIPTION OF DRAWINGS

[0021] The accompanying drawings, which form a part of the specification, are included to provide a further understanding of the application and are incorporated herein by reference. The illustrations are shown to explain the application and are not intended to limit the application.

[0022] Figure 1 A flowchart of a large model thought chain knowledge distillation method based on counterfactual reasoning in embodiment one of the application.

[0023] Figure 2 A modular flowchart of a large model thought chain knowledge distillation system based on counterfactual reasoning in embodiment two of the application. DETAILED DESCRIPTION

[0024] It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the application. Unless otherwise indicated, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the application pertains.

[0025] It should be noted that the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit the exemplary embodiments according to the application.

[0026] In the case of no conflict, the embodiments in the application and the features in the embodiments can be combined with each other.

[0027] Embodiment one The embodiment discloses a large model thinking chain knowledge distillation method based on counterfactual reasoning.

[0028] As Figure 1 shown, a large model thinking chain knowledge distillation method based on counterfactual reasoning comprises the following steps: Step S1, an original reasoning task dataset is obtained, each sample in the original reasoning task dataset contains question text, candidate options and standard answers; by identifying key causal word elements affecting answer prediction, minimum semantic perturbation is applied at the corresponding position to construct a counterfactual question; based on the original question and the counterfactual question, a large language model is called to generate multi-perspective reasoning chains containing positive reasoning chains and negative reasoning chains, and a set of paired reasoning chain samples with causal contrast properties are constructed as causal perturbation samples; Step S2, the causal influence effect is calculated through causal intermediary analysis, and the causal perturbation samples with a causal influence effect higher than a preset threshold are selected as a high-fidelity distillation dataset; Step S3, based on the high-fidelity distillation dataset, the large language model is subjected to thinking chain consistency optimization training, and a joint loss function containing reasoning chain preference loss, positive language modeling loss, counterfactual constraint loss and causal ordering loss is constructed; Step S4, the large language model after optimization training is deployed to a downstream task.

[0029] Based on the above process, the present application can improve the causal reliability and logical consistency of the large model thinking chain by analyzing the counterfactual space of the input question and quantifying the causal contribution of the reasoning chain to the final decision, thereby providing effective data support for downstream reasoning applications. In order to facilitate the understanding of the technical scheme of the present application, the specific implementation method in the technical scheme of the present application will be further explained and described below.

[0030] In step S1, an original reasoning task dataset is obtained; by identifying key causal word elements affecting answer prediction, minimum semantic perturbation is applied at the corresponding position to construct a counterfactual question; based on the original question and the counterfactual question, a large language model is called to generate multi-perspective reasoning chains containing positive reasoning chains and negative reasoning chains, and a set of paired reasoning chain samples with causal contrast properties are constructed as causal perturbation samples.

[0031] Each sample in the obtained original reasoning task dataset contains question text, candidate options and standard answers. On this basis, the present application uses the following method to perform counterfactual generation on the input sample to enhance the causal expression ability of the large language model thinking chain: First, for the input question, dependency syntax analysis, semantic role labeling and logical structure analysis are used to identify key causal word elements that affect the final answer, such as core predicates, conditional constraints and logical modifiers, etc.

[0032] Then, while maintaining the grammatical structure and overall semantic readability, a minimum semantic disturbance is applied to the key position to construct counterfactual questions, so that the disturbed question remains consistent with the original question in surface form, while forming a controllable reversal in causal conditions. Among them, the minimum semantic disturbance is applied to the corresponding position to construct counterfactual questions, including: according to the identified key causal word elements, performing a minimum editing operation through a semantic replacement function to generate a counterfactual form question as a counterfactual question.

[0033] Then, a large language model (i.e. teacher model) is called to generate counterfactual question instances with semantics close to the original task but with controllable changes in causal direction, thereby constructing the original and counterfactual reasoning tasks, providing a structured data basis for subsequent causal effect evaluation, i.e. generating multi-perspective thinking chains including positive reasoning chains supporting the standard answer and negative reasoning chains for excluding incorrect options for the original question (i.e. original sample) and counterfactual question (i.e. counterfactual sample), respectively, thereby constructing a set of paired reasoning chain samples with causal contrast properties for each task. Specifically, the teacher model generates positive perspective reasoning chains for supporting correct answers and negative perspective reasoning chains for excluding incorrect options according to specific prompt structures, thereby forming a "support path-rebuttal path" dual-perspective reasoning framework. By introducing semantic consistency verification and logical constraint filtering, it ensures that the generated reasoning chain is complete in content, clear in causal relationship and correct in logical structure, avoiding the introduction of redundant explanations or false causes into the subsequent distillation stage. Multi-perspective chains can help the model better understand the task structure, thereby improving the ability to recognize complex logical relationships.

[0034] Further, based on the above logic, the data processing process involved in step S1 includes: First, the original reasoning task data (i.e. original reasoning task dataset) is received, where each sample contains a question , a set of candidate answers and a standard answer . Then, the corresponding reasoning chain text is generated as the original reasoning chain by calling the teacher model, and the input question is subjected to dependency syntax analysis and semantic role labeling to construct a semantic graph ; where, represents a set of semantic entities, predicates and logical nodes, The causal and constraint relationship between nodes is represented. This process is not only used for distillation data construction, but also can make the large model expose its internal causal dependence when generating the reasoning chain, so as to provide an interpretable structure for subsequent reasoning chain optimization and quality evaluation.

[0035] In order to generate counterfactual perturbation samples, the importance of semantic nodes is estimated based on the output probability sensitivity analysis of the teacher model on the answer. For the question , the teacher model prediction probability of the answer is calculated . ; Wherein, the greater the gradient of the semantic node , the stronger the influence of the semantic node on the model decision. This analysis is not only used for subsequent counterfactual question construction, but also can be used to detect whether the large model reasoning chain sufficiently covers the key causal path, so as to serve as a reasoning chain coverage checking mechanism.

[0036] According to the importance ranking, the key causal nodes are selected, and the minimum editing operation is performed through the semantic replacement function to generate the counterfactual form question: ; Wherein, represents the changed causal condition under the premise of maintaining syntactic and semantic coherence. The teacher model generates the corresponding perturbation reasoning chain and the predicted answer for the counterfactual question after perturbation , so as to form the original sample and the counterfactual paired sample, providing the basis for causal verification.

[0037] On this basis, the modified question can be ensured to be grammatically smooth, semantically natural and to form a controlled change in causal condition. The teacher model then generates the corresponding reasoning chain and the predicted answer for the counterfactual question . By comparing the logical differences between the original reasoning chain and the perturbation reasoning chain , the possible redundant chain links or pseudo-causal reasoning in the large model reasoning chain can be explicitly identified, thereby assisting in improving the reasoning chain generation strategy of the large model.

[0038] In step S2, the causal impact effect is calculated through causal intermediary analysis, and the causal perturbation samples with a causal impact effect higher than a preset threshold are selected as the high-fidelity distillation dataset.

[0039] The fidelity of reasoning chains is screened based on Causal Mediation Analysis (CMA). By fixing the question text and replacing the input reasoning chains from different perspectives, the degree of change in the output distribution of the large language model is compared to quantify the causal contribution of the reasoning chain to the final answer, resulting in the fidelity index CIE. When a reasoning chain can significantly influence the model's decision under the replacement conditions, it indicates that it has strong causal explanatory power and is marked as a high-fidelity chain; if the influence is insufficient, it is removed or downweighted.

[0040] To mitigate interference from differences in linguistic expression, this invention further introduces semantic similarity constraints (also known as semantic consistency constraints) to ensure semantic consistency in the screening results. These constraints include operations such as text embedding alignment, logical structure matching, and redundant description reduction. This mechanism effectively filters out false causal chains, retaining only the key causal paths that truly influence decision-making. Finally, samples with high causal fidelity are selected as the high-fidelity distillation dataset based on the strength of causal influence, and assigned corresponding weights. Low-fidelity samples are discarded or downweighted. Each sample in the high-fidelity distillation dataset contains the question text, a set of candidate answers, the standard answer, a positive inference chain, a negative inference chain, and causal influence weights. This screening mechanism effectively eliminates inference chains that only offer superficial explanations and lack genuine causality, thereby improving the causal reliability of subsequent training data.

[0041] Furthermore, based on the above logic, the data processing procedures involved in step S2 include: Given a fixed question text, input the original inference chain and the perturbed inference chain respectively, and calculate the teacher model's accuracy for the correct answer. From the output probability, we get: ; ; in, This indicates the teacher model in the original inference chain. The probability of outputting the correct answer under given conditions. This indicates that the teacher model is in the perturbation inference chain. The probability of outputting the correct answer under given conditions.

[0042] Using the difference between the two as the causal effect of the inference chain (CIE): ; The CIE metric is not only used to screen distillation samples, but also provides a quantitative means to assess the "causal fidelity" of the inference chain in large models. When A lower value indicates that the reasoning chain generated by the large model lacks causal coupling with the answer, which can be used to fine-tune the large model, modify the hint strategy, or correct the reasoning chain template.

[0043] Subsequently, the system calculates semantic similarity to eliminate pseudo-causal fluctuations caused by expression differences. Finally, a high-fidelity sample is obtained as a high-fidelity distillation dataset: ; wherein, represents the high-fidelity distillation dataset obtained by screening, represents a preset threshold.

[0044] The high-fidelity distillation dataset can not only be used to train a small language model, but also can be used as a large model inference chain quality evaluation dataset to assist in improving and optimizing the inference chain structure.

[0045] In step S3, based on the high-fidelity distillation dataset, the large language model is trained for thought chain consistency optimization, and a joint loss function including inference chain preference loss, forward language modeling loss, counterfactual constraint loss and causal ordering loss is constructed.

[0046] Based on the fidelity screening, a two-stage large model thought chain optimization based on counterfactual reasoning consistency is performed, which is implemented in a thought chain consistency optimization module. The thought chain consistency optimization module includes an inference chain generation module and a faithful reasoning module. The inference chain generation module is used to generate chain reasoning text that meets the causal logic by adopting a preference optimization strategy under the supervision of a high-fidelity chain, taking a high-fidelity forward chain as a preference target, to generate a large model thought chain with clear causal direction and complete logic, thereby correcting the redundancy, skipping or inconsistency of the original large model in the inference chain expression. The faithful reasoning module is used to output answers that meet the logical expectations and are more stable under different chain inputs by language modeling constraints, counterfactual consistency constraints and causal ordering constraints. The two modules share part of the network structure, that is, they share part of the Transformer encoding layer parameters, and a logical alignment regular term is added to maintain the consistency of the latent semantic structure; through the strategy of alternating or joint optimization, a causal closed loop of "chain generation-causal correction-result prediction" is formed, so that the quality and causal rigor of the large model inference chain are effectively enhanced.

[0047] Further, based on the above logic, the data processing process involved in step S3 includes: Fusion processing is performed on the semantic representation of the original sample and the counterfactual sample. The semantic vectors of the original inference chain and the perturbed inference chain are obtained using the text encoder of the teacher model, and the fidelity is adaptively fused according to the fidelity: ; wherein, denotes the fused sample semantic representation vector; denotes the weight coefficient dynamically determined based on the causal influence effect (CIE), and the value range , which can be automatically adjusted by the CIE. denotes the text encoder. The semantic fusion mechanism can provide causal-consistent semantic representation for distilled data on the one hand, and can also be used as a tool to analyze the internal semantic path of the large model inference chain, so that the internal activation difference under different causal conditions can be presented, thereby providing a basis for improving the generation strategy of the large model inference chain.

[0048] Finally, the fused samples are structured and arranged to form a unified format , and logical consistency check is performed to ensure that the inference chain and the answer have a stable causal relationship. The generated distilled data can not only be used to enhance the inference ability of the small language model, but also provide a set of quantifiable, interpretable and iterative improvement of the inference chain quality control framework for the large model, thereby promoting the reliability and causal consistency of the large model in multi-step reasoning tasks.

[0049] Optimizing the thought chain consistency of the large language model, constructing a joint loss function including reasoning chain preference loss, forward language modeling loss, counterfactual constraint loss and causal ordering loss, specifically: Reasoning chain preference loss is used to learn the preference ordering relationship of the teacher model for positive and negative reasoning chains, which can be specifically represented as: ; wherein, denotes the reasoning chain preference loss, denotes the Sigmoid activation function; denotes the matching score function of the student model for the "input text-reasoning chain" pair; denotes the high-fidelity forward reasoning chain (correct reasoning path); denotes the negative reasoning chain (not true or counterfactual path); denotes the input sample (including question and context information).

[0050] Forward language modeling loss is used to supervise the answer generation of the student model under the condition of the forward reasoning chain, which can be specifically represented as: ; wherein, denotes the forward language modeling loss, denotes the conditional probability of the student model predicting the output sequence under the parameter ; denotes the correct answer corresponding to the forward reasoning chain.

[0051] The counterfactual constraint loss is used to enhance the distinguishing ability of the student model to the counterfactual reasoning chain, and can be specifically represented as: ; Wherein, The counterfactual constraint loss is represented by, The "wrong answer" or "target output under counterfactual condition" corresponding to the counterfactual reasoning chain.

[0052] The causal ordering loss is used to strengthen the causal directionality within the reasoning chain and suppress non-causal paths, and can be specifically represented as: ; Wherein, The causal ordering loss is represented by, The consistency score function of the student model to the "input-reasoning chain-answer"; The ordering margin (margin) hyperparameter.

[0053] Therefore, the joint loss function can be represented as: ; Wherein, The joint loss function is represented by, The reasoning chain preference loss is represented by, The forward language modeling loss is represented by, The counterfactual constraint loss is represented by, The causal ordering loss is represented by; The total number of training samples is represented by, The causal fidelity weight obtained by causal intermediary analysis is represented by; The balance coefficients of the reasoning preference loss, the language modeling loss, the counterfactual constraint loss and the causal ordering loss are represented by, respectively.

[0054] In step S4, the large language model optimized after training is deployed to downstream tasks.

[0055] The large language model optimized can be deployed to downstream application systems as a reasoning engine or a distillation teacher model, and performs reasoning tasks in the mode of "generating a causal-consistent reasoning chain-drawing an answer according to the chain". Through counterfactual reasoning, causal effect screening and causal consistency optimization, the present application constructs a causal enhancement mechanism for the large model thinking chain, so that it has higher logical stability, causal credibility and explainability in multi-step reasoning and distributed scenarios. As an optional way, the counterfactual disturbance intensity, the fidelity threshold, the perspective ratio, the reasoning chain length and the logic verification rule can be flexibly adjusted according to the task requirements.

[0056] Based on the above method, the present application can achieve the following significant technical effects: On the one hand, the application realizes the causal calibration of the reasoning chain quality of the large language model and the high-fidelity migration of the reasoning ability of the small language model by explicitly modeling the causal structure of the reasoning chain in the data generation and distillation training stage.

[0057] On the other hand, the application constructs structured counterfactual samples through the causal disturbance generation method, so that the system can observe the change behavior of the reasoning chain under controlled conditions, thereby identifying the causal nodes and logical paths that have a key impact on the final conclusion. This mechanism not only improves the perception ability of the student model to causal dependence, but also can be used to diagnose and calibrate the reasoning chain stability of the teacher model, find its potential pseudo-causal reasoning and inconsistent logical structure, and provide a basis for optimizing the thinking chain generation strategy of the large model.

[0058] On the third hand, the application can accurately quantify the real causal contribution of the reasoning chain text to the prediction result in combination with the causal mediation analysis (CMA) framework when performing fidelity screening, and eliminate reasoning fragments with weak surface correlation or weak explanatory components, so that the distillation training focuses on high-trust causal chains. Through this mechanism, the student model can avoid learning invalid, neutral or illusory reasoning chains, thereby significantly improving the explainability and stability of reasoning; at the same time, the screening process can also be used for causal consistency evaluation of the output of the large language model, providing data guidance for improving the reasoning chain quality.

[0059] In addition, the thinking chain consistency optimization structure proposed by the application cooperatively combines preference-based reasoning chain learning and causal ordering constraints, so that the student model can inherit the reasoning style of the teacher model while maintaining the causal consistency of the reasoning direction. At the same time, the designed logical alignment regularization term further ensures that the semantic representation space inside the student model is synchronized with the reasoning topology of the teacher model, thereby maintaining consistent causal paths in both the reasoning chain generation and answer prediction stages. By introducing the progressive CIE weighting strategy, the training process can adaptively increase the influence of high-fidelity samples, making the model optimization process more stable and significantly enhancing the reasoning robustness and causal explainability of the student model in the counterfactual scenario, that is, the weight is reduced in the early training stage to stabilize the gradient, and the weight is gradually increased in the later training stage to make the model focus more on high-fidelity samples and improve causal consistency.

[0060] To further illustrate the significant progress of the application, the following experimental verification is performed in this embodiment: ​​As shown in Table 1, the simulation experiment uses four public inference class data sets, specifically CommonsenseQA, QuaRel, QASC and ARC. Acc, CIE and LAS are used as evaluation indexes, wherein Acc is used to evaluate the overall decision performance of the model on the inference question, CIE is used to measure the causal influence intensity of the inference chain on the final answer, and LAS is used to evaluate the logical consistency between the inference chain and the model output. It can be known by comparison that the method provided by the present application has achieved significant improvement in each index (the values of the three indexes are obviously higher), which shows that the present application can effectively enhance the causal consistency and inference stability of the small language model.

[0061] Table 1 Performance comparison of the present application and prior art FC-CoT algorithm

[0062] It can be understood that the present application allows dynamic adjustment of fidelity threshold, sample weight, preference temperature, counterfactual sampling ratio and semantic redundancy reduction rules according to data size, inference task type and computing resource condition to adapt to the inference needs of different task scenarios; and the structure form, decoding mode and optimization strategy of the large model can be replaced or extended, as long as the basic idea of the present application is not changed, they should be included in the protection scope of the present application.

[0063] Embodiment two The embodiment discloses a large model thinking chain knowledge distillation system based on counterfactual reasoning.

[0064] As shown in Figure 2 , a large model thinking chain knowledge distillation system based on counterfactual reasoning comprises: A causal disturbance generation module is configured to: obtain an original inference task data set, each sample in the original inference task data set containing question text, candidate options and standard answer; by identifying key causal word units affecting answer prediction, applying minimum semantic disturbance at the corresponding position, and constructing counterfactual questions; based on the original question and the counterfactual question, a large language model is called to generate multi-perspective inference chains containing positive and negative inference chains, respectively, to build a set of paired inference chain samples with causal comparison properties as causal disturbance samples; A fidelity screening module is configured to: calculate the causal influence effect through causal intermediary analysis, and screen out causal disturbance samples with a causal influence effect higher than a preset threshold as a high-fidelity distillation data set; A thinking chain consistency optimization module is configured to: based on the high-fidelity distillation data set, perform thinking chain consistency optimization training on the large language model, and construct a joint loss function containing inference chain preference loss, positive language modeling loss, counterfactual constraint loss and causal ordering loss; The model deployment module is configured to deploy the large language model after optimization training to downstream tasks, that is, after consistency optimization is completed, the optimized thought chain large model is deployed to actual application scenarios. During deployment, model compression, quantization or parameter pruning can be performed to reduce resource occupation and improve inference efficiency; the model is served through an inference interface to realize the interpretable inference output of "question-inference chain-answer"; for multi-task scenarios, the module supports task adaptive loading and model switching mechanism, so that the system can flexibly switch the inference strategy in common sense reasoning, logical analysis, process decision and other tasks. The module can also introduce an inference chain caching mechanism to accelerate the inference process of high-frequency tasks and improve the stability and throughput of the overall service.

[0065] Further, the cause-effect disturbance generation module includes a cause-effect feature recognition submodule and a counterfactual construction submodule; wherein the cause-effect feature recognition submodule is used to locate key cause-effect words in the semantic structure, and the counterfactual construction submodule is used to perform semantic direction conversion and minimum editing disturbance to generate counterfactual questions with consistent structure and controlled cause-effect relationship.

[0066] Further, the fidelity screening module includes a semantic consistency alignment submodule for performing semantic matching and alignment on the forward and counterfactual chains to avoid surface language differences interfering with the cause-effect evaluation results, thereby ensuring the accuracy and stability of the fidelity screening.

[0067] Further, the thought chain consistency optimization module can adopt a parameter sharing structure to keep the inference chain generation and answer prediction consistent in the representation space by sharing part of the encoding layer or attention module, and build a cause-effect consistency learning mechanism of "inference-driven decision"; at the same time, an ordering preference weight strategy can be used to make high-fidelity samples obtain higher gradient contribution in the training process to improve the optimization effect.

[0068] Further, the model deployment module can support online updating, incremental distillation and cross-task fast switching, so that the optimized large language model can be dynamically upgraded or expanded with new inference capabilities under the condition of uninterrupted operation, improving the maintainability and long-term stability of the system.

[0069] Further, the model deployment module includes a cause-effect decoding and inference chain caching mechanism during model deployment: the cause-effect decoding mode is enabled to enhance the consistency of the inference chain in logical reasoning and counterfactual tasks; the cause-effect constraint is turned off to reduce the computational load in fact question and answer tasks; the inference chain results of high-frequency inputs are cached to speed up the inference.

[0070] In conclusion, the large model thinking chain knowledge distillation system based on counterfactual reasoning provided by the present application forms a complete closed loop through counterfactual disturbance construction, causal fidelity screening and thinking chain consistency optimization, has simple structure, clear logic and clear module division, and can significantly improve the causal consistency, logical stability and distribution external generalization ability of the large language model in complex reasoning tasks, so that the large model structure and reasoning ability are maintained, and higher causal explanation and reasoning reliability are obtained.

[0071] Embodiment three The purpose of this embodiment is to provide a computer-readable storage medium.

[0072] A computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the steps in the large model thinking chain knowledge distillation method based on counterfactual reasoning described in Embodiment One of the present disclosure.

[0073] Embodiment four The purpose of this embodiment is to provide an electronic device.

[0074] An electronic device comprising a memory, a processor, and a program stored on the memory and executable on the processor, wherein the processor executes the program to implement the steps in the large model thinking chain knowledge distillation method based on counterfactual reasoning described in Embodiment One of the present disclosure.

[0075] The steps and methods involved in the above embodiments two, three and four correspond to Embodiment One, and the specific implementation can be referred to the relevant description of Embodiment One. The term "computer-readable storage medium" should be understood to include a single medium or multiple media of one or more instruction sets; it should also be understood to include any medium capable of storing, encoding or carrying instruction sets for execution by a processor and causing the processor to perform any method in the present application.

[0076] Those skilled in the art should understand that each module or step of the present application described above can be realized by a general computer device, alternatively, they can be realized by program code executable by a computing device, so that they can be stored in a storage device for execution by a computing device, or they can be made into individual integrated circuit modules, or a plurality of modules or steps among them can be made into a single integrated circuit module to realize. The present application is not limited to any specific combination of hardware and software.

[0077] Although the specific embodiments of the present application are described above in combination with the drawings, it is not a limitation on the scope of protection of the present application, and those skilled in the art should understand that various modifications or changes made by those skilled in the art on the basis of the technical solutions of the present application without creative labor are still within the scope of protection of the present application.

Claims

1. A large model thinking chain knowledge distillation method based on counterfactual reasoning, characterized in that, The method comprises the following steps: Obtain an original inference task data set, each sample of which contains question text, candidate options and standard answers; By identifying key causal word units that affect answer prediction, a counterfactual question is constructed by applying minimal semantic perturbation at the corresponding position; Based on the original question and the counterfactual question, a large language model is called to generate a multi-perspective reasoning chain containing a positive reasoning chain and a negative reasoning chain, and a set of paired reasoning chain samples with causal contrast properties are constructed as causal perturbation samples; By causal intermediary analysis, the causal impact effect is calculated, and the causal perturbation samples with a causal impact effect higher than a preset threshold are selected as a high-fidelity distillation data set; Based on the high-fidelity distillation data set, the large language model is subjected to thought chain consistency optimization training, and a joint loss function containing reasoning chain preference loss, positive language modeling loss, counterfactual constraint loss and causal ordering loss is constructed; finally, the large language model after optimization training is deployed to downstream tasks.

2. The large model thinking chain knowledge distillation method based on counterfactual reasoning of claim 1, wherein, The key causal word units are identified by dependency syntax analysis and semantic role labeling methods; wherein the key causal word units include core predicates, conditional constraints and logical modification components.

3. The large model thinking chain knowledge distillation method based on counterfactual reasoning of claim 1, wherein, The counterfactual question is constructed by applying minimal semantic perturbation at the corresponding position, which includes performing minimal editing operations through a semantic replacement function according to the identified key causal word units to generate a question in counterfactual form as the counterfactual question.

4. The large model thinking chain knowledge distillation method based on counterfactual reasoning of claim 1, wherein, By introducing semantic consistency verification and logical constraint filtering, the content completeness, causal relationship clarity and logical structure correctness of the multi-perspective reasoning chain are maintained.

5. The large model thinking chain knowledge distillation method based on counterfactual reasoning of claim 1, wherein, When constructing the causal perturbation samples, the pseudo causal perturbation caused by expression differences is eliminated by calculating semantic similarity.

6. The large model thinking chain knowledge distillation method based on counterfactual reasoning of claim 1, wherein, Each sample in the high-fidelity distillation data set contains question text, candidate answer set, standard answer, positive reasoning chain, negative reasoning chain and causal impact weight.

7. The large model thinking chain knowledge distillation method based on counterfactual reasoning of claim 1, wherein, The joint loss function is represented as: ; wherein, represents a joint loss function, represents an inference chain preference loss, represents a forward language modeling loss, represents a counterfactual constraint loss, represents a causal ordering loss; represents a total number of training samples; represents a causal fidelity weight obtained by causal intermediary analysis; respectively represent balancing coefficients of the inference preference loss, the language modeling loss, the counterfactual constraint loss, and the causal ordering loss.

8. A large model thinking chain knowledge distillation system based on counterfactual reasoning, characterized in that, The method comprises the following steps: A causal perturbation generation module is configured to obtain an original inference task data set, each sample of which contains question text, candidate options and standard answers; By identifying key causal word units that affect answer prediction, a counterfactual question is constructed by applying minimal semantic perturbation at the corresponding position; based on the original question and the counterfactual question, a large language model is called to generate a multi-perspective reasoning chain containing a positive reasoning chain and a negative reasoning chain, and a set of paired reasoning chain samples with causal contrast properties are constructed as causal perturbation samples; A fidelity screening module is configured to calculate the causal impact effect through causal intermediary analysis, and select the causal perturbation samples with a causal impact effect higher than a preset threshold as a high-fidelity distillation data set; A thought chain consistency optimization module is configured to perform thought chain consistency optimization training on the large language model based on the high-fidelity distillation data set, and construct a joint loss function containing reasoning chain preference loss, positive language modeling loss, counterfactual constraint loss and causal ordering loss; A model deployment module is configured to deploy the large language model after optimization training to downstream tasks.

9. A computer-readable storage medium having stored thereon a program, characterized in that, The program, when executed by a processor, implements the steps of a method for knowledge distillation of a large model thinking chain based on counterfactual reasoning according to any one of claims 1-7.

10. An electronic device comprising a memory, a processor, and a program stored in the memory and capable of running on the processor, characterized by The program, when executed by a processor, implements the steps of a method for knowledge distillation of a large model thinking chain based on counterfactual reasoning according to any one of claims 1-7.

Citation Information

Patent Citations

  • Large language model distillation method based on thinking chain

    CN116739110A

  • Model training method and device, equipment, storage medium and product

    CN119398118A

  • Large model knowledge distillation method based on anti-fact data enhancement and multi-view thinking chain

    CN119721182A

  • Legal thinking chain data construction method and device and program product

    CN120632054A

  • Generative AI text reasoning and characterization method based on loyalty perception mechanism

    CN120996214A

Cited By

  • Thinking chain optimization method and electronic equipment

    CN121615788A

  • A thought chain optimization method and electronic device

    CN121615788B

  • Multi-modal large language model machine forgetting method based on causal orthogonal decoupling

    CN121809559A

  • Dynamic knowledge retrieval enhancement method based on large language model

    CN121960791A

  • Generative document reordering method based on retrieval enhancement generation

    CN122019766A