arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2307.10156cs.CL
收藏

探索Transformer的外推能力

Exploring Transformer Extrapolation

Shanghai Artificial Intelligence Laboratory(上海人工智能实验室);Northwestern Polytechnical University(西北工业大学)

Zhen Qin, Yiran Zhong, Hui Deng

AI总结:

该研究通过数学与实证分析,发现相对位置编码的指数级数收敛是Transformer具备长度外推能力的条件,据此提出实践方案与无需训练的理论感受野TRF,经多数据集验证其可行性且与实证感受野趋势一致。

摘要:

长度外推近年来受到广泛关注,因为它允许Transformer在比训练时更长的序列上进行测试。此前研究表明,通过精心设计的相对位置编码(Relative Positional Encodings,RPEs)可以实现这一特性。尽管这些方法在多种语料库上表现良好,但长度外推的实现条件尚未得到研究。本文通过全面的数学分析与实证研究,试图确定哪些类型的RPE支持长度外推。我们发现,只要与RPE的指数函数对应的级数收敛,Transformer就必然具备长度外推特性。我们从这些条件中推导出两种实践方案,并在多种语料库的语言建模任务中进行了验证。作为条件推导的额外成果,我们提出了一种新的理论感受野(Theoretical Receptive Field,TRF),无需任何训练步骤即可衡量RPE的感受野。我们在Wikitext-103、Books、Github和WikiBook数据集上开展了大量实验,证明了所发现条件的可行性。我们还在不同模型中将TRF与实证感受野(Empirical Receptive Field,ERF)进行了对比,结果显示二者在上述数据集上的趋势始终一致。代码可在https://github.com/OpenNLPLab/Rpe获取。

英文摘要:

Length extrapolation has attracted considerable attention recently since it allows transformers to be tested on longer sequences than those used in training. Previous research has shown that this property can be attained by using carefully designed Relative Positional Encodings (RPEs). While these methods perform well on a variety of corpora, the conditions for length extrapolation have yet to be investigated. This paper attempts to determine what types of RPEs allow for length extrapolation through a thorough mathematical and empirical analysis. We discover that a transformer is certain to possess this property as long as the series that corresponds to the RPE's exponential converges. Two practices are derived from the conditions and examined in language modeling tasks on a variety of corpora. As a bonus from the conditions, we derive a new Theoretical Receptive Field (TRF) to measure the receptive field of RPEs without taking any training steps. Extensive experiments are conducted on the Wikitext-103, Books, Github, and WikiBook datasets to demonstrate the viability of our discovered conditions. We also compare TRF to Empirical Receptive Field (ERF) across different models, showing consistently matched trends on the aforementioned datasets. The code is available at https://github.com/OpenNLPLab/Rpe.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑