Causal-based model double checking method, system, device, and storage medium

By generating counterfactual samples and evaluating their consistency with factual samples, and combining the consistency results to check and correct the model's prediction results, the problem of the model's performance plummeting on difficult samples is solved, thereby enhancing the model's robustness and decision credibility.

CN115700546BActive Publication Date: 2026-07-10UNIV OF SCI & TECH OF CHINA

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
UNIV OF SCI & TECH OF CHINA
Filing Date
2022-09-19
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing models suffer from a sharp drop in performance when dealing with difficult samples and lack the ability to check and correct their own decision results, leading to unreliable predictions.

Method used

By generating counterfactual samples and evaluating their consistency with factual samples, the model prediction results are checked and corrected based on the consistency results, including the counterfactual generation model, the consistency evaluation model, and the modified model.

Benefits of technology

It improves the model's ability to handle difficult samples, enhances the reliability of the model's decision results, and is effective for various classification models, exhibiting stronger robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115700546B_ABST
    Figure CN115700546B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on cause and effect's model double-checking method, system, equipment and storage medium, whether the model inference result (classification prediction result) can be accurately evaluated reliable, simultaneously, when identifying inference result unreliable, can effectively modify the inference result of model in combination with the consistency result evaluated, the present application is effective for various classification models, and the robustness to interference is stronger.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of machine learning and causal reasoning, and in particular to a causal-based model double-checking method, system, device, and storage medium. Background Technology

[0002] Deep learning has developed rapidly in the past decade, and neural network models have been widely used in scenarios such as vision, natural language processing, and recommender systems. In existing applications, models are usually trained online and then directly deployed in offline testing scenarios. At this time, the models often process various types of data indiscriminately, but their inference results for hard samples are often unreliable. In order to solve the problem of performance slump on hard samples caused by the overly simplistic one-pass inference process of models (i.e., only one forward propagation for each data point), existing research has explored from the perspectives of model post-processing techniques and causal inference.

[0003] Post-processing is typically based on heuristic strategies. Some studies utilize ensemble learning to integrate predictions from multiple models, but hard samples often result in low confidence levels for most model predictions, ultimately leading to unsatisfactory ensemble performance. Other studies employ domain-specific knowledge to design rules for checking model predictions on specific problems, but these methods are often difficult to transfer to other scenarios.

[0004] To enable models to better handle difficult samples, research on improving training data or training schemes from a causal perspective has recently received considerable attention. Some studies, starting from the data perspective, argue that the model's performance degradation is due to its failure to make predictions based on causally stable features in the data. Therefore, they generate counterfactual samples by modifying the causal features of the training samples and use them for training. Other studies not only generate counterfactual samples but also consider using them to modify the training scheme. However, these methods do not endow the model with the ability to reflect on its own decision-making outcomes. Therefore, how to enable the model to learn to check and correct its own decision-making outcomes (double checking) is a pressing technical problem that needs to be solved. Summary of the Invention

[0005] The purpose of this invention is to provide a causal-based model double-checking method, system, device, and storage medium that has the ability to reflect on and correct the reasoning results.

[0006] The objective of this invention is achieved through the following technical solution:

[0007] A causal-based model double-checking method includes:

[0008] By using the input samples as fact samples and intervening in the mediating variables during the fact sample generation process, counterfactual samples for each category are generated.

[0009] The classification model is used to obtain the classification prediction results of the fact samples, evaluate the consistency between the fact samples and the counterfactual samples of each category, and check whether the classification prediction results of the classification model are reliable by combining the classification prediction results with the consistency results obtained from the evaluation; wherein, the classification model includes an image classification model and a text classification model, the input sample for the image classification model is an input image, and the input sample for the text classification model is an input text;

[0010] When the classification prediction results of the classification model are unreliable, the classification prediction results are modified based on the consistency between the fact samples and the counterfactual samples of each category.

[0011] A causal-based model-based double-checking system includes:

[0012] The counterfact generation model takes the input sample as the fact sample and generates counterfact samples for each category by intervening in the mediating variables in the fact sample generation process.

[0013] A consistency evaluation model is used to obtain the classification prediction results of the classification model for factual samples, evaluate the consistency between the factual samples and the counterfactual samples of each category, and check whether the classification prediction results of the classification model are reliable by combining the classification prediction results with the consistency results obtained from the evaluation. The classification model includes an image classification model and a text classification model. For the image classification model, the input sample is an input image, and for the text classification model, the input sample is an input text.

[0014] Modify the model: when the classification prediction results of the classification model are unreliable, modify the classification prediction results based on the consistency between the fact samples and the counterfactual samples of each category.

[0015] A processing device includes: one or more processors; and a memory for storing one or more programs;

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the aforementioned method.

[0017] A readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned method.

[0018] As can be seen from the technical solution provided by the present invention, it can accurately evaluate whether the model inference results (classification prediction results) are reliable. At the same time, when the inference results are deemed unreliable, the model inference results can be effectively corrected by combining the evaluated consistency results. The present invention is effective for various classification models and has stronger robustness to interference. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A flowchart of a causal-based model double-checking method provided for embodiments of the present invention;

[0021] Figure 2 A schematic diagram illustrating the principle of the cause-effect graph generated from data provided in an embodiment of the present invention;

[0022] Figure 3 A framework diagram of a causal-based model double-checking method provided in an embodiment of the present invention;

[0023] Figure 4 A schematic diagram illustrating the experimental results provided in the embodiments of the present invention;

[0024] Figure 5 A schematic diagram of a causal-based model dual-check system provided for an embodiment of the present invention;

[0025] Figure 6 This is a schematic diagram of a processing device provided in an embodiment of the present invention. Detailed Implementation

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

[0027] First, the following explanations are provided for the terms that may be used in this article:

[0028] The term "and / or" means that either or both can be achieved simultaneously. For example, X and / or Y means that it includes both "X" or "Y" as well as the three cases of "X and Y".

[0029] The terms “including,” “comprising,” “containing,” “having,” or other similar semantic descriptions should be interpreted as non-exclusive inclusion. For example, “including a technical feature element (such as raw material, component, ingredient, carrier, dosage form, material, size, part, component, mechanism, device, step, process, method, reaction conditions, processing conditions, parameter, algorithm, signal, data, product or article of manufacture, etc.)” should be interpreted as including not only the expressly listed technical feature element, but also other technical feature elements that are not expressly listed and are well-known in the art.

[0030] The following is a detailed description of a causal-based model dual-check scheme provided by the present invention. Contents not described in detail in the embodiments of the present invention are prior art known to those skilled in the art. Where specific conditions are not specified in the embodiments of the present invention, they should be performed according to conventional conditions in the art or conditions recommended by the manufacturer.

[0031] Example 1

[0032] This invention provides a causal-based model double-checking method, such as... Figure 1 As shown, the main steps include the following:

[0033] Step 1: Using the input sample as the fact sample, generate counterfactual samples for each category by intervening in the mediating variables during the fact sample generation process.

[0034] In this embodiment of the invention, the main concern is the assumption in the causal graph of a specific task, namely, that there are at least two mediating variables, and counterfactual samples can be generated by intervening in one of the mediating variables.

[0035] Step 2: Obtain the classification prediction results of the classification model for the fact samples, evaluate the consistency between the fact samples and the counterfactual samples of each category, and check whether the classification prediction results of the classification model are reliable by combining the classification prediction results with the consistency results obtained from the evaluation.

[0036] In this embodiment of the invention, the classification model can be an image classification model or a text classification model; correspondingly, depending on the classification model, the input sample is an image or text.

[0037] In this embodiment of the invention, both the image classification model and the text classification model can be various existing models, which obtain classification prediction results through reasoning. For the image classification model, the output classification prediction result is the category of the target in the image; for the text classification model, the classification prediction result also varies depending on the text classification task. For example, in the sentiment analysis task of text classification, the classification prediction result is the sentiment category of the text.

[0038] Step 3: When the classification prediction results of the classification model are unreliable, modify the classification prediction results based on the consistency between the fact samples and the counterfactual samples of each category.

[0039] The above-described scheme in this invention is effective for various classification models. For example, it can be applied to various image recognition systems (such as a shopping platform). Based on the original image recognition model, the dual-checking method proposed in this invention can reduce unnecessary problems caused by obviously erroneous decisions made by the model on difficult samples (samples that cannot pass the consistency assessment in the dual-checking framework) being directly used in downstream tasks, thus enhancing the reliability of the model's probability feedback of decision results. Furthermore, for the small portion of feedback provided by this invention (related information content that modifies the classification prediction results), the system can also introduce a costly ultra-large model or human verification to further improve the system's upper limit.

[0040] The principle of the dual-checking method provided by this invention will be explained in detail below using image classification as an example.

[0041] To achieve double checking, classification models need to have two capabilities: to assess the reliability of the model's inference results and to make reasonable modifications to unreliable results.

[0042] I. Evaluate the reliability of the model's inference results.

[0043] Assume that the classification model makes unreliable inferences because it misidentifies sample features. Based on this, a double-checking approach assesses the reliability of feature identification from opposite directions: first, assuming the classification model correctly predicts the category, then imagine a counterfactual sample that matches the features of that category, and estimate the consistency between the factual sample and the imagined counterfactual sample. This consistency can be used to determine the reliability of the original inference result. Therefore, the key to modeling the first capability lies in modeling counterfactual thinking and assessing consistency.

[0044] It should be noted that in this embodiment of the invention, samples (factual samples and counterfactual samples) are used as the subject of the description, but in actual operation, the features of the samples are used for calculation.

[0045] For the C-class classification problem, let x denote the features of the fact samples and let y denote the true class. The traditional definition of counterfactual samples is:

[0046]

[0047] Where X and Y are random variables, representing sample features and categories respectively, and y is the hypothetical counterfactual sample category; X Y=yThis represents the counterfactual sample feature obtained when the value of variable Y is adjusted to the assumed category y through intervention. Therefore, when That is, when the true category is defined, the counterfactual sample features. This represents the feature x of the factual sample. However, in practice, the features of counterfactual samples cannot be estimated using the above formula. Firstly, during testing, the true category... It is unknown, and on the other hand, the complete causal graph of the data generation process is not known, making it difficult to intervene in all the mediating variables.

[0048] like Figure 2 As shown, this illustrates the principle behind the cause-effect graph generated from the data. Figure 2 As shown on the left, it is difficult to intervene in all intermediate variables in the complete causal graph of the fact sample feature generation process. To address this issue, the assumption is relaxed to intervene in only one mediating variable: T = T y Where T is a key mediating variable on the path from Y to X in the causal graph, the causal graph that generates counterfactual sample features is as follows: Figure 2 As shown on the right.

[0049] Based on the above principle, in this embodiment of the invention, a specified mediator variable is selected from multiple mediator variables included in the feature generation process of the fact sample, and its value is changed from T to another value T. y The features of counterfactual samples are generated in the following manner.

[0050]

[0051] Where X and Y are random variables, representing sample features and categories, respectively. This is the conditional part, representing the condition during the generation of features for counterfactual samples when the assumed class happens to be the true class. At that time, the generated features The actual feature x is the same. Indicates the true category is Specify the value of the mediator variable at that time. The values ​​of the mediating variables are specified for the fact samples. This means changing the value T of the specified mediator variable to another value T. y The features of the counterfactual samples obtained afterward. Of course, this is an ideal situation, and it will not be exactly the same in reality. E represents the expectation, y is the hypothetical category of the counterfactual sample, y∈[1,C], and C is the number of categories. The features represent counterfactual samples of category y.

[0052] In object recognition tasks, mediating variables can be shape and texture. Preferably, this invention intervenes in the mediating variable of texture (T hereafter represents the texture variable), as long as the T of each category... Y=y If the differences between them are discriminable, then the characteristics of the generated counterfactual samples are also discriminable (distinctive in terms of category). Here, T Y=y That is, the T mentioned earlier y Different categories correspond to different T values. y value.

[0053] For example, a pre-trained Counterfactual Generation Network (CGN) can be selected to automatically generate counterfactual samples, generating features for counterfactual samples for each category:

[0054] This section primarily addresses the assumptions in causal graphs for specific tasks, namely, the existence of at least two mediating variables, and the ability to generate counterfactual samples by intervening in one of these mediating variables. As previously mentioned, this invention can also be applied to text classification models. For text classification models, the mediating variables are no longer texture variables, but are determined based on the specific text classification task. For example, in sentiment analysis, a text classification task, the classification result is a sentiment category, and when intervening in the mediating variables, one can choose mediating variables such as writing style or sentence structure.

[0055] Once we have discernible counterfactual samples, the next step is to consider how to conduct a consistency assessment.

[0056] In this embodiment of the invention, a twin subnetwork is selected. The consistency between the fact samples and the counterfactual samples of each category is evaluated using the Siamese subnetwork. The consistency evaluation is performed by inputting the features of each sample. Here, s(.,.|η) is the identifier of the Siamese subnetwork, η represents the parameters of the Siamese subnetwork before training, and the features x of the fact samples and the features x of the counterfactual samples are used for calculation. All of these are inputs to the twin subnetwork.

[0057] To enable the network to distinguish credible counterfactual samples (of the same category as the factual samples) from the generated counterfactual samples of various categories, a search task is defined to train the Siamese sub-network. The feature x of the factual sample is set as the search object, and the features of all counterfactual samples are used as the search target. The samples are divided into positive and negative samples, where y represents a category and C is the number of categories; positive samples are counterfactual samples whose feature x is the same category as the factual sample. Right now Let the positive samples be denoted as For the true category of the fact sample, The category with the highest probability in the classification prediction results is represented by the negative sample; the negative sample is a feature of the counterfactual sample of other categories. Right now y′ represents the category of the negative sample. The Siamese subnetwork used to measure the consistency between counterfactual and factual samples is equivalent to an image search model. It first calculates the consistency between each counterfactual and factual sample, then outputs the category of the counterfactual sample with the highest consistency. Furthermore, the structure of the Siamese subnetwork is consistent with the classification model f(x|θ), where θ is the parameter of the classification model.

[0058] In this embodiment of the invention, the training loss of the twin network is the following ternary loss function:

[0059]

[0060] in, η represents the parameters of the trained twin network, and η represents the parameters of the untrained twin network. The feature x representing the fact sample and the negative sample Consistent results The feature x representing the fact sample and the positive sample The consistency results are obtained, where α is a set hyperparameter.

[0061] For example, the consistency measure function s(.) can be a cosine similarity function, which uses the cosine similarity of the features of the fact sample and the features of each counterfactual sample in the latent space to evaluate consistency.

[0062] After training the twin network, the consistency results between the fact samples and all counterfactual samples are obtained. Then, the reliability of the classification prediction results of the classification model is checked by combining the consistency results obtained from the classification prediction results with those obtained from the evaluation. This is expressed as follows:

[0063]

[0064] in, The comparison confidence level is represented by δ, which is the Kronecker function, equal to 1 only when the two parameters in parentheses are the same, otherwise it is 0; Features x representing factual samples and features x representing counterfactual samples The consistent result is y∈[1,C]; This indicates the category corresponding to the counterfactual sample with the highest output consistency. The category with the highest probability in the classification prediction results.

[0065] like This indicates that the classification model's prediction results are reliable, meaning that the consistency between the counterfactual sample features and the factual sample features corresponding to the categories predicted by the classification model is the highest among all categories. If This indicates that the classification prediction results of the classification model are unreliable, meaning that the consistency between counterfactual samples and factual samples in other categories is higher.

[0066] Second, make reasonable modifications to unreliable results.

[0067] The consistency between various counterfactual samples and factual samples provides important clues for modifying the original inference results. Based on this, the present invention designs a modification model: Where w represents the parameter w used to modify the model. This represents the classification prediction result; it is a vector where each element represents the probability of belonging to the corresponding class. The consistency results between counterfactual and factual samples for each category are computed for the Siamese network. It is a vector, where each element represents the consistency result between counterfactual and factual samples for a single category. Modify the model input consistency results. and classification prediction results The classification prediction results, along with the consistency results between the fact samples and the counterfactual samples of each category, are stacked into a matrix, and then the classification prediction results are modified based on the information in the matrix.

[0068] In this embodiment of the invention, the modified model includes, in sequence: a stacked layer, a one-dimensional convolutional layer, and two fully connected layers. The stacked layer is used to stack the classification prediction results and the consistency results between the factual samples and the counterfactual samples of each category into a matrix, denoted as [matrix name missing]. Where R is the set of real numbers. During stacking, each column of the matrix represents the probability value of a certain class in the classification prediction results and the consistency result between the counterfactual samples and the factual samples of the corresponding class. That is, the i-th column A[i] of the matrix corresponds to the probability value of the class with the i-th largest probability in the classification prediction results and the consistency result value between the counterfactual samples and the factual samples of the corresponding class, i∈[1,C]. This better highlights the pattern between the model inference results and the consistency evaluation results. The one-dimensional convolutional layer includes several one-dimensional convolutional filters. Each one-dimensional convolutional filter is used to independently extract the patterns within the stacked layer output matrix and output it to the first fully connected layer. Two fully connected layers are used to integrate the features output by the one-dimensional convolutional layer and make the final decision.

[0069] In this embodiment of the invention, the one-dimensional convolutional filters operate independently, and their outputs are each connected to the first fully connected layer. The one-dimensional convolutional filters are designed to make the mapped input more complex (mapping from low-dimensional to high-dimensional), thus making them easier for the fully connected layers to learn. The pattern can be understood as the category with the highest probability in the classification prediction result... Not a real category At that time, from the stacked matrix A to the true class The correct mapping between them, that is, the function that needs to learn the correct mapping, is to correct the classification prediction results output by the classification model.

[0070] In this embodiment of the invention, two fully connected layers are connected in sequence, with a ReLU activation function layer between them. The output of the second fully connected layer is a corrected probability vector (corrected classification prediction result), and the category with the highest probability is taken as the final classification result.

[0071] In this embodiment of the invention, the modification module is trained based on the cross-entropy loss function. During training, the modification module learns how to modify unreliable inference results based on the information provided by the consistency results. The cross-entropy loss function and training process involved here can refer to conventional techniques, and will not be elaborated upon in this invention.

[0072] Figure 3 This paper presents the overall framework of a causal-based model-based double-checking approach, which includes a counterfactual generation model (CGN) and a consistency assessment model. and modify the model Treating these elements as a whole with the classification model f(x|θ) endows the classification model f(x|θ) with double-checked reflective and corrective capabilities. To integrate this framework with traditional machine learning frameworks, the training and testing processes need to be modified separately: during training, the classification model, counterfactual generation model, consistency evaluation model, and modified model are trained sequentially; during testing, the double-checked framework is used to calculate the confidence level of each inference result of the classification model, and unreliable results are then modified. It should be noted that... Figure 3 The presented predicted classifications and revised classifications are for illustrative purposes only and do not constitute a limitation.

[0073] The above-mentioned solutions provided by the embodiments of the present invention have the following main advantages:

[0074] 1) In the reliability assessment process, unreliable inferences of the model within each probability interval can be efficiently screened out, so that difficult samples can receive more attention.

[0075] 2) It can effectively correct unreliable inference results, especially those with low probabilities. That is, it can correct the category with the highest probability in the classification model's prediction results. When the classification model outputs the probability A very small value indicates a low confidence level in the classification model's predictions; for example, when the highest probability category in the classification predictions is... probability That is, the probability is 60%, which is the highest among all categories. However, the value is relatively low, so the reliability of the prediction result is not high.

[0076] 3) It is effective for various classification models and has stronger robustness to interference.

[0077] To fully illustrate the advantages of this invention (hereinafter referred to as L2D), detailed experiments were conducted on several typical classification models using NICO, a commonly used image classification dataset for evaluating model generalization and transferability (the prediction results of typical classification models in this scenario require further refinement). The NICO dataset comprises two distinct subsets: Animal and Vehicle. Each category in each dataset has 10 different backgrounds (e.g., grassland, city, snow, river, etc.). Different distributions of test sets were constructed by controlling the background of the test samples for each class to differ from the background used during training. Table 1 shows the specific settings for the two datasets in the experiments.

[0078] Table 1: The partitioning settings of the two subsets of the NICO dataset in the experiment

[0079] Dataset training set Validation set test set Training set background number Test set background number Animal 5318 1088 2524 5 5 Vehicle 4322 885 2073 5 5

[0080] 1. Efficiently filter unreliable inference results across various probability intervals.

[0081] Based on the model's inference results, the first step is to use the maximum class probability predicted by the model for each sample. The samples were divided into multiple groups, and the original accuracy and the accuracy of inferences judged as reliable and unreliable by the L2D consistency evaluation model were calculated for each group. Three models were tested: ResNet-18, the self-challenging representation model RSC, and the deep stable learning model DSL. The experimental results are as follows: Figure 4 As shown, the left column corresponds to the Animal dataset, and the right column corresponds to the Vehicle dataset.

[0082] It can be seen that for the inference results of the model across various probability intervals, the accuracy of the L2D consistency evaluation model when it is judged as "reliable" is much higher than that when it is judged as "unreliable". Even for the results with probabilities between 0.9 and 0.99, this gap is still 20% to 40%, and the accuracy of unreliable inference results is generally below 60% at this point, demonstrating the great potential for examining and modifying the original prediction results of the model and the rationality of the L2D framework.

[0083] 2. Effectively correct erroneous inference results for difficult samples.

[0084] The complete L2D framework was applied to a classification model, and the effectiveness of L2D on hard samples in the test set was observed. The performance of the datasets Animal and Vehicle shows that the proportion of difficult samples is about 20% and 10% respectively, as shown in Table 2.

[0085] Table 2: Accuracy (%) of the model on difficult samples and accuracy after adding the L2D framework

[0086] Model ResNet-18 RSC DSL Animal 31.10 29.47 29.23 +L2D 40.08 38.55 39.78 Vehicle 41.85 31.88 38.97 +L2D 47.04 39.85 45.67

[0087] As can be seen, by adding the L2D framework to the classification model, the model's performance on hard samples improved by 9.8% and 6.6% on Animal and Vehicle, respectively. This improvement is due to two factors: firstly, the consistency evaluation model in L2D can effectively capture the consistency between the features of factual and counterfactual samples, improving the model's feature discrimination ability; and secondly, the modification model in L2D can effectively learn modification strategies.

[0088] 3. It is effective for various models and enhances robustness.

[0089] First, we examined the impact of L2D on different models on the complete test set, and the results are shown in Table 3.

[0090] Table 3: Accuracy (%) of the model on the test set before and after adding L2D

[0091] Model ResNet-18 RSC DSL Animal 75.04 78.26 74.61 +L2D 76.47 79.32 77.10 Vehicle 83.99 85.32 83.26 +L2D 84.50 85.88 84.21

[0092] It can be seen that L2D can further improve the performance of different classification models on the basis of the original model.

[0093] Furthermore, we consider adding some perturbation to the data: the original processing directly interpolates the image to (224, 224), but we consider adding an additional interpolation, that is, first interpolating the image size to (256, 256), and then interpolating to (224, 224). This additional interpolation does not change the semantic information of the image, but it applies a small change to the overall pixel values. Compared with Table 3, the test accuracy of the model has decreased significantly, as shown in Table 4.

[0094] Table 4: Accuracy (%) of the model on the perturbed test set before and after adding L2D

[0095] Model ResNet-18 RSC DSL Animal 72.58 76.15 72.34 +L2D 75.16 77.50 75.35 Vehicle 82.58 83.84 82.00 +L2D 83.72 84.61 83.44

[0096] As can be seen, L2D can still significantly improve the model's performance at this point. This is because perturbations to pixels do not affect the consistency estimation of sample features by the consistency evaluation model in L2D.

[0097] Example 2

[0098] This invention also provides a causal-based model double-checking system, which is mainly implemented based on the method provided in the foregoing embodiments, such as... Figure 5 As shown, the system mainly includes:

[0099] The counterfact generation model takes the input sample as the fact sample and generates counterfact samples for each category by intervening in the mediating variables in the fact sample generation process.

[0100] A consistency evaluation model is used to obtain the classification prediction results of the classification model for factual samples, evaluate the consistency between the factual samples and the counterfactual samples of each category, and check whether the classification prediction results of the classification model are reliable by combining the classification prediction results with the consistency results obtained from the evaluation. The classification model includes an image classification model and a text classification model. For the image classification model, the input sample is an input image, and for the text classification model, the input sample is an input text.

[0101] Modify the model: when the classification prediction results of the classification model are unreliable, modify the classification prediction results based on the consistency between the fact samples and the counterfactual samples of each category.

[0102] Those skilled in the art will understand that, for the sake of convenience and brevity, the above-described division of functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the system can be divided into different functional modules to complete all or part of the functions described above.

[0103] Example 3

[0104] The present invention also provides a processing device, such as Figure 6 As shown, it mainly includes: one or more processors; a memory for storing one or more programs; wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the foregoing embodiments.

[0105] Furthermore, the processing device also includes at least one input device and at least one output device; in the processing device, the processor, memory, input device, and output device are connected via a bus.

[0106] In this embodiment of the invention, the specific types of the memory, input device, and output device are not limited; for example:

[0107] Input devices can be touchscreens, image acquisition devices, physical buttons, or mice, etc.

[0108] The output device can be a display terminal;

[0109] The memory can be random access memory (RAM) or non-volatile memory, such as disk storage.

[0110] Example 4

[0111] The present invention also provides a readable storage medium storing a computer program that, when executed by a processor, implements the method provided in the foregoing embodiments.

[0112] In this embodiment of the invention, the readable storage medium is a computer-readable storage medium and can be disposed in the aforementioned processing device, for example, as a memory in the processing device. Furthermore, the readable storage medium can also be any medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.

[0113] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations 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. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A causal-based model double-checking method, characterized in that, include: By using the input samples as fact samples and intervening in the mediating variables during the fact sample generation process, counterfactual samples for each category are generated. The fact sample generation process includes multiple mediating variables. A specific mediating variable is selected from these variables, and its value is determined by… Change to other values The features of counterfactual samples are generated in the following manner. : ;in, and Let be random variables, representing sample features and categories, respectively. Characteristics representing factual samples, This indicates that the assumed category Y equals the true category. Sample characteristics at that time Indicates the true category is Specify the value of the mediator variable at that time. The values ​​of the mediating variables specified for the fact samples. This indicates that the value of the specified mediator variable will be used. Change to other values The counterfactual sample features obtained later Expressing expectations, The category of the hypothetical counterfactual sample. , For the number of categories, Indicates category as Characteristics of counterfactual samples; The classification model is used to obtain the classification prediction results of the fact samples, evaluate the consistency between the fact samples and the counterfactual samples of each category, and check whether the classification prediction results of the classification model are reliable by combining the classification prediction results with the consistency results obtained from the evaluation; wherein, the classification model includes an image classification model and a text classification model, the input sample for the image classification model is an input image, and the input sample for the text classification model is an input text; When the classification prediction results of the classification model are unreliable, the classification prediction results are modified based on the consistency between the fact samples and the counterfactual samples of each category.

2. The causal-based model double-checking method according to claim 1, characterized in that, The assessment of the consistency between the factual samples and the counterfactual samples of each category includes: A twin sub-network is set up to evaluate the consistency between the fact samples and the counterfactual samples of each category. When evaluating consistency, the features of each sample are used for calculation. A search task is defined to train the twin sub-network, incorporating the features of the fact samples... Set as the search object, and select the features of all counterfactual samples. Divided into positive and negative samples, Represents a category, The number of categories; positive samples are the features compared to fact samples. Features of counterfactual samples of the same category ,Right now Let the positive samples be denoted as , For the true category of the fact sample, The category with the highest probability in the classification prediction results is represented by the negative sample; the negative sample is a feature of the counterfactual sample of other categories. ,Right now , The category of negative samples.

3. The causal-based model double-checking method according to claim 2, characterized in that, The training loss for the Siamese network is the following ternary loss function: ; in, Represents the parameters of the trained twin network; Features representing fact samples With negative samples Consistent results Features representing fact samples Compared with positive samples Consistent results These are the hyperparameters that are set.

4. The causal-based model double-checking method according to claim 1, characterized in that, The method of checking the reliability of the classification prediction results by combining the classification prediction results with the consistency results obtained from the evaluation is expressed as follows: ; in, Indicates the credibility of the comparison. This is the Kronecker function, which equals 1 only if the two parameters in parentheses are the same, otherwise it is 0; Representing factual samples Counterfactual samples Consistent results , Represents a category, Number of categories; This indicates the category corresponding to the counterfactual sample with the highest output consistency. The category with the highest probability in the classification prediction results; like If , it means the classification prediction result of the classification model is reliable; if If the value is 0, it means that the classification prediction results of the classification model are unreliable.

5. The causal-based model double-checking method according to claim 1, characterized in that, Modifying the classification prediction results based on the consistency between the factual samples and the counterfactual samples for each category includes: Set up a modification model whose inputs are the classification prediction results and the consistency results between the fact samples and the counterfactual samples of each category; the modification model stacks the classification prediction results and the consistency results between the fact samples and the counterfactual samples of each category into a matrix, and then modifies the classification prediction results based on the information in the matrix.

6. The causal-based model double-checking method according to claim 5, characterized in that, The modified model includes, in sequence: a stacked layer, a one-dimensional convolutional layer, and two fully connected layers; wherein: The stacking layer is used to stack the classification prediction results and the consistency results of the fact samples and the counterfactual samples of each category into a matrix, denoted as . ,in, This represents the classification prediction result. It is a vector, where each element represents the probability of belonging to the corresponding category. It represents the consistency result between the fact sample and the counterfactual sample of each category. It is a vector, and each element represents the consistency result between the counterfactual sample and the fact sample of a single category. For the set of real numbers, The number of categories; when stacked, each column of the matrix represents the probability value of a certain category in the classification prediction results and the consistency result between the counterfactual sample and the factual sample of the corresponding category, i.e., the matrix's [number of columns]. List This corresponds to the probability number in the classification prediction results. The probability values ​​of the major categories and the consistency results between the counterfactual samples and the factual samples of the corresponding categories. , Number of categories; A one-dimensional convolutional layer includes several one-dimensional convolutional filters. Each one-dimensional convolutional filter is used to independently extract the patterns inside the output matrix of the stacked layer and output them to the first fully connected layer. Two fully connected layers are connected in sequence to integrate the features output by the one-dimensional convolutional layer, and the corrected classification prediction result is output by the second fully connected layer.

7. A causal-based model-based double-checking system, characterized in that, Based on the method described in any one of claims 1 to 6, the system comprises: The counterfact generation model takes the input sample as the fact sample and generates counterfact samples for each category by intervening in the mediating variables in the fact sample generation process. A consistency evaluation model is used to obtain the classification prediction results of the classification model for factual samples, evaluate the consistency between the factual samples and the counterfactual samples of each category, and check whether the classification prediction results of the classification model are reliable by combining the classification prediction results with the consistency results obtained from the evaluation. The classification model includes an image classification model and a text classification model. For the image classification model, the input sample is an input image, and for the text classification model, the input sample is an input text. Modify the model: when the classification prediction results of the classification model are unreliable, modify the classification prediction results based on the consistency between the fact samples and the counterfactual samples of each category.

8. A processing apparatus, characterized in that, include: One or more processors; Memory, used to store one or more programs; Wherein, when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the method as described in any one of claims 1 to 6.

9. A readable storage medium storing a computer program, characterized in that, When a computer program is executed by a processor, it implements the method as described in any one of claims 1 to 6.