SlowGuess/NeurIPS_2023_OCR huggingface dataset:
As mentioned in Mouli and Ribeiro [25], given a set of attributes  $(\mathcal{A})$ , we train two models for each subset  $(\alpha)$  of the attributes  $(\alpha \subset \mathcal{A})$  (1) model trained to predict the task label  $Y$  while being invariant to the attributes in  $\alpha$ , (2) a model trained to predict the random label while being invariant to the attributes in  $\alpha$ . Using these two models we compute the score for every  $\alpha$  as defined in Equation 8 in Mouli and Ribeiro [25]. Then we select the subset of attributes with the lowest score as spurious and train a classifier to predict the task label and be invariant to this subset of attributes. Similar to [25] we use counterfactual data augmentation (CAD) to impose invariance w.r.t to desired set of attributes (denoted as Mouli+CAD in all our experiments). We also experiment with using AutoACER to impose instead of CAD by using a causal effect equal to 0 for the attributes for which we want to impose invariance (see §4.2 for details). When using AutoACER we search over regularization hyperparameter  $R$  from the set  $\{1, 10, 100, 1000\}$ . Unless otherwise specified, we use the same selection criteria to select the best model for comparison with other methods as described in Eq. 33.
E.7 Setup: JTT baseline
We follow Algorithm 1 as described in Liu et al. [21] and train the model in two steps. First, we train a model with cross-entropy loss over all the examples (ERM). For Syn-Text-Unobs-Conf dataset, we tune the number epoch to train the model from set  $\{4,8\}$  using the model selection criteria defined later in step 2 of this method. For MNIST34 and Twitter-AAE we keep the number epochs fixed at 8 and 10 respectively for this first step. In the next step, we upsample the examples in the dataset that the ERM model predicted wrong in the first step by a factor of  $\lambda_{up}$ . We tuned the hyperparameter  $\lambda_{up}$  over the set  $\{2,4,8\}$  for Syn-Text-Unobs-Conf dataset and over set  $\{2,4\}$  for both MNIST34 and Twitter-AAE datasets. We train the final model using the oversampled dataset for 20 epochs for Syn-Text-Unobs-Conf, 20 epochs for MNIST34, and 10 epochs for Twitter-AAE dataset. Unless otherwise specified, we use the same selection criteria to select the best model using the validation dataset as described in Eq. 33.
E.8 Setup: IRM baseline
We implement the IRMv1 to train the model using IRM objective as described in Arjovsky et al. [1]. We use the cross-entropy loss for estimating the prediction error  $(R^{e}$  in the IRMv1 equation). We compute the norm of the gradient term directly by squaring the gradient of cross-entropy loss w.r.t. the dummy classifier  $w = 1.0$  as described in the IRMv1 equation. We fine-tune the regularization coefficient  $\lambda$  over the set  $\{1e15,5e15\}$  for Syn-Text-Unobs-Conf dataset,  $\{1e14\}$  for MNIST34 dataset and  $\{1e14,5e14,1e15\}$  for the Twitter-AAE dataset. We used such high regularization to scale up the gradient penalty term to have the same scale as the cross-entropy loss term which otherwise would have dominated the training objective. Unless otherwise specified, we use the same selection criteria to select the best model using the validation dataset as described in Eq. 33.
Table 6: Estimated Causal Effect for spurious attribute in Syn-Text-Obs-Conf dataset: The causal effect is estimated on multiple datasets with varying predictive correlation  $(\kappa)$ . The true causal effect of spurious attribute is 0. In our experiment, we used two different causal effect estimators, Direct and Riesz. Each of them has two different ways to select the best estimate, using validation loss or validation accuracy (see §E.4 for details). The causal effect from Direct estimator is close to the correct value 0 for lower predictive correlation  $(\kappa \leq 0.7)$  but the error increases as  $\kappa$  increases. The causal effect for causal and spurious attribute is identifiable in this dataset since the confound attribute is a sufficient backdoor adjustment. Riesz estimator learns a common representation that approximates the backdoor adjustment, thus, is expected to perform better even under a high value of  $\kappa$ . We observe  $Riesz(loss)$  estimator has the lowest or equivalent estimation error compared to other estimators for all values of  $\kappa$ .
κ	True	Direct	Riesz
Direct(acc)	Direct(loss)	Riesz(acc)	Riesz(loss)
0.5	0	-0.01	-0.00	0.01	0.00
0.6	0	-0.01	0.00	0.01	0.03
0.7	0	0.00	0.01	0.02	0.03
0.8	0	0.05	0.08	0.04	0.03
0.9	0	0.10	0.16	0.20	0.05
0.99	0	0.17	0.22	0.26	0.15
Table 7: Estimated Causal Effect for spurious attribute in Syn-Text-Unobs-Conf dataset: The causal effect is estimated on multiple datasets with varying predictive correlation  $(\kappa)$ . The true causal effect of spurious attribute is 0. In our experiment, we used two different causal effect estimators, Direct and Riesz. Each of them has two different ways to select the best estimate, using validation loss or validation accuracy (see §E.4 for details). The data-generating process for this dataset is given by DGP-3 (Fig. 2) where the confound attribute is the unobserved variable (see §E.1 for details) and the identifiability of causal effect is not guaranteed. Thus, as expected, both the methods Direct and Riesz have a high estimation error and the error increases as the value of  $\kappa$  increases. Among both, the Direct estimator performs better than Riesz for this dataset. Our method uses this estimated causal effect to regularize the classifier. We observe that our method is robust to this error in the estimation of causal effect and trains a classifier that performs better on average group accuracy and has significantly lower  $\Delta$ Prob compared to other baselines (see §4.4, F.2 and Fig. 4a, 14, 11 for discussion).
κ	True	Direct	Riesz
DE(acc)	DE(loss)	Riesz(acc)	Riesz(loss)
0.5	0	-0.01	-0.01	0.01	0.06
0.6	0	0.10	0.13	0.16	0.19
0.7	0	0.20	0.24	0.29	0.31
0.8	0	0.38	0.37	0.43	0.42
0.9	0	0.49	0.49	0.57	0.58
0.99	0	0.65	0.67	0.67	0.70
E.9 Computing Resources
We use an internal cluster of P40, P100, and V100 Nvidia GPUs to run all the experiments. We run each experiment for 3 random seeds and report the mean and standard error (using an error bar) for each of the metrics in our experiment of Stage 2 and other baselines and report the mean over 3 random runs for all the experiments in Stage 1 (Causal Effect Estimation).
F Additional Empirical Results
F.1 Extended Evaluation of Stage 1: Detecting Spurious Attribute
Causal Effect Estimator Recommendation. In this work we evaluate the performance of 2 different causal effect estimators — Direct and Riesz — each with two different ways of selecting the best mode either using validation loss or accuracy (see §E.4 for details) on 6 different datasets.
Table 8: Estimated Causal Effect for causal attribute in Syn-Text-Unobs-Conf dataset: The causal effect is estimated on multiple datasets with varying predictive correlation  $(\kappa)$ . The true causal effect of spurious attribute is 0.29. In our experiment, we used two different causal effect estimators, Direct and Riesz. Each of them has two different ways to select the best estimate, using validation loss or validation accuracy (see §E.4 for details). The increasing value of  $\kappa$  indicates the increasing predictive correlation of spurious attribute in the dataset (see E.1 for details). Even though there is no guarantee of the identifiability of causal effect, both the methods estimate almost correct causal effect for the causal feature. On the other hand, the previous method Mouli+CAD will incorrectly identify the causal feature as spurious for this dataset and thus will incorrectly impose invariance w.r.t to causal attribute. (see Fig. 5a and §F.1 for more discussion).
κ	True	Direct	Riesz
DE(acc)	DE(loss)	Riesz(acc)	Riesz(loss)
0.5	0.29	0.31	0.25	0.33	0.29
0.6	0.29	0.29	0.30	0.27	0.32
0.7	0.29	0.27	0.30	0.29	0.30
0.8	0.29	0.33	0.30	0.34	0.29
0.9	0.29	0.32	0.31	0.32	0.29
0.99	0.29	0.31	0.31	0.30	0.29
Table 9: Estimated Causal Effect for spurious attribute (rotation) in MNIST34 dataset: The causal effect is estimated on multiple datasets with varying predictive correlation  $(\kappa)$ . The true causal effect of spurious attribute is 0. In our experiment, we used two different causal effect estimators, Direct and Riesz. Each of them has two different ways to select the best estimate, using validation loss or validation accuracy (see §E.4 for details). The data-generating process of this dataset is given by DGP-2 (Fig. 2) and the causal effect is identifiable using only observational data (see Prop 3.1). The ground truth causal effect of spurious attribute is 0. Overall the Riesz(loss) estimator has a lower or equivalent error in the estimation of the causal effect for most of  $\kappa$  except very high  $\kappa = 0.99$ . As the predictive correlation  $(\kappa)$  of spurious attribute increases the error in the causal effect estimate of spurious attribute increases. When training the classifier, we show that our method (AutoACER) is robust to this error in the estimation of the causal effect of spurious attribute (see §4.4, F.2 and Fig. 4b, 15, 12 for discussion).
κ	True	Direct	Riesz
DE(acc)	DE(loss)	Riesz(acc)	Riesz(loss)
0.5	0	0.02	0.02	0.01	-0.01
0.6	0	0.04	0.03	-0.01	0.06
0.7	0	0.05	0.05	-0.10	0.05
0.8	0	0.07	0.06	-0.07	0.04
0.9	0	0.11	0.15	0.09	0.20
0.99	0	0.28	0.27	0.50	0.31
Table 6 (Syn-Text-Obs-Conf), Table 7, 8 (Syn-Text-Unobs-Conf), Table 9(MNIST34) and Table 10 (Twitter-AAE and Civil-Comments) summarizes the performance of different causal effect estimator on these datasets. Different datasets bring different data-generating processes which bring different challenges for these estimators since the causal effect may or may not be identifiable (see individual tables for each dataset for discussion). We observe that one particular setting of the Riesz estimator i.e.  $Riesz(loss)$  performs consistently better or comparable to other estimators across the dataset. There are certain settings, especially at the high predictive correlation  $(\kappa)$  where even  $Riesz(loss)$  doesn't perform well and have a large error in the estimation of treatment effect. But we will show in  $\S F.2$  that our method AutoACER is robust to error in the estimation of the causal effect.
Baseline Mouli+CAD can incorrectly detect causal attribute as spurious. When given a spurious attribute we have seen that Mouli+CAD can sometimes fail to detect the spurious attribute (see §4.3 for discussions). But sometimes this Mouli+CAD can make an even more severe mistake — detect a causal attribute as spurious. Fig. 5a demonstrate on such failure in Syn-Text-Unobs-Conf dataset. When both the attribute—causal and spurious—is given to Mouli+CAD, it incorrectly identifies both the attributes as spurious for  $\kappa \leq 0.7$  (shown by the red curve having the lowest score).
Table 10: Estimated Causal Effect for spurious attribute in Twitter-AAE, Civil-Comments (Race), Civil-Comments (Gender) and Civil-Comments (Religion) dataset: The causal effect is estimated on multiple versions of each datasets with varying predictive correlation  $(\kappa)$ . In our experiment, we used two different causal effect estimators, Direct and Riesz. Each of them has two different ways to select the best estimate, using validation loss or validation accuracy (see §E.4 for details). In Twitter-AAE dataset the spurious attribute in race, in Civil-Comments (Race) the spurious attribute is also race, in Civil-Comments (Gender) the spurious attribute is gender and in Civil-Comments (Religion) the spurious attribute is religion. The prediction task in Twitter-AAE dataset is sentiment classification and in Civil-Comments datasets it is toxicity prediction. The true causal effect of spurious attribute is unknown in every dataset. But we expect the spurious attribute to have a 0 causal effect on the task label since changing the race/gender/religion of a person should not change the sentiment or toxicity of the sentence. The data-generating process for all these dataset is given by DGP-1 (Fig. 2), where the attribute "A" is the spurious attribute (see §E.1 for details). The causal effect for any attribute "A" is identifiable given access to observational data and interventional distribution  $P(X|do(A))$  (Prop 3.1). Since Riesz estimator assumes access to the counterfactual distribution  $\mathcal{Q} \coloneqq P(\boldsymbol{x}_{a'}|\boldsymbol{x}_a)$  (see §E.4), we expect it to have lower estimation error than Direct. Surprisingly, Direct performs comparably to Riesz estimator in all the datasets. When training the classifier, we show that our method (AutoACER) is robust to error in the estimation of the causal effect of spurious attribute (see §4.4, F.2 and Fig. 4c, 16, 13 for discussion).
Dataset	κ	Direct	Riesz
DE(acc)	DE(loss)	Riesz(acc)	Riesz(loss)
Twitter-AAE	0.5	0.01	0.01	0.03	0.02
0.6	0.07	0.07	0.12	0.07
0.7	0.12	0.12	0.12	0.12
0.8	0.21	0.20	0.18	0.17
0.9	0.32	0.27	0.25	0.27
0.99	0.35	0.31	0.40	0.37
Civil-Comments (Race)	0.5	0.02	0.02	0.06	0.06
0.6	0.04	0.04	0.09	0.09
0.7	0.07	0.05	0.08	0.09
0.8	0.08	0.08	0.09	0.11
0.9	0.15	0.15	0.15	0.18
0.99	0.22	0.22	0.23	0.27
Civil-Comments (Gender)	0.5	0.00	0.00	0.03	0.01
0.6	0.01	0.01	0.04	0.05
0.7	0.03	0.02	0.09	0.09
0.8	0.04	0.05	0.06	0.12
0.9	0.09	0.09	0.12	0.12
0.99	0.13	0.12	0.15	0.18
Civil-Comments (Religion)	0.5	0.01	0.00	0.00	0.00
0.6	0.02	0.03	0.02	0.02
0.7	0.02	0.03	0.01	0.04
0.8	0.04	0.04	0.04	0.03
0.9	0.06	0.06	0.06	0.05
0.99	0.07	0.08	0.09	0.08
For  $\kappa > 0.7$ , again it incorrectly detects the true causal attribute as spurious. If we only give the causal attribute as input to Mouli+CAD, again causal attribute (shown in orange) will be detected as spurious attribute since it has a lower score than the subset with no attribute (blue curve) for all values of  $\kappa$ . But if we look at the causal effect estimate of causal attribute in Syn-Text-Unobs-Conf dataset it is close to the correct value 0.29 for all values of  $\kappa$  even though the identifiability of causal effect for this dataset is not guaranteed (see Table 8). Thus using a continuous measure of the spuriousness of a attribute using the causal effect estimates can help mitigate the limitation of discrete measures (used in Mouli+CAD) like false positive and false negative detection of spurious attributes.
(d) Civil-Comments (Race)
(e) Civil-Comments (Gender)
(c) Twitter-AAE
(f) Civil-Comments (Religion)
Figure 5: Score used by Mouli+CAD for determining the spurious attribute. Given a tuple of attributes in a given dataset, the baseline method Mouli+CAD defines a score for every subset of attribute and determines the least scoring subset as spurious. The empty subset “()” denotes that no attribute is considered spurious. The x-axis shows different levels of predictive correlation  $(\kappa)$  in the dataset and the y-axis shows the score assigned by Mouli+CAD to different subsets of attributes. We include some additional attribute not considered in Fig. 3 for Syn-Text-Unobs-Conf and MNIST34 datasets and summarize the score for Civil-Comments datasets. In (a), we include the score for all the subsets of attributes (causal and spurious) in the Syn-Text dataset. When given all the attributes at the same time, Mouli+CAD will incorrectly detect both the attribute (causal and spurious) as spurious shown by the red curve for  $\kappa < 0.7$  and the causal attribute as spurious for  $\kappa > 0.8$ . Thus Mouli+CAD will completely fail in determining the correct spurious attribute for Syn-Text dataset. When only given the causal attribute in the dataset, it will again incorrectly detect causal attribute as spurious since it will have a lower score compared to the subset with no attribute as shown by the orange curve being always lower than the blue curve. In (b), we again include the score for every subset of attributes—rotation (spurious) and color (causal) which were partially included in Fig. 3. Again, Mouli+CAD will fail to identify any attribute as spurious for all  $\kappa \leq 0.9$  (shown by the blue curve with the lowest score) and will incorrectly detect the causal attribute (color) as spurious for  $\kappa = 0.99$  (shown by the orange curve). For (c) Twitter-AAE, (d) Civil-Comments (Race), (e) Civil-Comments (Gender) and (f) Civil-Comments (Religion) Mouli+AutoACER is able to correctly identify the spurious attribute shown by the orange curve with the lowest score. In Fig. 6, we show that Mouli+CAD doesn’t always impose correct invariance with respect to spurious attribute and might fail to detect the correct spurious attribute once the correct invariance is imposed. See §F.1 for further discussions.
Spuriousness Score used by Mouli+CAD can be misleading. Given a set of attributes, Mouli+CAD creates multiple classifiers where they impose invariance with respect to different subsets of attributes. Using these invariant classifiers, they define a spuriousness score for all the subsets of attributes. Then the subset of attributes with a minimum score is selected as spurious. We observe in our experiment that Mouli+CAD when training the invariant classifier is not able to completely enforce invariance. Thus the score defined using the invariant model might be misleading. Fig. 6 shows one such instance of failure. The second row of Fig. 6c shows that Mouli+CAD doesn't impose correct invariance w.r.t the spurious race attribute (shown by high  $\Delta$  Prob of the orange curve). Next, we use AutoACER to enforce correct invariance w.r.t race attribute by regularizing the classifier with zero causal effect for race attribute. This enforces correct invariance shown by low  $\Delta$  Prob in the second row of Fig. 6f. As a result, we observe that the score for the spurious attribute (shown by the orange curve in the first row of Fig. 6f), is higher than blue. Thus enforcing the correct invariance Mouli+CAD will fail to detect the race attribute as spurious since the blue curve has a lower score than orange for all values of  $\kappa < 0.9$ .
F.2 Extended Evaluation of Stage 2: AutoACER and other baselines assuming the Spurious attribute is known
In §4.4 and Fig. 4 we compared AutoACER with other baselines where we used overall accuracy as the selection criteria to select the best model (see Eq. 33). However, some of the baselines (IRM and JTT) assume that spurious attributes are known and use this information to train and select the best model that generalizes under spurious correlations. Thus, in this section for a fair comparison, we re-evaluate all the methods on all the datasets again by providing them with the knowledge of spurious attributes. Refer to Eq. 34 for details on how we select the best model with this information. Fig. 7 summarizes the result for AutoACER and other baseline with this selection criteria.
Other evaluation metrics for Syn-Text-Unobs-Conf, MNIST34 and Twitter-AAE dataset We extend the evaluation in Fig. 7, by adding the comparison of the performance of AutoACER and other baselines over these accuracy metrics for Syn-Text-Unobs-Conf, MNIST34, and Twitter-AAE datasets in Fig. 8. Overall, AutoACER performs comparable or better than other baselines for Syn-Text-Unobs-Conf and MNIST34 datasets. In Twitter-AAE dataset, Mouli+CAD performs better in worst group and minority group accuracy than AutoACER. But AutoACER has significantly lower  $\Delta$  Prob compared to other baselines signifying that the learned classifier is invariant to the spurious attribute.
Evaluation of AutoACER on Civil-Comments dataset. We evaluate our method on Civil-Comments dataset — a real-world dataset where given a sentence the task is to predict the toxicity of the sentence. We have three different subsets of this dataset, Civil-Comments (Race), Civil-Comments (Gender), and Civil-Comments (Religion) where the attribute race, gender and religion are the spuriously correlated with task label (see §E.1 for details). Fig. 10 compares AutoACER with other baselines over a number of different metrics. Unlike Twitter-AAE dataset where Mouli+CAD gave significant gains in the average group accuracy, AutoACER performs comparably to Mouli+CAD and improves over ERM over this metric on all the subsets. Although,  $\Delta$  Prob is low for all the baseline methods, AutoACER again gives a classifier with much lower  $\Delta$  Prob, especially for high values of predictive correlation  $(\kappa)$ . On all subsets of Civil-Comments dataset, AutoACER also performs comparably to other baselines over other accuracy metrics — minority group accuracy and worst group accuracy — used to evaluate the efficacy of generalization over spurious attribute [30].
Counterfactual Data Augmentation is not sufficient for imposing correct invariance. Fig. 7 gives us a hint that Mouli+CAD might not be sufficient for learning a model that is invariant to spurious attribute. For Twitter-AAE dataset (see Fig. 7c) and Civil-Comments dataset (see Fig. 10), AutoACER has comparable or slightly lower average group accuracy than Mouli+CAD. But AutoACER has a significantly lower value of  $\Delta$  Prob than other baselines and thus is able to impose correct invariance w.r.t spurious attribute. Thus it seems that counterfactual data augmentation used in Mouli+CAD might be using some other mechanism to perform better on average group accuracy than imposing invariance w.r.t to spurious attribute. In Fig. 9 we combine Mouli+CAD and AutoACER to get the best out of both worlds (denoted as Mouli+AutoACER +CAD). As expected we observed that the final classifier has a significant gain in the average group accuracy and has  $\Delta$  Prob than ERM classifier. We leave the task of understanding how CAD gives better gains in average group accuracy to future work. See Fig. 9 for details of other additional details of experiments with CAD that might shed some light on this question.
Robustness of AutoACER on error in detection of spurious attributes. AutoACER follows a two-step procedure to train a classifier that generalizes to spurious correlation. First, in Stage 1, it estimates the causal effect of the given attribute on the task label to determine a continuous degree of spuriousness for that attribute. Then in Stage 2, it regularizes the classifier proportional to the estimated causal effect with the goal of imposing invariance with respect to spurious attribute. Since AutoACER is heavily reliant on the estimate of causal effect for correctly enforcing the invariance with respect to spurious attribute we need to analyze its robustness to noise in the estimation of causal effect. For simpler classifiers, our 3.1 shows that we don't need a correct causal effect estimate to learn a classifier invariant to spurious correlation. For the case when we have two high dimensional variables - one causal and another spurious - as long as the ranking of the causal effect of causal and spurious attribute is correct AutoACER will learn a classifier completely invariant to spurious attribute. This result on a simpler classification task hinted that we don't need a completely correct
estimate of attribute to learn a more complicated invariant classifier trained on a real-world dataset. We conduct an experiment where we knowing use a range of non-zero causal effects for spurious attribute (ground truth causal effect is zero) to regularize the model using AutoACER. We observe that AutoACER is less sensitive to even large noise in the causal effect  $(>0.5)$  on the metrics like average group accuracy and  $\Delta$  Prob for a large range of regularization strength (R). Even with a large error in the causal effect AutoACER trains a classifier with high average group accuracy and low  $\Delta$  Prob. Fig. 11, 12 and 13 summarizes the result for Syn-Text-Unobs-Conf, MNIST34 and Twitter-AAE dataset. Also, we show the robustness of AutoACER when using the causal effect estimates from different estimators we consider in our work in Fig. 14, 15 and 16 for these datasets.
(a) MNIST34, Mouli+CAD
(b) Civil-Comments (Race), Mouli+CAD
(c) Twitter-AAE, Mouli+CAD
(d) MNIST34, Mouli+AutoACER  $(R = 100)$
(e) Civil-Comments (Race), Mouli+AutoACER  $(\mathrm{R} = 1000)$