Test-Time Adaptation by Causal Trimming

Yingnan Liu, Rui Qiao, Mong-Li Lee, Wynne Hsu

Introduction

Test-Time Adaptation by Causal Trimming (TACT) is a novel approach designed to make machine learning models more robust when encountering data that diverges from their training set. By utilizing data augmentations and Principal Component Analysis (PCA) to identify and "trim" non-causal (spurious) features from data representations, TACT allows models to focus on the stable, causal signals that genuinely matter for the task at hand.

The Challenge of Distribution Shift

Machine learning models frequently degrade in real-world deployments due to distribution shift. For instance, a model trained to identify bird species in a quiet forest might fail in a noisy city because it inadvertently learned to rely on "non-causal" features—like specific background noises or microphone settings—rather than the "causal" features of the bird's song itself.

Causal graph illustrating how both causal ($X_C$) and non-causal ($X_{NC}$) features generate the input $X$, but only causal features determine the label $Y$.

Existing Test-Time Adaptation (TTA) methods attempt to resolve this by updating the model using incoming unlabeled test data. However, most TTA methods rely on the model’s own predictions (pseudo-labels) to guide this update. If the model is already misled by spurious, non-causal features, its predictions will be incorrect, creating a feedback loop where the model adapts to its own errors.

The TACT Methodology

To break this cycle, the authors propose TACT, which identifies and removes misleading components directly from the model's internal feature representations. The process operates in three primary steps:

  1. Non-Causal Feature Identification: For a given test sample, TACT generates several augmented versions (e.g., altering the color jitter of an image or adding demographic-neutral sentences to text). These augmentations are specifically chosen to preserve the "causal" content (the core object or meaning) while varying the "non-causal" attributes.
  2. Causal Trimming via PCA: TACT extracts the feature representations for all augmented samples and applies Principal Component Analysis (PCA) to find the directions of maximum variance. Assuming causal features remain stable across augmentations while non-causal ones fluctuate, the top principal components represent the "noise" or non-causal directions. TACT then "trims" the representation by subtracting its projection onto these identified directions.
  3. Prototype Adaptation: The model utilizes "prototypes" (template representations for each class). TACT applies the same trimming process to these prototypes and maintains a moving average during adaptation to ensure stable predictions.

Notably, TACT is inherently backpropagation-free, meaning it can improve performance without expensive gradient updates. However, the authors also introduce a "TACT-adapt" variant that combines this trimming with gradient-based learning for further gains.

Key Insights

  • Variance as a Signal for Spuriousness: The core insight is that if a feature changes significantly under a label-preserving augmentation, it is likely non-causal. PCA elegantly isolates these volatile dimensions.
  • Linearity of Semantics: The method leverages the "linear representation hypothesis"—the concept that high-level semantic concepts are encoded as linear directions in a model's latent space.
  • Immediate Correction: Unlike self-training methods requiring many iterations to unlearn bias, TACT filters out noise in the representation space to improve predictions on the very first batch.

Experimental Results

The authors evaluated TACT across multiple modalities, including audio (Birdcalls), medical imaging (Camelyon17), natural language (CivilComments), and visual benchmarks (ImageNet-R & ImageNet-V2).

Performance comparison of TACT against state-of-the-art TTA methods across various datasets.

TACT consistently outperformed state-of-the-art (SOTA) methods across all benchmarks:

  • CivilComments: Achieved a massive jump in worst-group accuracy, rising from a baseline of 55.38% to 71.80% (BP-free), outperforming previous SOTA methods significantly.
  • Birdcalls: Improved the macro F1 score from 22.74% (no adaptation) to 31.14%.
  • Robustness & Efficiency: TACT demonstrated strong performance even with extremely small batch sizes (as low as 1), making it highly suitable for real-time, streaming applications. While it requires more memory than simple inference due to augmentations and PCA, the substantial accuracy gains justify the trade-off.

Limitations and Future Directions

While highly effective, TACT has a few limitations. It depends heavily on the choice of augmentations; selecting the wrong augmentation could inadvertently trim away necessary causal information. Furthermore, the method assumes that causal and non-causal features are roughly orthogonal in the feature space, which may not always hold true. Future work will explore identifying non-causal directions without predefined augmentations and relaxing the orthogonality constraint.

Summary updated

BibTeX
@inproceedings{liu2025test,
  author = {Yingnan Liu and Rui Qiao and Mong-Li Lee and Wynne Hsu},
  title = {{Test-Time Adaptation by Causal Trimming}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=zFGdHL9pcD},
}
Figure