Compositional generalization is a hallmark of human intelligence. If you know what a "blue elephant" looks like and what a "bicycle" is, you can easily imagine a "blue elephant riding a bicycle"—even if you’ve never seen one.
Current AI models, however, struggle with this. They frequently fail under compositional shift, a specific type of distribution shift where certain combinations of attributes (e.g., "Waterbird" + "Land Background") are entirely absent during training but appear at test time. Standard training methods like Empirical Risk Minimization (ERM) tend to memorize spurious correlations. If a model only sees waterbirds on water, it might learn that the water is the bird, failing completely when the background changes.
To address this, researchers have developed Compositional Risk Minimization (CRM), a novel framework that enables machine learning models to accurately predict attribute combinations they have never encountered during training.
The CRM Framework: Additive Energy and Affine Hulls
While previous research has explored compositional generalization for generative tasks (like image synthesis), this work tackles the harder problem of discriminative tasks: making accurate predictions in novel, unseen circumstances. The CRM approach rests on two core pillars:
- Additive Energy Distributions (AED): Instead of treating every combination of attributes as a unique, isolated class, the model assumes the "energy" (or log-probability) of an input is the sum of independent energy terms for each attribute. Think of it like a recipe: the total flavor is the sum of the salt, the sugar, and the spice. If you know how salt tastes in ten different dishes, you can predict its effect in an eleventh.
- The Discrete Affine Hull: The authors provide a key mathematical proof showing that an additive model can generalize to any new attribute combination that falls within the "discrete affine hull" of the training data. Essentially, if a novel combination can be expressed as a linear re-mixing of seen combinations, the model can handle it.
The CRM Algorithm operates in two distinct steps: * Step 1: Train an additive energy classifier to predict all attributes jointly on the available training data. * Step 2: Adjust the classifier’s "bias" terms for the test distribution. Because the model is additive, it can mathematically extrapolate the correct bias for an unseen group using only data from the seen groups.
Key Insights: Exponential Growth from Linear Data
Perhaps the most surprising finding is how little data is actually needed to achieve this generalization. The authors prove that the "volume" of the discrete affine hull grows exceptionally fast. A model only needs to see roughly $O(md \log d)$ combinations (where $m$ is the number of attributes and $d$ is the number of values per attribute) to generalize to all $d^m$ possible combinations. For instance, in a system with 5 binary attributes, seeing just a handful of combinations is enough to master all 32 possibilities.
However, the paper also demonstrates that the affine hull is a necessary condition. If a combination falls outside this mathematical space, the model cannot reliably extrapolate.
Empirical Results
The researchers evaluated CRM on several popular benchmarks modified to create "compositional holes" (dropping specific attribute combinations from the training set), including Waterbirds, CelebA, MetaShift, MultiNLI, CivilComments, and NICO++.
CRM consistently outperformed state-of-the-art robust methods designed for subpopulation shifts, such as GroupDRO and Logit Correction (LC):
- Waterbirds: When a specific group was entirely missing from training, CRM achieved a 78.7% Worst-Group Accuracy (WGA), whereas standard ERM plummeted to 43.0%.
- Scaling to Complexity: In a complex version of CelebA with 5 attributes, CRM maintained a WGA of 63.2%, while the next best baseline managed only 34.3%.
- Closing the Gap: CRM often performed nearly as well on unseen groups as other models did on groups they had seen during training, effectively neutralizing the penalty of missing data.
Limitations and Future Directions
While powerful, CRM has limitations. Primarily, it relies on the assumption that all attributes (even spurious ones like background type) are labeled during training. In many real-world datasets, confounding factors are unknown. Furthermore, while AEDs are flexible, they assume attributes do not have complex, non-linear interactions.
Future work could extend this framework to unsupervised settings where the model must discover attributes on its own before applying CRM logic. Additionally, these discriminative insights could be cycled back into generative models to further improve the compositional quality of AI-generated content.
Summary updated