Abstract
Test-time adaptation aims to improve model robustness under distribution shifts by adapting models with access to unlabeled target samples. A primary cause of performance degradation under such shifts is the model's reliance on features that lack a direct causal relationship with the prediction target. We introduce Test-time Adaptation by Causal Trimming (TACT), a method that identifies and removes non-causal components from representations for test distributions. TACT applies data augmentations that preserve causal features while varying non-causal ones. By analyzing the changes in the representations using Principal Component Analysis, TACT identifies the highest variance directions associated with non-causal features. It trims the representations by removing their projections on the identified directions, and uses the trimmed representations for the predictions. During adaptation, TACT continuously tracks and refines these directions to get a better estimate of non-causal features. We theoretically analyze the effectiveness of this approach and empirically validate TACT on real-world out-of-distribution benchmarks. TACT consistently outperforms state-of-the-art methods by a significant margin.
Introduction: The Challenge of Distribution Shift
Machine learning models often suffer from performance degradation when deployed in environments that differ from their training data. This phenomenon, known as distribution shift, occurs when a model relies on non-causal features—spurious correlations that are present in the training set but change or disappear at test time. For instance, a bird classifier might learn to associate a specific forest background with a species rather than the bird's physical characteristics.
As shown in the causal graph above, the input $X$ is composed of both causal features $X_C$ (which directly influence the label $Y$) and non-causal features $X_{NC}$. Standard Test-Time Adaptation (TTA) methods often struggle because they use the model's own biased predictions to guide updates, potentially reinforcing the reliance on $X_{NC}$.
Methodology: Causal Trimming via PCA
TACT addresses this by actively identifying and "trimming" non-causal signals from data representations before making predictions. The process involves four key steps:
- Non-Causal Feature Identification: TACT generates multiple augmented versions of a test sample. These augmentations (e.g., color jittering or adding demographic-neutral text) are designed to vary the non-causal context while keeping the causal content stable.
- PCA Trimming: By performing Principal Component Analysis (PCA) on the representations of these augmented samples, TACT identifies directions of maximum variance. Since causal features remain stable across augmentations, these high-variance directions are assumed to represent non-causal noise.
- Representation Refinement: The method "trims" the representation by subtracting its projection onto these identified non-causal directions. This refinement is also applied to the model’s internal class prototypes.
- Adaptation: TACT can operate as a backpropagation-free method (adjusting representations only) or as TACT-adapt, which uses the refined predictions to guide traditional gradient-based model updates.
Experimental Results
The authors evaluated TACT across a diverse set of benchmarks, including audio (Birdcalls), medical imaging (Camelyon17), natural language (CivilComments), and general vision (ImageNet-R/V2).
As demonstrated in the table above, TACT and TACT-adapt consistently outperform existing state-of-the-art methods like SHOT, Tent, and DeYO. Notably, on the CivilComments dataset, TACT achieved a significant improvement in "worst-group accuracy," highlighting its ability to ignore spurious demographic correlations.
Key Insights
- Uncovering Latent Knowledge: TACT suggests that models often already possess causal knowledge, but it is overshadowed by high-magnitude non-causal signals. Trimming acts as a surgical tool to uncover these stable signals.
- Immediate Reliability: Unlike many TTA methods that require multiple batches to adapt, TACT provides improved predictions from the very first sample by removing interference immediately.
- Practicality: The method is robust to small batch sizes, making it suitable for real-time, on-device applications.
Conclusion and Future Work
TACT represents a significant step forward in making TTA more robust by grounding it in causal principles. While currently dependent on well-designed augmentations and linear assumptions, future work may explore automated discovery of non-causal directions and non-linear separation techniques to further enhance model reliability in the wild.
Summary updated