arXiv:2610.33904cs.LGOct 2026

Manuscript Offprint

arXiv:2610.33904

Counterfactual Test-Time Augmentation for Shortcut Removal in Language Models

Katie Matton, Rosalind W. Picard, John Guttag, Maggie Makar

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language models (LLMs) can exploit shortcuts, i.e., correlations present in training data that may not hold at test time. This can lead to poor predictions when correlations shift. Most existing solutions for removing shortcuts operate at training time, requiring labeled training data, model weight access, and significant computational resources. Here, we study the problem of test-time shortcut removal. We propose a family of counterfactual test-time augmentation (CTTA) methods: given an example, each method uses an auxiliary model to generate counterfactual edits in which the shortcut value is changed, and then takes a weighted average of the LLM's predictions across these edits. We prove that the optimal shortcut-invariant predictor is a member of this CTTA family, and we characterize its weights. The weights depend on the training distribution, and therefore are, in general, not identifiable from the trained model and unlabeled test data. However, we present assumptions under which the weights can be obtained using the token probabilities of the trained LLM, and propose tests to detect violations of these assumptions. We use these tests to develop Select-CTTA, an aggregate method that selects among CTTA methods. Empirically, we find that Select-CTTA outperforms test-time baselines and approaches the performance of models fine-tuned on shortcut-balanced data.

1 Introduction

Despite impressive performance on a range of tasks, large language models (LLMs) remain brittle. They have been shown to abandon correct answers when users push back (Sharma et al., 2024), change answers when multiple-choice options are reordered (Pezeshkpour & Hruschka, 2024), and rely on demographic stereotypes when making decisions about people (Tamkin et al., 2023). Each of these failures is related to a common issue: LLMs are prone to relying on shortcuts, i.e., correlations in training data that may not hold at inference time. As a result, LLMs use heuristics, such as prefer option A and agree with the user, that reduce training loss but lead to errors during deployment (Zheng et al., 2024; Sharma et al., 2024). Reliance on shortcuts is a major impediment to LLM safety and reliability.

Most existing methods for removing shortcuts in language models are designed to be applied at training time. However, training an LLM requires many resources, including labeled training data, access to model weights, and substantial compute. Users often lack these resources. Hence, here we study a different approach: removing shortcuts from LLMs at test-time without access to model weights or labeled data.

We propose a family of test-time shortcut removal methods that we call counterfactual test-time augmentation (CTTA). Given a test example, each CTTA method uses an auxiliary model to create counterfactual edits in which the shortcut value is changed. We then take a weighted average of the

Preprint.

LLM’s predictions across the edits. As we show in this work, if the chosen weights do not depend on the shortcut value observed in the example, the resulting predictor is shortcut-invariant.

Among the set of predictors that are shortcut invariant, we want the one with the lowest error, i.e., the optimal shortcut-invariant predictor. We prove that under a common model of shortcut learning, the optimal shortcut-invariant predictor is a member of the CTTA family. The optimal weights depend on the training distribution and therefore, in general, cannot be identified without access to the training data. However, we present a set of assumptions under which the weights can be obtained using the observable token probabilities of the trained LLM. We call the resulting method Model-Weighted CTTA.

Since the assumptions needed to recover the optimal weights are not always met in practice, we also study simple fixed weighting schemes, such as uniform weighting, that do not require a weight estimation step. We prove fixed weighting schemes have a desirable property: they achieve the same AUROC as the optimal shortcut-invariant predictor, although they are miscalibrated. To select among CTTA methods, we propose Select-CTTA, a procedure that performs diagnostic tests to detect violations of the Model-Weighted CTTA assumptions. When the checks pass, Select-CTTA selects Model-Weighted CTTA; otherwise, it selects uniform weights.

We evaluate the CTTA methods on two text classification benchmarks and six LLMs, spanning multiple model families and sizes. Select-CTTA consistently achieves the best or near-best performance among CTTA methods and outperforms test-time calibration baselines. In many cases, it approaches the performance of models trained on gold-standard balanced data, while requiring substantially fewer resources.

Our contributions are: (1) We propose a family of Counterfactual Test Time Augmentation (CTTA) methods as a solution for test-time shortcut removal in LLMs. (2) We theoretically analyze the optimality of our proposed methods, providing an understanding of when they match (and fail to match) the performance of the optimal shortcut-invariant predictor. (3) We introduce Select-CTTA, a procedure that adaptively selects between model-based and uniform CTTA weights using label-free diagnostic tests. (4) We demonstrate that Select-CTTA outperforms test-time baselines and often approaches the performance of fine-tuning on shortcut-balanced data at substantially lower cost.

References (56)