Compositional Generalization Across Distributional Shifts with Sparse Tree Operations

Paul Soulos, Henry Conklin, Mattia Opper, Paul Smolensky, Jianfeng Gao, Roland Fernandez

Abstract

Standard neural networks often struggle with compositional generalization—the ability to combine known components in novel ways. This paper introduces the Sparse Differentiable Tree Machine (sDTM), a unified neurosymbolic architecture that performs symbolic tree operations directly in vector space. By utilizing Sparse Coordinate Trees (SCT) and bit-shift operations, the sDTM achieves a 70x reduction in parameters and a 13x speedup over previous models while maintaining superior performance on out-of-distribution (OOD) tasks, particularly in zero-shot lexical scenarios.

Introduction

While massive Transformers excel at pattern recognition, they frequently fail at structural or lexical shifts. For instance, a model that understands "jump" and "run twice" may fail to interpret "jump twice" if that specific combination was absent from its training data. Existing solutions typically fall into two categories: purely connectionist models that require vast amounts of data, or hybrid neurosymbolic systems that are often brittle and difficult to scale.

The sDTM aims to bridge this gap by implementing symbolic operations (such as moving a subtree) as differentiable neural operations. This allows the model to retain the flexibility of a neural network while benefiting from the rigorous structure of a symbolic program.

Methods: Sparse Coordinate Trees and Bit-Shifts

The core innovation of the sDTM is the Sparse Coordinate Tree (SCT). Unlike previous methods that used memory-intensive Tensor Product Representations (TPRs), SCT stores trees as a list of (index, value) pairs. The index is a Gorn address—a binary representation of the path from the root—which allows the model to bypass empty nodes and handle deep trees efficiently.

To perform structural transformations like left-child or construct, the model employs Bit-Shift Operations on these Gorn indices. This approach enables parallelized, differentiable tree transformations without exponential memory growth.

Mechanism for differentiable tree transformations using bit-shifts on Gorn indices.

The sDTM Architecture

The architecture consists of three primary components:

  1. Agent: A Transformer encoder that determines which symbolic operation to execute.
  2. Interpreter: Executes the SCT operations based on the Agent's guidance.
  3. Memory: Stores intermediate tree states for complex computations.

To integrate variable-sized trees back into the Transformer Agent, the authors utilize Pooling by Attention (PMA) to create a fixed-dimensional summary of the tree state.

Experimental Evaluation

The sDTM was evaluated on several benchmarks designed to test distributional shifts:

  • Active↔Logical: Semantic parsing and natural language generation.
  • FOR2LAM: Program translation (imperative to functional) involving deep structures.
  • SCAN: Synthetic command-following tasks focusing on systematic generalization.
  • GeoQuery: Natural language to SQL translation.

Evaluation metrics focused on Out-of-Distribution (OOD) shifts, including 0-shot lexical (novel words), structural/length (longer sequences), and Maximum Compound Divergence (MCD).

Results and Discussion

The sDTM demonstrates significant improvements in both efficiency and generalization. Compared to the original DTM, it achieved a 70x reduction in parameters (from 72M to 1M) and a 13x speedup in inference.

Radar chart comparing sDTM against NQG and RU-Transformer baselines across multiple generalization benchmarks.

As shown in the performance comparison, the sDTM (red) dominates in 0-shot lexical generalization. On the Active↔Logical task, it maintained perfect 1.0 accuracy on lexical shifts where standard Transformers dropped to 0.0. This success stems from the model's ability to factorize content (vectors) from structure (indices); if the model knows how to manipulate a "slot," the specific word occupying that slot becomes irrelevant.

Limitations

Despite its strengths, the sDTM faced challenges with the GeoQuery dataset due to high natural language variation and small training sets. Additionally, while it excels at lexical and structural shifts, it still struggles with Maximum Compound Divergence (MCD), where the distribution of combinations changes drastically between training and testing.

Conclusion

The sDTM represents a significant step toward practical neurosymbolic computing. By performing symbolic operations in a unified vector space and leveraging sparsity for scalability, it provides a robust framework for compositional generalization. Future work will focus on refining how the Transformer Agent parameterizes symbolic operations to improve performance on more natural, less synthetic language tasks.

Summary updated

BibTeX
@inproceedings{soulos2024compositional,
  author = {Paul Soulos and Henry Conklin and Mattia Opper and Paul Smolensky and Jianfeng Gao and Roland Fernandez},
  title = {{Compositional Generalization Across Distributional Shifts with Sparse Tree Operations}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=fOQunr2E0T},
}
Figure