Learning Causal Semantic Representation for Out-of-Distribution Prediction

Chang Liu, Xinwei Sun, Jindong Wang, Haoyue Tang, Tao Li, Tao Qin, Wei Chen, Tie-Yan Liu

Deep learning models often fail on out-of-distribution (OOD) data because they rely on spurious correlations between semantic features (like an object's shape) and variation factors (like the background). When deployed in a new domain, these correlations break, causing performance to plummet.

This paper introduces a Causal Semantic Generative (CSG) model that separates these factors using causal reasoning. It provides theoretical guarantees for identifying true semantic factors from a single training domain, significantly improving OOD generalization and domain adaptation.

The Problem: Spurious Correlations

Machine learning models are typically trained under the IID assumption—that training and testing data come from the same distribution. In reality, standard models unconsciously mix up two types of latent factors:

  1. Semantic factors ($s$): The actual cause of the label (e.g., the shape of a bed).
  2. Variation factors ($v$): Contextual elements that don't cause the label (e.g., a bedroom background).

In training data, $s$ and $v$ are often spuriously correlated (e.g., beds usually appear in bedrooms). Standard models use this correlation as a crutch. Existing methods to fix this usually require data from multiple training domains to learn what is invariant. This paper tackles the much harder, more common problem: how to untangle these factors and generalize safely using only a single training domain.

Methodology: The Causal Semantic Generative Model

The authors propose the CSG model, which explicitly models $s$ and $v$ separately. The core idea relies on the Causal Invariance Principle: the generative mechanisms of nature—how a label is generated from semantics $p(y|s)$, and how an image is generated from both semantics and variations $p(x|s, v)$—are invariant across domains. The only thing that changes across domains is the prior correlation between the factors, $p(s, v)$.

Causal graphs for CSG, CSG-ind, and CSG-DA

To leverage this, the authors develop two specific methods using Variational Bayes:

  • CSG-ind (for OOD Generalization): When predicting on a completely unseen domain, the model actively discards the spurious correlation learned during training. It forces an independent prior $p(s)p(v)$ during inference, promoting a cautious, neutral belief that prevents the model from relying on training-specific crutches.
  • CSG-DA (for Domain Adaptation): When unlabeled data from the test domain is available, the model keeps the causal generative mechanisms frozen but learns a new, updated prior $\tilde{p}(s, v)$ that fits the test data.

To make training efficient, they use a clever mathematical reformulation of the Evidence Lower Bound (ELBO) that avoids the need to train separate, costly inference models for the training and test phases.

Key Insights

  • Causal Invariance > Inference Invariance: Many existing domain adaptation methods try to learn a domain-invariant feature extractor (inference). The authors argue this is flawed because inference inherently relies on domain-specific priors. Instead, it is the generative causal mechanisms (how the world creates the data) that are truly invariant.
  • Single-Domain Identifiability is Possible: The most surprising theoretical contribution is proving that under certain conditions (additive noise and bijective mappings), a model can mathematically identify the true semantic factor from a single training domain, even if it is heavily correlated with variation factors.
  • Independence as a Defense: By artificially severing the connection between semantics and variations during inference (CSG-ind), the model becomes highly robust to unknown distribution shifts.

Experimental Results

The authors tested their approach on several datasets, including a custom Shifted-MNIST diagnostic dataset, ImageCLEF-DA, and PACS.

  • Shifted-MNIST: CSG-ind achieved 82.6% accuracy in OOD generalization, crushing a standard Cross-Entropy (CE) baseline which fell to random guessing (42.9%) due to position bias. For domain adaptation, CSG-DA hit 97.6%, vastly outperforming standard adaptation methods like DANN (40.9%), which actually suffered from negative transfer.
  • Real-World Benchmarks: On PACS and ImageCLEF-DA, CSG-ind consistently outperformed standard baselines. CSG-DA achieved state-of-the-art or highly competitive results against complex, dedicated domain adaptation methods (like CDAN and MDD).
  • Theoretical Guarantees: The authors mathematically proved that successfully identifying the semantic factor guarantees a bounded OOD generalization error, driven primarily by the Fisher divergence between the training and test priors.

Limitations and Future Work

The mathematical guarantees for identifying the semantic factor rely on specific assumptions, such as additive noise and bijectivity. While standard in causal discovery, these may not perfectly hold in all complex, high-dimensional real-world datasets. Furthermore, because CSG is a generative model, it requires more parameters and compute to train compared to purely discriminative baselines. Future work may explore the broader connection between causal representation learning and causal discovery from observed variables.

Summary updated

BibTeX
@inproceedings{liu2021learning,
  author = {Chang Liu and Xinwei Sun and Jindong Wang and Haoyue Tang and Tao Li and Tao Qin and Wei Chen and Tie-Yan Liu},
  title = {{Learning Causal Semantic Representation for Out-of-Distribution Prediction}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=GsOON5c-pU},
}
Figure