Introduction
Compositional generalisation—the ability of a model to handle complex structures or longer sequences than those encountered during training—remains a significant challenge in Natural Language Processing (NLP). While modern sequence-to-sequence (seq2seq) models like Transformers excel at pattern recognition, they often struggle with out-of-distribution (OOD) scenarios, frequently "hallucinating" or failing to capture the underlying logical structure of a task. This paper, presented at EACL 2023, proposes a novel architecture that incorporates explicit structural inductive biases to bridge the gap between flexible neural networks and rule-based symbolic grammars.
Architecture: Fertility and Reordering Layers
The core innovation of this work is the introduction of two differentiable structural layers situated between the encoder and the decoder. These layers explicitly decouple the generation process into two fundamental operations: determining how many times a token appears (fertility) and where it is positioned (reordering).
- The Fertility Layer: Instead of relying on an
<EOS>token to guess the end of a sequence, the model predicts a fertility value for each input token, representing the number of times it should appear in the output (ranging from 0 to $d$). The total output length is then calculated as the sum of these fertilities. - The Reordering Layer: Utilizing permutation trees, this layer learns to shuffle tokens into the correct output order. This mechanism is capable of handling non-monotonic movements, which are common in tasks like semantic parsing and translation.
To maintain end-to-end differentiability, the authors employ Structured Attention. Rather than selecting a single discrete configuration, the model uses dynamic programming to compute the expected value across all possible fertilities and permutations. Furthermore, a simplified decoder is used to ensure the model relies on these structural layers for logic rather than memorizing text chunks.
Experimental Evaluation
The model was evaluated across several challenging benchmarks designed to test compositional generalisation:
- Mirroring Task: A synthetic test requiring the model to reverse strings (e.g.,
abctoabccba). - Semantic Parsing (Geoquery, ATIS, Okapi): Tasks involving the translation of natural language into formal code, with specific splits to test generalisation to longer queries.
- StylePTB: A style transfer benchmark focused on structural transformations, such as active-to-passive voice conversion.
Key Results and Insights
The proposed model (F→R) demonstrated remarkable robustness in length generalisation. On the synthetic Mirroring task, the model maintained 100% accuracy even as sequence lengths increased, whereas standard LSTMs and Transformers saw performance plummet to near zero as sequences grew longer.
Beyond synthetic tasks, the architecture significantly outperformed much larger pre-trained models. On the ATIS length split, the F→R model achieved 35.41% accuracy, more than doubling the 19.03% accuracy of a fine-tuned BART-base. These results suggest that well-designed structural bottlenecks can provide a more effective inductive bias than raw parameter scaling.
Conclusion and Future Work
By treating output length as a sum of fertilities and explicitly modeling reordering, this research provides a path toward more reliable compositional generalisation. While the current implementation faces computational challenges—specifically the cubic runtime complexity of the reordering layer relative to sequence length—it sets a new standard for structural modeling in neural NLP. Future work may explore faster reordering algorithms or the integration of these layers with large-scale pre-trained decoders.
Summary updated