CLEX: Continuous Length Extrapolation for Large Language Models

Guanzheng Chen, Xin Li, Zaiqiao Meng, Shangsong Liang, Li Bing
10/1/2023

No official code found. Best implementation: DAMO-NLP-SG/CLEX (78 stars, MIT, last commit 2024-03-12).

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.

View on arXivView PDF

Code Implementations(1)

DAMO-NLP-SG/CLEXCommunity100%
MIT

[ICLR 2024] CLEX: Continuous Length Extrapolation for Large Language Models

7811Shell, PythonOct 25, 20232 years agoMIT
large-language-modelslong-context-modelingrotary-position-embedding

Similar Papers

Cite this paper

@article{chen2023clex,
  title  = {CLEX: Continuous Length Extrapolation for Large Language Models},
  author = {Guanzheng Chen and Xin Li and Zaiqiao Meng and Shangsong Liang and Li Bing},
  year   = {2023},
  eprint = {2310.16450},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2310.16450},
  journal = {ICLR 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2310.16450.svg)](https://codeofpaper.com/paper/2310.16450)

Discussion