Method and system for enhancing causal reasoning capabilities of large models based on latent outcome framework

CN122965705APending Publication Date: 2026-10-23PEKING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611442289.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-17
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0005]鉴于上述的分析,本发明实施例旨在提供一种基于潜在结果框架增强大模型因果推理能力的方法和系统,用以解决现有大模型在文本逻辑推理时存在因果推理能力弱的问题

Benefits of technology

1、构建基于因果推断理论的大模型架构,显式分离通用推理表征与特定实例表征,解耦二者对输出结果的因果效应,提升模型的可解释性与推理透明度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122965705A_ABST
    Figure CN122965705A_ABST
Patent Text Reader

Abstract

The present application relates to a kind of method and system based on latent result framework to enhance the causal reasoning ability of large model, belong to large model technical field, solve the problem that weak causal reasoning ability exists in the text logical reasoning of large model in prior art.Large model is included in at least one layer network in method;Adapter includes general adapter and specific adapter;General adapter is used to extract invariant causal representation of input data, and specific adapter is used to extract specific instance representation of input data;Training sample set for fine-tuning training of large model is constructed;General adapter and specific adapter of large model are trained on training sample set, and during training, according to intervention instruction, generate counterfactual sample based on invariant causal representation and specific instance representation, calculate training loss based on counterfactual sample and update general adapter and specific adapter;The large model of enhanced causal reasoning ability is obtained.The causal reasoning ability of large model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of large model technology, and in particular to a method and system for enhancing the causal reasoning ability of large models based on a potential outcome framework. Background Technology

[0002] In recent years, large-scale modeling technologies, represented by ChatGPT and DeepSeek, have sparked a new wave of development in general artificial intelligence, with AI technologies integrating causal reasoning attracting widespread attention from scholars both domestically and internationally. Current research on large-scale models primarily focuses on correlation analysis, but fundamentally lacks the ability to perform counterfactual reasoning and logical checks—specifically, the ability to identify, extract, verify, and infer true causal relationships (including cause, effect, causal direction, chain mediation, interaction, and confounding variables) between events or states from natural language text. This deficiency directly leads to models' inability to deeply understand the implicit causal structures within text, resulting in frequent errors in complex semantic scenarios. Significant deficiencies exist in the modeling and understanding of causal relationships, directly limiting the model's reasoning ability in complex scenarios. Furthermore, current large-scale models primarily rely on statistical correlations in training data for decision-making, exhibiting significant limitations in causal relationship modeling and reasoning, specifically manifested in the following ways: In terms of architecture and training paradigm, existing Transformer-based architectures and training methods that predict the next token cause models to rely on correlation rather than causality when learning parameters. This leads to errors when handling text-based causal reasoning tasks that require causal understanding (such as mathematical reasoning and logical judgment), often due to confusion between general solutions and specific instance information. For example, when dealing with questions like "The doctor hired a secretary because he was highly recommended," large models may incorrectly identify "he" as the doctor rather than the secretary due to the high-frequency co-occurrence bias of "secretary" and "woman" in the training data, reflecting their insufficient grasp of the essential logic of causal relationships.

[0003] In terms of reasoning ability, the large model is overly sensitive to causal question formats. Comparing the two question formats, "Does X cause Y?" and "Is there a causality between X and Y?", the model shows a significant difference in judging the causal relationship between variables, outputting results based solely on superficial linguistic changes. In text-based logical reasoning tasks such as text question answering or text reasoning, the accuracy rate is only 62% at its highest, which is generally low, failing to accurately capture the inherent laws of causal relationships. At the same time, the model exhibits poor stability in fact generation, with significant fluctuations in error rates across different domains (such as physical common sense and social rules), and higher error rates in some domains.

[0004] In application scenarios, these limitations restrict the use of large models for textual logical reasoning in high-risk decision-making fields such as healthcare, autonomous driving, and finance. For example, AI systems in the medical field struggle to accurately identify disease causes because correlation does not equate to causation; and in complex and dynamic environments, autonomous driving systems relying on statistical correlations cannot guarantee safety and reliability. Summary of the Invention

[0005] Based on the above analysis, the embodiments of the present invention aim to provide a method and system for enhancing the causal reasoning ability of large models based on the potential outcome framework, in order to solve the problem that existing large models have weak causal reasoning ability in textual logical reasoning.

[0006] On one hand, embodiments of the present invention provide a method for enhancing the causal reasoning capabilities of large models based on a potential outcome framework, comprising the following steps: A method for enhancing the causal reasoning ability of large models based on the potential outcome framework is characterized by the following steps: An adapter is added to at least one layer of the network in the large model; the adapter includes a general adapter and a specific adapter; the general adapter is used to extract invariant causal representations of the input data, and the specific adapter is used to extract specific instance representations of the input data; Construct a training sample set for fine-tuning training of a large model; The general adapter and specific adapter of the large model are trained on the training sample set. During the training process, counterfactual samples are generated based on the invariant causal representation and specific instance representation according to the intervention instructions. The training loss is calculated based on the counterfactual samples to update the general adapter and specific adapter, thereby obtaining a large model with enhanced causal reasoning ability.

[0007] Based on further improvements to the above method, the intervention instruction includes intervention types; the intervention types include instance-based interventions and general interventions; the training sample set includes samples of various task types; Counterfactual samples are generated based on the intervention instructions in the following manner: If the intervention type is instance intervention, then an intervention sample pair is constructed based on real samples of the same task type in the current training batch, and counterfactual samples are generated based on the intervention sample pair; If the intervention type is a general intervention, then intervention sample pairs are constructed based on real samples of different task types in the current training batch, and counterfactual samples are generated based on the intervention sample pairs.

[0008] Based on the above method, a further improvement is made to the method of generating counterfactual samples from intervention samples, using the following approach: By taking the invariant causal representation of one sample and the specific instance representation of the other sample from the intervention sample pair, a feature representation of a counterfactual sample is obtained.

[0009] Based on the further improvement of the above method, the training loss is calculated using the following formula: ; in, This indicates the loss from fine-tuning the task. Indicates instance intervention loss, Indicates general intervention loss, and This represents the weighting parameter.

[0010] Based on the further improvement of the above method, the instance intervention loss is calculated using the following formula:

[0011] in, This represents the set of instance intervention sample pairs in the current training batch. express The number of intervention sample pairs in the middle instance express Instance intervention sample pairs, This represents the sigmoid function. Represents the similarity function. This represents the feature representation of the samples extracted by the large model. Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, real sample and real samples These are samples of the same task type.

[0012] Based on further improvements to the above method, the general intervention loss is calculated using the following formula: ; in, This represents the set of general intervention sample pairs in the current training batch. express The number of general intervention sample pairs in China express Universal intervention sample pairs, This represents the sigmoid function. Represents the similarity function. This represents the feature representation of the samples extracted by the large model. Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, real sample and real samples Samples for different task types.

[0013] Based on a further improvement to the above method, the training loss also includes cross-environment invariant loss, which is calculated using the following formula:

[0014] Where M represents the number of training environments in the current training batch. This represents the set of training environments for the current training batch. Indicates the training environment Experience, task, and risk This represents the average risk of the experience task across all training environments in the current training batch.

[0015] Based on a further improvement to the above method, the training loss also includes mutual information loss, which is calculated using the following formula:

[0016]

[0017]

[0018] in, This represents the set of real samples in the current training batch. express The number of samples in the middle This represents the output of the large model for the i-th real sample. This represents the invariant causal representation of the i-th sample. This represents the output of the large model for the j-th real sample. This represents the invariant causal representation of the j-th sample. express Embedded representation, express Embedded representation, Indicates the temperature coefficient. Represents the similarity function. and This represents intermediate parameters.

[0019] Based on a further improvement to the above method, the training loss also includes an orthogonal constraint loss, which is calculated using the following formula:

[0020] in, Indicates the first The dimensionality-reduced low-rank matrix of the general adapter for the layer. Indicates the first The dimensionality-reduced low-rank matrix of the specific adapter of the layer. Indicates the first The upgraded low-rank matrix of the general adapter for the layer. Indicates the first The up-dimensional low-rank matrix of a specific adapter in a layer. Indicates the first Features of the layer's generic adapter output, Indicates the first The characteristics output by a specific adapter in a layer, where L represents the number of layers with adapters added to the large model. The superscript represents the F-norm of a matrix. This indicates transpose.

[0021] On the other hand, embodiments of the present invention provide a system for enhancing the causal reasoning capabilities of large models based on a potential outcome framework, comprising: A model building module is used to add adapters to at least one layer of a large model network; the adapters include a general adapter and a specific adapter; the general adapter is used to extract invariant causal representations of the input data, and the specific adapter is used to extract specific instance representations of the input data; The sample set construction module is used to build a training sample set for fine-tuning training of large models; The training module is used to train the general adapter and specific adapter of the large model on the training sample set. During the training process, counterfactual samples are generated based on the invariant causal representation and specific instance representation according to the intervention instructions. The training loss is calculated based on the counterfactual samples to update the general adapter and specific adapter, thereby obtaining a large model with enhanced causal reasoning ability.

[0022] Compared with the prior art, the present invention has at least one of the following beneficial effects: 1. Construct a large-scale model architecture based on causal inference theory, explicitly separate general reasoning representations from specific instance representations, decouple the causal effects of the two on the output results, and improve the interpretability and reasoning transparency of the model.

[0023] 2. Design causal intervention mechanisms and counterfactual loss functions to quantify the independent causal effects of general and specific representations on the output, promote the transformation of the model from relying on statistical correlation to mastering causal logic, and improve causal reasoning ability.

[0024] 3. By using cross-environment invariant loss, the general adapter is enabled to capture task-related factors that are stable across environments, reducing the model's dependence on biases specific to a single task type or data source.

[0025] 4. By using mutual information loss, we ensure that the invariant causal representation is task-relevant and avoid it from degenerating into an invalid representation under excessive invariance constraints.

[0026] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from the description and drawings, which are particularly pointed out. Attached Figure Description

[0027] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. Figure 1 This is a flowchart illustrating a method for enhancing the causal reasoning capability of large models based on a potential outcome framework, as described in an embodiment of the present invention. Figure 2 This is a block diagram of a system for enhancing the causal reasoning capabilities of large models based on a potential outcome framework, according to an embodiment of the present invention. Detailed Implementation

[0028] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.

[0029] One specific embodiment of the present invention discloses a method for enhancing the causal reasoning capabilities of large models based on a potential outcome framework, such as... Figure 1 As shown, it includes the following steps: S1. Add adapters to at least one layer of the large model network; the adapters include general adapters and specific adapters; the general adapter is used to extract invariant causal representations of the input data, and the specific adapter is used to extract specific instance representations of the input data; S2. Construct a training sample set for fine-tuning the large model; S3. Train the general adapter and specific adapter of the large model on the training sample set. During the training process, generate counterfactual samples based on invariant causal representation and specific instance representation according to the intervention instructions. Calculate the training loss based on the counterfactual samples and update the general adapter and specific adapter; thus obtaining a large model with enhanced causal reasoning ability.

[0030] This invention uses causal invariance learning constraints to enable the model to learn general knowledge representations that remain stable in the face of instance changes, and separates variable instance information, thereby improving the model's generalization ability and interpretability in text reasoning tasks.

[0031] It should be noted that adapter-based fine-tuning is one of the methods for fine-tuning large models. Its goal is to enable the large model to adapt to new tasks while preserving the original parameters of the pre-trained large model. This is achieved by inserting small neural modules, called "adapters," between each or selected layers of the model. These adapters are trainable, while the parameters of the original large model remain unchanged.

[0032] Compared with existing technologies, the method for enhancing the causal reasoning ability of large models based on the potential outcome framework provided in this embodiment adds a general adapter and a specific adapter to the large model for extracting invariant causal representations and specific instance representations. This separates the model's general problem-solving ability and specific instance features based on the causal framework, decouples the causal effects of the two on the output, improves the interpretability and reasoning transparency of the model, and generates counterfactual samples through intervention. The large model is then fine-tuned (i.e., the adapter is trained) on the training sample set to quantify the independent causal effects of general and specific representations on the output. This promotes the transformation of the model from relying on statistical correlations to mastering causal logic, thereby enhancing the causal reasoning ability.

[0033] In text-based question answering or text-based reasoning tasks, different samples may share the same general knowledge or reasoning rules, but have different entity names, quantities, times, locations, or conditions. Existing large models often encode general knowledge and instance details together in the same hidden layer representation, which allows the model to fit the question pattern within the training distribution, but it is easily affected by surface word relevance when instance conditions are replaced, question expression changes, or cross-domain transfer occurs.

[0034] More specifically, this invention addresses the problem of the mixture of general knowledge and instance knowledge in the hidden space of large language models during text input scenarios. For the same type of text task, the model should represent inference rules, conceptual relationships, algorithmic steps, or task structures that can be reused across samples as invariant causal representations. It represents concrete entities, values, object attributes, context conditions, etc., as mutable instance representations. And by using representation replacement intervention, the two can form decoupled representations during the training process.

[0035] For example, the math word problem text is: "Jimmy has 3 apples, and Tom gives Jimmy 2 more apples. How many apples does Jimmy have now?". In this text, the general knowledge is the rule that "giving someone some items increases the amount they possess, and the new quantity is calculated by addition," a rule that can be reused across samples. This rule is derived from... The specific people, items, and quantities indicated by "Jimmy," "Tom," "Apple," "3," and "2" are provided by [the relevant authority / organization]. This means that if the sample is changed to "Lily has 5 books, and Lucy gave Lily 4 more books," Changes but The model should remain stable, therefore the same addition rule should be transferred.

[0036] For example, a comparison-based text might ask: "Product A costs 20 yuan, and product B costs 35 yuan. Which product is more expensive?" This represents the general task knowledge of "comparing the numerical properties of two objects and selecting the larger one". This represents instance knowledge such as "product A, product B, 20 yuan, 35 yuan," etc. If the product name or specific value is changed, the model should primarily be updated. If the question is changed to "Which product is cheaper?", the general direction of comparison changes, and this should primarily be reflected in... In the task rules. In this invention, the input prompt word is denoted as The hidden representation formed by the input prompt words in the large language model is denoted as... Hidden layer representation Decomposed into and Two parts, of which It represents invariant causal representations, used to represent information that is independent of specific instances, such as logical rules, algorithm steps, problem types, and task structures. This represents a specific instance representation, used to carry information that varies with the sample, such as specific numerical values, text parameters, sample conditions, and instance details. The knowledge representation of model activation is denoted as... Its main influence Impact; model output is denoted as , its origin and Joint decision. According to the potential outcome framework, when and When the timing is set, the corresponding potential output is denoted as... For example, given the input prompt "1+1=?", This is the model representation of the prompt word. Corresponding to the general rule of "addition", For instances where both addends are "1", The corresponding addition-related knowledge activated in the model, The answer given by the corresponding model. By changing them respectively. or And observe Changes in this can quantify the independent causal effects of invariant causal components and instance details on the model output. In existing large-scale model architectures, this has not been addressed. and No decoupling is performed, so the influence of the two on the output is always coupled, causing the model to make incorrect associations, confusing general logic with instance details, and thus giving incorrect answers.

[0037] In implementation, a high-level network of L layers is used for the large model. Adapters are added to the Transformer attention layer or feedforward layer of each layer, including general adapters and specific adapters. The adapters can adopt existing adapter network structures, such as Low-Rank Adaptation of Large Language Models (LoRA). The general adapter of the layer receives the current layer's hidden state. Output the invariant causal representation of this layer The specific adapter receives the current layer's hidden state. Output the specific instance representation of this layer For the first The layer, whose final output features are the invariant causal representations of that layer. and the specific instance representation of this layer The features obtained after concatenation and linear mapping are used as input features for the next layer.

[0038] During implementation, use and These represent all invariant causal representations and specific instance representations of the sample at layer L, respectively.

[0039] In implementation, a training sample set is constructed for fine-tuning the large model. This set is built by collecting samples from various task types from different sources. Each sample is labeled with its data source and task type. (Data source identification is also included.) The data source used to characterize the samples can be determined based on the dataset name. Task type identifier. Used to characterize the task category to which a sample belongs, such as addition task or multiplication task.

[0040] The general adapter and specific adapters of the large model are trained based on the constructed training sample set.

[0041] To quantify the effects of causal intervention, it is necessary to conduct causal intervention on the samples and generate counterfactual samples to quantify the causal effect.

[0042] During implementation, counterfactual samples are generated based on the invariant causal representation and specific instance representation according to the intervention instructions during the training process. For example, in some training batches, counterfactual samples are generated based on the intervention instructions.

[0043] Specifically, intervention instructions include intervention types, which include instance-based interventions and general interventions.

[0044] General interventions are used to measure the causal effect of invariant causal representations on model outputs, while instance interventions are used to measure the causal effect of specific instance representations on model outputs.

[0045] Specifically, counterfactual samples are generated according to the intervention instructions in the following manner: If the intervention type is instance intervention, then an intervention sample pair is constructed based on real samples of the same task type in the current training batch, and counterfactual samples are generated based on the intervention sample pair; If the intervention type is a general intervention, then intervention sample pairs are constructed based on real samples of different task types in the current training batch, and counterfactual samples are generated based on the intervention sample pairs.

[0046] The causal effect of specific instance representations among tasks of the same type is greater than the causal effect of invariant causal representations. Therefore, if several pre-type instances are intervened, counterfactual samples are generated based on real samples of the same task type in the current training batch.

[0047] The causal effect of instance features across different task types is smaller than the causal effect of invariant causal representations. Therefore, if several pre-typed general interventions are used, counterfactual samples are generated based on real samples of different task types in the current training batch.

[0048] During implementation, if several pre-type interventions are instance-based, then real samples of the same task type are selected from the current batch of training samples to form intervention sample pairs. If the intervention type is a general intervention, then real samples of different task types are selected from the current batch of training samples to form intervention sample pairs.

[0049] Counterfactual samples are generated based on intervention samples using the following method: By taking the invariant causal representation of one sample and the instance-specific representation of the other sample from the intervention sample pair, a feature representation of a counterfactual sample is obtained.

[0050] For example, intervention sample pairs ,sample Original feature representation The corresponding invariant causal characterization is Specific instances are characterized as , in the The invariant causal representation of the layer is expressed as Specific instances are characterized as .sample Original feature representation The corresponding invariant causal characterization is Specific instances are characterized as , in the The invariant causal representation of the layer is expressed as Specific instances are characterized as .

[0051] In practice, the invariant causal representation of one sample in the intervention sample pair and the specific instance representation of the other sample are taken to obtain the feature representation of a counterfactual sample. For example... Indicates a counterfactual sample, This represents another counterfactual sample.

[0052] During implementation, for the first Layer, take samples In the Layer invariant causal representation and samples In the Specific instance representation of a layer As a counterfactual sample The counterfactual sample obtained by concatenating the invariant causal representation and the specific instance representation at this layer and performing a linear mapping, as described above. The features extracted at this layer are used as input features for the next layer. The counterfactual samples extracted before the output layer of the large model... The features are represented as The final counterfactual samples output by the large model The prediction result is represented as Y .

[0053] Similarly, take samples In the Layer invariant causal representation and samples In the Specific instance representation of a layer As a counterfactual sample The counterfactual sample obtained by concatenating the invariant causal representation and the specific instance representation at this layer and then applying a linear mapping is... The features extracted at this layer are used as input features for the next layer. The counterfactual samples extracted before the output layer of the large model... The features are represented as The final counterfactual samples output by the large model The prediction result is represented as Y .

[0054] When implementing interventions, the instructions may also include a quantity. For example, if the intervention type is instance intervention and the quantity is 100, then 100 pairs of intervention samples will be selected from the current batch of training samples to form real samples of the same task type.

[0055] It should be noted that the large model with adapters is trained on the constructed training sample set. During training, the original parameters of the large model remain unchanged, while the parameters of each adapter are updated.

[0056] Specifically, the training loss is calculated based on counterfactual samples to update the general adapter and the specific adapter. When the loss function converges, training is stopped, resulting in a large model with enhanced causal reasoning capabilities.

[0057] Specifically, the training loss is calculated using the following formula: ; in, This indicates the loss from fine-tuning the task. Indicates instance intervention loss, Indicates general intervention loss, and This represents the weighting parameter.

[0058] In practice, the fine-tuning task loss can be achieved using commonly used supervised fine-tuning loss methods, such as the cross-entropy loss function, which calculates the loss between the label of each real sample in the current batch and the prediction result of the large model, and then averages the results to obtain the fine-tuning task loss for the current training batch.

[0059] During implementation, , , where is the weight hyperparameter.

[0060] By minimizing the joint loss, the model will learn to explicitly separate general inference logic from instance details at the adapter level while completing downstream fine-tuning tasks, thus achieving interpretable separation of causal effects and transparent modeling of the inference process.

[0061] Specifically, the instance intervention loss is calculated using the following formula: ; in, This represents the set of instance intervention sample pairs in the current training batch. express The number of intervention sample pairs in the middle instance express Instance intervention sample pairs, This represents the feature representation of the samples extracted by the large model. Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, real sample and real samples These are samples of the same task type. This represents the sigmoid function. The similarity function is used as a measure of semantic difference in the output; this invention uses cosine similarity as an example. The feature representation of the samples extracted by the large model is the feature obtained before the output layer of the large model.

[0062] Instance intervention loss The causal effect of instance features across similar tasks is greater than the causal effect of invariant causal representations. For example, consider two instance samples of the same task. (enter Output )and (enter Output Extract the invariant causal representation of the adapter outputs of both. , and the corresponding specific instance representation , If the adapter learns the decoupling characteristics, it should have Therefore, counterfactual samples can be generated by replacing invariant causal representations or specific instance representations. and ).

[0063] Instance intervention loss causes the model to produce instance-level output differences when general logic remains unchanged but instance conditions change, such as changes in numerical answers. It also helps maintain similar invariant causal representations between tasks of the same type, during replacement... When answering, avoid unnecessary changes in the structure of your response.

[0064] Specifically, the general intervention loss is calculated using the following formula: ; in, This represents the sigmoid function. Represents the similarity function. This represents the feature representation of the samples extracted by the large model. Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, real sample and real samples Samples for different task types and This is a counterfactual sample. This represents the set of general intervention sample pairs in the current training batch. express The number of general intervention sample pairs in China express A general intervention sample pair.

[0065] General intervention loss The causal effect of instance features across different task types is smaller than the causal effect of invariant causal representations. For example, consider two instance samples from different task types. (enter Output )and (enter Output Extracting the invariant causal representations of both. , and the corresponding specific instance representation , If the adapter learns the decoupling characteristics, it should have Therefore, counterfactual samples can be generated by replacing the invariant causal representation and the instance-specific representation. and .

[0066] The general intervention loss prompts the model to change its response logic, reasoning steps, or grammatical structure when the invariant causal components change, while it mainly changes local numerical values, entity or conditional content when only instance information changes.

[0067] Based on the above training loss, the large model is fine-tuned to obtain a large model with enhanced causal reasoning ability.

[0068] In implementation, the model may preferentially utilize error correlations specific to a particular task type or data source to ensure invariant causal representation. The predictive contributions vary across different environments. To enable the universal adapter to capture task-related factors that are stable across environments, this invention incorporates a cross-environment invariant loss into the training loss. It should be noted that the cross-environment invariant loss is calculated on real samples.

[0069] During implementation, for the real samples of the current training batch, samples with the same data source and the same task type are grouped into the same training environment according to their data source identifier and task type identifier, thereby dividing the real samples of the current training batch into M training environments.

[0070] Specifically, the cross-environment invariant loss is calculated using the following formula:

[0071] Where M represents the number of training environments in the current training batch. This represents the set of training environments for the current training batch. Indicates the training environment Experience, task, and risk This represents the average risk of the experience task across all training environments in the current training batch. (·) indicates variance.

[0072] Among them, the current training batch belongs to the training environment The average fine-tuning task loss for all samples is the training environment. Experience, task, and risk.

[0073] Cross-environment invariant loss achieves invariant learning by suppressing the variance of task risk across different environments, thereby reducing the model's dependence on biases specific to a single task type or data source and preserving the stable task-related effects of causal representations.

[0074] In practice, the training loss function with cross-environment invariant loss is: .

[0075] in, Both represent weight parameters.

[0076] To ensure that the invariant causal representation remains task-relevant and to prevent it from degenerating into an invalid representation when the invariant learning constraints are too strong, mutual information loss is added to the training loss as a supplement to cross-environment invariant constraints.

[0077] Specifically, the mutual information loss is represented as follows:

[0078] in, This represents the mutual information between the invariant causal representation and the task output.

[0079] In actual training, InfoNCE can be used for approximate optimization, which maximizes the mutual information between the invariant causal representation and the correct task output by minimizing InfoNCE.

[0080] Among them, intermediate parameters , , express Embedded representation, express Embedded representation, Indicates the temperature coefficient. . This represents the similarity function. This represents the set of real samples in the current training batch. express The number of samples in the middle This represents the output of the large model for the i-th real sample. This represents the invariant causal representation of the i-th sample. This represents the output of the large model for the j-th real sample. This represents the invariant causal representation of the j-th sample.

[0081] During implementation, the large model will output the results. The corresponding embedding representation is obtained by encoding with an existing text encoder or a large model.

[0082] In practice, the training loss function incorporating mutual information loss is: .

[0083] in, Both represent weight parameters.

[0084] To avoid representation aliasing between the general adapter and the specific adapter, an orthogonal constraint loss is added to the training loss. Specifically, the orthogonal constraint loss is calculated using the following formula:

[0085] in, Indicates the first The dimensionality-reduced low-rank matrix of the general adapter for the layer. Indicates the first The dimensionality-reduced low-rank matrix of the specific adapter of the layer. Indicates the first The upgraded low-rank matrix of the general adapter for the layer. Indicates the first The up-dimensional low-rank matrix of a specific adapter in a layer. Indicates the first Features of the layer's generic adapter output, Indicates the first The characteristics output by a specific adapter in a layer, where L represents the number of layers with adapters added to the large model. The superscript represents the F-norm of a matrix. This indicates transpose.

[0086] In the orthogonal constraint loss, the first two terms constrain the orthogonality of the low-rank matrix column spaces of the two adapters, and the last term constrains the decoupling of the invariant causal representation and the variable instance representation.

[0087] In an optional implementation, the LoRA incremental parameters can be further constrained to remain orthogonal or decorrelated to the principal direction of the frozen pre-trained parameters in order to reduce redundant perturbations of the original pre-trained representations by incremental fine-tuning.

[0088] In practice, the training loss function with orthogonal constraint loss is: .

[0089] in, This represents the weighting parameter.

[0090] During implementation, cross-environment invariance loss, mutual information loss, and orthogonal constraint loss can also be added simultaneously: .

[0091] in, This represents the weighting parameter.

[0092] During implementation, the weighting coefficients can be set according to the importance of each weight, and the values ​​can be positive.

[0093] This invention introduces two types of low-rank adapter channels within a large language model: a general adapter and a specific adapter. These channels are used to carry task-related invariant causal components and instance-related variable components, respectively. This invention distinguishes the sources of output variation at the intermediate representation level of the model, determining whether the model's prediction results are primarily influenced by stable task logic or by sample conditions, data bias, or error-related factors, thereby improving the interpretability of the large language model's reasoning process.

[0094] This invention employs cross-environment training based on observable data partitioning, representation replacement intervention, counterfactual intervention loss, cross-environment risk variance invariant learning regularization, orthogonal constraints, and mutual information regularization. This enables the model to go beyond simply learning the statistical correlation between input terms and answers; it further learns stable, task-related representations across environments and the causal effects of different internal representations on the output. Consequently, the model can better distinguish between stable inference rules and variable instance factors, achieving more stable output results in scenarios such as complex reasoning, counterfactual prediction, distribution changes, and few-sample task transfer, reducing the risk of illusions or logical inconsistencies caused by erroneous correlations and data bias.

[0095] One specific embodiment of the present invention discloses a system for enhancing the causal reasoning capabilities of large models based on a potential outcome framework, such as... Figure 2 As shown, it includes: A model building module is used to add adapters to at least one layer of a large model network; the adapters include a general adapter and a specific adapter; the general adapter is used to extract invariant causal representations of the input data, and the specific adapter is used to extract specific instance representations of the input data; The sample set construction module is used to build a training sample set for fine-tuning training of large models; The training module trains the general adapter and specific adapter of the large model on the training sample set. During the training process, counterfactual samples are generated based on the invariant causal representation and specific instance representation according to the intervention instructions. The training loss is calculated based on the counterfactual samples to update the general adapter and specific adapter, thereby obtaining a large model with enhanced causal reasoning ability.

[0096] The above-described method and system embodiments are based on the same principles, and their related aspects can be referenced from each other to achieve the same technical effects. For specific implementation processes, please refer to the foregoing embodiments, which will not be repeated here.

[0097] Electronic device example: One specific embodiment of this application discloses an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method in the method embodiment for enhancing the causal reasoning capability of a large model based on a potential outcome framework.

[0098] Examples of readable storage media: One specific embodiment of this application discloses a non-transitory computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method in the method embodiment for enhancing the causal reasoning capability of large models based on a potential outcome framework.

[0099] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.

[0100] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for enhancing the causal reasoning ability of large models based on a potential outcome framework, characterized in that, Includes the following steps: Add an adapter to at least one layer of the network in the large model; The adapter includes a general adapter and a specific adapter; the general adapter is used to extract invariant causal representations of the input data, and the specific adapter is used to extract specific instance representations of the input data. Construct a training sample set for fine-tuning training of a large model; The general adapter and specific adapter of the large model are trained on the training sample set. During the training process, counterfactual samples are generated based on the invariant causal representation and specific instance representation according to the intervention instructions. The training loss is calculated based on the counterfactual samples to update the general adapter and specific adapter. A large model was obtained that enhances the ability of causal reasoning.

2. The method for enhancing the causal reasoning ability of large models based on the potential outcome framework according to claim 1, characterized in that, The intervention instructions include intervention types; the intervention types include instance-based interventions and general interventions; the training sample set includes samples of various task types; Counterfactual samples are generated based on the intervention instructions using the following methods: If the intervention type is instance intervention, then an intervention sample pair is constructed based on real samples of the same task type in the current training batch, and counterfactual samples are generated based on the intervention sample pair; If the intervention type is a general intervention, then intervention sample pairs are constructed based on real samples of different task types in the current training batch, and counterfactual samples are generated based on the intervention sample pairs.

3. The method for enhancing the causal reasoning ability of large models based on the potential outcome framework according to claim 2, characterized in that, Counterfactual samples are generated based on intervention samples using the following method: By taking the invariant causal representation of one sample and the specific instance representation of the other sample from the intervention sample pair, a feature representation of a counterfactual sample is obtained.

4. The method for enhancing the causal reasoning ability of large models based on the potential outcome framework according to claim 1, characterized in that, The training loss is calculated using the following formula: ; in, This indicates the loss from fine-tuning the task. Indicates instance intervention loss, Indicates general intervention loss, and This represents the weighting parameter.

5. The method for enhancing the causal reasoning ability of large models based on the potential outcome framework according to claim 4, characterized in that, The instance intervention loss is calculated using the following formula: in, This represents the set of instance intervention sample pairs in the current training batch. express The number of intervention sample pairs in the middle instance express Instance intervention sample pairs, This represents the sigmoid function. Represents the similarity function. This represents the feature representation of the samples extracted by the large model. Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, real sample and real samples These are samples of the same task type.

6. The method for enhancing the causal reasoning ability of large models based on the potential outcome framework according to claim 4, characterized in that, The general intervention loss is calculated using the following formula: ; in, This represents the set of general intervention sample pairs in the current training batch. express The number of general intervention sample pairs in China express Universal intervention sample pairs, This represents the sigmoid function. Represents the similarity function. This represents the feature representation of the samples extracted by the large model. Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, Represents real samples The invariant causal characterization, Represents real samples Specific instance representation, real sample and real samples Samples for different task types.

7. The method for enhancing the causal reasoning ability of large models based on the potential outcome framework according to claim 5, characterized in that, The training loss also includes environment-invariant loss, which is calculated using the following formula: Where M represents the number of training environments in the current training batch. This represents the set of training environments for the current training batch. Indicates the training environment Experience, task, and risk This represents the average risk of the experience task across all training environments in the current training batch.

8. The method for enhancing the causal reasoning ability of large models based on the potential outcome framework according to claim 7, characterized in that, The training loss also includes mutual information loss, which is calculated using the following formula: in, This represents the set of real samples in the current training batch. express The number of samples in the middle This represents the output of the large model for the i-th real sample. This represents the invariant causal representation of the i-th sample. This represents the output of the large model for the j-th real sample. This represents the invariant causal representation of the j-th sample. express Embedded representation, express Embedded representation, Indicates the temperature coefficient. Represents the similarity function. and This represents intermediate parameters.

9. The method for enhancing the causal reasoning ability of large models based on the potential outcome framework according to claim 5, characterized in that, The training loss also includes orthogonal constraint loss, which is calculated using the following formula: in, Indicates the first The dimensionality-reduced low-rank matrix of the general adapter for the layer. Indicates the first The dimensionality-reduced low-rank matrix of the specific adapter of the layer. Indicates the first The upgraded low-rank matrix of the general adapter for the layer. Indicates the first The up-dimensional low-rank matrix of a specific adapter in a layer. Indicates the first Features of the layer's generic adapter output, Indicates the first The characteristics output by a specific adapter in a layer, where L represents the number of layers with adapters added to the large model. The superscript represents the F-norm of a matrix. This indicates transpose.

10. A system for enhancing the causal reasoning ability of large models based on a potential outcome framework, characterized in that, include: The model building module is used to add adapters to at least one layer of a large model's network; The adapters include general-purpose adapters and specific adapters; The general adapter is used to extract invariant causal representations of the input data, and the specific adapter is used to extract specific instance representations of the input data. The sample set construction module is used to build a training sample set for fine-tuning training of large models; The training module is used to train the general adapter and specific adapter of the large model on the training sample set. During the training process, counterfactual samples are generated based on the invariant causal representation and specific instance representation according to the intervention instructions. The training loss is calculated based on the counterfactual samples to update the general adapter and specific adapter. A large model was obtained that enhances the ability of causal reasoning.