Neural Attention: A Novel Mechanism for Enhanced Expressive Power in Transformer Models

Andrew DiGiugno, Ausif Mahmood
2/24/2025
cs.LGcs.NE

Official code: awayfromzel/neural-attention-research (1 star, MIT, last commit 2025-11-07).

Abstract

Transformer models typically calculate attention matrices using dot products, which have limitations when capturing nonlinear relationships between embedding vectors. We propose Neural Attention, a technique that replaces dot products with feed-forward networks, enabling a more expressive representation of relationships between tokens. This approach modifies only the attention matrix calculation while preserving the matrix dimensions, making it easily adaptable to existing transformer-based architectures. We provide a detailed mathematical justification for why Neural Attention increases representational capacity and conduct controlled experiments to validate this claim. When comparing Neural Attention and Dot-Product Attention, NLP experiments on WikiText-103 show a reduction in perplexity of over 2 percent. Similarly, experiments on CIFAR-10 and CIFAR-100 show improvements in accuracy of more than 4 percentage points for image classification tasks. While Neural Attention introduces higher computational demands, we develop techniques to mitigate these challenges, ensuring practical usability without sacrificing the increased expressivity it provides. This work establishes Neural Attention as an effective means of enhancing the predictive capabilities of transformer models across a variety of applications. The code for all experiments is available at https://github.com/awayfromzel/neural-attention-research.

View on arXivView PDF

Code Implementations(1)

MIT

Research implementation a novel neural attention mechanism replacing dot-product attention with a learned MLP over concatenated Q/K embeddings, achieving improved perplexity in transformer models.

10PythonFeb 22, 202511 months agoMIT

Similar Papers

Cite this paper

@article{digiugno2025neural,
  title  = {Neural Attention: A Novel Mechanism for Enhanced Expressive Power in Transformer Models},
  author = {Andrew DiGiugno and Ausif Mahmood},
  year   = {2025},
  eprint = {2502.17206},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.17206v2}
}

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

Discussion