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

Transformer Module Networks for Systematic Generalization in Visual Question Answering

Moyuru Yamada, Vanessa D'Amario, Kentaro Takemoto, Xavier Boix, Tomotake SasakiarXiv 2022

TL;DR

Transformer Module Networks (TMNs) combine the representational power of Transformers with the structural flexibility of Neural Module Networks to solve Visual Question Answering (VQA). By assembling specialized Transformer-based modules into question-specific architectures, TMNs achieve state-of-the-art systematic generalization, outperforming standard Transformers by over 30% on novel linguistic combinations.

What Problem Does This Paper Address?

While Transformer-based models dominate Visual Question Answering (VQA) benchmarks, they often rely on spurious correlations rather than true reasoning. Specifically, they struggle with systematic generalization: the ability to handle novel combinations of known concepts. For example, a model trained on "red squares" and "blue circles" might fail to recognize a "red circle" or understand a complex question structure it hasn't seen before.

Previous research suggested that Neural Module Networks (NMNs)—which decompose questions into sub-tasks handled by specialized neural "modules"—generalize better. However, most NMNs use older CNN-based architectures. This paper asks: Can we combine the attention mechanisms of Transformers with the modularity of NMNs to bridge the gap between in-distribution performance and systematic generalization?

Methods

The authors introduce the Transformer Module Network (TMN). The core idea is to treat a question as a "program" of sub-tasks (e.g., FILTER(square), COUNT) and build a custom network for each question using a library of specialized modules.

Key architectural features include:

  • Transformer Modules: Each module (e.g., a FILTER module or a RELATE module) is implemented as a small stack of Transformer encoders.
  • Question-Specific Composition: Unlike standard Transformers that use a fixed number of layers, a TMN’s depth and structure change based on the question's complexity. If a program has $L$ sub-tasks and each module has $K$ layers, the total depth is $K \times L$.
  • Shared Workspace: The tokens representing the input image act as a shared workspace. Each module in the sequence transforms these representations before passing them to the next.
  • Modular Structures: The authors explored two ways to arrange these modules: a simple Stack (sequential) and a Tree structure, which allows for parallel processing of logical operations (like AND/OR).
Figure 1: Overview of Transformer Module Network (TMN). (a) TMN has a library of neural mod- ules that tackle a sub-task, and each module is implemented with a small stack of Transformer encoders. (b) The modules are composed into a question-specific network. This network takes as input an image and a program that corresponds to a question. The total number of Transformer layers is the number of Transformer layers of each module (K) × the program length (L).

Datasets

The models were evaluated on three benchmarks designed to test systematic generalization:

  1. CLEVR-CoGenT: A synthetic dataset testing generalization to novel combinations of visual attributes (e.g., seeing a "green cube" for the first time).
  2. CLOSURE: A benchmark that uses CLEVR images but introduces novel, complex linguistic constructs to test how well models recombine known sub-tasks.
  3. GQA-SGL (Systematic Generalization to Linguistic combinations): A newly introduced benchmark by the authors. It adapts the GQA dataset (which uses natural images) to specifically test systematic generalization by creating 200 new questions with linguistic combinations never seen in the training set.

Key Insights and Ideas

  • Modularity is the Antidote to Overfitting: Standard Transformers tend to "memorize" the training distribution. By forcing the model to use discrete, specialized modules, TMNs are pushed to learn the underlying logic of sub-tasks, which transfers better to new scenarios.
  • Specialization is Mandatory: The authors found that simply having a variable number of layers isn't enough. The modules must be specialized for their specific sub-task (e.g., a COUNT module must behave differently than a FILTER module) to achieve high generalization scores.
  • Trees Beat Stacks for Logic: For complex linguistic reasoning (like in the CLOSURE dataset), the Tree structure significantly outperformed the Stack structure, likely because it better mirrors the inherent hierarchical nature of human language.
  • Visual vs. Linguistic Bottlenecks: TMNs showed massive gains in linguistic generalization but more modest gains in visual attribute generalization. This suggests that visual generalization is more dependent on the initial feature extractor (the CNN/Vision Transformer) than the reasoning backbone.

Key Results

The TMN-Tree model achieved remarkable results across the board:

  • CLOSURE: TMN-Tree reached 95.4% accuracy, a staggering improvement over the standard Transformer's 57.4%.
  • GQA-SGL: On natural images, TMN-Tree (53.7%) outperformed both the standard Transformer (47.7%) and the recently proposed Meta-Module Network (51.0%).
  • CLEVR-CoGenT: TMNs were competitive with state-of-the-art models like MDETR, proving they can handle visual shifts as well as linguistic ones.

Limitations and Future Work

The primary limitation of TMNs (and NMNs in general) is their reliance on programmatic descriptions of questions. Currently, the model requires a human-annotated or pre-parsed "program" to know which modules to assemble. Applying this to datasets where such programs aren't available remains a challenge.

Future work involves developing methods to automatically decompose raw natural language questions into these modular programs without losing the generalization benefits. The authors also aim to investigate more diverse types of systematic generalization beyond the visual and linguistic combinations studied here.

Summary updated

BibTeX
@misc{yamada2022transformer,
  author = {Moyuru Yamada and Vanessa D'Amario and Kentaro Takemoto and Xavier Boix and Tomotake Sasaki},
  title = {{Transformer Module Networks for Systematic Generalization in Visual Question Answering}},
  year = {2022},
  eprint = {2201.11316},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2201.11316},
}
Figure