Cost-Effective Attention Mechanisms for Low Resource Settings: Necessity & Sufficiency of Linear Transformations
Peyman Hosseini, Mehran Hosseini, Ignacio Castro, Matthew Purver
TL;DR
This paper tackles the high memory and compute demands of scaled dot-product attention (SDPA) in low-resource environments. It introduces three SDPA variants—Optimized Attention, Efficient Attention, and Super Attention—that modify the arrangement of linear transformations (including absorbing projections into other matrices and adding a left-mixing alignment kernel) to cut parameters by 25-50% and reduce FLOPs, while preserving or improving model quality. Across NLP benchmarks (sentiment, MT, generative LM, NLI) and Vision Transformers, Optimized and Efficient Attentions match standard SDPA with far fewer parameters and faster inference, while Super Attention frequently outperforms the baseline by up to about 10% in accuracy and is also more edge-friendly. The findings suggest these attention variants enable more capable transformer models to run on devices with limited computation and memory, broadening practical deployment in real-world, resource-constrained settings.
Abstract
From natural language processing to vision, Scaled Dot Product Attention (SDPA) is the backbone of most modern deep learning applications. Unfortunately, its memory and computational requirements can be prohibitive in low-resource settings. In this paper, we improve its efficiency without sacrificing its versatility. We propose three attention variants where we remove consecutive linear transformations or add a novel one, and evaluate them on a range of standard NLP and vision tasks. Our proposed models are substantially lighter than standard SDPA (and have 25-50% fewer parameters). We show that the performance cost of these changes is negligible relative to size reduction and that in one case (Super Attention) we succeed in outperforming SDPA by up to 10% while improving its speed and reducing its parameters by 25%.
