Learning Algebraic Recombination for Compositional Generalization

Chenyao Liu, Shengnan An, Zeqi Lin, Qian Liu, Bei Chen, Jian-Guang Lou, Lijie Wen, Nanning Zheng, Dongmei Zhang

Abstract

Compositional generalization—the ability to understand and produce an infinite number of novel combinations from a finite set of known components—remains a significant challenge for modern neural networks. This paper presents LEAR (Learning Algebraic Recombination), a novel neural architecture designed to bridge the gap between flat sequence processing and recursive linguistic structure. By modeling semantic parsing as a mathematical homomorphism between latent syntax and semantic operations, LEAR achieves substantial improvements on compositional generalization benchmarks, notably increasing accuracy on the CFQ dataset from 67% to 91%.

Introduction: The Challenge of Compositional Generalization

While standard neural networks excel at pattern recognition, they often struggle with "compositional generalization." A model might learn that "John" is a subject and "teaches" is a verb, yet fail when these elements are nested in complex, recursive structures it hasn't encountered during training.

The authors distinguish between two fundamental types of recombination:

  1. Lexical Recombination: Swapping individual words within a known structure (e.g., changing "John teaches the girl" to "The girl teaches John").
  2. Algebraic Recombination: Dynamically nesting structured expressions into recursive patterns (e.g., understanding "Tom teaches John’s daughter’s daughter").
Algebraic vs. Lexical Recombination: (a) illustrates the recursive nesting of structured expressions, while (b) shows the simpler swapping of lexical units.

Most current sequence-to-sequence models, including Transformers, treat language as a flat string. This approach lacks the inductive bias necessary to capture the underlying "algebra" of grammar, leading to poor performance on tasks requiring deep recursion.

The LEAR Architecture

To address these limitations, the authors propose LEAR, which consists of two primary modules trained jointly via reinforcement learning.

The Composer: Latent Syntactic Parsing

The Composer acts as a latent syntactic parser. Utilizing a Latent Tree-LSTM, it constructs a binary tree from the input sentence in a bottom-up manner. A key innovation is "Abstraction by Nonterminal Symbols," where the model learns to categorize sub-trees into abstract categories (e.g., a noun phrase). This allows the model to treat a complex phrase like "John's daughter" as a single unit that can be seamlessly plugged into larger, more complex structures.

The Interpreter: Assigning Meaning

The Interpreter assigns semantic value to the tree produced by the Composer. It maps leaf nodes (words) to semantic primitives and internal nodes to semantic operations (such as "JOIN" or "AND"). This mapping follows the principle of semantic locality, where the meaning of a compound expression is determined solely by its constituent parts, preventing the model from over-fitting to specific global sentence patterns.

Training via Reinforcement Learning

Since ground-truth labels for internal tree structures are unavailable, LEAR is trained using REINFORCE. The model receives a reward based on the accuracy of the final generated logical form. To stabilize training, the authors employ Curriculum Learning, gradually increasing the complexity and length of the training sentences.

Experimental Results

LEAR was evaluated on three major benchmarks designed to test different aspects of compositional generalization:

  • CFQ (Compositional Freebase Questions): A large-scale dataset of natural language questions mapped to SPARQL queries. LEAR achieved 90.9% accuracy, a significant leap over the previous state-of-the-art (67.3%) and standard Transformers (~18%).
  • COGS: A benchmark targeting both lexical and structural challenges. LEAR reached 97.7% accuracy, compared to 35% for a standard Transformer baseline.
  • GEO: A dataset of real-world geographical queries. LEAR achieved 84.1%, demonstrating its effectiveness on non-synthetic data.

Key Insights

The success of LEAR highlights several critical factors for compositional generalization:

  • Parsing as Homomorphism: Treating language as a mapping between syntax and semantics allows the model to learn general rules rather than memorizing specific strings.
  • Latent Structure: Ablation studies confirmed that the explicit tree structure is essential; performance drops significantly when the model is forced to process language as a flat sequence.
  • Recursive Robustness: Unlike many models that degrade as input length increases, LEAR maintains high accuracy (over 86%) even on the most complex, deeply nested test cases.

Conclusion and Future Work

LEAR demonstrates that incorporating latent recursive structures and algebraic inductive biases can dramatically improve a model's ability to generalize. However, challenges remain. The model currently assumes a relatively direct alignment between input words and output meaning units, struggling with "one-to-many" mappings (e.g., "brother" implying both "sibling" and "male"). Additionally, the set of possible semantic operations must still be defined by human experts for each domain. Future research will focus on automating the discovery of these operations and relaxing alignment constraints to better handle the nuances of natural language.

Summary updated

BibTeX
@inproceedings{liu2021learning,
  author = {Chenyao Liu and Shengnan An and Zeqi Lin and Qian Liu and Bei Chen and Jian-Guang Lou and Lijie Wen and Nanning Zheng and Dongmei Zhang},
  title = {{Learning Algebraic Recombination for Compositional Generalization}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.findings-acl.97},
}
Figure