Since the proposal of transformers, these models have been limited to bounded input lengths, because of their need to attend to every token in the input. In this work, we propose Unlimiformer: a general approach that wraps any existing pretrained encoder-decoder transformer, and offloads the cross-attention computation to a single k-nearest-neighbor (kNN) index, while the returned kNN distances are the attention dot-product scores. This kNN index can be kept on either the GPU or CPU memory and queried in sub-linear time; this way, we can index practically unlimited input sequences, while every attention head in every decoder layer retrieves its top-k keys, instead of attending to every key. We evaluate Unlimiformer on several long-document and book-summarization benchmarks, showing that it can process even 500k token-long inputs from the BookSum dataset, without any input truncation at test time. We demonstrate that 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提出以来,这些模型一直受限于有界输入长度,因为它们需要关注输入中的每一个词元。在本工作中,我们提出Unlimiformer:一种通用方法,它可以封装任何现有的预训练编码器-解码器Transformer,并将交叉注意力计算卸载到单个k近邻(kNN)索引上,而返回的kNN距离即为注意力点积分数。该kNN索引可保存在GPU或CPU内存中,并以亚线性时间进行查询;通过这种方式,我们能够索引几乎无限长的输入序列,同时每个解码器层中的每个注意力头仅检索其前k个键,而非关注所有键。我们在多个长文档和书籍摘要基准上评估了Unlimiformer,结果表明它能够处理来自BookSum数据集的长达50万词元的输入,且在测试时无需任何输入截断。我们证明,Unlimiformer无需额外学习权重或修改代码,即可通过将预训练模型(如BART和Longformer)扩展到无限输入来改进它们。我们已在https://github.com/abertsch72/unlimiformer 公开代码和模型。

0
下载
关闭预览

相关内容

百篇论文纵览大型语言模型最新研究进展
专知会员服务
70+阅读 · 2023年3月31日
最新《Transformers模型》教程,64页ppt
专知会员服务
326+阅读 · 2020年11月26日
专知会员服务
46+阅读 · 2020年10月5日
Transformer文本分类代码
专知会员服务
118+阅读 · 2020年2月3日
【干货】用BRET进行多标签文本分类(附代码)
专知会员服务
85+阅读 · 2019年12月27日
【哈佛大学商学院课程Fall 2019】机器学习可解释性
专知会员服务
106+阅读 · 2019年10月9日
【ICML2019】IanGoodfellow自注意力GAN的代码与PPT
GAN生成式对抗网络
18+阅读 · 2019年6月30日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
基于PyTorch/TorchText的自然语言处理库
专知
28+阅读 · 2019年4月22日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
可解释的CNN
CreateAMind
18+阅读 · 2017年10月5日
【推荐】RNN/LSTM时序预测
机器学习研究会
25+阅读 · 2017年9月8日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
1+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
Arxiv
0+阅读 · 2023年7月5日
Arxiv
11+阅读 · 2023年3月8日
VIP会员
最新内容
《决策模型比较研究》
专知会员服务
8+阅读 · 今天5:16
《美军水下战与海床战概述及本地实施》
专知会员服务
4+阅读 · 今天4:30
面向未来冲突推进陆军情报体制改革
专知会员服务
4+阅读 · 今天4:12
乌克兰纵深打击如何重塑俄罗斯的战略选择
专知会员服务
3+阅读 · 7月24日
俄乌战争中关于中程打击无人机部署的经验启示
《基于强化学习的自动化红队测试》
专知会员服务
6+阅读 · 7月23日
相关基金
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
1+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
Top
微信扫码咨询专知VIP会员