Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

LM-Infinite: Zero-Shot Extreme Length Generalization for Large Language Models

About

Today's large language models (LLMs) typically train on short text segments (e.g., <4K tokens) due to the quadratic complexity of their Transformer architectures. As a result, their performance suffers drastically on inputs longer than those encountered during training, substantially limiting their applications in real-world tasks involving long contexts such as encoding scientific articles, code repositories, or long dialogues. Through theoretical analysis and empirical investigation, this work identifies three major factors contributing to this length generalization failure. Our theoretical analysis further reveals that commonly used techniques like truncating the attention window or relative positional encodings are inadequate to address them. Answering these challenges, we propose LM-Infinite, a simple and effective method for enhancing LLMs' capabilities of handling long contexts. LM-Infinite is highly flexible and can be used with most modern LLMs off-the-shelf. Without any parameter updates, it allows LLMs pre-trained with 2K or 4K-long segments to generalize to up to 200M length inputs while retaining perplexity. It also improves performance on downstream tasks such as Passkey Retrieval and Qasper in the zero-shot setting. LM-Infinite brings substantial efficiency improvements: it achieves 2.7x decoding speed up and 7.5x memory saving over the original model. Our codes are released at \url{https://github.com/Glaciohound/LM-Infinite}.

Chi Han, Qifan Wang, Hao Peng, Wenhan Xiong, Yu Chen, Heng Ji, Sinong Wang• 2023

Related benchmarks

TaskDatasetResultRank
Multi-hop Question AnsweringHotpotQA--
221
Multi-hop Question Answering2WikiMQA--
154
Abstractive SummarizationMulti-News--
47
Single-hop Question AnsweringNarrativeQA
Score18.83
22
Single-hop Question AnsweringQasper
Score42.53
22
Single-hop Question AnsweringMFQA en
Score40.08
22
Single-hop Question AnsweringMFQA en 16k
Overall Score14.1
22
Single-hop Question AnsweringFactrecall en
Score31.36
17
Single-hop Question AnsweringLoogle SD
Score18.2
17
few-shot question answeringTREC
Accuracy50
5
Showing 10 of 20 rows

Other info

Follow for update