Transformer-based models typically have a predefined bound to their input length, because of their need to potentially attend to every token in the input. In this work, we propose Unlimiformer: a general approach that can wrap any existing pretrained encoder-decoder transformer, and offload the attention computation across all layers to a single $k$-nearest-neighbor index; this index can be kept on either the GPU or CPU memory and queried in sub-linear time. This way, we can index extremely long input sequences, while every attention head in every decoder layer retrieves its top-$k$ keys, instead of attending to every key. We demonstrate Unlimiformers's efficacy on several long-document and multi-document summarization benchmarks, showing that it can summarize even 350k token-long inputs from the BookSum dataset, without any input truncation at test time. Unlimiformer improves pretrained models such as BART and Longformer by extending them to unlimited inputs without additional learned weights and without modifying their code. We make our code and models publicly available at https://github.com/abertsch72/unlimiformer .


翻译:Transformer-based模型通常会对它们的输入长度有一个预定义的限制,因为它们需要考虑到输入中的每个标记。 在这项工作中,我们提出了Unlimiformer:一种通用方法,可以包装任何现有的预先训练的编码器-解码器Transformer,并将注意力计算跨越所有层分配给单个 $k$-nearest-neighbor索引; 该索引可以保留在GPU或CPU内存上并在次线性时间内查询。这样,我们就可以索引极长的输入序列,而每个解码器层中的每个注意力头都检索其前 $k$ 个键,而不是考虑每个键。我们在几个长文档和多文档摘要基准测试中展示了Unlimiformer的效果,表明它可以总结甚至来自BookSum 数据集的长度为350k个标记的输入,而不在测试时截断输入。Unlimiformer通过扩展它们以处理无限输入而无需增加学习的权重或修改它们的代码来改进了预先训练模型,例如BART和Longformer。我们在https://github.com/abertsch72/unlimiformer上公开了我们的代码和模型。

1
下载
关闭预览

相关内容

专知会员服务
36+阅读 · 2021年5月15日
Transformer文本分类代码
专知会员服务
116+阅读 · 2020年2月3日
【Google论文】ALBERT:自我监督学习语言表达的精简BERT
专知会员服务
22+阅读 · 2019年11月4日
一文带你浏览Graph Transformers
PaperWeekly
1+阅读 · 2022年7月8日
Hierarchically Structured Meta-learning
CreateAMind
23+阅读 · 2019年5月22日
TensorFlow seq2seq中的Attention机制(续)
深度学习每日摘要
15+阅读 · 2017年11月16日
【推荐】RNN/LSTM时序预测
机器学习研究会
25+阅读 · 2017年9月8日
【推荐】全卷积语义分割综述
机器学习研究会
19+阅读 · 2017年8月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
1+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
Arxiv
12+阅读 · 2022年11月21日
Arxiv
13+阅读 · 2017年12月5日
VIP会员
相关资讯
一文带你浏览Graph Transformers
PaperWeekly
1+阅读 · 2022年7月8日
Hierarchically Structured Meta-learning
CreateAMind
23+阅读 · 2019年5月22日
TensorFlow seq2seq中的Attention机制(续)
深度学习每日摘要
15+阅读 · 2017年11月16日
【推荐】RNN/LSTM时序预测
机器学习研究会
25+阅读 · 2017年9月8日
【推荐】全卷积语义分割综述
机器学习研究会
19+阅读 · 2017年8月31日
相关基金
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
1+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
Top
微信扫码咨询专知VIP会员