Lune

ICLR2024Top-tier venue

CLEX: Continuous Length Extrapolation for Large Language Models

Guanzheng Chen, Xin Li, Zaiqiao Meng, Shangsong Liang, Lidong Bing

Abstract

Transformer-based Large Language Models (LLMs) are pioneering advances in many natural language processing tasks, however, their exceptional capabilities are restricted within the preset context window of Transformer. Position Embedding (PE) scaling methods, while effective in extending the context window to a specific length, demonstrate either notable limitations in their extrapolation abilities or sacrificing partial performance within the context window. Length extrapolation methods, although theoretically capable of extending the context window beyond the training sequence length, often underperform in practical long-context applications. To address these challenges, we propose Continuous Length EXtrapolation (CLEX) for LLMs. We generalise the PE scaling approaches to model the continuous dynamics by ordinary differential equations over the length scaling factor, thereby overcoming the constraints of current PE scaling methods designed for specific lengths. Moreover, by extending the dynamics to desired context lengths beyond the training sequence length, CLEX facilitates the length extrapolation with impressive performance in practical tasks. We demonstrate that CLEX can be seamlessly incorporated into LLMs equipped with Rotary Position Embedding, such as LLaMA and GPT-NeoX, with negligible impact on training and inference latency. Experimental results reveal that CLEX can effectively extend the context window to over 4x or almost 8x training length, with no deterioration in performance. Furthermore, when evaluated on the practical LongBench benchmark, our model trained on a 4k length exhibits competitive performance against state-of-the-art open-source models trained on context lengths up to 32k. Our code is available at https://github.com/DAMO-NLP-SG/CLEX.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

25 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • MambaLRP: Explaining Selective State Space Sequence Models cites Training-Free Long-Context Scaling of Large Language Models
  • Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation cites Compressive Transformers for Long-Range Sequence Modelling
  • FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness cites Compressive Transformers for Long-Range Sequence Modelling
  • InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
  • InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory cites FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
  • InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory cites Training-Free Long-Context Scaling of Large Language Models
  • InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory cites Compressive Transformers for Long-Range Sequence Modelling
  • DAPE: Data-Adaptive Positional Encoding for Length Extrapolation cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
  • DAPE: Data-Adaptive Positional Encoding for Length Extrapolation cites Training-Free Long-Context Scaling of Large Language Models
  • FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning cites FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Training-Free Long-Context Scaling of Large Language Models cites FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Training-Free Long-Context Scaling of Large Language Models cites FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
  • Training-Free Long-Context Scaling of Large Language Models cites Compressive Transformers for Long-Range Sequence Modelling
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers25

  1. InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context MemoryChaojun Xiao, Pengle Zhang, Xu Han, Guangxuan Xiao et al.NeurIPS 2024 · 223 citations
  2. Training-Free Long-Context Scaling of Large Language ModelsChenxin An, Fei Huang, Jun Zhang, Shansan Gong et al.ICML 2024 · 68 citations
  3. MambaLRP: Explaining Selective State Space Sequence ModelsFarnoush Rezaei Jafari, Grégoire Montavon, Klaus-Robert Müller, Oliver EberleNeurIPS 2024 · 44 citations
  4. DAPE: Data-Adaptive Positional Encoding for Length ExtrapolationChuanyang Zheng, Yihang Gao, Han Shi, Minbin Huang et al.NeurIPS 2024 · 42 citations
  5. EverMemOS: A Self-Organizing Memory Operating System for Structured Long-Horizon ReasoningChuanrui Hu, Xingze Gao, Zuyi Zhou, Dannong Xu et al.ACL 2026 · 26 citations

Builds on12

  1. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra et al.NeurIPS 2022 · 5,493 citations
  2. Finetuned Language Models are Zero-Shot LearnersJason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu et al.ICLR 2022 · 4,966 citations
  3. FlashAttention-2: Faster Attention with Better Parallelism and Work PartitioningTri DaoICLR 2024 · 2,600 citations
  4. Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 citations
  5. Compressive Transformers for Long-Range Sequence ModellingJack W. Rae, Anna Potapenko, Siddhant M. Jayakumar, Chloe Hillier et al.ICLR 2020 · 833 citations

Related papers

  1. Extending Context Window of Large Language Models from a Distributional PerspectiveYingsheng Wu, Yuxuan Gu, Xiaocheng Feng, Weihong Zhong et al.EMNLP 2024 · 1 citation
  2. Scaling Laws of RoPE-based ExtrapolationXiaoran Liu, Hang Yan, Chenxin An, Xipeng Qiu et al.ICLR 2024 · 130 citations
  3. LaMPE: Length-aware Multi-grained Positional Encoding for Adaptive Long-context Scaling Without TrainingSikui Zhang, Guangze Gao, Ziyun Gan, Chunfeng Yuan et al.ACL Findings 2026
  4. YaRN: Efficient Context Window Extension of Large Language ModelsBowen Peng, Jeffrey Quesnelle, Honglu Fan, Enrico ShippoleICLR 2024 · 508 citations
  5. Base of RoPE Bounds Context LengthMingyu Xu, Xin Men, Bingning Wang, Qingyu Zhang et al.NeurIPS 2024 · 56 citations
Dusk over the sea between two cliffs drawn in fine vertical lines