Is logical analysis performed by transformers taking place in self-attention or in the fully connected part?

Evgeniy Shin, Heinrich Matzinger
1/20/2025
cs.CLcs.AIcs.LG

No confident code implementation found for this paper.

Abstract

Transformers architecture apply self-attention to tokens represented as vectors, before a fully connected (neuronal network) layer. These two parts can be layered many times. Traditionally, self-attention is seen as a mechanism for aggregating information before logical operations are performed by the fully connected layer. In this paper, we show, that quite counter-intuitively, the logical analysis can also be performed within the self-attention. For this we implement a handcrafted single-level encoder layer which performs the logical analysis within self-attention. We then study the scenario in which a one-level transformer model undergoes self-learning using gradient descent. We investigate whether the model utilizes fully connected layers or self-attention mechanisms for logical analysis when it has the choice. Given that gradient descent can become stuck at undesired zeros, we explicitly calculate these unwanted zeros and find ways to avoid them. We do all this in the context of predicting grammatical category pairs of adjacent tokens in a text. We believe that our findings have broader implications for understanding the potential logical operations performed by self-attention.

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{shin2025logical,
  title  = {Is logical analysis performed by transformers taking place in self-attention or in the fully connected part?},
  author = {Evgeniy Shin and Heinrich Matzinger},
  year   = {2025},
  eprint = {2501.11765},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2501.11765v1}
}

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

Discussion