NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Discovering modular solutions that generalize compositionally

Simon Schug, Seijin Kobayashi, Yassir Akram, Maciej Wolczyk, Alexandra Maria Proca, Johannes von Oswald, Razvan Pascanu, Joao Sacramento, Angelika Steger

TL;DR

Neural networks often struggle to solve new tasks that are simply novel combinations of familiar "building blocks." This paper proves that modular architectures—specifically hypernetworks—can discover these underlying blocks and achieve compositional generalization if the training data meets two specific criteria: every block is seen at least once, and they appear in enough overlapping combinations to "glue" their representations together.

What Problem Does This Paper Address?

Imagine an AI that has learned to "push green boxes" and "jump over red boxes." Ideally, it should immediately know how to "jump over green boxes," even if it has never seen that specific combination. This ability to recombine known elements into novel behaviors is known as compositional generalization.

Most modern AI models are "monolithic"—the entire network is involved in every task. While powerful, these models often fail to decompose knowledge into reusable modules. To solve $M$ possible components, a monolithic model might implicitly try to learn all $2^M$ possible combinations from scratch.

Modular vs. Monolithic Architectures

This paper investigates whether modular architectures can autonomously discover the "ground truth" modules of a task distribution, and what conditions the training data must meet for this discovery to happen without explicit human labeling.

Methods

The authors use a teacher-student framework to study this problem with mathematical precision.

  1. The Architecture: They focus on Hypernetworks. A hypernetwork is a "meta-model" that takes a task description (a latent code) and generates the weights for a smaller "target" network that actually performs the task. This setup naturally represents multiplicative interactions and modularity.
  2. The Comparison: They compare modular hypernetworks against popular monolithic meta-learning baselines like MAML (Model-Agnostic Meta-Learning) and ANIL (Almost No Inner Loop).
  3. The Theory: They define two essential conditions for a student to "identify" the teacher's modules:
  4. Compositional Support: The student must see every underlying module at least once during training.
  5. Connected Support: Modules must appear in overlapping combinations. If modules $\{1, 2, 3\}$ only ever appear together and modules $\{4, 5, 6\}$ only ever appear together, the student cannot learn how to consistently "align" their internal representations to solve a mixed task like $\{1, 6\}$.

Datasets

The authors evaluated their ideas across several increasingly complex environments:

  • Synthetic Teacher-Student: A controlled setting where a linear hypernetwork generates weights for a 2-layer ReLU MLP.
  • Hyperteacher: A more complex symbolic task where tasks are sparse, discrete combinations of modules.
  • Compositional Preference Grid World: An agent must navigate a grid to collect colored objects based on a modular reward function (e.g., "I like red 3x more than blue").
  • Compositional Goal Grid World: A navigation task where goals are defined by four independent factors: maze layout, target object, required interaction, and quadrant.

Key Insights and Ideas

  • Identification equals Generalization: The paper shows that if a student can mathematically "identify" the teacher's modules (even up to a linear transformation), it will perfectly generalize to any new combination of those modules.
  • The "Glue" of Connected Support: This is the "aha moment" of the paper. Simply seeing every module isn't enough. Without "connected support," the network might learn inconsistent internal permutations for different groups of modules, making it impossible to combine them later.
Connected vs. Disconnected Task Families
  • Linear Identification is Sufficient: You don't need to recover the exact weights of the teacher. Recovering a linear transformation of them is enough for the student to function perfectly on unseen tasks.
  • Overparameterization is Tricky: While having a few extra neurons helps the model optimize and find a solution, having too many modules in the student allows it to "cheat" by assigning one module per training task. This destroys its ability to find the shared compositional structure.

Key Results

  • Hypernetworks Win at OOD: In the Goal Grid World, modular hypernetworks achieved high accuracy on out-of-distribution (OOD) task combinations, while monolithic models like MAML and ANIL failed completely.
  • Theoretical Validation: When the "Connected Support" condition was intentionally broken in experiments, the performance of the hypernetworks plummeted, confirming that seeing overlapping combinations is a hard requirement for modular discovery.
  • Linear Decodability: The authors showed they could "decode" the ground-truth teacher modules from the student's learned embeddings with an $R^2$ score near 1.0, proving the student actually found the hidden structure.

Limitations and Future Work

  • Sample Complexity: The number of tasks required to achieve 90% OOD accuracy seems to scale poorly as the number of underlying modules ($M$) increases.
  • Number of Modules ($K$): The models tended to overfit to the specific number of modules used in training combinations. If trained on combinations of 2 modules, they struggled when asked to solve a combination of 4.
  • Scaling to LLMs: While the paper mentions Large Language Models (LLMs) as a motivation, the experiments are limited to smaller, controlled environments. Applying these modularity constraints to massive transformer architectures remains a significant open challenge.
  • Optimization Guarantees: The theory describes the global minima of the loss function, but it doesn't guarantee that standard gradient descent will always find these modular solutions in more complex, non-convex landscapes.

Summary updated

BibTeX
@inproceedings{schug2024discovering,
  author = {Simon Schug and Seijin Kobayashi and Yassir Akram and Maciej Wolczyk and Alexandra Maria Proca and Johannes von Oswald and Razvan Pascanu and Joao Sacramento and Angelika Steger},
  title = {{Discovering modular solutions that generalize compositionally}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=H98CVcX1eh},
}
Figure