Generative Classifiers Avoid Shortcut Solutions

Alexander C. Li, Ananya Kumar, Deepak Pathak

Abstract

Standard discriminative models often fail under distribution shifts because they rely on "shortcuts"—spurious correlations like backgrounds rather than core features. This paper demonstrates that generative classifiers, which model the class-conditional distribution $p(x|y)$ using modern diffusion and autoregressive models, are naturally more robust to these shifts. By forcing the model to explain the entire data distribution rather than just the easiest path to a label, generative classifiers achieve state-of-the-art performance on major distribution shift benchmarks.

Introduction

Deep learning models are notoriously "lazy." When trained to predict a label $y$ from an input $x$ (discriminative learning), they often latch onto shortcuts: features that are correlated with the label in the training set but are not causally or fundamentally linked to the class. A classic example is a model learning to identify a "bird" based on a "water" background. When presented with a bird in a forest (a distribution shift), the model fails.

While previous attempts to mitigate shortcut learning have relied on specialized data augmentations or complex regularization, these methods often require prior knowledge of the specific shortcuts present in the data. This paper explores a more fundamental shift: moving from discriminative to generative classification to bypass the shortcut problem entirely.

The Generative Classification Framework

The authors revisit the classical concept of generative classification, powered by modern high-capacity architectures. Instead of learning the conditional probability $p(y|x)$ directly, the models are trained to learn the class-conditional distribution $p(x|y)$. At inference time, the model applies Bayes’ Rule to determine the most likely class: $p(y|x) \propto p(x|y)p(y)$.

Implementation across Modalities

  1. Image Classification (Diffusion-Based): For image tasks, the authors utilize Latent Diffusion Models (LDMs). Because diffusion models do not provide an exact likelihood, the authors use the denoising error as a proxy for $p(x|y)$. This represents how effectively the model can reconstruct a noisy image when conditioned on a specific class label.
  2. Text Classification (Autoregressive): For text, Llama-style Transformers are employed. The standard "Beginning of Sequence" token is replaced with a special class token. The model’s ability to predict the subsequent text sequence given that class token provides the likelihood estimate.

Why Generative Models Resist Shortcuts

The paper identifies several key reasons why this generative approach outperforms traditional discriminative models under distribution shift:

1. Modeling the Entire Input

Discriminative models can ignore the vast majority of an input once they find a single predictive shortcut. In contrast, a generative model’s objective is to reconstruct or explain the entire input. To minimize its loss, the model must eventually learn the core features of the object, as these are essential for a high-fidelity reconstruction of $x$.

2. Gradient Persistence

In discriminative training, the gradient (the signal used for learning) for majority groups often vanishes once a shortcut is identified. In generative models, the gradient remains strong throughout training. This allows the model to continuously refine its understanding of core features even after it has "solved" the training labels.

3. The "Consistently Predictive" Bias

Through Gaussian toy mathematical analysis, the authors demonstrate that generative models possess an inductive bias toward features that are consistently correlated with the label. Discriminative models, conversely, prefer features that allow for a "max-margin" separation, even if those features are noisy or spurious.

Experimental Evaluation

The generative approach was evaluated on five rigorous distribution shift benchmarks: Waterbirds and CelebA (subpopulation shifts), Camelyon17 (medical domain shift), FMoW (satellite imagery shifts), and CivilComments (text toxicity detection).

The results demonstrate that generative classifiers achieve state-of-the-art (SOTA) performance, often by significant margins:

  • Waterbirds: The generative model achieved 79.4% worst-group accuracy, a massive improvement over the 32.2% achieved by standard Empirical Risk Minimization (ERM) and 31.6% for other specialized robust methods.
  • CivilComments: Worst-group accuracy improved to 61.4% (vs. 53.3% for ERM).
  • FMoW: Out-of-distribution (OOD) accuracy reached 35.8%, compared to 27.5% for the baseline.

Notably, generative classifiers also showed improved in-distribution accuracy on most datasets, suggesting they are less prone to standard overfitting than their discriminative counterparts.

Limitations and Future Work

Despite their robustness, generative classifiers face practical challenges. The primary hurdle is inference cost; diffusion-based classification requires multiple denoising steps for every possible class, making it significantly slower than a single forward pass of a standard discriminative network.

Additionally, the authors noted that on specific datasets like Camelyon17, very large generative models may eventually begin to overfit, leading to a decline in OOD performance. Future research may focus on integrating popular training augmentations like "Mixup" into the generative framework and applying this logic to broader tasks such as reasoning and code completion.

Conclusion

Generative classifiers offer a promising path toward building models that understand the "why" behind a label rather than just the "how" of the training data. By forcing models to explain the data they see, we can move closer to AI systems that are robust, reliable, and resistant to the pitfalls of shortcut learning.

Summary updated

BibTeX
@inproceedings{li2025generative,
  author = {Alexander C. Li and Ananya Kumar and Deepak Pathak},
  title = {{Generative Classifiers Avoid Shortcut Solutions}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=oCUYc7BzXQ},
}
Figure