NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Transcoding Compositionally: Using Attention to Find More Generalizable Solutions

Kris Korrel, Dieuwke Hupkes, Verna Dankers, Elia Bruni

TL;DR

This paper introduces seq2attn, a novel architecture that enhances sequence-to-sequence models by introducing a "transcoder" module. This module uses attention to modulate information flow, encouraging models to learn compositional patterns rather than relying on superficial heuristics, leading to better generalization and interpretability.

What Problem Does This Paper Address?

Deep learning models, particularly sequence-to-sequence (seq2seq) models, have achieved remarkable success in various tasks. However, a critical question remains: do these models truly "understand" the underlying rules of the tasks they perform, or do they merely exploit statistical biases in the training data? Research suggests that while these models can be highly accurate, their generalization capabilities are often limited, especially when faced with novel combinations of known elements. This lack of true understanding, or compositional generalization, makes it difficult to predict when and why these models might fail. The paper aims to address this by developing a model that is explicitly designed to learn and apply compositional rules, leading to more robust and interpretable solutions.

Methods

The core contribution is the seq2attn architecture, which augments a standard encoder-decoder model with a new component called a transcoder.

  • Transcoder: This is a recurrent module that sits between the encoder and decoder. It modulates the information flow by generating sparse attention vectors. Crucially, it uses separate keys and values for attention, which helps disentangle the representation of what to attend to from how to attend.
  • Gumbel-Softmax: To encourage more selective attention (focusing on specific parts of the input rather than a distributed average), the authors employ Gumbel-Softmax. This technique allows for a continuous relaxation of the categorical distribution, enabling backpropagation while still encouraging sparse attention patterns.
  • Input Embeddings as Attention Values: The decoder uses input embeddings as attention values, further restricting it to work with disentangled representations of individual input symbols.
  • Full Focus Decoder: The decoder's hidden state is integrated with the context vector using an element-wise multiplication, making the output more directly dependent on the current context.

These components are integrated into a standard recurrent encoder-decoder framework. The key novelty lies in the transcoder and its use of Gumbel-Softmax to promote compositional attention.

Datasets

The paper evaluates seq2attn on two datasets specifically designed to test compositional generalization:

  • Lookup Tables: This dataset, adapted from Liška et al. (2018), involves applying sequences of simple, bijective functions (lookup tables) to bitstrings. The challenge lies in learning to apply these functions compositionally rather than treating the entire input sequence as a single unit. The authors use specific training/testing splits, including "held-out tables" and "held-out compositions," to rigorously test generalization.
  • SCAN: This dataset, from Lake and Baroni (2018), involves mapping natural language commands (e.g., "jump after walk left twice") to sequences of actions. The authors focus on experiments designed to assess systematic compositionality, particularly concerning how models handle novel combinations of primitives and modifiers.

Key Insights and Ideas

  • Compositionality is Key to Generalization: The paper strongly advocates that true understanding in AI tasks, especially those involving language, requires compositional generalization – the ability to combine known elements in novel ways.
  • Attention Can Be More Than a Black Box: By carefully designing the attention mechanism (via the transcoder and Gumbel-Softmax), the authors show that attention patterns can become highly interpretable, revealing how a model arrives at its solution.
  • Overgeneralization as a Proxy for Compositional Bias: The authors propose a novel testing paradigm: observing how a model handles "exceptions" (instances designed to be learned only through memorization). A model with a strong compositional bias might overgeneralize its learned rules to these exceptions, which can be a valuable indicator of its underlying learning strategy.
  • Heuristics vs. Rules: The work highlights the distinction between models that learn superficial heuristics (which lead to high accuracy on training data but poor generalization) and those that learn underlying rules (which are more robust).

Key Results

  • Lookup Tables: seq2attn achieves perfect accuracy (100%) on held-out test sets, demonstrating strong generalization. A standard seq2seq baseline fails to generalize on these sets.
  • SCAN: seq2attn shows significantly better performance on challenging SCAN conditions (e.g., the "0 fillers" condition) compared to a standard seq2seq model, indicating a better ability to learn compositional rules for novel command combinations.
  • Interpretability: Attention patterns generated by seq2attn are shown to be sparse and systematic, clearly attending to relevant input parts, unlike the diffused attention of the baseline.
  • Overgeneralization: In both tasks, seq2attn exhibits a stronger tendency to overgeneralize on exceptions compared to the baseline, supporting the hypothesis that it has a stronger compositional bias.

Limitations and Future Work

  • Rigid Information Flow: The authors acknowledge that the transcoder's information flow from encoder to decoder is currently quite rigid.
  • Future Work: They suggest exploring less skewed activation functions (e.g., Sparsemax) or adaptive computation time. Importantly, they plan to integrate seq2attn into other popular seq2seq architectures like convolutional seq2seq and Transformers. They also note that for tasks where test accuracy isn't directly linked to compositionality (like general natural language modeling), additional assessment methods are needed.

Summary updated

BibTeX
@inproceedings{korrel2019transcoding,
  author = {Kris Korrel and Dieuwke Hupkes and Verna Dankers and Elia Bruni},
  title = {{Transcoding Compositionally: Using Attention to Find More Generalizable Solutions}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2019},
}
Figure