Learning to Substitute Spans towards Improving Compositional Generalization

Zhaoyi Li, Ying Wei, Defu Lian

Abstract

Neural sequence models frequently fail to generalize to novel combinations of familiar components, a challenge known as compositional generalization. This paper introduces Span Substitution (SpanSub), a flexible data augmentation method that swaps multi-grained, semantically self-contained text fragments. To maximize the effectiveness of this augmentation, the authors propose the Learning to Substitute Span (L2S2) framework. L2S2 uses a differentiable augmenter to identify and prioritize the most challenging span combinations for the model. Evaluated on benchmarks like SCAN, COGS, and GeoQuery, the approach achieves state-of-the-art results, including an absolute improvement of up to 66.5% on SCAN.

Introduction

Compositional generalization is the ability of a system to understand and produce novel combinations of known parts. While humans do this effortlessly, neural sequence models like Transformers and LSTMs often struggle when faced with unseen structures, even if the individual components are familiar. For instance, a model might correctly interpret "walk right" and "jump left" but fail on "walk around right twice" if that specific combination was absent from the training set.

Previous attempts to address this have relied on data augmentation, typically through word-level or subtree-level swaps. However, these methods are often too rigid to capture the full spectrum of linguistic composition, particularly general substructures that do not fit neatly into a single subtree.

Comparison of word-level, subtree-level, and general substructure-level composition.

Methodology

Span Substitution (SpanSub)

The authors propose Span Substitution (SpanSub) to overcome the limitations of fixed-grain augmentation. SpanSub identifies "eligible spans"—consecutive fragments of tokens that are semantically self-contained. Unlike subtrees, spans can represent more general substructures. These spans are then swapped with others from the same "equivalence class," defined by the syntactic roles of their boundary tokens. This allows for a more diverse and flexible set of synthesized training examples.

Learning to Substitute Span (L2S2)

To move beyond random augmentation, the L2S2 framework introduces an automated, difficulty-aware selection process. It utilizes a differentiable augmenter model ($ϕ$) that learns to select spans for substitution. The augmenter is trained in an adversarial-like loop: it aims to generate examples that maximize the loss of the downstream sequence model ($θ$). This forces the system to focus on "elusive" concepts and novel contexts that the model currently finds most difficult to master.

The L2S2 framework: An augmenter selects spans to create challenging training examples for the neural sequence model.

Experimental Results

The proposed method was evaluated on three key benchmarks:

  • SCAN: Focused on the Maximum Compound Divergence (MCD) splits. The model achieved an absolute improvement of up to 66.5%, with accuracy on MCD3 rising from 6.0% to 80.2%.
  • COGS: Designed to test linguistic abstractions like active-to-passive voice. L2S2 improved overall accuracy by 10.3% over previous state-of-the-art augmentation methods.
  • GeoQuery: A real-world US geography dataset. The method set a new state-of-the-art accuracy of 89.5% on the compositional query split.

Conclusion

By combining multi-grained span substitution with an adversarial learning framework, the authors demonstrate a powerful approach to improving compositional generalization. L2S2 effectively creates a curriculum of increasingly difficult examples, allowing neural models to learn complex linguistic rules that were previously out of reach. Future work aims to further automate the span extraction process to make the framework more easily applicable to diverse domains.

Summary updated

BibTeX
@inproceedings{li2023learning,
  author = {Zhaoyi Li and Ying Wei and Defu Lian},
  title = {{Learning to Substitute Spans towards Improving Compositional Generalization}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.157},
}
Figure