LLM Maybe LongLM: Self-Extend LLM Context Window Without Tuning

Hongye Jin, Xiaotian Han, Jingfeng Yang, Zhimeng Jiang, Zirui Liu +3 more
1/2/2024
cs.CLcs.AIcs.LG

Official code: datamllab/LongLM (666 stars, MIT, last commit 2024-06-01). 1 more implementation below.

Abstract

It is well known that LLMs cannot generalize well to long contexts whose lengths are larger than the training sequence length. This poses challenges when employing LLMs for processing long input sequences during inference. In this work, we argue that LLMs themselves have inherent capabilities to handle long contexts without fine-tuning. To achieve this goal, we propose SelfExtend to extend the context window of LLMs by constructing bi-level attention information: the grouped attention and the neighbor attention. The grouped attention captures the dependencies among tokens that are far apart, while neighbor attention captures dependencies among adjacent tokens within a specified range. The two-level attentions are computed based on the original model's self-attention mechanism during inference. With minor code modification, our SelfExtend can effortlessly extend existing LLMs' context window without any fine-tuning. We conduct comprehensive experiments on multiple benchmarks and the results show that our SelfExtend can effectively extend existing LLMs' context window length. The code can be found at \url{https://github.com/datamllab/LongLM}.

View on arXivView PDF

Code Implementations(2)

datamllab/LongLMOfficial100%
MIT

[ICML'24 Spotlight] LLM Maybe LongLM: Self-Extend LLM Context Window Without Tuning

66662PythonJan 4, 20242 years agoMIT
context-windowlarge-language-modelsllmlonglmself-extend+1 more
PyTorchMIT

Implementation of SelfExtend from the paper "LLM Maybe LongLM: Self-Extend LLM Context Window Without Tuning" from Pytorch and Zeta

130Shell, PythonJan 3, 20241 years agoMIT
aiartificial-intelligenceattention-is-all-you-needattention-mechanismattention-model+5 more

Similar Papers

Cite this paper

@article{jin2024maybe,
  title  = {LLM Maybe LongLM: Self-Extend LLM Context Window Without Tuning},
  author = {Hongye Jin and Xiaotian Han and Jingfeng Yang and Zhimeng Jiang and Zirui Liu and Chia-Yuan Chang and Huiyuan Chen and Xia Hu},
  year   = {2024},
  eprint = {2401.01325},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2401.01325v3},
  journal = {ICML 2024 2024}
}

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/2401.01325.svg)](https://codeofpaper.com/paper/2401.01325)

Discussion