Neural Attentive Circuits

Martin Weiss, Nasim Rahaman, Francesco Locatello, Christopher Pal, Yoshua Bengio, Bernhard Schölkopf, Li Erran Li, Nicolas Ballas

TL;DR

This paper introduces Neural Attentive Circuits (NACs), a novel general-purpose neural architecture that combines modularity with learned, sparse connectivity. NACs excel at tasks requiring adaptation and robustness, outperforming non-modular baselines in few-shot learning and out-of-distribution scenarios, while also offering significant computational efficiency gains.

What Problem Does This Paper Address?

Modern deep learning often relies on "general-purpose" architectures that can handle diverse data types without strong domain-specific assumptions. These models perform well with large datasets but can struggle with sample efficiency and robustness to unseen data. On the other hand, modular architectures, which break down problems into smaller, interacting components, offer potential benefits in these areas. However, existing modular approaches often require domain knowledge and face challenges in jointly learning both the behavior of individual modules and how they connect. This paper aims to bridge this gap by proposing a general-purpose architecture that learns a modular structure, including sparse connectivity, without prior domain expertise.

Methods

The core innovation is the Neural Attentive Circuits (NACs) architecture. NACs consist of two main components trained end-to-end:

  • Circuit Generator: This component learns to create a "circuit design." This design specifies:
  • Module Connectivity: Which modules should interact with each other, determined by learned "signature" vectors.
  • Module Computation: How each module should behave, conditioned by learned "code" vectors.
  • Circuit Executor: This component takes the circuit design and an input, then processes it through a series of learned neural modules. Key elements include:
  • Modulated Fully-Connected (ModFC) Layers: These layers allow module computation to be adaptively conditioned by the "code" vectors from the circuit design.
  • Stochastic Kernel Modulated Dot-Product Attention (SKMDPA): This mechanism enables sparse and attentive communication between modules. The probability of interaction between modules is dynamically determined by the distance between their signature vectors, encouraging sparsity.

NACs can be trained in two ways: unconditionally (circuit design learned globally) or conditionally (circuit design generated per input sample, useful for multi-modal tasks).

Datasets

NACs were evaluated on a variety of datasets across different modalities:

  • Image Classification: Tiny-ImageNet, Tiny-ImageNet-R (for out-of-distribution robustness), and ImageNet (for pre-training and few-shot adaptation).
  • Few-Shot Adaptation: Caltech-UCSD Birds (CUB) and CIFAR datasets.
  • Point Cloud Classification: A benchmark from Carreira et al. [14].
  • Symbolic Processing: ListOps dataset.
  • Text Classification: A task using raw ASCII bytes.
  • Multi-modal Reasoning: Natural Language for Visual Reasoning for Real (NLVR2) dataset.

Key Insights and Ideas

  • Learned Modularity for Generalization: The paper demonstrates that imposing a learned modular structure, particularly with sparse connectivity, significantly improves performance on tasks requiring adaptation to new data (few-shot learning) and robustness to unseen data distributions (OOD).
  • Joint Learning of Connectivity and Computation: NACs' ability to jointly learn how modules connect (via signatures) and what they compute (via codes) is crucial. This end-to-end learning allows the architecture to discover optimal modular configurations for specific tasks.
  • Adaptive Computation for Efficiency: The sparse connectivity learned by NACs allows for significant pruning of modules at inference time without substantial performance degradation. This leads to substantial speedups and reduced computational cost, making NACs adaptable to different resource constraints.
  • Conditional Circuit Design for Reasoning: For tasks like multi-modal reasoning (NLVR2), conditioning the circuit design on specific input modalities (e.g., text) allows the model to generate tailored computational pathways, suggesting potential for more nuanced reasoning.

Key Results

  • Few-Shot Adaptation: NACs improved low-shot adaptation on CIFAR and CUB datasets by approximately 10% compared to a strong non-modular baseline (Perceiver IO).
  • OOD Robustness: NACs achieved about 2.5% improvement on the Tiny-ImageNet-R out-of-distribution dataset.
  • Computational Efficiency: NACs can achieve an 8x speedup at inference time by dropping modules, with less than a 3% loss in performance.
  • General-Purpose Performance: NACs showed competitive results across diverse tasks including point-cloud classification, symbolic processing, and text classification from raw bytes.
  • Qualitative Analysis (NLVR2): Conditional NACs generated diverse and meaningful module connectivity graphs that qualitatively correlated with different types of linguistic reasoning.

Limitations and Future Work

  • Graph Prior Trade-offs: The paper notes that the choice of graph prior (e.g., scale-free vs. ring-of-cliques) can lead to a trade-off between in-distribution (IID) and out-of-distribution (OOD) performance.
  • Conditional Generator Implementation: The conditional circuit generator was implemented using a simple cross-attention mechanism, and the authors suggest that other methods (e.g., auto-regressive models, GFlowNets) could be explored.
  • Further Exploration of Graph Properties: The authors suggest that exploring different graph properties and regularization techniques could unlock further performance gains.
  • Understanding Co-adaptation: While experiments suggest modules co-adapt, further investigation into the degree and nature of this co-adaptation could be beneficial.
  • Scalability of Conditional Generation: While promising, the scalability and efficiency of generating circuit designs per sample for very large inputs or complex reasoning tasks could be a future research direction.

Summary updated

BibTeX
@inproceedings{weiss2022neural,
  author = {Martin Weiss and Nasim Rahaman and Francesco Locatello and Christopher Pal and Yoshua Bengio and Bernhard Schölkopf and Li Erran Li and Nicolas Ballas},
  title = {{Neural Attentive Circuits}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
}
Figure