Length Extrapolation of Transformers: A Survey from the Perspective of Positional Encoding
Liang Zhao, Xiachong Feng, Xiaocheng Feng, Weihong Zhong, Dongliang Xu, Qing Yang, Hongtao Liu, Bing Qin, Ting Liu
TL;DR
The paper addresses the challenge of transforming Transformers to handle inputs longer than their training context. It foregrounds positional encoding as the key factor for length extrapolation and organizes techniques into interpolation and extrapolation, further split into zero-shot and fine-tuned families. Key contributions include a comprehensive taxonomy, detailed surveys of ALiBi, RoPE, XPOS, LongNet, Landmark Attention, and memory-augmented methods, plus critical analysis of zero-shot and fine-tuned extrapolation strategies and their empirical performance. The work highlights practical implications for long-document understanding and retrieval-augmented generation, identifying promising directions for scalable, memory-efficient long-context modeling in real-world applications.
Abstract
Built upon the Transformer, large language models (LLMs) have captured worldwide attention due to their remarkable abilities. Nevertheless, all Transformer-based models including LLMs suffer from a preset length limit and can hardly generalize from short training sequences to longer inference ones, namely, they cannot perform length extrapolation to handle long sequences, which severely hinders their application in scenarios demanding long input sequences such as legal or scientific documents. Thus, numerous methods have emerged to enhance the length extrapolation of Transformers. Despite the great research efforts, a systematic survey is still lacking. To fill this gap, we delve into these advances in a unified notation from the perspective of positional encoding (PE), as it has been considered the primary factor on length extrapolation. Specifically, we begin with extrapolatable PEs that have dominated this research field. Then, we dive into extrapolation methods based on them, covering position interpolation and randomized position methods. Finally, several challenges and future directions in this area are highlighted. Through this survey, we aim to enable the reader to gain a deep understanding of existing methods and provide stimuli for future research.
