Implicit Reasoning in Transformers: Bridging the Compositionality Gap in GPT-2-like Models

Davide Venuto, Leonardo Venuto
10/28/2026
cs.CLcs.AI
transformer-attention

No confident code implementation found for this paper.

Abstract

Compositional generalization remains a persistent limitation of transformer language models: even when a model learns to combine known facts correctly in-distribution (ID), the same compositional mechanism may fail when applied to out-of-distribution (OOD) knowledge. We investigate this compositionality gap in a controlled two-hop reasoning setting using a GPT-2-like transformer model trained from scratch.

Show full abstract

Building on prior work identifying a circuit associated with compositional generalization, we test whether the failure of OOD transfer is related to how atomic knowledge is structurally exposed during training. We modify the training distribution by presenting both ID and OOD atomic facts in a format positionally aligned with the second-hop retrieval step of the learned compositional circuit, without modifying the model architecture or adding OOD compositional supervision. Under this intervention, the model successfully transfers the learned ID compositional behaviour to held-out OOD atomic facts, closing the observed compositionality gap in the controlled setting. Our results provide evidence that the observed compositionality gap is not a fundamental architecture limitation and that it can be overcome through mechanistically informed training distribution design.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{venuto2026implicit,
  title  = {Implicit Reasoning in Transformers: Bridging the Compositionality Gap in GPT-2-like Models},
  author = {Davide Venuto and Leonardo Venuto},
  year   = {2026},
  eprint = {2610.39016},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2610.39016v1}
}

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/2610.39016.svg)](https://codeofpaper.com/paper/2610.39016)

Discussion