Abstract
Domain generalization (DG) is about training models that generalize well under domain shift. Previous research on DG has been conducted mostly in single-source or multi-source settings. In this paper, we consider a third, lesser-known setting where a training domain is endowed with a collection of pairs of examples that share the same semantic information. Such semantic sharing (SS) pairs can be created via data augmentation and then utilized for consistency regularization (CR). We present a theory showing CR is conducive to DG and propose a novel CR method called Logit Attribution Matching (LAM). We conduct experiments on five DG benchmarks and four pretrained models with SS pairs created by both generic and targeted data augmentation methods. LAM outperforms representative single/multi-source DG methods and various CR methods that leverage SS pairs. The code and data of this project are available at https://github.com/Gaohan123/LAM
Introduction
Deep learning models are notoriously "lazy," often relying on spurious correlations rather than causal features. For example, if a dataset always shows cows on green grass, a model might learn that "green grass = cow." When tested on a "cow on a beach," the model fails because it relied on the background rather than the actual features of the cow. Domain Generalization (DG) aims to build models that remain robust when the test data comes from a different distribution (domain shift) than the training data. While most DG research focuses on having multiple source domains, this paper explores a more accessible setting: using Semantic Sharing (SS) pairs. These are pairs consisting of an original image and a version transformed by data augmentation (e.g., putting a giraffe in a different forest). The challenge is how to best use these pairs to teach the model what really matters for classification.
Semantic Sharing and Data Augmentation
The core idea of the proposed method relies on SS pairs—pairs of images that share the same object but differ in style or background. These pairs can be generated through various data augmentation techniques, such as background swapping, geometric transformations, or style transfer. By matching the individual feature contributions across these pairs, the model is forced to ignore spurious correlations and focus on the actual causal features of the object.
Logit Attribution Matching (LAM)
The authors propose a causal framework called Causal Latent Decomposition (CLD), which separates an image into "causal" factors (the object) and "non-causal" factors (style, background). To achieve optimal generalization, a model should be causally invariant—its prediction should only change if the causal factors change.
To enforce this, they introduce Logit Attribution Matching (LAM). Unlike standard consistency methods that just match the final output (the "logit") or the probability, LAM is "finer-grained."
- The Mechanism: For a pair of images $(x, \tilde{x})$ sharing the same label $y$, LAM doesn't just look at the final score. It looks at the contribution of every single feature unit to that score.
- The Math: It minimizes the squared difference between the "attributions" (feature value $\times$ classification weight) of the two images for the target class.
- The Dual Force: This exerts two pressures: it tells the classification head to put more weight on features that are consistent across the pair, and it tells the feature extractor to produce similar values for those important features, effectively "channeling" the common semantic information.
Experimental Evaluation
The authors evaluated LAM across five diverse DG benchmarks:
- iWildCam2020-WILDS: Wildlife photos from different camera trap locations (background shift).
- ImageNet-9: A subset of ImageNet specifically designed to test background robustness.
- NICO: Animal and vehicle images in various contexts (e.g., "dog on grass" vs. "dog in water").
- Camelyon17-WILDS: Medical histopathology images from different hospitals (style/stain shift).
- PACS: Images in four styles: Photo, Art, Cartoon, and Sketch.
They also introduced iWildCam-N, a more difficult variant of iWildCam with added background noise to further test the model's ability to ignore irrelevant objects.
Results and Insights
LAM consistently outperformed standard Empirical Risk Minimization (ERM), data augmentation alone (ERM+DA), and other state-of-the-art DG methods. Across five benchmarks, LAM achieved an average OOD score of 81.1%, compared to 71.4% for standard ERM and 78.7% for ERM with targeted data augmentation. On the challenging iWildCam dataset, LAM improved the Macro F1 score from 30.2% (ERM) to 41.2%. When combined with advanced CLIP model fine-tuning (FLYP), LAM pushed the state-of-the-art on iWildCam from 47.1% to 48.7%.
Key insights include:
- Attribution over Output: Matching the reasoning (attribution) is more powerful than matching the result (logit). If two images get the same score for different reasons, the model hasn't truly learned the invariant concept.
- Model Focus: Weight distribution analysis showed that LAM models have significantly "sparser" and more "focused" classification heads. Visual proof using Grad-CAM saliency maps shows that LAM-trained models consistently "look" at the foreground object, while other models often get distracted by the background.
Conclusion
LAM introduces a powerful way to leverage semantic sharing pairs for domain generalization. By matching feature attributions rather than just final outputs, it forces models to focus on causal features. While its effectiveness depends on the quality of data augmentation and it carries some computational overhead, it represents a significant step forward in building robust, invariant models. Future work may involve using generative models to create even more diverse SS pairs, or exploring parallels between SS pairs in DG and preference pairs used in LLM alignment.
Summary updated