InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Xiao, Chaojun, Zhang, Pengle, Han, Xu, Xiao, Guangxuan, Lin, Yankai, Zhang, Zhengyan, Liu, Zhiyuan, Sun, Maosong
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866929361549000704
author Xiao, Chaojun
Zhang, Pengle
Han, Xu
Xiao, Guangxuan
Lin, Yankai
Zhang, Zhengyan
Liu, Zhiyuan
Sun, Maosong
author_facet Xiao, Chaojun
Zhang, Pengle
Han, Xu
Xiao, Guangxuan
Lin, Yankai
Zhang, Zhengyan
Liu, Zhiyuan
Sun, Maosong
contents Large language models (LLMs) have emerged as a cornerstone in real-world applications with lengthy streaming inputs (e.g., LLM-driven agents). However, existing LLMs, pre-trained on sequences with a restricted maximum length, cannot process longer sequences due to the out-of-domain and distraction issues. Common solutions often involve continual pre-training on longer sequences, which will introduce expensive computational overhead and uncontrollable change in model capabilities. In this paper, we unveil the intrinsic capacity of LLMs for understanding extremely long sequences without any fine-tuning. To this end, we introduce a training-free memory-based method, InfLLM. Specifically, InfLLM stores distant contexts into additional memory units and employs an efficient mechanism to lookup token-relevant units for attention computation. Thereby, InfLLM allows LLMs to efficiently process long sequences with a limited context window and well capture long-distance dependencies. Without any training, InfLLM enables LLMs that are pre-trained on sequences consisting of a few thousand tokens to achieve comparable performance with competitive baselines that continually train these LLMs on long sequences. Even when the sequence length is scaled to $1,024$K, InfLLM still effectively captures long-distance dependencies. Our code can be found in \url{https://github.com/thunlp/InfLLM}.
format Preprint
id arxiv_https___arxiv_org_abs_2402_04617
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory
Xiao, Chaojun
Zhang, Pengle
Han, Xu
Xiao, Guangxuan
Lin, Yankai
Zhang, Zhengyan
Liu, Zhiyuan
Sun, Maosong
Computation and Language
Artificial Intelligence
Machine Learning
Large language models (LLMs) have emerged as a cornerstone in real-world applications with lengthy streaming inputs (e.g., LLM-driven agents). However, existing LLMs, pre-trained on sequences with a restricted maximum length, cannot process longer sequences due to the out-of-domain and distraction issues. Common solutions often involve continual pre-training on longer sequences, which will introduce expensive computational overhead and uncontrollable change in model capabilities. In this paper, we unveil the intrinsic capacity of LLMs for understanding extremely long sequences without any fine-tuning. To this end, we introduce a training-free memory-based method, InfLLM. Specifically, InfLLM stores distant contexts into additional memory units and employs an efficient mechanism to lookup token-relevant units for attention computation. Thereby, InfLLM allows LLMs to efficiently process long sequences with a limited context window and well capture long-distance dependencies. Without any training, InfLLM enables LLMs that are pre-trained on sequences consisting of a few thousand tokens to achieve comparable performance with competitive baselines that continually train these LLMs on long sequences. Even when the sequence length is scaled to $1,024$K, InfLLM still effectively captures long-distance dependencies. Our code can be found in \url{https://github.com/thunlp/InfLLM}.
title InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory
topic Computation and Language
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2402.04617