We introduce WildCat, a high-accuracy, low-cost approach to compressing the attention mechanism in neural networks. While attention is a staple of modern network architectures, it is also notoriously expensive to deploy due to resource requirements that scale quadratically with the input sequence length $n$. WildCat avoids these quadratic costs by only attending over a small weighted coreset. Crucially, we select the coreset using a fast but spectrally-accurate subsampling algorithm -- randomly pivoted Cholesky -- and weight the elements optimally to minimise reconstruction error. Remarkably, given bounded inputs, WildCat approximates exact attention with super-polynomial $O(n^{-\sqrt{\log(\log(n))}})$ error decay while running in near-linear $O(n^{1+o(1)})$ time. In contrast, prior practical approximations either lack error guarantees or require quadratic runtime to guarantee such high fidelity. We couple this advance with a GPU-optimized PyTorch implementation and a suite of benchmark experiments demonstrating the benefits of WildCat for image generation, image classification, and language model KV cache compression.


翻译:本文提出WildCat,一种高精度、低成本的神经网络注意力机制压缩方法。注意力机制作为现代网络架构的核心组件,因其计算资源需求随输入序列长度$n$呈二次方增长而难以实际部署。WildCat通过仅对小型加权核心集进行注意力计算来规避二次方复杂度。我们采用快速且谱精度保持的随机主元Cholesky子采样算法选取核心集,并通过优化权重配置最小化重构误差。值得注意的是,在输入有界条件下,WildCat能以超多项式误差衰减率$O(n^{-\sqrt{\log(\log(n))}})$逼近精确注意力,同时保持近乎线性的$O(n^{1+o(1)})$时间复杂度。相比之下,现有实用化近似方法要么缺乏误差保证,要么需要二次方时间复杂度才能实现同等精度保障。我们将该算法与GPU优化的PyTorch实现相结合,通过图像生成、图像分类及语言模型KV缓存压缩等基准实验验证了WildCat的优越性。

0
下载
关闭预览

相关内容

Attention机制最早是在视觉图像领域提出来的,但是真正火起来应该算是google mind团队的这篇论文《Recurrent Models of Visual Attention》[14],他们在RNN模型上使用了attention机制来进行图像分类。随后,Bahdanau等人在论文《Neural Machine Translation by Jointly Learning to Align and Translate》 [1]中,使用类似attention的机制在机器翻译任务上将翻译和对齐同时进行,他们的工作算是是第一个提出attention机制应用到NLP领域中。接着类似的基于attention机制的RNN模型扩展开始应用到各种NLP任务中。最近,如何在CNN中使用attention机制也成为了大家的研究热点。下图表示了attention研究进展的大概趋势。
卷积神经网络中的注意力机制综述
专知会员服务
77+阅读 · 2021年10月22日
最新「注意力机制」大综述论文,66页pdf569篇文献
专知会员服务
210+阅读 · 2021年4月2日
注意力机制综述
专知会员服务
83+阅读 · 2021年1月26日
注意力机制介绍,Attention Mechanism
专知会员服务
172+阅读 · 2019年10月13日
注意力机制综述(中文版)
专知
23+阅读 · 2021年1月26日
注意力机制可解释吗?这篇ACL 2019论文说……
机器之心
11+阅读 · 2019年6月16日
【干货】注意力机制(Attention)最新综述论文及相关源码
GAN生成式对抗网络
11+阅读 · 2018年11月16日
【干货】基于Keras的注意力机制实战
专知
59+阅读 · 2018年5月4日
深度学习中的注意力机制
人工智能头条
16+阅读 · 2017年11月2日
国家自然科学基金
3+阅读 · 2017年12月31日
国家自然科学基金
43+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
Arxiv
0+阅读 · 2月16日
Arxiv
0+阅读 · 2月12日
Arxiv
0+阅读 · 2月12日
VIP会员
相关资讯
注意力机制综述(中文版)
专知
23+阅读 · 2021年1月26日
注意力机制可解释吗?这篇ACL 2019论文说……
机器之心
11+阅读 · 2019年6月16日
【干货】注意力机制(Attention)最新综述论文及相关源码
GAN生成式对抗网络
11+阅读 · 2018年11月16日
【干货】基于Keras的注意力机制实战
专知
59+阅读 · 2018年5月4日
深度学习中的注意力机制
人工智能头条
16+阅读 · 2017年11月2日
相关基金
国家自然科学基金
3+阅读 · 2017年12月31日
国家自然科学基金
43+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员