betaFeedback

WorksComputer Science

Disentangling Spurious Correlations: How IRM Handles Diverse Shortcuts in Text Classification

Abstract

In NLP, models trained via Empirical Risk Minimization (ERM) often exploit spurious correlations, such as dialectal markers, at the expense of robust linguistic features, thereby degrading their out-of-distribution (OOD) generalization. Invariant Risk Minimization (IRM) aims to suppress such shortcuts by identifying predictive relationships that remain stable across environments, but its practical utility for NLP remains debated. We use a causality-driven framework to evaluate IRM under three shortcut-generating mechanisms: label-generated features, confounding, and selection bias. Our results show that IRM successfully rejects shortcuts across the evaluated causal and anti-causal structures, including under limited environmental variation and increasing label noise. We then extend our analysis beyond controlled synthetic artifacts to two less constrained settings: gender-profession associations in Bias in Bios and semantically loaded actor-name shortcuts in ActorCorr. These experiments show that invariant learning can mitigate more realistic textual shortcuts, while semantically meaningful features require careful calibration of the invariance penalty.

Introduction

Predictive success in NLP often masks a vulnerability: models frequently rely on dataset-specific biases rather than genuine robust linguistic features. Under the ERM paradigm (Vapnik, 2013), models exploit statistical shortcuts, such as negation words [17], syntactic heuristics [25], or demographic dialectal markers [9], leading to catastrophic performance drops when encountering real-world distribution shifts where these biases no longer hold.

To mitigate this lack of robustness, several strategies have been proposed. Domain adaptation methods [8, 15] and sample reweighting techniques (Shimodaira, 2000) aim to align distributions or correct known selection biases. However, these techniques face a major limitation: they generally require prior knowledge of the test distribution, either through access to unlabeled target data or by explicitly identifying the specific confounding variables to be rebalanced. In many real-world NLP applications, this target distribution is unknown or subject to unpredictable shifts. In this context, IRM [5] has emerged as a powerful theoretical alternative. The core originality of IRM lies in its ability to operate without any information regarding the target distribution. By leveraging data partitioned into multiple distinct training environments, IRM enforces a strict learning constraint. It compels the representation to discard features whose predictive validity fluctuates, isolating only those stable, invariant correlations that yield simultaneously optimal classifiers across all environments. In doing so, IRM seeks to capture robust linguistic principles that guarantee optimal generalization, even to domains entirely unseen during training (Figure 1). Despite these theoretical promises, the practical effectiveness of IRM remains heavily debated. While large-scale benchmarks in machine learning have questioned its out-of-the-box superiority over ERM in standard domain generalization [16], evaluations on specific NLP tasks have also tempered expectations [22], notably regarding its capacity for robust bias mitigation [12]. To understand why cross-environment invariant methods lack effectiveness in NLP, we must move beyond treating spurious correlations as an undifferentiated problem. A non-causal correlation between a spurious textual variable and the label YY can originate from distinctly different mechanisms: a common cause, a selection bias, or a label-generated feature [27]. As these distinct generative processes result in structurally different distributional shifts, investigating how IRM responds to each specific spurious mechanism might help clarify the precise conditions required for its success in NLP. Furthermore, IRM’s core assumption, that spurious correlations must fluctuate across environments, raises questions about the required magnitude of variation and its behavior when the genuine task-relevant signal is degraded.

Optimization dynamics under multi-environment training

Figure 1. Optimization dynamics under multi-environment training. On a binary classification task, ERM exploits a global spurious correlation, while IRM leverages environment boundaries to detect its instability and discard it. (C: Contradiction, E: Entailment).

Our contributions. We provide a causal analysis of when IRM mitigates textual shortcuts. First, § 4.2 distinguishes three shortcut-generating mechanisms, label-generated features, confounding, and selection bias, across causal and anticausal tasks. Second, § 5.2 and § 5.3 quantify how success depends on cross-environment variation and task-signal reliability. Third, § 6 extends the analysis to naturally occurring gender-profession correlations and semantically loaded actor-name shortcuts, revealing an accuracy-invariance trade-off.

Background

Problem Setting: OOD Generalization

At the core of current challenges in NLP lies the issue of robustness to change, as models are rarely deployed under linguistic conditions identical to those encountered during training. To formalize this heterogeneity, we adopt the concept of environment from the invariant learning literature [5] (Peters et al. 2016). Intuitively, an environment corresponds to a distinct data source, such as formal book reviews versus informal tweets, where the underlying task is identical, but the specific vocabulary, style, or local biases differ. Each environment ee represents a specific generative context (such as a particular domain or demographic group) characterized by a joint probability distribution Pe(X,Y)P^{e}(X,Y) over texts XX and labels YY. We denote by Eall\mathcal{E}_{\mathrm{all}} the comprehensive set of all possible environments across which we evaluate a model’s ability to achieve OOD generalization. The goal is to find ff that minimizes the risk Re(f)R^{e}(f) in the worst-case scenario across all possible environments:

min⁡fmax⁡e∈EallRe(f),\min_{f}\max_{e\in\mathcal{E}_{\mathrm{all}}} R^{e}(f),

where Re(f)=E(x,y)∼Pe[ℓ(f(x),y)]R^{e}(f)=\mathbb{E}_{(x,y)\sim P^{e}}[\ell(f(x),y)] represents the expected risk under environment ee for a given loss function ℓ\ell.

Empirical Risk Minimization and Its Limitations

The standard paradigm for predictive learning is ERM, which relies on a strict stationarity assumption: it presumes that the training data is independent and identically distributed (i.i.d.). It assumes that the global training distribution PtrainP_{\mathrm{train}}, which is defined as the mixture of the joint distributions from all training environments e∈Etre\in\mathcal{E}_{\mathrm{tr}}, is strictly identical to the test distribution PtestP_{\mathrm{test}} (representing a target environment etest∉Etre_{\mathrm{test}}\notin\mathcal{E}_{\mathrm{tr}}). In practice, given a subset of training environments Etr⊂Eall\mathcal{E}_{\mathrm{tr}}\subset\mathcal{E}_{\mathrm{all}}, ERM minimizes the average empirical risk RERM(f)R_{\mathrm{ERM}}(f) over a pooled dataset of size nn:

f^ERM=arg min⁡f 1n∑i=1nℓ(f(xi),yi)(1)\hat{f}_{\mathrm{ERM}}=\underset{f}{\operatorname{arg\,min}}\ \frac{1}{n}\sum_{i=1}^{n}\ell(f(x_i),y_i) \tag*{(1)}

By blindly minimizing this pooled loss, the model exploits all statistical correlations globally present in PtrainP_{\mathrm{train}}. This is the core vulnerability of ERM: it fails to distinguish between robust features and spurious correlations. In an OOD scenario where Ptrain≠PtestP_{\mathrm{train}}\ne P_{\mathrm{test}}, these shortcuts vanish, inevitably causing the model’s performance to collapse.

Invariant Risk Minimization

To address this generalization failure, IRM leverages the distributional diversity across the available training environments Etr\mathcal{E}_{\mathrm{tr}}. Within this multienvironment framework, the fundamental intuition is to extract a unique feature representation Φ\Phi such that a single classifier ww built on top of it remains simultaneously optimal across all contexts. The explicit role of Φ\Phi is to capture exclusively the stable correlations that persist across environments. By enforcing this strict invariance constraint, the model is compelled to discard environment-specific spurious correlations and rely solely on these robust features. Formally, IRM is framed as a bi-level optimization problem:

min⁡Φ,w∑e∈EtrRe(w∘Φ)s.t.w∈arg⁡min⁡w~Re(w~∘Φ), ∀e∈Etr.(2)\begin{aligned} \min_{\Phi,w}\quad&\sum_{e \in\mathcal{E}_{\mathrm{tr}}} R^{e}(w \circ\Phi)\\ \text{s.t.}\quad&w \in\arg\min_{\widetilde{w}} R^{e}(\widetilde{w} \circ\Phi),\ \forall e \in\mathcal{E}_{\mathrm{tr}}. \tag*{(2)} \end{aligned}

Because this is an intractable bilevel optimization problem, a practical relaxation known as IRMv1 is typically used ([5, 10, 12]). In IRMv1, Φ\Phi is parameterized to directly output predictive logits, while the classifier ww is reduced to a scalar dummy variable fixed at w=1w = 1. Invariance is encouraged by penalizing the gradient of each environment-specific risk with respect to this dummy classifier:

min⁡Φ∑e∈Etr[Re(Φ)+λ∥∇w∣w=1Re(w⋅Φ)∥2].(3)\min_{\Phi}\sum_{e \in\mathcal{E}_{\mathrm{tr}}}\left[R^{e}(\Phi)+\lambda\left\lVert\nabla_{w|w=1}R^{e}(w\cdot\Phi)\right\rVert^{2}\right]. \tag*{(3)}

The dummy classifier ww is not a trainable model component. Gradients of the penalty are propagated through Φ\Phi, whose parameters are optimized. The multiplier λ\lambda acts as a hyperparameter controlling the trade-off between standard empirical risk minimization and the invariance of the representation (enforced via the gradient penalty). We provide a sensitivity analysis of λ\lambda in Appendix § 9, where we examine its impact on model performance. Crucially, the success of IRM relies on the assumption that spurious correlations vary across Etr\mathcal{E}_{\mathrm{tr}}, while task-relevant predictive relationships remain invariant. This dependency motivates our environment construction strategy in § 4, where we deliberately generate training sets by varying the strength of spurious correlations across environments, thereby creating the necessary heterogeneity to rigorously evaluate IRM’s invariance.

Related Work

Applications of invariant learning in NLP. Applications of invariant learning to NLP have produced mixed results. In the WILDS benchmark, Koh et al. [22] evaluated IRM alongside several other methods for improving robustness to naturally occurring domain and subpopulation shifts, including NLP tasks, but found no consistent advantage over standard training. Focusing more directly on natural language inference, Dranker et al. [12] similarly reported limited benefits when natural MNLI genres were treated as environments. However, IRM performed more favorably when environments were explicitly constructed to differ in the prevalence of a known bias, emphasizing the importance of environment definition. Other studies have adapted invariant learning more directly to NLP-specific objectives. Peyrard et al. (2022) introduced an invariant language-modeling objective and obtained clearer benefits in controlled bias-removal experiments than across broad, heterogeneous corpora. For demographic bias mitigation, Zhou et al. (2023) proposed Causal-Debias, which identifies bias-relevant factors as non-causal and label-relevant factors as causal, intervenes on the former across demographic groups, and applies an invariant learning loss during downstream fine-tuning. Their experiments show that this task-aware formulation can reduce stereotypical associations while preserving downstream performance. Taken together, these studies suggest that invariant learning is most effective when the environments or interventions are explicitly designed to expose the targeted bias. Our work complements these approaches by studying whether IRM’s behavior depends on the mechanism that generates the spurious correlation and by extending the evaluation from controlled synthetic shortcuts to naturally occurring and semantically loaded signals.

Alternative approaches to shortcut mitigation. Other mitigation methods rely on different signals to identify shortcut-conflicting examples. Group DRO minimizes the worst-group risk but requires annotations for the relevant subpopulations ((Sagawa et al., 2020)). JTT removes this requirement by upweighting examples misclassified by an initial ERM model ([23]), whereas LfF uses a deliberately biased model and assumes that spurious features are easier to learn than task-relevant ones ([26]). Bias-model approaches similarly reweight examples according to their compatibility with a known superficial heuristic (Utama et al., 2020). IRM uses a distinct source of supervision: rather than identifying biased examples directly, it suppresses predictive relationships that fail to support a common classifier across environments. It therefore does not require the shortcut to be explicitly annotated or easier to learn, but it does require the environment partition to expose variation in its association with the target.

Experiment Design

Model Architecture

All experiments share the same two-component architecture: a frozen DistilBERT encoder Sanh et al. (2019) ΦBERT:X→R768\Phi_{\mathrm{BERT}}:\mathcal{X}\to\mathbb{R}^{768}, which extracts fixed sentence-level embeddings via masked mean pooling, followed by a single trainable linear head Wθ∈Rdout×768W_{\theta}\in\mathbb{R}^{d_{\mathrm{out}}\times768}, where dout=1d_{\mathrm{out}}=1 for binary classification and dout=Cd_{\mathrm{out}}=C for CC-class classification. To connect this architecture with the IRMv1 notation introduced in § 2.3, we define the complete logit-producing map as Φθ(x)=WθΦBERT(x)\Phi_{\theta}(x)=W_{\theta}\Phi_{\mathrm{BERT}}(x). Thus, Φθ\Phi_{\theta} plays the role of the trainable classifier Φ\Phi in the IRMv1 objective, even though the pretrained encoder ΦBERT\Phi_{\mathrm{BERT}} itself remains frozen. Its trainable parameters θ\theta correspond exclusively to the linear head WθW_{\theta}. ERM and IRMv1 consequently optimize exactly the same model parameters WθW_{\theta} and differ only in their training objective. ERM minimizes the standard classification loss over the pooled training examples, whereas IRMv1 retains the two training environments {e1,e2}\{e_1,e_2\} and optimizes the sum of the environment-specific risks augmented by the invariance penalty from Equation (3).

Keeping ΦBERT\Phi_{\mathrm{BERT}} frozen is a deliberate design choice. Because WθW_{\theta} constitutes the only trainable component under both ERM and IRMv1, the two methods are compared within the same fixed pretrained representation space and with an identical set of trainable parameters. This places our analysis in a controlled linear setting, in which any behavioral difference between ERM and IRMv1 can be attributed to the optimization objective rather than to encoder fine-tuning dynamics or differences in model capacity. This design therefore isolates the effect of the invariance objective, which is the primary object of study.

Environment Construction

Controlled shortcut injection makes it possible to manipulate a feature’s correlation with the label

and directly measure the consequences of relying on it. Previous work has used this approach to study shortcut formation and evaluate model explanations [7] (Pezeshkpour et al. 2022). Following the environment-based formulation of IRM [5], we construct two training environments in which a designated shortcut remains predictive but varies in strength, together with an OOD test environment in which its correlation with the label is inverted. Unlike prior protocols that treat injected artifacts as a single class of spurious correlations, we organize our environments according to the process generating the shortcut–label correlation. Following the causal terminology of Veitch et al. (2021), we distinguish label-generated features, confounding, and selection bias, using graphical representations inspired by their framework. For each mechanism, we vary only the structural equation or sampling component responsible for the shortcut while preserving the task-relevant relationship. Table 1 summarizes the shared environment parameters, while Figure 2, Figure 3, and Figure 4 illustrate the corresponding structures.

MechanismParam.e1e_1e2e_2OOD
Label-generatedpcp_c0.700.900.00
Confoundingaa0.010.101.00
Selection biaspsp_s0.700.900.00

Table 1. Environment parameters shared across datasets. The OOD environment inverts the training-time shortcut. Parameter definitions and dataset-specific shortcut realizations are provided in Appendix § 14.

Causal and anti-causal settings for label-generated features

Figure 2. Label-Generated Feature. Spurious mechanism: Y→Z→XY⊥Y \to Z \to X^{\perp}_{Y}. The red box indicates the observable text XX.

Causal and anti-causal settings for confounding

Figure 3. Confounding. Backdoor path via unobserved UU.

Causal and anti-causal settings for selection bias

Figure 4. Selection Bias. Conditioned on selection collider SS.

Label-Generated Feature (Figure 2). In this mechanism, Y→Z→XY⊥Y\to Z\to X^{\perp}_{Y}. The target label YY generates a latent concept ZZ, which in turn produces the observable spurious feature XY⊥X^{\perp}_{Y}. Mirroring the classic Colored MNIST setup Arjovsky et al. [5], this label-dependent process can make the shortcut more predictive than the genuine task-relevant textual signal.

We implement this mechanism by inserting a class-associated token before neutral function words2 throughout the text. The parameter pc(e)=P(e)(Z=Y∣Y)p_{c}^{(e)}=P^{(e)}(Z=Y\mid Y) controls the probability that the injected token agrees with the label. The OOD intervention reverses this correlation. To prevent the task-relevant signal from trivially dominating, we apply label noise at rate ϵ=0.2\epsilon=0.2 before token injection.

Confounding (Figure 3). An unobserved confounder UU influences both the target YY and a latent concept ZZ, opening the backdoor path Y←U→Z→XY⊥Y \leftarrow U \to Z \to X^{\perp}_{Y}. This induces a non-causal statistical dependency that models can exploit as a predictive shortcut. The influence of UU on YY remains fixed across environments, while only the fidelity of the proxy ZZ varies. This preserves the invariance conditions required by IRM, see Appendices B and C.

Experimentally, we sample a binary confounder U∼Ber⁡(0.5)U \sim\operatorname{Ber}(0.5), which influences YY through a fixed, environment-independent mechanism. Its environment-dependent proxy is generated as Z(e)=U⊕Ber⁡(a(e))Z^{(e)} = U \oplus\operatorname{Ber}(a^{(e)}), where ⊕\oplus denotes XOR. The parameter a(e)a^{(e)} is the probability of flipping the value of UU, so smaller values produce a more faithful shortcut. The OOD intervention completely reverses the proxy while leaving the relationship between UU and YY unchanged. The resulting concept Z(e)Z^{(e)} determines the injected textual feature.

Selection Bias (Figure 4). An unobserved selection mechanism SS is influenced by both YY and a latent feature ZZ, forming the collider Y→S←ZY \to S \leftarrow Z. The feature ZZ also generates the observable component XY⊥X^{\perp}_{Y}. Training only on examples satisfying S=1S = 1 induces a non-causal correlation between YY and XY⊥X^{\perp}_{Y}. Unlike the previous mechanisms, selection does not change their underlying values, but biases their observed co-occurrence frequencies.

We simulate selection bias by subsampling each dataset according to the alignment between YY and a dataset-specific latent feature ZZ. Examples for which ZZ heuristically agrees with YY are called aligned, whereas the remaining examples are misaligned. The parameter ps(e)=P(e)(aligned∣S=1)p_{s}^{(e)} = P^{(e)}(\text{aligned} \mid S = 1) controls the proportion of aligned examples retained in environment ee. The OOD test set contains only misaligned examples, making the training-time correlation systematically misleading. The dataset-specific definitions of ZZ and alignment are provided in Appendix F.

Datasets

We evaluate the three shortcut-generating mechanisms on three balanced text-classification benchmarks covering causal and anti-causal tasks. Each corpus is partitioned into 80% training, 10% in-distribution validation, and 10% OOD test data. The training partition is divided equally between the two environments defined in § 4.2.

Amazon Books Reviews (Hou et al., [18]) (Causal, X→YX \to Y): We predict whether a book review is unhelpful (Y=0Y = 0) or helpful (Y=1Y = 1) based on its text and user votes. The balanced corpus contains 100,000 reviews, including 80,000 training examples. We treat this task as causal because the review’s informativeness and quality influence its perceived helpfulness.

AG News (Zhang et al., 2015) (Causal, X→YX \to Y): We classify news articles into World, Sports, Business, or Sci/Tech (Y∈{0,1,2,3}Y \in\{0,1,2,3\}). The balanced corpus contains 127,600 articles, including 101,460 training examples. We treat this task as causal because the linguistic content of an article determines its thematic category.

IMDB Genres ([24]) (Anti-causal, Y→XY \to X): We classify movie plot descriptions as Thriller (Y=0Y = 0) or Romance (Y=1Y = 1). The balanced corpus contains 87,533 descriptions, including 70,027 training examples. We treat the task as anti-causal because the movie genre acts as a latent generative variable that influences the description’s vocabulary, style, and thematic content. Although IRM is often motivated through causal prediction, it can also identify invariant predictive relationships in anti-causal settings when class proportions remain stable across environments, as ensured by our balanced construction. Appendix D provides the formal argument and discusses the limitation under label shift.

Results

We evaluate the ability of IRM to identify robust predictors across nine experimental configurations (three spurious correlation mechanisms applied to three datasets, as summarized in Table 1). The aim is to quantify the robustness of invariance against the structural nature of the misleading correlation and environmental variability.

ID and OOD Performance

Table 2 and Table 3 report, respectively, the in-distribution (ID) validation accuracy and the OOD test accuracy across all configurations.

Spurious MechanismAmazon (Causal)AG News (Causal)IMDB (Anti-causal)
Label-Generated0.814±0.001/0.758±0.0080.814 \pm0.001 / 0.758 \pm0.008<br>(−0.056-0.056)0.810±0.000/0.769±0.0040.810 \pm0.000 / 0.769 \pm0.004<br>(−0.041-0.041)0.812±0.002/0.790±0.0070.812 \pm0.002 / 0.790 \pm0.007<br>(−0.022-0.022)
Confounding0.869±0.005/0.833±0.0140.869 \pm0.005 / 0.833 \pm0.014<br>(−0.036-0.036)0.862±0.003/0.745±0.0020.862 \pm0.003 / 0.745 \pm0.002<br>(−0.117-0.117)0.740±0.002/0.718±0.0020.740 \pm0.002 / 0.718 \pm0.002<br>(−0.022-0.022)
Selection Bias0.843±0.003/0.788±0.0090.843 \pm0.003 / 0.788 \pm0.009<br>(−0.055-0.055)0.926±0.001/0.881±0.0040.926 \pm0.001 / 0.881 \pm0.004<br>(−0.045-0.045)0.794±0.003/0.716±0.0050.794 \pm0.003 / 0.716 \pm0.005<br>(−0.078-0.078)

Table 2. In-distribution (ID) validation accuracy for ERM and IRM.

Spurious MechanismAmazon (Causal)AG News (Causal)IMDB (Anti-causal)
Label-Generated0.117±0.003/0.672±0.0070.117 \pm0.003 / 0.672 \pm0.007<br>(+0.555+0.555)0.417±0.011/0.798±0.0070.417 \pm0.011 / 0.798 \pm0.007<br>(+0.381+0.381)0.147±0.009/0.728±0.0080.147 \pm0.009 / 0.728 \pm0.008<br>(+0.581+0.581)
Confounding0.501±0.006/0.638±0.0320.501 \pm0.006 / 0.638 \pm0.032<br>(+0.137+0.137)0.244±0.010/0.699±0.0140.244 \pm0.010 / 0.699 \pm0.014<br>(+0.455+0.455)0.622±0.005/0.691±0.0120.622 \pm0.005 / 0.691 \pm0.012<br>(+0.069+0.069)
Selection Bias0.544±0.005/0.721±0.0040.544 \pm0.005 / 0.721 \pm0.004<br>(+0.177+0.177)0.756±0.008/0.836±0.0100.756 \pm0.008 / 0.836 \pm0.010<br>(+0.080+0.080)0.209±0.006/0.701±0.0250.209 \pm0.006 / 0.701 \pm0.025<br>(+0.492+0.492)

Table 3. Out-of-distribution (OOD) test accuracy for ERM and IRM.

As expected in Table 2, ERM achieves higher ID accuracy in all configurations, with IRM incurring losses of 2.2 to 11.7 percentage points. This reflects the cost of discarding unstable features that remain predictive within the training distribution.

Under shortcut inversion, IRM outperforms ERM in all nine dataset–mechanism configurations, with gains ranging from 6.9 to 58.1 percentage points. The improvement spans label-generated features, confounding, and selection bias, suggesting that shortcut rejection does not depend on a single generating mechanism. It also holds on the anti-causal IMDB task under the stable class proportions imposed by our balanced construction, consistent with the conditions discussed in Appendix D.

Sensitivity Analysis

To identify the minimal conditions for IRM to succeed, we varied the statistical disparity between training environments, defined as the gap in the strength of the spurious correlation across Etr\mathcal{E}_{\mathrm{tr}} ([10]). This disparity is the fundamental requirement for the invariance penalty: it creates the distributional instability that allows the model to distinguish unreliable shortcuts from stable causal correlation. Concretely, for a target gap Δ\Delta, environments are constructed symmetrically around a fixed center cc: p1=c−Δ/2p_1 = c - \Delta/2 and p2=c+Δ/2p_2 = c + \Delta/2. For Label-Generated and Selection Bias, we fix c=0.85c = 0.85 so that both environments maintain a globally strong spurious signal; only their differential varies (e.g., Δ=0.20\Delta= 0.20 yields p1=0.75p_1 = 0.75, p2=0.95p_2 = 0.95). For Confounding, the center is c=0.05c = 0.05 on the proxy-noise parameter aa, with Δ∈[0,0.18]\Delta\in[0, 0.18]. At Δ=0\Delta= 0, the two environments are statistically identical and IRM cannot detect any correlation instability, degenerating to ERM.

Our results (Figure 5) reveal that IRM can leverage even the slightest statistical disparity. While a minimal gap is often sufficient for the invariance penalty to begin discarding the misleading correlation in favor of a stable task-relevant signal, we observe that IRM’s OOD performance tends to increase as the correlation gap between environments widens. This sensitivity is an encouraging sign for real-world applications where domain differences may be subtle.

Figure 5. Sensitivity analysis. OOD accuracy as a function of the correlation gap for label-generated features (top-left), confounding (top-right), and selection bias (bottom-center).

Robustness to Label Noise

We investigate the models’ behavior as the reliability of the task-relevant signal is progressively degraded. By gradually increasing the label noise rate ϵ\epsilon, we artificially weaken the predictive power of the causal features relative to the spurious ones. This experiment is designed to determine whether a model continues to favor invariant features as the task-relevant signal becomes less reliable.

As shown in Figure 6, increasing ϵ\epsilon progressively weakens the causal signal while leaving the shortcut configuration unchanged, making the spurious signal relatively more attractive for minimizing training loss. ERM succumbs to this bias. As the genuine signal fades, the model shifts its reliance to the shortcut, leading to catastrophic performance degradation at test time when the correlation is inverted. Conversely, IRM remains largely insensitive to label noise. IRM does not select features based on their relative predictive convenience, but strictly based on their structural stability. By rejecting correlations that vary across environments, IRM maintains its focus on the causal features, preferring a noisy yet invariant signal over a cleaner but unstable shortcut, even when the latter offers lower training loss.

Noise-sweep analysis across Amazon Books, AG News, and IMDB Genres

Figure 6. Noise-sweep analysis. OOD accuracy as a function of label noise. Rows correspond to Amazon Books (top), AG News (middle), and IMDB Genres (bottom). Columns correspond to label-generated features (left) and selection bias (right).

Beyond Synthetic Shortcuts

The controlled experiments in § 4 isolate the origin and strength of each spurious correlation. We now consider two less controlled settings. Bias in Bios ([11]) contains a naturally occurring association between gender and profession, whereas ActorCorr ([13]) introduces real entity names whose representations already carry semantic information from pretraining. These experiments test whether the behavior observed with neutral synthetic artifacts extends to more realistic shortcuts.

Naturally Occurring Gender Correlations

We use Bias in Bios, a corpus of 397,000 biographies annotated with profession and binary gender. We construct binary tasks pairing a male-typical profession with a female-typical profession and resample two training environments such that P(gender=canonical(y)∣Y=y)P(\text{gender} = \text{canonical}(y) \mid Y = y) equals 0.99 and 0.80, respectively. This naturally occurring correlation is fully inverted at test time. We add a label-noise rate of ϵ=0.25\epsilon= 0.25 and train the same frozen DistilBERT classifier as in the controlled experiments. To examine whether semantic separability affects shortcut reliance, we compare the five semantically closest and the five most semantically distant eligible profession pairs. Each training environment contains at least 1,000 examples, and results are averaged over three seeds. Further details on environment construction, pair selection, and semantic-distance estimation are provided in Appendix § 15.

Across the ten profession pairs, IRM improves mean OOD accuracy from 43.35% to 78.78%, corresponding to an average gain of 35.44 percentage points. The improvement is positive for every evaluated pair. The results are consistent with greater shortcut reliance when professions are semantically similar. For the five semantically closest pairs, ERM and IRM reach average OOD accuracies of 28.3% and 72.3%, respectively, yielding a 43.9 percentage-point gain.

For the five most semantically distant pairs, they reach 58.4% and 85.3%, yielding a smaller 26.9 percentage-point gain. As expected, when profession pairs are semantically close, profession-specific cues are less discriminative, making gender a comparatively easier and more attractive signal for separating the classes. For semantically distant pairs, other textual features already provide strong predictive cues, reducing the relative usefulness of gender. IRM’s average advantage is therefore 17.0 percentage points larger for semantically close pairs, primarily because ERM is less robust when profession-specific representations are harder to separate.

Semantically Loaded Entity Shortcuts

We next evaluate ActorCorr, which introduces actor names into IMDB reviews as semantically loaded sentiment shortcuts. At a fixed injection frequency of 5%5\%, Morgan Freeman is associated with positive sentiment and Adam Sandler with negative sentiment. We construct two training environments with shortcut purities π(e)∈{1.0,0.85}\pi^{(e)} \in\{1.0, 0.85\}, where π(e)\pi^{(e)} is the probability that the injected actor agrees with the sentiment label. Unlike the neutral tokens used in our controlled experiments, these names may carry associations inherited from pretraining. Each test review is evaluated under three conditions: clean, corresponding to the original unmodified review; correlated, with an actor agreeing with the label; and anti-correlated, with an actor associated with the opposite label.

We report the Anti-Correlated Accuracy Change (ACAC; [13]), defined as the signed average of the class-specific accuracy difference between the original (clean) and anti-correlated conditions:

ACAC=12∑y∈{pos,neg}(Accclean(y)−Accanti(y)).(4)\mathrm{ACAC} = \frac{1}{2} \sum_{y \in\{\mathrm{pos},\mathrm{neg}\}} \left(\mathrm{Acc}_{\mathrm{clean}}^{(y)} - \mathrm{Acc}_{\mathrm{anti}}^{(y)}\right). \tag*{(4)}

Higher positive values indicate greater sensitivity to misleading actor cues. Because ACAC is signed, class-specific effects may partially cancel (we analyze this in Appendix § 16).

Table 5 shows a clear trade-off between OOD performance and shortcut invariance. ERM achieves an OOD accuracy of 0.739±0.0040.739 \pm0.004 with an ACAC of 0.186±0.0020.186 \pm0.002. With λ=10\lambda= 10, IRMv1 slightly improves OOD accuracy to 0.745±0.0070.745 \pm0.007 while reducing ACAC to 0.146±0.0020.146 \pm0.002. Increasing the penalty to λ=100\lambda= 100 further lowers ACAC to 0.049±0.0020.049 \pm0.002, but OOD accuracy drops to 0.704±0.0080.704 \pm0.008. Thus, larger penalties reduce sensitivity to the spurious actor cue but can also hurt predictive performance, requiring a trade-off between robustness and OOD accuracy. The low ACAC at λ=100\lambda= 100 should nevertheless be interpreted cautiously because of partial class-specific cancellation (Appendix § 16).

Modelλ\lambdaOOD ↑\uparrowACAC ↓\downarrow
ERM–0.739±0.0040.739 \pm0.0040.186±0.0020.186 \pm0.002
IRM100.745±0.0070.745 \pm0.0070.146±0.0020.146 \pm0.002
IRM1000.704±0.0080.704 \pm0.0080.049±0.0020.049 \pm0.002

Table 5. ActorCorr aggregate results over three seeds. IRM with λ=10\lambda= 10 achieves the highest pooled OOD accuracy, whereas IRM with λ=100\lambda= 100 achieves the lowest signed ACAC.

Table 6 highlights the contrasting behavior of ERM and IRMv1 (λ=100\lambda= 100) across evaluation conditions. ERM relies heavily on the actor cue: its accuracy rises to 0.8700.870 when the cue is correlated with the label but falls to 0.5740.574 when it becomes misleading. In contrast, IRMv1 is less sensitive to this shift, with accuracies of 0.7260.726 and 0.6710.671 in the correlated and anti-correlated conditions, respectively, reducing the condition spread from 0.2960.296 to 0.0550.055.

MetricERMIRM
ID accuracy0.755±0.0020.755 \pm0.0020.733±0.0030.733 \pm0.003
Pooled OOD accuracy0.739±0.0040.739 \pm0.0040.704±0.0080.704 \pm0.008
Clean accuracy0.7590.7590.7160.716
Correlated accuracy0.8700.8700.7260.726
Anti-correlated accuracy0.5740.5740.6710.671
Spread ↓\downarrow0.2960.2960.0550.055
ACAC ↓\downarrow0.186±0.0020.186 \pm0.0020.049±0.0020.049 \pm0.002

Table 6. ActorCorr condition-level results over three seeds for ERM and IRMv1 with λ=100\lambda= 100. Spread is the difference between the highest and lowest condition-level accuracies.

This robustness comes at the cost of lower clean and correlated accuracy, illustrating how invariant learning can suppress a semantically meaningful shortcut while sacrificing some predictive performance. The full penalty sweep and class-specific results are reported in Appendix § 16.

Conclusion

We systematically evaluated IRM across label-generated features, confounding, and selection bias. Under controlled shortcut shifts, IRM consistently improves OOD robustness across causal tasks and succeeds in anti-causal settings with stable class prevalence. As the task-relevant signal weakens, IRM also remains more robust than ERM by favoring invariant predictors. Beyond controlled shortcuts, IRM improves OOD accuracy across all Bias in Bios profession pairs, with larger average gains for semantically similar professions, although semantic distance does not fully explain shortcut reliance. On ActorCorr, IRM reduces sensitivity to semantically loaded actor cues, but reveals an accuracy–invariance trade-off. Overall, IRM’s effectiveness depends less on the shortcut’s structural origin than on whether training environments expose its instability while preserving a stable task-relevant mechanism. These findings also show the importance of targeted interventions and class-specific metrics, as pooled OOD accuracy may conceal shortcut reliance. Extending this analysis to naturally occurring environments and fully fine-tuned language models remains an important direction for future work.

Limitations

A first limitation concerns the controlled nature of our spurious mechanisms. Selection bias differs fundamentally from the other mechanisms considered here: it arises at the observation stage through conditioning on a collider, whereas confounding and label-generated features can be part of the underlying data-generating process itself. To isolate these mechanisms while retaining real-world text semantics, we introduce the corresponding shortcuts post hoc through controlled token injection. This design enables precise manipulation of the relevant causal relationships, but does not capture spurious correlations that emerge organically in natural text, such as environment-dependent shifts in style, lexical choice, or discourse. Our injected cues should therefore be viewed as controlled proxies for more diffuse real-world shortcuts, whose causal sources are substantially harder to isolate.

A second limitation concerns the scope of IRM theory. Although IRM has been widely studied in classification settings ([5, 3, 10, 20]), its original theoretical guarantees were developed primarily for regression. Extending invariance principles to classification remains an active research problem: subsequent work provides guarantees under more specific assumptions ([2]), while their applicability to modern Transformer-based models remains less well understood ((Peyrard et al., 2022)). A third limitation is that we freeze the pretrained encoder and train only a linear classification head. This choice deliberately places ERM and IRMv1 in the same fixed representation space, allowing us to isolate the effect of the optimization objective, but it does not reflect the fully fine-tuned setting commonly used with language models. This is particularly relevant because IRM can behave differently in highly overparameterized models, where additional capacity may permit solutions that satisfy the invariance penalty without yielding the intended OOD generalization benefits ([16] (Rosenfeld et al. 2021)). Extending the present analysis to fully fine-tuned Transformers therefore remains an important direction for future work. Finally, our study is designed to compare causal shortcut mechanisms under controlled interventions rather than to benchmark IRM against the broader bias-mitigation literature. Evaluating the same mechanisms in less controlled real-world settings would enable direct comparisons with representative alternatives such as Group DRO ((Sagawa et al., 2020)), JTT ([23]), Learning from Failure (LfF) ([26]), and bias-model-based reweighting ((Utama et al., 2020)). Such comparisons would help clarify when the explicit environment supervision used by IRM provides advantages over methods based on group annotations or on identifying biased examples from model behavior.

Ethical Considerations

We exclusively utilize publicly available benchmarks in strict accordance with their original licenses for research purposes. Our methodology involves the artificial synthesis of environments through token injection; this process does not involve the collection of new personally identifiable information or the use of private user data. To minimize the environmental footprint of our extensive sensitivity analyses, we conducted all experiments using DistilBERT ((Sanh et al., 2019)), a smaller and more energy-efficient architecture than standard large-scale models.

Model Architecture and Experimental Setup

Before detailing our environmental synthesis framework, we formally define the predictive architecture shared by ERM and IRMv1 and clarify its correspondence with the notation introduced in § 2.3. Let X\mathcal{X} denote the input text space and Y\mathcal{Y} the downstream label space.

Encoder Architecture and Text Representation. All experiments use a frozen DistilBERT encoder ΦBERT:X→R768\Phi_{\mathrm{BERT}} : \mathcal{X} \to\mathbb{R}^{768}. Specifically, we use DistilBERT (distilbert-base-uncased) (Sanh et al., 2019), a knowledge-distilled variant of BERT-base with 6 Transformer layers, 12 attention heads, and approximately 66 million parameters. DistilBERT retains 97% of BERT’s language understanding capabilities while being 40% smaller and 60% faster, making it well suited to the extensive sensitivity analyses conducted in this study. Texts are tokenized using the DistilBERT WordPiece tokenizer with a maximum sequence length of 256 tokens for AG News (Zhang et al., 2015), and 512 tokens for IMDB Genres and Amazon Books. For any input sequence x∈Xx \in\mathcal{X}, the encoder produces a fixed sentence-level representation z(x)=ΦBERT(x)∈R768z(x) = \Phi_{\mathrm{BERT}}(x) \in\mathbb{R}^{768}, obtained by masked mean pooling over the final hidden states of all non-padding tokens. The parameters of ΦBERT\Phi_{\mathrm{BERT}} remain frozen throughout all experiments.

Classification Head and IRMv1 Parameterization. A single trainable linear head Wθ∈Rdout×768W_{\theta} \in\mathbb{R}^{d_{\mathrm{out} \times768}} is placed on top of the frozen representation, with dout=1d_{\mathrm{out}} = 1 for the binary Amazon Books and IMDB Genres tasks and dout=4d_{\mathrm{out}} = 4 for AG News. The resulting predictive logits are Φθ(x)=WθΦBERT(x)\Phi_{\theta}(x) = W_{\theta}\Phi_{\mathrm{BERT}}(x). We use Φθ\Phi_{\theta} deliberately to match the notation of IRMv1. In (3), Φ\Phi denotes the parameterized mapping that directly outputs predictive logits. In our architecture, this mapping corresponds to the composition Wθ∘ΦBERTW_{\theta} \circ\Phi_{\mathrm{BERT}}. Although ΦBERT\Phi_{\mathrm{BERT}} is fixed, Φθ\Phi_{\theta} remains trainable through the parameters θ\theta of WθW_{\theta}. Importantly, the matrix WθW_{\theta} should not be confused with the scalar classifier ww appearing in the IRMv1 objective. The former is the actual trainable classification head, whereas the latter is the dummy scalar variable at which the invariance penalty is evaluated:

∥∇w∣w=1Re(w⋅Φθ)∥2.(5)\left\lVert\left.\nabla_{w}\right|_{w=1} R^{e}(w \cdot\Phi_{\theta}) \right\rVert^{2}. \tag*{(5)}

The dummy classifier ww is not an independently optimized model component; gradients of this penalty are propagated through Φθ\Phi_{\theta} and therefore update WθW_{\theta}. For the binary Amazon Books and IMDB Genres tasks, Φθ(x)∈R\Phi_{\theta}(x) \in\mathbb{R} and we use binary cross-entropy (BCE) with logits, with predictions obtained by thresholding the logit at zero. For AG News, Φθ(x)∈R4\Phi_{\theta}(x) \in\mathbb{R}^{4} and we use standard multiclass cross-entropy loss.

Optimization and Hardware. Both ERM and IRM heads are trained using the Adam optimizer [21] with hyperparameters β1=0.9\beta_{1} = 0.9, β2=0.999\beta_{2} = 0.999, ϵ=10−8\epsilon= 10^{-8}, and a weight decay of 10−410^{-4}. We use a batch size of 256. Each model is trained for 25,000 gradient steps. The learning rate and IRM penalty weight λ\lambda are kept identical for both ERM and IRM within each experimental configuration to rigorously isolate the effect of the objective function. All reported results are averaged over three random seeds (0, 1, 2). Finally, given the compact size of our frozen architecture, all experiments were conducted efficiently using a single NVIDIA RTX A5000 GPU with 24 GB of VRAM.

Hyperparameter Selection: IRM Penalty Weight λ\lambda. The penalty coefficient λ\lambda in IRMv1 (Equation 3) was selected via a grid search over λ∈{50,75,100,125}\lambda\in\{50, 75, 100, 125\}, covering all dataset-mechanism combinations (3 datasets ×\times 3 mechanisms ×\times 4 noise levels ×\times 2 correlation strengths, yielding 48 cells), with all other conditions held fixed (same seed, 25,000 gradient steps, learning rate 10−410^{-4}). Figure 7 shows the corresponding accuracy curves as a function of label noise, while Table 7 reports the underlying OOD accuracies. All IRM variants consistently outperform ERM, and performance is broadly robust to the exact choice of λ\lambda; λ=100\lambda= 100 achieves the best or near-best OOD accuracy in 31 out of 48 cells and is therefore fixed as the default for all main-paper experiments.

Nine-panel plot of OOD accuracy as a function of label noise across datasets and mechanisms

Figure 7. OOD accuracy as a function of label noise, for each λ∈{50,75,100,125}\lambda\in\{50, 75, 100, 125\} (solid colored lines) and ERM (dashed red). Each panel corresponds to one dataset–mechanism pair. All IRM variants consistently outperform ERM. Performance differences across λ\lambda values are modest, confirming robustness of the chosen λ=100\lambda= 100.

MechanismModelAG News: Label-noise rate ϵ\epsilon 0.00AG News: Label-noise rate ϵ\epsilon 0.10AG News: Label-noise rate ϵ\epsilon 0.20AG News: Label-noise rate ϵ\epsilon 0.25Amazon Books: Label-noise rate ϵ\epsilon 0.00Amazon Books: Label-noise rate ϵ\epsilon 0.10Amazon Books: Label-noise rate ϵ\epsilon 0.20Amazon Books: Label-noise rate ϵ\epsilon 0.25IMDB Genres: Label-noise rate ϵ\epsilon 0.00IMDB Genres: Label-noise rate ϵ\epsilon 0.10IMDB Genres: Label-noise rate ϵ\epsilon 0.20IMDB Genres: Label-noise rate ϵ\epsilon 0.25
ConfoundingERM0.8750.8510.8140.7840.7840.7770.7520.7380.8130.8070.7960.786
ConfoundingIRM (λ=50\lambda= 50)0.8450.8190.7830.7650.7530.7440.7230.7100.8040.7940.7720.762
ConfoundingIRM (λ=75\lambda= 75)0.8370.8050.7780.7630.7440.7360.7230.7110.7950.7840.7630.753
ConfoundingIRM (λ=100\lambda= 100)0.8290.7970.7700.7610.7370.7300.7230.7100.7790.7760.7550.748
ConfoundingIRM (λ=125\lambda= 125)0.7300.7860.7810.7740.7280.7240.7170.7080.7160.7530.7370.731
Label-GeneratedERM0.8070.6450.4100.3090.4120.2480.1120.0610.5160.3500.1490.075
Label-GeneratedIRM (λ=50\lambda= 50)0.7980.7590.7590.7660.6500.6400.6350.6360.6800.6740.6850.683
Label-GeneratedIRM (λ=75\lambda= 75)0.8090.7720.7820.7840.6690.6620.6600.6580.7080.7000.7160.718
Label-GeneratedIRM (λ=100\lambda= 100)0.7330.7820.8020.8050.6760.6710.6720.6720.6850.7160.7330.738
Label-GeneratedIRM (λ=125\lambda= 125)0.6770.7680.7710.8030.6800.6800.6780.6860.6360.6590.7410.747
SelectionERM0.7540.5540.4220.3660.5550.4510.3020.2730.5420.3840.2000.126
SelectionIRM (λ=50\lambda= 50)0.8300.8040.7910.6980.6820.6460.6560.6140.6780.6440.6250.625
SelectionIRM (λ=75\lambda= 75)0.8340.8070.8060.7550.6960.6670.6830.6470.6910.6670.6560.660
SelectionIRM (λ=100\lambda= 100)0.8310.8150.7970.7790.7110.6790.7050.6730.7070.7040.6770.685
SelectionIRM (λ=125\lambda= 125)0.8240.8120.6120.7860.7250.6930.7140.6860.6900.7170.6910.692

Table 7. Hyperparameter search results. Mean final OOD accuracy for IRM penalty values λ∈{50,75,100,125}\lambda\in\{50, 75, 100, 125\} across label-noise rates ϵ∈{0.00,0.10,0.20,0.25}\epsilon\in\{0.00, 0.10, 0.20, 0.25\}. Results are averaged over spurious-correlation levels. Bold indicates the best IRM result for each dataset, mechanism, and noise configuration.

Structural Equation Models and the Nature of Environments

In IRM theory, the algorithm exploits natural datasets collected from distinct temporal or spatial contexts to identify invariant correlations. However, since we synthesize our own environments by injecting misleading correlations, it is imperative to demonstrate the scientific validity of this procedure. This justification relies on the formal framework of Structural Equation Models (SEM).

Definition B.1 (SEM). An SEM C:=(S,N)\mathcal{C := (S, N)} governing a random vector X=(X1,…,Xd)X = (X_{1}, \ldots, X_{d}) is a set of structural equations:

Si:Xi←fi(Pa⁡(Xi),Ni)S_{i}: X_{i} \leftarrow f_{i}(\operatorname{Pa}(X_{i}), N_{i})

where Pa⁡(Xi)⊆{X1,…,Xd}∖{Xi}\operatorname{Pa}(X_{i}) \subseteq\{X_{1}, \ldots, X_{d}\} \setminus\{X_{i}\} denotes the set of causal parents of XiX_{i}, and NiN_{i} are independent noise variables. We say that XiX_{i} causes XjX_{j} if Xi∈Pa⁡(Xj)X_{i} \in\operatorname{Pa}(X_{j}). The causal graph of XX is obtained by drawing an edge from XiX_{i} to XjX_{j} if Xi∈Pa⁡(Xj)X_{i} \in\operatorname{Pa}(X_{j}), assuming the graph is a Directed Acyclic Graph (DAG).

Within this framework, an environment ee is defined as the result of an intervention on the SEM [5] (Peters et al. 2016), consisting of replacing one or more of its structural equations to obtain a new SEM Ce=(Se,Ne)\mathcal{C}^{e} = (\mathcal{S}^{e}, \mathcal{N}^{e}). For IRM’s guarantees to be theoretically legitimate, these interventions must be “valid”, satisfying three criteria:

  • The causal graph remains acyclic.

  • The conditional expectation remains invariant: E[Ye∣Pa⁡(Y)]=E[Y∣Pa⁡(Y)]\mathbb{E}[Y^{e} \mid\operatorname{Pa}(Y)] = \mathbb{E}[Y \mid\operatorname{Pa}(Y)].

  • The variance V[Ye∣Pa⁡(Y)]\mathbb{V}[Y^{e} \mid\operatorname{Pa}(Y)] remains within a finite range.

Our protocol strictly respects these conditions. By injecting spurious variables without altering the intrinsic semantic link between the text and its label, we generate our training environments Etr\mathcal{E}_{\mathrm{tr}} via valid interventions by mathematically modulating the strength of these spurious correlations. This approach ensures that any observed failure of IRM stems from a structural limitation of the tested mechanism rather than a violation of the method’s core assumptions. This structural rigor is fundamental to the analysis in the following section, where we evaluate confounding. By distinguishing between three possible modeling scenarios, we clarify which interventions preserve the target mechanism and why invariance of the causal mechanism need not imply invariance of the optimal predictor when relevant causal parents are latent.

Confounding and IRM Validity

Unlike the other two processes, the confounder UU exerts a causal influence on the label YY. For IRM to be theoretically valid, the influence of causal parents on the target must remain stable, as established in Appendix § 10. We distinguish three environment-generation strategies. The first two illustrate, respectively, a valid intervention on the shortcut mechanism and an invalid intervention on the target mechanism. The third is also structurally valid under the criterion of Appendix § 10, but highlights the distinction between invariance of the causal mechanism and invariance of the optimal predictor when causal parents are latent.

  • Varying proxy: The link between the unobserved confounder UU and the latent concept ZZ varies across environments, but the U→YU \to Y relationship remains fixed. This is the intervention used in our main confounding experiments: the causal rule remains fixed, and only the misleading proxy relationship fluctuates. This setup preserves the condition E[Ye∣Pa⁡(Y)]=E[Y∣Pa⁡(Y)]\mathbb{E}[Y^{e} \mid\operatorname{Pa}(Y)] = \mathbb{E}[Y \mid\operatorname{Pa}(Y)].

  • Varying causal strength: In this scenario, the direct causal link between the confounder UU and the target YY varies. This represents a direct violation of IRM’s assumptions, as the conditional expectation E[Y∣Pa⁡(Y)]\mathbb{E}[Y \mid\operatorname{Pa}(Y)] is no longer invariant. Since no stable relationship exists across environments, IRM systematically fails to identify a robust predictor.

  • Confounder-prevalence shift: A third possibility is to keep both structural mechanisms causal mechanism and invariance of the optimal predictor when causal parents are latent.

P(Y∣U)P(Y \mid U) and P(Z∣U)P(Z \mid U) fixed while changing the marginal distribution P(e)(U)P^{(e)}(U) across environments. Unlike a change in the U→YU \to Y mechanism, such a prevalence shift does not by itself violate the validity condition introduced in Appendix § 10: the causal relationship between YY and its parent UU remains unchanged, and therefore E[Ye∣U]=E[Y∣U]\mathbb{E}[Y^{e} \mid U] = \mathbb{E}[Y \mid U]. However, because UU is unobserved, changing its prevalence can alter predictive conditionals involving observed proxies. In particular, P(e)(Y∣Z)=∑uP(Y∣u)P(e)(u∣Z)P^{(e)}(Y \mid Z) = \sum_u P(Y \mid u)P^{(e)}(u \mid Z), and P(e)(u∣Z)P^{(e)}(u \mid Z) generally depends on P(e)(U)P^{(e)}(U). Consequently, a prevalence shift may change the optimal predictor based on the observed representation even though the underlying causal mechanism remains invariant. Whether IRM can recover an invariant predictor then depends on whether the observed representation contains sufficient stable information about the target independently of the prevalence-sensitive proxy.

The Role of Causal Direction

IRM seeks a representation for which the same predictor remains optimal across environments. However, its formal guarantees rely on a connection between invariance and causality ([4, 5]). The implications of this connection depend on the generative direction of the prediction task: causal learning (X→YX \to Y) or anti-causal learning (Y→XY \to X). This distinction can be understood through the Principle of Independent Causal Mechanisms (ICM) (Schölkopf et al., 2012; Peters et al., 2017). The ICM principle states that a causal generative process consists of autonomous mechanisms: the conditional distribution of an effect given its cause is structurally independent of the marginal distribution of that cause.

Causal Learning

In a causal prediction task (X→YX \to Y), such as topic classification or review-helpfulness prediction, the observed features XX causally determine the target YY. Under the ICM principle, the mechanism P(Y∣X)P(Y \mid X) may remain stable even when the distribution of inputs P(e)(X)P^{(e)}(X) changes across environments. The joint distribution in environment ee can be factorized as

P(e)(X,Y)=P(e)(X)P(Y∣X),(6)P^{(e)}(X,Y) = P^{(e)}(X)P(Y \mid X), \tag*{(6)}

where environmental variation affects P(e)(X)P^{(e)}(X) but leaves the causal mechanism P(Y∣X)P(Y \mid X) unchanged. In this setting, identifying an invariant representation amounts to preserving the direct causal parents of YY, which define a stable and optimal predictor across valid interventions ([4, 5]). IRM is therefore theoretically well aligned with causal prediction when the environmental changes do not modify the mechanism generating YY from its causes.

Anti-Causal Learning

In an anti-causal prediction task (Y→XY \to X), the target variable generates the observed features. Sentiment classification provides a typical example: the latent sentiment YY generates the vocabulary, expressions, and other textual features contained in XX. Predicting YY from XX therefore inferring a cause from its effects [19, 14]. Under the ICM principle, the stable mechanism is now the generative distribution P(X∣Y)P(X \mid Y) rather than the predictive distribution P(Y∣X)P(Y \mid X). The environment-specific joint distribution factorizes as

P(e)(X,Y)=P(X∣Y)P(e)(Y),(7)P^{(e)}(X,Y) = P(X \mid Y)P^{(e)}(Y), \tag*{(7)}

where P(X∣Y)P(X \mid Y) is assumed to remain stable, but the class prevalence P(e)(Y)P^{(e)}(Y) may vary across environments. A classifier estimates the posterior distribution P(e)(Y∣X)P^{(e)}(Y \mid X), which follows from Bayes’ theorem:

P(e)(Y∣X)=P(X∣Y)P(e)(Y)P(e)(X)=P(X∣Y)P(e)(Y)∑y′∈YP(X∣Y=y′)P(e)(Y=y′).(8)\begin{aligned} P^{(e)}(Y \mid X) = \frac{P(X \mid Y)P^{(e)}(Y)}{P^{(e)}(X)} \\ &= \frac{P(X \mid Y)P^{(e)}(Y)}{\sum_{y' \in\mathcal{Y}} P(X \mid Y = y')P^{(e)}(Y = y')}. \tag*{(8)} \end{aligned}

where Y\mathcal{Y} denotes the set of possible target labels. Even if the generative mechanism P(X∣Y)P(X \mid Y) remains invariant, the optimal predictive distribution P(e)(Y∣X)P^{(e)}(Y \mid X) depends explicitly on the environment-specific class prevalence P(e)(Y)P^{(e)}(Y). This creates two distinct regimes for invariant learning:

  • Stable class prevalence. If P(e)(Y)P^{(e)}(Y) is identical across training and test environments, and P(X∣Y)P(X \mid Y) remains stable, then P(e)(Y∣X)P^{(e)}(Y \mid X) is also invariant. IRM can suppress unstable environmental shortcuts while retaining predictive relationships shared across environments.

  • Label shift. If P(e)(Y)P^{(e)}(Y) changes across environments, then the optimal posterior P(e)(Y∣X)P^{(e)}(Y \mid X) generally changes even though P(X∣Y)P(X \mid Y) remains stable. Enforcing a common optimal predictor across environments then conflicts with the environment-specific predictor required by Bayes’ rule.

Label shift therefore creates a structural difficulty for IRM in anti-causal tasks. The problem is not that the underlying generative mechanism becomes unstable, but that the posterior used for prediction depends on a changing class prior. A strict invariance constraint may consequently prevent the classifier from adapting to the posterior required in each environment.

Implications for Our Experiments

Our anti-causal experiments are conducted with balanced and constant class proportions across training and test environments. This construction keeps P(e)(Y)P^{(e)}(Y) fixed while varying only the association between the target and the designated shortcut. Under the assumed stability of P(X∣Y)P(X \mid Y), the optimal predictive mechanism can therefore remain invariant across environments. This design isolates IRM’s ability to reject unstable shortcuts without simultaneously introducing label shift. The resulting performance should consequently be interpreted as evidence that IRM can operate in an anti-causal setting under stable class prevalence, rather than as evidence that it is generally robust to arbitrary distribution shifts in anti-causal NLP tasks.

Methodological Justification of Sequence Length as a Spurious Feature

To ensure that our experimental design in the IMDB Genres setting is theoretically justified, it is necessary to establish that text description length is a feature that models can readily extract and exploit as a predictive shortcut. Linguistic probing and model analysis literature establish that sequence length information is preserved within sentence-level vector spaces [1]. Consequently, when sentence representations are computed via token averaging (mean pooling), the resulting vector is directly bound to the sequence length NN, as embedding norms predictably decrease as sentences grow longer due to the properties of natural language distributions. Transformer-based architectures are highly susceptible to the sequence length learning problem whenever downstream classes exhibit asymmetrical length distributions [6]. In these unbalanced scenarios, standard ERM objectives tend to opportunistically exploit sequence length as a primary predictive feature instead of relying on genuine textual or semantic information. Furthermore, because sequence length distributions effectively behave like a distinct domain or environmental property during training, a significant mismatch or inversion of these length patterns at test time routinely triggers an overfitting collapse (Variš and Bojar, 2021). Modulating this engineered length bias across training environments therefore provides a theoretically justified and rigorous proxy for evaluating the capacity of IRM to bypass surface heuristics in favor of invariant features.

Detailed Construction of Spurious Mechanisms

To rigorously evaluate IRM across diverse causal structures, we artificially inject or induce spurious correlations in each of the three datasets. Each corpus is partitioned into an 80% training set, a 10% in-distribution validation set, and a 10% out-of-distribution test set. The training partition is further divided equally into two environments Etr={e1,e2}\mathcal{E}_{\mathrm{tr}} = \{e_1,e_2\}, characterized by contrasting spurious correlation strengths, so as to create the distributional instability required by the invariance penalty. We detail below the exact construction procedure for each of the three mechanisms.

Label-Generated Features (pcp_c). The target label YY causally generates a discrete textual artifact, which is embedded in the raw text prior to encoding. For each dataset, we associate a set of semantically neutral vocabulary tokens to the possible classes: {moon, sun} for Amazon Books, {red, blue, green, yellow} for AG News (one per class), and {pine, ash} for IMDB Genres. Rather than simply prepending a single token at the start of the text, the selected token is inserted immediately before every occurrence of a predefined list of high-frequency, content-free function words (e.g., the, a, of, in, to). This distributes the spurious signal across the entire sequence, making the shortcut substantially harder for ERM to ignore.

The correlation strength is controlled by pc=P(Z=y∣Y=y)p_c = P(Z = y \mid Y = y). To prevent the true semantic signal from trivially dominating, a uniform label noise ϵ=0.2\epsilon= 0.2 is applied globally to the entire training partition before splitting into environments, ensuring that both environments share the same noise pattern. The two training environments are then constructed by injecting tokens with pc∈{0.70,0.90}p_c \in\{0.70,0.90\} respectively. In the OOD test set, this correlation is completely inverted (pc=0.0p_c = 0.0), so the injected token systematically identifies the wrong class.

Confounding (aa). An unobserved confounder CC introduces a spurious backdoor path to the observed label. For each training example, CC is drawn uniformly from all possible classes for a fraction pc-flip=0.50p_{c\text{-flip}} = 0.50 of the data; for the remainder, CC coincides with the true label Y∗Y^* (inactive confounder). The observed label YobsY_{\mathrm{obs}} is then biased toward CC: when Y∗≠CY^* \ne C, it is replaced by CC with probability γ\gamma (set to 0.8 for Amazon and AG News, 0.5 for IMDB Genres). The model never observes CC directly; instead, it observes a noisy proxy ZZ, generated as Z(e)=C⊕Ber⁡(a(e))Z^{(e)} = C \oplus\operatorname{Ber}(a^{(e)}), where ⊕\oplus is the XOR operator and a(e)a^{(e)} governs how faithfully ZZ tracks CC. The injected token encodes ZZ rather than YobsY_{\mathrm{obs}}, so the spurious correlation propagates through the backdoor path Yobs←C→Z→XY∗Y_{\mathrm{obs}} \leftarrow C \rightarrow Z \rightarrow X^{Y^*}. The two training environments differ solely in the proxy noise rate: a(e)∈{0.01,0.10}a^{(e)} \in\{0.01,0.10\}, keeping ZZ a reliable proxy in both environments. In the OOD test set, aa is set to 1.0, making ZZ perfectly anti-correlated with CC; evaluation is performed on the clean labels Y∗Y^* (without label bias), maximally penalizing any model that has relied on the proxy token.

Selection Bias (psp_s). Unlike the token injection mechanisms above, selection bias operates purely by subsampling the corpus based on an unobserved collider SS. A pre-existing latent feature ZZ is defined for each dataset, and a sample is included in training (S=1S = 1) based on whether its (Y,Z)(Y,Z) pair is typical (aligned) or atypical (misaligned). The parameter psp_s controls the proportion of typical examples retained in each environment (ps∈{0.70,0.90}p_s \in\{0.70,0.90\}). The OOD test set contains exclusively atypical examples, completely inverting the spurious alignment.

For Amazon Books, the latent feature ZZ is derived from the star rating: reviews with 4–5 stars are considered positive (Z=1Z = 1) and reviews with 1–2 stars negative (Z=0Z = 0). A typical example is one where ZZ aligns with YY: helpful reviews are positive, unhelpful reviews are negative. The OOD set consists exclusively of counter-heuristic instances (helpful reviews with negative sentiment, and vice versa).

For AG News, ZZ is the character length of the article, discretized into four global length bins via corpus-wide quartiles (Q1: ≤P25\le P_{25}, Q2: P25P_{25}–P50P_{50}, Q3: P50P_{50}–P75P_{75}, Q4: >P75> P_{75}). Each class is assigned a dedicated typical bin: World →\rightarrow Q1, Sports →\rightarrow Q2, Business →\rightarrow Q3, Sci/Tech →\rightarrow Q4. In the OOD test set, each class is evaluated exclusively on articles from its most distant bin (i.e., Q1 ↔\leftrightarrow Q4 and Q2 ↔\leftrightarrow Q4 or Q1), ensuring the length cue is maximally misleading at test time.

For IMDB Genres, ZZ is the description length, thresholded at the global P25 and P75 percentiles to obtain a short (<P25< P_{25}) and a long (>P75> P_{75}) category; intermediate-length texts are excluded. A typical example is a long Romance or a short Thriller. Training environments are assembled from ps∈{0.70,0.90}p_s \in\{0.70, 0.90\} typical pairs, while the OOD set contains exclusively atypical instances: short Romances and long Thrillers.

Additional Bias in Bios Details

This section provides supplementary details on the construction of the Bias in Bios experiments introduced in § 6.1, including the environment-generation procedure, the semantic-distance analysis used to select profession pairs, and an additional multiclass experiment.

Dataset and Environment Construction

Bias in Bios contains approximately 400,000 short biographies annotated with one of 28 professions and binary gender [11]. We construct binary classification tasks from pairs containing one male-typical and one female-typical profession. A profession is defined as male-typical when fewer than 50% of its biographies are annotated as female, and female-typical otherwise. Let YY denote the profession label, GG the gender annotation, and canonical⁡(Y)\operatorname{canonical}(Y) the majority gender of profession YY in the original corpus. Shortcut alignment is defined as

A=1[G=canonical⁡(Y)].(9)A = 1[G = \operatorname{canonical}(Y)] . \tag*{(9)}

Gender is not provided as a separate input, but may be inferred from names, pronouns, and other gender-associated expressions. Two training environments are produced by resampling biographies within each profession while preserving class balance. Their shortcut strengths are

P(e1)(A=1∣Y)=0.99,P(e2)(A=1∣Y)=0.80.(10)\begin{aligned} P^{(e_1)}(A = 1 \mid Y) &= 0.99,\\ P^{(e_2)}(A = 1 \mid Y) &= 0.80. \tag*{(10)} \end{aligned}

The OOD test environment fully reverses the association, P(test)(A=1∣Y)=0P^{(\mathrm{test})}(A = 1 \mid Y) = 0, so that every test biography belongs to the minority-gender subset of its profession. A classifier relying on the training-time gender association therefore receives a systematically misleading cue at test time. Because profession-specific vocabulary is highly predictive, we apply a label-flip rate of ϵ=0.25\epsilon= 0.25 to the training labels to make the gender cue competitive. Gender annotations and biography texts are left unchanged, and evaluation uses the original profession labels. We use the frozen DistilBERT encoder and masked mean pooling described in Appendix § 9. Only the linear classification head is optimized. ERM pools the two environments, whereas IRMv1 retains the environment partition and uses a penalty coefficient of λ=1000\lambda= 1000. Both models are trained for 3,000 steps with Adam and a learning rate of 10−410^{-4}.

Semantic Distance and Pair Selection

We quantify profession similarity in the representation space of the same frozen encoder. For each profession cc, up to 300 biographies are sampled from the full corpus and encoded using masked mean pooling. The normalized profession centroid is

ϕ~c=1nc∑i:Yi=cΦBERT(xi)∥1nc∑i:Yi=cΦBERT(xi)∥2.(11)\widetilde{\phi}_c = \frac{\frac{1}{n_c}\sum_{i:Y_i=c}\Phi_{\mathrm{BERT}}(x_i)} {\left\lVert\frac{1}{n_c}\sum_{i:Y_i=c}\Phi_{\mathrm{BERT}}(x_i)\right\rVert_2}. \tag*{(11)}

For a male-typical profession cmc_m and a female-typical profession cfc_f, their distance is

d(cm,cf)=1−ϕ~cmTϕ~cf.(12)d(c_m,c_f) = 1 - \widetilde{\phi}_{c_m}^{\mathsf{T}}\widetilde{\phi}_{c_f}. \tag*{(12)}

After applying the corpus-availability criteria used in preprocessing, 160 cross-gender profession pairs are retained and ranked by this distance. Lower values indicate greater similarity in the frozen representation space. For the experiments in § 6.1, we select five semantically close and five semantically distant eligible pairs while requiring enough examples for repeated balanced resampling with at least 1,000 examples per training environment. The ten evaluated pairs and their OOD results are reported in Table 4. The close group is attorney/paralegal, professor/psychologist, chiropractor/psychologist, chiropractor/nurse, and physician/nurse; the distant group is dj/nurse, rapper/psychologist, dj/paralegal, rapper/paralegal, and rapper/nurse.

Profession pairERMIRMΔ\Delta
Semantically close pairs
attorney/paralegal8.4±0.68.4 \pm0.647.1±0.547.1 \pm0.5+38.8±0.7+38.8 \pm0.7
professor/psychologist22.5±0.522.5 \pm0.579.6±1.479.6 \pm1.4+57.1±1.3+57.1 \pm1.3
chiropractor/psychologist33.9±3.033.9 \pm3.077.4±1.477.4 \pm1.4+43.5±4.4+43.5 \pm4.4
chiropractor/nurse41.9±2.041.9 \pm2.073.6±3.273.6 \pm3.2+31.7±5.2+31.7 \pm5.2
physician/nurse35.0±0.535.0 \pm0.583.6±0.983.6 \pm0.9+48.6±1.1+48.6 \pm1.1
Semantically distant pairs
dj/nurse47.1±2.447.1 \pm2.491.7±1.491.7 \pm1.4+44.6±1.1+44.6 \pm1.1
rapper/psychologist39.8±2.339.8 \pm2.379.4±4.579.4 \pm4.5+39.6±3.7+39.6 \pm3.7
dj/paralegal74.9±1.274.9 \pm1.281.5±14.181.5 \pm14.1+6.6±13.2+6.6 \pm13.2
rapper/paralegal77.3±3.077.3 \pm3.086.9±3.586.9 \pm3.5+9.6±0.5+9.6 \pm0.5
rapper/nurse52.7±1.852.7 \pm1.887.0±2.887.0 \pm2.8+34.3±4.3+34.3 \pm4.3

Table 4. Bias in Bios OOD accuracy for semantically close and distant profession pairs. Results are mean ±\pm standard deviation over three seeds; values are percentages.

Semantic distance is used only as a descriptive proxy for the availability of profession-specific information. It does not directly measure the accessibility of gender, the frequency of explicit gender markers, within-class dispersion, or the orientation of the learned decision boundary. Consequently, distance should not be expected to predict ERM shortcut reliance or the IRM gain monotonically. Its role is to construct comparisons with different levels of representation-space separability, rather than to provide a complete model of shortcut attractiveness. For reference, the closest pair in the retained ranking is attorney/paralegal, with distance 0.0094, while the maximum observed distance is 0.1489 for rapper/nurse. The complete ranking is provided with the accompanying experimental material.

Supplementary Multiclass Experiment

We additionally construct a six-class task to test whether the shortcut remains competitive when the prediction space contains professions from several distinct domains. Training environments are created using the same resampling principle, and the gender–profession association is inverted at test time. In this single-seed experiment, ERM obtains an ID validation accuracy of 0.897 and an OOD accuracy of 0.706, compared with a chance level of 1/6. Only 25.6% of its predictions follow the inverted gender cue. These results suggest that gender is less competitive when profession-specific content provides strong class separation. This experiment remains supplementary because it uses a single seed and is not directly comparable to the binary tasks reported in Table 4.

Model and Optimization

We use the same frozen DistilBERT encoder and linear classification head described in Appendix § 9. Biography representations are obtained using masked mean pooling over the final hidden states. Only the linear classification head is optimized. ERM pools the two training environments and minimizes the standard classification loss. IRMv1 retains the environment partition and optimizes the sum of the environment-specific risks and the invariance penalty. Both models are trained for 3,000 gradient steps with Adam and learning rate 10−410^{-4}. For this experiment, the IRMv1 penalty coefficient is set to λ=1000\lambda= 1000. The larger penalty relative to the controlled experiments reflects the strong profession-specific semantic signal in Bias in Bios and the more diffuse nature of the demographic shortcut. All other model components are shared between ERM and IRM.

ActorCorr: Experimental Details and Additional Results

Experimental Setup

ActorCorr is based on IMDB movie reviews and the actor-name shortcut protocol of Eshuijs et al. [13]. We use the authors’ data-generation pipeline, which identifies existing actor mentions through named-entity recognition and replaces an eligible mention at a fixed injection frequency of 5%. Following the original pairing, Morgan Freeman is associated with positive sentiment and Adam Sandler with negative sentiment. Let ZZ denote the injected actor and YY the sentiment label. Shortcut purity in environment ee is defined as

π(e)=P(e)(Z=zcanonical(Y)∣actor injected),(13)\pi^{(e)} = P^{(e)}\left(Z = z_{\mathrm{canonical}}(Y) \mid\text{actor injected}\right), \tag*{(13)}

where zcanonical(Y)z_{\mathrm{canonical}}(Y) is the actor assigned to class YY. We construct two training environments with

π(e1)=1.0,π(e2)=0.85.(14)\pi^{(e_1)} = 1.0,\qquad\pi^{(e_2)} = 0.85. \tag*{(14)}

The injection frequency is identical across environments, and only the actor–label agreement varies. Unlike the neutral tokens used in the controlled experiments, actor names may carry associations inherited from pretraining. ActorCorr therefore tests IRM against a semantically loaded shortcut. We use the same frozen DistilBERT encoder and trainable linear classification head as in the controlled experiments. ERM pools both environments, whereas IRMv1 retains the environment partition when computing its risk and invariance penalty. Models are trained for 25,000 gradient steps, and results are averaged over three random seeds. The main ActorCorr experiment uses λ=100\lambda= 100. Each test review is evaluated under three conditions:

  • Clean: no actor cue is injected;

  • Correlated: the actor agrees with the sentiment label;

  • Anti-correlated: the actor is associated with the opposite label.

To measure shortcut sensitivity independently of pooled accuracy, we compare each review with its anti-correlated variant, in which the injected actor cue points toward the incorrect sentiment class. For each sentiment class y∈Yy \in\mathcal{Y}, we define the class-specific clean-to-anti-correlated accuracy gap as

Gy=Acc⁡clean(y)−Acc⁡anti(y),(15)G_y = \operatorname{Acc}_{\mathrm{clean}}^{(y)} - \operatorname{Acc}_{\mathrm{anti}}^{(y)}, \tag*{(15)}

where Acc⁡clean(y)\operatorname{Acc}_{\mathrm{clean}}^{(y)} is the accuracy on clean reviews from class yy, and Acc⁡anti(y)\operatorname{Acc}_{\mathrm{anti}}^{(y)} is the accuracy on the same class under the anti-correlated actor intervention. Since ActorCorr is a binary sentiment-classification task with Y={neg,pos}\mathcal{Y} = \{\mathrm{neg}, \mathrm{pos}\}, this definition yields two class-specific gaps:

Gneg=Acc⁡clean(neg)−Acc⁡anti(neg),(16)G_{\mathrm{neg}} = \operatorname{Acc}_{\mathrm{clean}}^{(\mathrm{neg})} - \operatorname{Acc}_{\mathrm{anti}}^{(\mathrm{neg})}, \tag*{(16)}
Gpos=Acc⁡clean(pos)−Acc⁡anti(pos).(17)G_{\mathrm{pos}} = \operatorname{Acc}_{\mathrm{clean}}^{(\mathrm{pos})} - \operatorname{Acc}_{\mathrm{anti}}^{(\mathrm{pos})}. \tag*{(17)}

Here, GnegG_{\mathrm{neg}} measures the accuracy loss caused by injecting the positive-associated actor into negative reviews, whereas GposG_{\mathrm{pos}} measures the loss caused by injecting the negative-associated actor into positive reviews. These gaps therefore quantify how strongly the misleading actor cue affects each sentiment class. A large positive value of GyG_y indicates that the anti-correlated actor reduces accuracy, showing that the model remains sensitive to the shortcut for class yy. A value close to zero indicates that the intervention has little effect. A negative value means that accuracy is higher under the anti-correlated intervention than in the clean condition, indicating a sign-inverted response rather than straightforward invariance. We summarize the model’s average signed sensitivity using the Anti-Correlated Accuracy Change:

ACAC=1∣Y∣∑y∈YGy.(18)\mathrm{ACAC} = \frac{1}{|\mathcal{Y}|} \sum_{y \in\mathcal{Y}} G_y. \tag*{(18)}

Because ActorCorr contains two sentiment classes, this expression reduces to

ACAC=Gneg+Gpos2.(19)\mathrm{ACAC} = \frac{G_{\mathrm{neg}} + G_{\mathrm{pos}}}{2}. \tag*{(19)}

A large positive ACAC indicates that anti-correlated actor cues reduce accuracy on average, suggesting reliance on the shortcut. An ACAC close to zero indicates limited average signed sensitivity. However, reporting GnegG_{\mathrm{neg}} and GposG_{\mathrm{pos}} in addition to ACAC is important because the effect of the actor cue may be asymmetric across sentiment classes. In particular, a positive gap for one class and a negative gap for the other can partially cancel in the macro-average, producing a low ACAC even though the model remains sensitive to the intervention. Consequently, a robust model should ideally combine high clean and anti-correlated accuracy with both GnegG_{\mathrm{neg}} and GposG_{\mathrm{pos}} close to zero. The aggregate ACAC measures average signed sensitivity, while the two class-specific gaps show whether that apparent invariance holds consistently across both sentiment classes.

Results by Test Condition

Table 8 decomposes the pooled OOD results by test condition.

Test conditionERMIRM
Clean0.7590.716
Correlated0.8700.726
Anti-correlated0.5740.671
Spread0.2960.055

Table 8. ActorCorr accuracy by test condition, averaged over three seeds. Spread denotes the difference between the highest and lowest condition-level accuracies.

ERM strongly benefits from the correlated actor cue but deteriorates when the cue contradicts the label, producing a spread of 0.296 across test conditions. IRM is less accurate on clean and correlated examples, but substantially more accurate under the anti-correlated intervention. Its spread is reduced to 0.055, indicating more homogeneous behavior across conditions. Pooled OOD accuracy therefore understates the difference in shortcut reliance, since ERM’s gains on correlated examples partially compensate for its failures on anti-correlated examples.

Sensitivity to the Invariance Penalty

Because ActorCorr combines a relatively small purity difference across environments with semantically meaningful actor names, we evaluate the following penalty values:

λ∈{10,25,50,75,100}.(20)\lambda\in\{10, 25, 50, 75, 100\}. \tag*{(20)}

All configurations use the same architecture, training environments, and optimization protocol.

Increasing λ\lambda monotonically reduces ACAC from 0.146±0.0020.146 \pm0.002 to 0.049±0.0020.049 \pm0.002, but also lowers pooled OOD accuracy from 0.745±0.0070.745 \pm0.007 to 0.704±0.0080.704 \pm0.008. ActorCorr therefore reveals a clear accuracy–invariance trade-off: the penalty value that minimizes sensitivity to the targeted shortcut does not maximize aggregate predictive performance. Relative to the ERM reference, every IRM configuration reduces ACAC and both class-specific gaps, confirming that the invariance penalty consistently weakens reliance on the actor cue. However, only λ∈{10,25}\lambda\in\{10, 25\} matches or improves upon ERM’s OOD accuracy, whereas stronger penalties achieve greater invariance at the cost of predictive performance. The class-specific gaps further show that this trade-off is asymmetric. For the negative class, GnegG_{\mathrm{neg}} remains positive for all penalty values. For the positive class, the gap approaches zero at λ=75\lambda= 75 and becomes negative at λ=100\lambda= 100, with Gpos=−0.051±0.003G_{\mathrm{pos}} = -0.051 \pm0.003. The strongest penalty therefore induces a sign-inverted response for positive examples rather than simply removing sensitivity to the actor cue. This asymmetry may result from unequal associations of the two actor names in the frozen pretrained representation space. Consequently, a single global penalty can suppress the two class-specific shortcut responses at different rates.

Sensitivity to Shortcut Prevalence

The main ActorCorr experiment fixes the effective actor-injection frequency at 5%. To assess how the prevalence of the shortcut changes the comparison, we additionally generate two datasets in which 10% or 25% of reviews in each training environment receive an actor substitution. We retain the same actor–label purities, π(e1)=1.0\pi^{(e_1)} = 1.0 and π(e2)=0.85\pi^{(e_2)} = 0.85, the same three evaluation conditions, and the same optimization protocol. Thus, this intervention changes the prevalence of the actor cue without changing its environment-specific agreement mechanism.

Table 10 shows that the frequency manipulation successfully controls shortcut attractiveness. Increasing the injection frequency from 10% to 25% raises ERM’s ACAC from 0.160±0.0050.160 \pm0.005 to 0.291±0.0030.291 \pm0.003, while lowering its pooled OOD accuracy from 0.732±0.0070.732 \pm0.007 to 0.717±0.0080.717 \pm0.008. At 25%, IRMv1 with λ=50\lambda= 50 is the best accuracy–invariance compromise: it improves OOD accuracy to 0.728±0.0080.728 \pm0.008 and reduces ACAC to 0.115±0.0040.115 \pm0.004. This corresponds to a 60.5% reduction in signed average sensitivity relative to ERM, while both class-specific gaps remain positive and smaller than their ERM counterparts.

InjectionModelOODACACGnegG_{\mathrm{neg}}GposG_{\mathrm{pos}}
10%ERM0.732±0.0070.732 \pm0.0070.160±0.0050.160 \pm0.0050.203±0.0110.203 \pm0.0110.118±0.0030.118 \pm0.003
IRM, 100.741±0.0080.741 \pm0.0080.124±0.0020.124 \pm0.0020.174±0.0010.174 \pm0.0010.075±0.0030.075 \pm0.003
IRM, 250.739±0.0050.739 \pm0.0050.100±0.0010.100 \pm0.0010.138±0.0030.138 \pm0.0030.062±0.0010.062 \pm0.001
IRM, 500.734±0.0050.734 \pm0.0050.071±0.0030.071 \pm0.0030.115±0.0030.115 \pm0.0030.027±0.0020.027 \pm0.002
IRM, 750.725±0.0050.725 \pm0.0050.055±0.0030.055 \pm0.0030.115±0.0030.115 \pm0.003−0.004±0.004-0.004 \pm0.004
IRM, 1000.709±0.0050.709 \pm0.0050.043±0.0000.043 \pm0.0000.142±0.0020.142 \pm0.002−0.055±0.003-0.055 \pm0.003
25%ERM0.717±0.0080.717 \pm0.0080.291±0.0030.291 \pm0.0030.324±0.0060.324 \pm0.0060.258±0.0030.258 \pm0.003
IRM, 100.724±0.0080.724 \pm0.0080.227±0.0010.227 \pm0.0010.256±0.0040.256 \pm0.0040.198±0.0020.198 \pm0.002
IRM, 250.728±0.0090.728 \pm0.0090.170±0.0030.170 \pm0.0030.202±0.0060.202 \pm0.0060.137±0.0030.137 \pm0.003
IRM, 500.728±0.0080.728 \pm0.0080.115±0.0040.115 \pm0.0040.164±0.0110.164 \pm0.0110.065±0.0080.065 \pm0.008
IRM, 750.716±0.0090.716 \pm0.0090.098±0.0050.098 \pm0.0050.162±0.0020.162 \pm0.0020.033±0.0090.033 \pm0.009
IRM, 1000.697±0.0070.697 \pm0.0070.071±0.0040.071 \pm0.0040.176±0.0130.176 \pm0.013−0.034±0.005-0.034 \pm0.005

Table 10. ActorCorr sensitivity to effective actor-injection frequency and IRM penalty, reported as mean ±\pm standard deviation over three seeds. GyG_y is the clean-to-anti-correlated accuracy gap for class yy; negative values indicate a sign-inverted response.

The lowest ACAC values are obtained with λ=100\lambda= 100, but this setting also reduces OOD accuracy and makes GposG_{\mathrm{pos}} negative at both injection frequencies. As in the fixed-frequency sweep, this behavior is evidence of a sign-inverted response for the positive class rather than complete invariance. At the weaker 10% prevalence, the OOD optimum occurs at λ=10\lambda= 10; larger penalties trade accuracy for lower shortcut sensitivity. The frequency sweep therefore confirms that the useful penalty scale depends on shortcut prevalence, while preserving the same qualitative accuracy–invariance trade-off observed in Table 9.

λ\lambdaOODACACGnegG_{\mathrm{neg}}GposG_{\mathrm{pos}}
100.745±0.0070.745 \pm0.0070.146±0.0020.146 \pm0.0020.179±0.0010.179 \pm0.0010.114±0.0020.114 \pm0.002
250.740±0.0050.740 \pm0.0050.120±0.0020.120 \pm0.0020.160±0.0030.160 \pm0.0030.080±0.0020.080 \pm0.002
500.732±0.0040.732 \pm0.0040.082±0.0030.082 \pm0.0030.134±0.0040.134 \pm0.0040.031±0.0010.031 \pm0.001
750.726±0.0080.726 \pm0.0080.061±0.0000.061 \pm0.0000.124±0.0020.124 \pm0.002−0.001±0.002-0.001 \pm0.002
1000.704±0.0080.704 \pm0.0080.049±0.0020.049 \pm0.0020.148±0.0020.148 \pm0.002−0.051±0.003-0.051 \pm0.003
ERM0.739±0.0040.739 \pm0.0040.186±0.0020.186 \pm0.0020.221±0.0010.221 \pm0.0010.151±0.0020.151 \pm0.002

Table 9. ActorCorr sensitivity to λ\lambda, reported as mean ±\pm standard deviation over three seeds. GyG_y is the clean-to-anti-correlated accuracy gap for class yy; negative values indicate a sign-inverted response.

References

  1. [1]Yossi Adi, Einat Kermany, Yonatan Belinkov, Ofer Lavi, and Yoav Goldberg. 2017. Fine-grained analysis of sentence embeddings using auxiliary prediction tasks. In International Conference on Learning Representations.
  2. [2]Kartik Ahuja, Ethan Caballero, Dinghuai Zhang, Jean-Christophe Gagnon-Audet, Yoshua Bengio, Ioannis Mitliagkas, and Irina Rish. 2021. Invariance principle meets information bottleneck for out-of-distribution generalization. Advances in Neural Information Processing Systems, 34:3438–3450.arxiv.org/abs/2106.06607
  3. [3]Kartik Ahuja, Karthikeyan Shanmugam, Kush Varshney, and Amit Dhurandhar. 2020. Invariant risk minimization games. International Conference on Machine Learning, pages 145–155.arxiv.org/abs/2002.04692
  4. [4]Martin Arjovsky. 2020. Out of Distribution Generalization in Machine Learning. Ph.D. thesis, New York University.arxiv.org/abs/2103.02667
  5. [5]Martin Arjovsky, Léon Bottou, Ishaan Gulrajani, and David Lopez-Paz. 2019. Invariant risk minimization. arXiv preprint arXiv:1907.02893.arxiv.org/abs/1907.02893
  6. [6]Jean-Thomas Baillargeon and Luc Lamontagne. 2022. Assessing the impact of sequence length learning on classification tasks for transformer encoder models. arXiv preprint arXiv:2212.08399.arxiv.org/abs/2212.08399
  7. [7]Jasmijn Bastings, Sebastian Ebert, Polina Zablotskaia, Anders Sandholm, and Katja Filippova. 2022. “will you find these shortcuts?” a protocol for evaluating the faithfulness of input salience methods for text classification. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 976–991.
  8. [8]Shai Ben-David, John Blitzer, Koby Crammer, Alex Kulesza, Fernando Pereira, and Jennifer Wortman Vaughan. 2010. A theory of learning from different domains. Machine Learning, 79(1):151–175.
  9. [9]Su Lin Blodgett, Solon Barocas, Hal Daumé III, and Hanna Wallach. 2020. Language (technology) is power: A critical survey of “bias” in nlp. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 5454–5476.arxiv.org/abs/2005.14050
  10. [10]Yo Joong Choe, Jiyeon Ham, and Kyubyong Park. 2020. An empirical study of invariant risk minimization. arXiv preprint arXiv:2004.05007.arxiv.org/abs/2004.05007
  11. [11]Maria De-Arteaga, Alexey Romanov, Hanna Wallach, Jennifer Chayes, Christian Borgs, Alexandra Chouldechova, Sahin Geyik, Krishnaram Kenthapadi, and Adam Tauman Kalai. 2019. Bias in bios: A case study of semantic representation bias in a high-stakes setting. In Proceedings of the Conference on Fairness, Accountability, and Transparency (FAT*), pages 120–128.
  12. [12]Yana Dranker, He He, and Yonatan Belinkov. 2021. Irm — when it works and when it doesn’t: A test case of natural language inference. Advances in Neural Information Processing Systems, 34:18212–18224.
  13. [13]Leon Eshuijs, Shihan Wang, and Antske Fokkens. 2025. Short-circuiting shortcuts: Mechanistic investigation of shortcuts in text classification. In Proceedings of the 29th Conference on Computational Natural Language Learning, pages 105–125.arxiv.org/abs/2505.06032
  14. [14]Amir Feder, Katherine A Keith, Emaad Manzoor, Reid Pryzant, Dhanya Sridhar, Zach Wood-Doughty, Jacob Eisenstein, Justin Grimmer, Roi Reichart, Margaret E Roberts, and 1 others. 2022. Causal inference in natural language processing: Estimation, prediction, interpretation and beyond. Transactions of the Association for Computational Linguistics, 10:1138–1158.
  15. [15]Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario Marchand, and Victor Lempitsky. 2016. Domain-adversarial training of neural networks. Journal of Machine Learning Research, 17(59):1–35.arxiv.org/abs/1505.07818
  16. [16]Ishaan Gulrajani and David Lopez-Paz. 2021. In search of lost domain generalization. International Conference on Learning Representations.arxiv.org/abs/2007.01434
  17. [17]Suchin Gururangan, Swabha Swayamdipta, Omer Levy, Roy Schwartz, Samuel Bowman, and Noah A. Smith. 2018. Annotation artifacts in natural language inference data. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), pages 107–112.arxiv.org/abs/1803.02324
  18. [18]Yupeng Hou, Jiacheng Li, Xiangjun Fu, Zhankui He, An Yan, Xiusi Chen, and Julian McAuley. 2026. Bridging language and items for retrieval and recommendation: Benchmarking llms as semantic encoders. In Proceedings of the 64th Annual Meeting of the Association of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3251–3265.
  19. [19]Zhijing Jin, Julius von Kügelgen, Jingwei Ni, Tejas Vaidhya, Ayush Kaushal, Mrinmaya Sachan, and Bernhard Schoelkopf. 2021. Causal direction of data collection matters: Implications of causal and anti-causal learning for nlp. In Proceedings of the 2021 conference on empirical methods in natural language processing, pages 9499–9513.
  20. [20]Pritish Kamath, Akilesh Tangella, Danica Sutherland, and Nathan Srebro. 2021. Does invariant risk minimization capture invariance? International Conference on Artificial Intelligence and Statistics, pages 4069–4077.arxiv.org/abs/2101.01134
  21. [21]Diederik P. Kingma and Jimmy Ba. 2015. Adam: A method for stochastic optimization. International Conference on Learning Representations.arxiv.org/abs/1412.6980
  22. [22]Pang Wei Koh, Shiori Sagawa, Henrik Marklund, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasunaga, Richard Lanas Phillips, Irena Gao, and 1 others. 2021. Wilds: A benchmark of in-the-wild distribution shifts. In International conference on machine learning, pages 5637–5664. PMLR.arxiv.org/abs/2012.07421
  23. [23]Evan Z Liu, Behzad Haghighoo, Annie S Chen, Aditi Raghunathan, Pang Wei Koh, Shiori Sagawa, Percy Liang, and Chelsea Finn. 2021. Just train twice: Improving group robustness without training group information. In International conference on machine learning, pages 6781–6792. PMLR.arxiv.org/abs/2107.09044
  24. [24]Andrew Maas, Raymond E. Daly, Peter T. Pham, Dan Huang, Andrew Y. Ng, and Christopher Potts. 2011. Learning word vectors for sentiment analysis. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies, pages 142–150.
  25. [25]Tom McCoy, Ellie Pavlick, and Tal Linzen. 2019. Right for the wrong reasons: Diagnosing syntactic heuristics in natural language inference. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 3428–3448.arxiv.org/abs/1902.01007
  26. [26]Junhyun Nam, Hyuntak Cha, Sungsoo Ahn, Jaeho Lee, and Jinwoo Shin. 2020. Learning from failure: Debiasing classifier from biased classifier. Advances in Neural Information Processing Systems, 33:20673–20684.arxiv.org/abs/2007.02561
  27. [27]Judea Pearl. 2009. Causality. Cambridge University Press.

Paper details

vlnc:W_b6datrhh
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents