Learning to Generalize Compositionally by Transferring Across Semantic Parsing Tasks

Wang Zhu, Peter Shaw, Tal Linzen, Fei Sha

TL;DR

Can neural models transfer compositional generalization—the ability to understand novel combinations of familiar elements—from one task to another? This paper introduces DUEL, an alternating pre-finetuning algorithm that decouples encoder and decoder updates across compositional splits to inject compositional inductive bias into sequence encoders. When fine-tuned on downstream semantic parsing tasks like GeoQuery, DUEL outperforms standard pre-finetuning and sets a new neural state-of-the-art on compound divergence splits.

What Problem Does This Paper Address?

Standard deep learning models (such as Transformers) struggle when evaluated on inputs requiring compositional generalization (CG)—for example, interpreting longer sentences than those seen during training, or processing words in unfamiliar syntactic roles. While models perform well on independent and identically distributed (i.i.d.) splits, their accuracy collapses when tested on distributionally mismatched splits.

Most existing remedies involve task-specific architectures, specialized grammars, or data augmentation. This paper asks a different question: Can a model acquire a compositional inductive bias on one task and successfully transfer it to an entirely different task?

Methods

The authors target encoder-decoder models (specifically T5-Base and BERT2SEQ) and formulate a pre-finetuning method called DUEL (Dueling updates):

  1. Decoupled Architecture: The encoder $f(x; \theta)$ maps the input sequence into a generalizable representation space, while the decoder $g(\cdot; \phi)$ serves as the task-specific prediction head.
  2. Adversarial/Alternating Game on Pre-finetuning Splits: Given a pre-finetuning dataset with training distribution $s$ and mismatched evaluation distribution $\tilde{s}$:
  3. Update Head ($\phi$): Freeze $\theta$ and optimize $\phi$ on batches from $s$.
  4. Update Representation ($\theta$): Freeze $\phi$ and update encoder parameters $\theta$ on batches from $\tilde{s}$. This forces the representation to support zero-shot generalization using a head conditioned only on $s$.
  5. The two steps alternate until convergence criteria are met.
  6. Downstream Fine-tuning: The pre-finetuned decoder head is discarded, and the adapted encoder $\theta$ is fine-tuned together with a re-initialized decoder on the target training distribution $q$.
Pre-finetuning:
(x, y) ~ s   --->  f(·; θ) [frozen]  -->  g(·; φ) [update]
(x, y) ~ s̃   --->  f(·; θ) [update]  -->  g(·; φ) [frozen]

Target Fine-tuning:
(x, y) ~ q   --->  Keep θ, Re-init φ  -->  Standard fine-tuning (both updated)

Unlike baseline multi-task pre-finetuning (which lumps $s \cup \tilde{s}$ together, discarding the distribution gap), DUEL exploits the structural shift between $s$ and $\tilde{s}$.

Datasets

The authors evaluate transfer across three distinct semantic parsing and synthetic diagnostic datasets:

  • GeoQuery: 880 natural language questions mapped to FunQL queries about US geography. Evaluated using Target Maximum Compound Divergence (GEOcd) and length splits (GEOlen).
  • SCAN: Over 20,000 navigation commands mapped to action sequences. Evaluated on Maximum Compound Divergence (SCANcd) and length splits (SCANlen).
  • COGS: A synthetic semantic parsing benchmark mapping English sentences to $\lambda$-calculus-style logical forms, split into lexical and structural generalization challenges (COGScg).
  • COGS_VAR: A new set of 10 synthetic variants of COGS created by replacing proper nouns, nouns, and verbs with disjoint WordNet/spaCy vocabularies while keeping syntactic structures identical.

Key Insights and Ideas

  • Compositional Biases Transfer Across Tasks: Pre-finetuning on synthetic navigation commands (SCAN) significantly improves generalization on natural US geography queries (GeoQuery).
  • Partitioning Data Matters: Simply pre-training on merged data ($s \cup \tilde{s}$) provides modest gains, but DUEL’s alternating optimization across the split discrepancy yields significantly larger improvements.
  • Split-Type Alignment: DUEL works best when the compositional distribution shift in pre-finetuning resembles the downstream target shift. For instance, pre-finetuning on $SCAN_{len}$ (short $\to$ long commands) provides the largest boost when transferring to $GEO_{len}$ (short $\to$ long questions).
  • Length Regularization in Representations: Error analysis reveals that DUEL's gains on length splits predominantly come from correctly predicting longer inputs, demonstrating that the encoder learns to prevent premature phrase coupling.

Key Results

  • State-of-the-Art on GeoQuery TMCD (GEOcd): With T5-Base, pre-finetuning on $SCAN_{cd}$ with DUEL achieved 57.8% exact match accuracy—surpassing the previous state-of-the-art of 56.6% held by NQG-T5 (a hybrid neuro-symbolic grammar model). Direct fine-tuning without pre-finetuning yielded only 52.5%.
  • Length Generalization (GEOlen): On T5-Base, DUEL pre-finetuned on $SCAN_{len}$ increased accuracy from 38.6% (no pre-finetuning) and 39.1% (merged baseline) to 45.0%. Pre-finetuning on both COGS and SCAN raised accuracy to 46.4%.
  • SCAN MCD (SCANcd): Pre-finetuning on GeoQuery lifted T5 accuracy on SCAN from 15.4% to 21.3%.

Limitations and Future Work

  • Structural Generalization Remains Intractable: While DUEL boosts lexical generalization on COGS (up to 95.4%), structural generalization (e.g., deeply nested prepositional phrases) remained stubbornly low (~4.5%–5.2%), even when pre-finetuned on 10 structurally identical $COGS\_VAR$ tasks.
  • Dependency on Existing Splits: DUEL requires access to an existing pre-finetuning task that already contains an annotated compositional split.
  • Encoder Fine-tuning Sensitivity: Ablations show that freezing the encoder during the final target fine-tuning stage causes sharp performance drops; both encoder and decoder must be updated downstream for transfer to succeed.

Summary updated

BibTeX
@inproceedings{zhu2022learning,
  author = {Wang Zhu and Peter Shaw and Tal Linzen and Fei Sha},
  title = {{Learning to Generalize Compositionally by Transferring Across Semantic Parsing Tasks}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=ajIC9wlTd52},
}

Loading related content...

Figure