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

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: DiGiugno, Andrew, Mahmood, Ausif
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866909890905112576
author DiGiugno, Andrew
Mahmood, Ausif
author_facet DiGiugno, Andrew
Mahmood, Ausif
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2502_17206
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Neural Attention: A Novel Mechanism for Enhanced Expressive Power in Transformer Models
DiGiugno, Andrew
Mahmood, Ausif
Machine Learning
Neural and Evolutionary Computing
I.2.7; I.2.6; I.5.1; I.4.8
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.
title Neural Attention: A Novel Mechanism for Enhanced Expressive Power in Transformer Models
topic Machine Learning
Neural and Evolutionary Computing
I.2.7; I.2.6; I.5.1; I.4.8
url https://arxiv.org/abs/2502.17206