🤖 AI Summary
Standard Transformer self-attention relies on dot-product similarity, which lacks expressivity for capturing complex, nonlinear token interactions. To address this, we propose Neural Attention—a novel attention mechanism that replaces the fixed dot-product with a learnable feed-forward neural network to compute attention weights. This is the first approach to introduce parameterized nonlinear mapping into attention weight computation while preserving dimensional compatibility and mathematical differentiability, thereby substantially enhancing representational capacity. The mechanism is inherently cross-modal: it achieves consistent gains across NLP and CV benchmarks—reducing perplexity by over 5% on WikiText-103 and significantly improving classification accuracy on CIFAR-10/100. Through rigorous computational complexity analysis and architectural optimization, we ensure both enhanced modeling capability and practical deployability.
📝 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 5 percent. Similarly, experiments on CIFAR-10 and CIFAR-100 show comparable improvements 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.