Exploring Transformer Extrapolation

Authors

  • Zhen Qin OpenNLPLab, Shanghai AI Lab TapTap
  • Yiran Zhong OpenNLPLab, Shanghai AI Lab
  • Hui Deng Northwestern Polytechnical University

DOI:

https://doi.org/10.1609/aaai.v38i17.29855

Keywords:

NLP: (Large) Language Models, ML: Transparent, Interpretable, Explainable ML

Abstract

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 these datasets. Code is released at: https://github.com/OpenNLPLab/Rpe.

Published

2024-03-24

How to Cite

Qin, Z., Zhong, Y., & Deng, H. (2024). Exploring Transformer Extrapolation. Proceedings of the AAAI Conference on Artificial Intelligence, 38(17), 18897-18905. https://doi.org/10.1609/aaai.v38i17.29855

Issue

Section

AAAI Technical Track on Natural Language Processing II