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
FILTERmodule or aRELATEmodule) 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).
Datasets
The models were evaluated on three benchmarks designed to test systematic generalization:
- CLEVR-CoGenT: A synthetic dataset testing generalization to novel combinations of visual attributes (e.g., seeing a "green cube" for the first time).
- CLOSURE: A benchmark that uses CLEVR images but introduces novel, complex linguistic constructs to test how well models recombine known sub-tasks.
- 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
COUNTmodule must behave differently than aFILTERmodule) 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