Abstract
While Transformers excel at many tasks, they notoriously struggle with compositional generalization—the ability to combine known components (like "walk" and "thrice") into novel commands ("walk thrice") they haven't seen before. This paper demonstrates that by adding two simple auxiliary sequence prediction tasks that track the progress of repetitions and sub-actions, a Transformer can jump from <10% accuracy to a perfect 100% on the challenging SCAN benchmark.
Introduction
Human intelligence is inherently compositional. If you know what "dax" means as a verb, you immediately understand what it means to "dax twice." However, standard neural networks, including Transformers, tend to be "associative." Instead of learning the underlying algebraic rules of a language, they often memorize specific combinations seen during training.
When tested on the SCAN dataset—a benchmark requiring models to translate natural language commands (e.g., "jump opposite left twice") into action sequences—standard Transformers fail on "Maximum Compound Divergence" (MCD) splits. These splits ensure that the combinations of words in the test set are different from those in the training set. In these scenarios, accuracy often hovers below 10%, as the model tries to map novel commands to the closest "whole" command it memorized during training rather than parsing the structure.
Methods
The authors propose a multi-pronged approach to "induce" compositionality in Transformers through the CGPS-Transformer architecture and auxiliary supervision.
Core Innovations
- CGPS-Transformer Architecture: The model uses separate embedding matrices for every word: a functional (syntactic) embedding and a primitive (semantic) embedding. This forces the model to separate what an action is from how it fits into a sentence structure.
- Auxiliary Sequence Prediction: During training, the model predicts two additional sequences alongside the actual actions:
- AuxSeq1 (Repetition Tracker): Tracks the progress of loops (e.g., for "walk thrice," it signals the current repetition count).
- AuxSeq2 (Sub-action Tracker): Identifies the completion of individual primitive actions (e.g., the steps of "turning left" then "walking").
- Joint Inference: During testing, the model jointly predicts the next tokens in these auxiliary sequences, forcing it to maintain an internal state that understands the symbolic structure of the command.
- Low-Context Queries: The authors found that using the output of the decoder's first layer (less contextualized) as the query for auxiliary tasks worked better than using the final layer, preventing symbolic meaning from being "blurred" by excessive context.
Key Results
The proposed method achieved near-perfect generalization across all challenging splits of the SCAN benchmark, significantly outperforming previous state-of-the-art models and standard Transformer baselines.
- Perfect Generalization: On the MCD splits, where the baseline Transformer scored between 0.4% and 1.6%, the proposed model achieved 100% accuracy.
- Length Generalization: On the LENGTH split (generalizing to longer sequences), the model improved from 0% to 100%.
- Few-Shot Success: With only 5% of training data, the model reached 97.8% accuracy on MCD1. Without auxiliary tasks, the model couldn't reach even 10% accuracy with the full dataset.
Discussion and Conclusion
Compositionality isn't necessarily a matter of data volume; it is a matter of proper guidance. The auxiliary tasks act as a "scaffold," forcing the Transformer to adopt an algorithmic, step-by-step reasoning process rather than holistic pattern-matching.
While highly effective on synthetic datasets like SCAN and gSCAN, applying this to natural language remains a challenge. Generating these auxiliary sequences for "wild" language would require sophisticated heuristics or automated parsers. However, this work proves that with the right inductive biases, Transformers are capable of the rigorous symbolic reasoning required for true compositional intelligence.
Summary updated