Exploring Compositional Generalization (in COGS/ReCOGS_pos) by Transformers using Restricted Access Sequence Processing (RASP)
Bruns
Humans understand new combinations of words encountered if they are combinations of words recognized from different contexts, an ability called Compositional Generalization. The COGS benchmark (Kim and Linzen, 2020) arXiv:2010.05465 reports 0% accuracy for Transformer models on some structural generalizations. We use (Weiss et al., 2021) arXiv:2106.06981's Restricted Access Sequence Processing (RASP), a Transformer-equivalent programming language, to demonstrate that a Transformer Encoder-Decoder can perform COGS and the semantically equivalent ReCOGS_pos (Wu et al., 2024) arXiv:2303.13716 systematically and compositionally: Our RASP models attain near perfect scores on structural generalization splits on COGS (exact match) and ReCOGS_pos (semantic exact match). Our RASP models show the (Re)COGS tasks do not require a hierarchical or tree-structured solution (contrary to (Kim and Linzen, 2020) arXiv:2010.05465, (Yao and Koller, 2022) arXiv:2210.13050, (Murty et al., 2022) arXiv:2211.01288, (Liu et al., 2021) arXiv:2107.06516): we use word-level tokens with an "embedding" layer that tags with possible part of speech, applying just once per encoder pass 19 attention-head compatible flat pattern-matching rules (easily identified with specific training examples), shown using grammar coverage (Zeller et al., 2023) to cover the non-recursive aspects of the input grammar, plus masking out prepositional phrases ("pp noun") and/or sentential complements (cp) when recognizing grammar patterns and extracting nouns related to the main verb in the sentence, and output the next logical form (LF) token (repeating until the LF is complete). The models do not apply recursive, tree-structured rules like "np_det pp np -> np_pp -> np", but score near perfect semantic and string exact match on both COGS and ReCOGS pp recursion, cp recursion using the decoder loop.
academic
Exploring Compositional Generalization (in COGS/ReCOGS_pos) by Transformers using Restricted Access Sequence Processing (RASP)
Humans possess the ability to understand novel combinations of words identified in different contexts, a capability termed compositional generalization. The COGS benchmark reports that Transformer models achieve 0% accuracy on certain structural generalization tasks. This paper uses RASP (Restricted Access Sequence Processing) language to demonstrate that Transformer encoder-decoder architectures can systematically and compositionally execute COGS and semantically equivalent ReCOGS_pos tasks: the RASP model achieves near-perfect scores on structural generalization splits. The research reveals that (Re)COGS tasks do not require hierarchical or tree-structured solutions; instead, they employ 19 attention-head-compatible flat pattern-matching rules that identify grammatical patterns through masking prepositional phrases and clauses.
The core problem addressed in this research is the limitation of Transformer models' capabilities on compositional generalization tasks, particularly their poor performance on the COGS (Compositional Generalization Challenge based on Semantic Interpretation) benchmark.
Theoretical Significance: Compositional generalization is a core capability of human language understanding. Understanding how neural networks implement this capability is crucial for advancing AI's language comprehension.
Practical Significance: The near-0% accuracy of current Transformer models on structural generalization tasks indicates fundamental limitations that require solutions.
Shallow Network Constraints: The 2-layer Encoder-Decoder used by Kim and Linzen (2020) performs extremely poorly on structural generalization.
Incorrect Hierarchical Assumptions: Existing research assumes that tree structures or hierarchical representations are necessary to solve COGS tasks.
Ineffectiveness of Depth: Petty et al. (2024) found that even increasing to 32 layers provides no improvement for Transformers on COGS structural generalization.
The author was inspired by Zhou et al. (2023), who used RASP to analyze Transformer generalization capabilities. The goal is to demonstrate through constructive proof that Transformers can theoretically solve COGS tasks and analyze why existing models fail.
Constructive Proof: Uses RASP language to prove that Transformer Encoder-Decoder architectures can theoretically solve COGS and ReCOGS_pos tasks systematically.
Flat Solution: Proposes a non-hierarchical solution based on 19 flat pattern-matching rules without requiring recursive tree-structured rules.
Error Analysis: Predicts and validates specific error patterns in baseline Transformers through "attraction error" theory.
Performance Breakthrough: RASP model achieves 99.89% string exact match on COGS and 99.63% semantic exact match on ReCOGS_pos.
New Generalization Split: Discovers and validates a new challenging generalization split "v_dat_p2_pp_moved_to_recipient".
Kim, N., & Linzen, T. (2020). COGS: A compositional generalization challenge based on semantic interpretation. EMNLP 2020.
Wu, Z., Manning, C. D., & Potts, C. (2024). ReCOGS: How incidental details of a logical form overshadow an evaluation of semantic interpretation. TACL.
Weiss, G., Goldberg, Y., & Yahav, E. (2021). Thinking like transformers. NeurIPS 2021.
Zhou, H., et al. (2023). What algorithms can transformers learn? A study in length generalization. arXiv preprint.
Zeller, A., et al. (2023). Grammar coverage. In The Fuzzing Book.
Through rigorous theoretical analysis and empirical validation, this paper provides important insights into understanding Transformer capabilities and limitations on compositional generalization tasks. While it has certain practical limitations, its theoretical contributions and methodological innovations hold significant value for advancing related research.