Inducing Systematicity in Transformers by Attending to Structurally Quantized Embeddings

Yichen Jiang, Xiang Zhou, Mohit Bansal
2/9/2024
cs.CLcs.AIcs.LG

No official code found. Best implementation: jiangycTarheel/SQ-Transformer (10 stars, MIT, last commit 2024-02-12).

Abstract

Transformers generalize to novel compositions of structures and entities after being trained on a complex dataset, but easily overfit on datasets of insufficient complexity. We observe that when the training set is sufficiently complex, the model encodes sentences that have a common syntactic structure using a systematic attention pattern. Inspired by this observation, we propose SQ-Transformer (Structurally Quantized) that explicitly encourages systematicity in the embeddings and attention layers, even with a training set of low complexity. At the embedding level, we introduce Structure-oriented Vector Quantization (SoVQ) to cluster word embeddings into several classes of structurally equivalent entities. At the attention level, we devise the Systematic Attention Layer (SAL) and an alternative, Systematically Regularized Layer (SRL) that operate on the quantized word embeddings so that sentences of the same structure are encoded with invariant or similar attention patterns. Empirically, we show that SQ-Transformer achieves stronger compositional generalization than the vanilla Transformer on multiple low-complexity semantic parsing and machine translation datasets. In our analysis, we show that SoVQ indeed learns a syntactically clustered embedding space and SAL/SRL induces generalizable attention patterns, which lead to improved systematicity.

View on arXivView PDF

Code Implementations(1)

MIT
101Shell, PythonFeb 8, 20242 years agoMIT

Similar Papers

Cite this paper

@article{jiang2024inducing,
  title  = {Inducing Systematicity in Transformers by Attending to Structurally Quantized Embeddings},
  author = {Yichen Jiang and Xiang Zhou and Mohit Bansal},
  year   = {2024},
  eprint = {2402.06492},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.06492v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.06492.svg)](https://codeofpaper.com/paper/2402.06492)

Discussion