Cottention: Linear Transformers With Cosine Attention

变压器 计算机科学 数学 电气工程 工程类 电压
作者
Gabriel Mongaras,Trevor Dohm,Eric C. Larson
出处
期刊:Cornell University - arXiv [Cornell University]
标识
DOI:10.48550/arxiv.2409.18747
摘要

Attention mechanisms, particularly softmax attention, have been instrumental in the success of transformer-based models such as GPT. However, the quadratic memory complexity of softmax attention with respect to sequence length poses significant challenges for processing longer sequences. We introduce Cottention, a novel attention mechanism that replaces the softmax operation with cosine similarity. By leveraging the properties of cosine similarity and rearranging the attention equation, Cottention achieves native linear memory complexity with respect to sequence length, making it inherently more memory-efficient than softmax attention. We demonstrate that Cottention can be reformulated as a recurrent neural network (RNN) with a finite hidden state, allowing for constant memory usage during inference. We evaluate Cottention on both the bidirectional BERT and causal GPT tasks, demonstrating comparable performance to softmax attention while significantly reducing memory requirements. To ensure efficient computation, we develop a custom CUDA kernel for Cottention. Our results show that Cottention is a promising alternative to softmax attention, enabling the processing of longer sequences without sacrificing performance, due to its native linear memory complexity and ability to maintain a constant memory footprint during inference.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
123完成签到,获得积分10
1秒前
dawn完成签到,获得积分10
2秒前
3秒前
atopos发布了新的文献求助30
3秒前
taokey完成签到,获得积分10
4秒前
hui发布了新的文献求助10
5秒前
基拉发布了新的文献求助20
8秒前
11秒前
远方的蓝风铃完成签到,获得积分10
12秒前
安云野完成签到,获得积分10
13秒前
we发布了新的文献求助10
16秒前
温暖砖头发布了新的文献求助10
16秒前
GuanguanYaa发布了新的文献求助10
16秒前
柚子发布了新的文献求助10
18秒前
小四喜发布了新的文献求助10
18秒前
木冉完成签到 ,获得积分10
18秒前
wickedzz完成签到,获得积分0
21秒前
zcs完成签到,获得积分10
22秒前
xuhui发布了新的文献求助10
25秒前
向日葵发布了新的文献求助10
27秒前
zoe发布了新的文献求助10
32秒前
32秒前
怀念逸完成签到,获得积分10
34秒前
柚子发布了新的文献求助10
34秒前
Orange应助哦豁采纳,获得10
34秒前
蓝蓝的腿毛完成签到 ,获得积分10
35秒前
36秒前
Copyright应助科研通管家采纳,获得10
36秒前
36秒前
中野霊乃完成签到,获得积分10
36秒前
平淡的翅膀完成签到 ,获得积分10
36秒前
37秒前
侯侯侯发布了新的文献求助30
37秒前
潇洒的惋清应助yzm采纳,获得10
38秒前
YangZhang发布了新的文献求助30
39秒前
在水一方应助小官采纳,获得10
40秒前
Vergo发布了新的文献求助10
41秒前
无极微光应助迷你的书包采纳,获得20
42秒前
43秒前
44秒前
高分求助中
Principles of Economics, 11th Edition 10000
University Physics with Modern Physics, 16th edition 10000
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
Gründe der Seele:Die Wiener Psychatrie im 20.Jahrhundert 1000
Development of a Bridge Weigh-In-Motion System: A technology to convert the bridge response to the passage of traffic into data on vehicle configurations, speeds, times of travel and weights 1000
Organic Reactions, Volume 116 1000
Current concepts in cutaneous toxicity : proceedings of the Fourth Conference on Cutaneous Toxicity, Washington, D.C., May 9-11, 1979 1000
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 内科学 物理 复合材料 催化作用 细胞生物学 无机化学 光电子学 物理化学 电极 基因
热门帖子
关注 科研通微信公众号,转发送积分 7272679
求助须知:如何正确求助?哪些是违规求助? 8893613
关于积分的说明 18801081
捐赠科研通 6947050
什么是DOI,文献DOI怎么找? 3204865
关于科研通互助平台的介绍 2377027
邀请新用户注册赠送积分活动 2180253